Skip to content

feat(service-ai): per-instance gatewayModel option#1647

Merged
xuyushun441-sys merged 1 commit into
mainfrom
feat/ai-gateway-model-option
Jun 7, 2026
Merged

feat(service-ai): per-instance gatewayModel option#1647
xuyushun441-sys merged 1 commit into
mainfrom
feat/ai-gateway-model-option

Conversation

@xuyushun441-sys
Copy link
Copy Markdown
Contributor

What

AIServicePluginOptions gains an optional gatewayModel?: string. detectAdapter() now uses:

const gatewayModel = this.options.gatewayModel ?? process.env.AI_GATEWAY_MODEL;

So a host can select the Vercel AI Gateway model per plugin instance instead of only via the process-wide AI_GATEWAY_MODEL env var.

Why

A multi-tenant runtime builds one AIServicePlugin per environment kernel and needs to route the model per tenant/plan (e.g. free → haiku, paid → sonnet) within a single process. The env var is process-global and can't express that. Omitting the option preserves the exact current behavior (env fallback).

This is the open-core mechanism; the routing policy stays in the (closed) cloud runtime (cloud ADR-0005).

Tests

  • option wins over AI_GATEWAY_MODEL
  • falls back to env when option absent
  • full ai-service.test.ts suite: 95 passed

🤖 Generated with Claude Code

…WAY_MODEL)

AIServicePluginOptions gains `gatewayModel?: string`. detectAdapter() uses
`this.options.gatewayModel ?? process.env.AI_GATEWAY_MODEL`, so a multi-tenant
host can route the gateway model per kernel (e.g. by plan) instead of relying on
the single process-wide env var. Omitted → unchanged env-based behavior.

Tests: option wins over env; falls back to env when option absent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Building Building Preview, Comment Jun 7, 2026 10:52am

Request Review

@xuyushun441-sys xuyushun441-sys merged commit 0e614d2 into main Jun 7, 2026
7 of 8 checks passed
@xuyushun441-sys xuyushun441-sys deleted the feat/ai-gateway-model-option branch June 7, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants