zidane/ providers/ vercel-ai-gateway
The Vercel AI Gateway provider, with models from many labs on one API key.
import { … } from 'zidane/providers/vercel-ai-gateway'src/providers/vercel-ai-gateway.ts
Use vercelAIGateway() when your agent runs on the Vercel AI Gateway. It reads AI_GATEWAY_API_KEY when you pass no key, and its default model is anthropic/claude-opus-5.5. Model ids take the gateway's creator/model form. anthropic/* models go over the gateway's Anthropic Messages API, every other model over its chat completions (isVercelAIGatewayAnthropicModel() tells which). planVercelAIGatewayReasoning() maps a thinking level to the gateway's reasoning field.
import { createAgent } from 'zidane'
import { vercelAIGateway } from 'zidane/providers/vercel-ai-gateway'
const agent = createAgent({ provider: vercelAIGateway() })
const stats = await agent.run({ prompt: 'Summarize README.md in three bullets.', model: 'openai/gpt-6-sol' })
console.log(stats.turns)Functions#
isVercelAIGatewayAnthropicModelFunction#
Whether a model goes over the gateway's Anthropic Messages API.
function isVercelAIGatewayAnthropicModel(model: string): booleanParameters
| Name | Type | Description |
|---|---|---|
| model | string | Gateway model id. |
Returns
booleanplanVercelAIGatewayReasoningFunction#
Maps zidane's thinking level and budget to the gateway's reasoning field
on chat completions. It takes an effort or a max_tokens budget, never
both: an explicit budget wins. Unset, 'off' and 'adaptive' send
nothing, so the model keeps its own default.
function planVercelAIGatewayReasoning(
ctx: { thinking?: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'adaptive'; thinkingBudget?: number },
): Record<string, unknown> | undefinedParameters
| Name | Type | Description |
|---|---|---|
| ctx | { thinking?: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'adaptive'; thinkingBudget?: number } | Request thinking level and budget. |
Returns
Record<string, unknown> | undefinedvercelAIGatewayFunction#
Vercel AI Gateway provider. Claude models go over the gateway's Anthropic Messages API, every other model over its chat completions (see the module comment).
function vercelAIGateway(params?: VercelAIGatewayParams): ProviderParameters
| Name | Type | Description |
|---|---|---|
| params? | VercelAIGatewayParams | API key, base URL, default model, capabilities and extra headers. |
Returns
Example
import { createAgent } from 'zidane'
import { vercelAIGateway } from 'zidane/providers/vercel-ai-gateway'
const agent = createAgent({
provider: vercelAIGateway({ apiKey: process.env.AI_GATEWAY_API_KEY }),
})
await agent.run({ prompt: 'Say hello.', model: 'openai/gpt-6-sol' })Constants#
VERCEL_AI_GATEWAY_API_KEY_ENVConstant#
Environment variable the Vercel AI Gateway provider reads its API key from.
const VERCEL_AI_GATEWAY_API_KEY_ENV = 'AI_GATEWAY_API_KEY'VERCEL_AI_GATEWAY_DECISION_MODELSConstant#
Decision models the gateway serves on TypeSafe's System One protocol. The first is the default.
const VERCEL_AI_GATEWAY_DECISION_MODELS: readonly ['typesafe-ai/jev', 'typesafe-ai/jev-1.14.0', 'typesafe-ai/jev-1.13.0']VERCEL_AI_GATEWAY_DEFAULT_MODELConstant#
Model the Vercel AI Gateway provider uses when none is configured.
const VERCEL_AI_GATEWAY_DEFAULT_MODEL = 'anthropic/claude-opus-5.5'VERCEL_AI_GATEWAY_PROVIDER_KEYConstant#
Provider key, credentials-file key and pi-ai provider id of the gateway.
const VERCEL_AI_GATEWAY_PROVIDER_KEY = 'vercel-ai-gateway'Interfaces#
VercelAIGatewayParamsInterface#
Options for vercelAIGateway.
interface VercelAIGatewayParamsProperties
| Name | Type | Default | Description |
|---|---|---|---|
| apiKey? | string | API key. Falls back to the | |
| baseURL? | string | 'https://ai-gateway.vercel.sh' | Gateway origin, without |
| capabilities? | ProviderCapabilities | Provider capability flags. The gateway routes to many models, so the
default fits the default model: | |
| defaultModel? | string | 'anthropic/claude-opus-5.5' | Model used when a request does not set one. |
| extraHeaders? | Record<string, string> | Extra HTTP headers sent on every request, on both routes. |