Skip to content

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.

TypeScript
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.

TypeScript
function isVercelAIGatewayAnthropicModel(model: string): boolean
Parameters
NameTypeDescription
modelstring

Gateway model id.

boolean

src/providers/vercel-ai-gateway.ts:71

planVercelAIGatewayReasoningFunction#

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.

TypeScript
function planVercelAIGatewayReasoning(
  ctx: { thinking?: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'adaptive'; thinkingBudget?: number },
): Record<string, unknown> | undefined
Parameters
NameTypeDescription
ctx{ thinking?: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'adaptive'; thinkingBudget?: number }

Request thinking level and budget.

Record<string, unknown> | undefined

src/providers/vercel-ai-gateway.ts:85

vercelAIGatewayFunction#

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).

TypeScript
function vercelAIGateway(params?: VercelAIGatewayParams): Provider
Parameters
NameTypeDescription
params?VercelAIGatewayParams

API key, base URL, default model, capabilities and extra headers.

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' })

src/providers/vercel-ai-gateway.ts:113

Constants#

VERCEL_AI_GATEWAY_API_KEY_ENVConstant#

Environment variable the Vercel AI Gateway provider reads its API key from.

TypeScript
const VERCEL_AI_GATEWAY_API_KEY_ENV = 'AI_GATEWAY_API_KEY'

src/providers/vercel-ai-gateway.ts:29

VERCEL_AI_GATEWAY_DECISION_MODELSConstant#

Decision models the gateway serves on TypeSafe's System One protocol. The first is the default.

TypeScript
const VERCEL_AI_GATEWAY_DECISION_MODELS: readonly ['typesafe-ai/jev', 'typesafe-ai/jev-1.14.0', 'typesafe-ai/jev-1.13.0']

src/providers/vercel-ai-gateway.ts:35

VERCEL_AI_GATEWAY_DEFAULT_MODELConstant#

Model the Vercel AI Gateway provider uses when none is configured.

TypeScript
const VERCEL_AI_GATEWAY_DEFAULT_MODEL = 'anthropic/claude-opus-5.5'

src/providers/vercel-ai-gateway.ts:32

VERCEL_AI_GATEWAY_PROVIDER_KEYConstant#

Provider key, credentials-file key and pi-ai provider id of the gateway.

TypeScript
const VERCEL_AI_GATEWAY_PROVIDER_KEY = 'vercel-ai-gateway'

src/providers/vercel-ai-gateway.ts:26

Interfaces#

VercelAIGatewayParamsInterface#

Options for vercelAIGateway.

TypeScript
interface VercelAIGatewayParams
VercelAIGatewayParams properties
NameTypeDefaultDescription
apiKey?string

API key. Falls back to the AI_GATEWAY_API_KEY environment variable.

baseURL?string'https://ai-gateway.vercel.sh'

Gateway origin, without /v1: Claude goes to <baseURL>/v1/messages, other models to <baseURL>/v1/chat/completions. With a base URL of its own the provider has no decisions and no images.

capabilities?ProviderCapabilities

Provider capability flags. The gateway routes to many models, so the default fits the default model: { vision: true, imageInToolResult: false, documents: true }. Set vision: false when pinning a text-only 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.

src/providers/vercel-ai-gateway.ts:41