Skip to content
Docs

vercel ai-gateway

The vercel ai-gateway command manages AI Gateway resources from the Vercel CLI, including API keys, budgets, routing rules, virtual models, models, leaderboards, and coding agents.

Connecting a coding agent? vercel ai-gateway setup is the recommended way to do it. For per-agent behavior, model pickers, and manual configuration, see the coding agents guide.

terminal
vercel ai-gateway [subcommand]

Using the vercel ai-gateway command to manage AI Gateway resources for the current team.

Most subcommands accept --format json (-F json) to print a machine-readable payload instead of a table. The rules, models, and budgets set, list, inspect, and remove subcommands also accept --json, which does the same thing. setup uses --non-interactive instead.

Manage AI Gateway API keys for the current team.

terminal
vercel ai-gateway api-keys [subcommand]

Create a new AI Gateway API key. The CLI returns the plaintext key once; store it securely.

terminal
vercel ai-gateway api-keys create
Create an API key interactively, using the default settings.
terminal
vercel ai-gateway api-keys create --name my-key --limit 500 --refresh-period monthly

Create an API key with a human-readable name and a monthly $500 quota.

OptionTypeDescription
--name <NAME>StringHuman-readable name for the API key
--limit <AMOUNT>NumberQuota budget limit in dollars (minimum 1)
--refresh-period <PERIOD>StringQuota refresh cadence: daily, weekly, monthly, or none (default none)
--alert-thresholds <LIST>StringComma-separated spend percentages to alert at, a subset of 50, 75, and 100, for example 75,100
--expiration <PERIOD>StringExpiry for the key: 7d, 30d, 60d, 90d, 1y, or none (default none)
--zdr-exemptBooleanExempt the key from the team's zero data retention (ZDR) only model restriction. Team owners only

--limit is available in Vercel CLI v59.13.0 and later. On older versions, use --budget, which is deprecated but names the same quota limit.

A ZDR-exempt key can reach models that don't offer zero data retention, which is why only team owners can create one. Pair it with --expiration so the exemption doesn't outlive the work that needed it.

terminal
vercel ai-gateway api-keys create --name escape-hatch --zdr-exempt --expiration 7d
Create a ZDR-exempt key that expires in seven days.

List the AI Gateway API keys for the current team. The table shows each key's ID, name, masked key, quota, and expiry. Alias: ls.

terminal
vercel ai-gateway api-keys ls
OptionTypeDescription
--format <FORMAT>StringSet to json for the full key payload

Show the details of one API key, including its quota, current spend, alert thresholds, and expiry. Keys created with --zdr-exempt also show a zdr exempt row, so you can audit which keys carry the exemption.

terminal
vercel ai-gateway api-keys inspect key_123
OptionTypeDescription
--format <FORMAT>StringSet to json for the full key payload

Remove an API key by its ID. Aliases: rm, delete. Pass --yes to skip the confirmation prompt.

terminal
vercel ai-gateway api-keys remove key_123 --yes
OptionTypeDescription
--yes, -yBooleanSkip the confirmation prompt
--format <FORMAT>StringSet to json for the machine-readable payload

Manage AI Gateway budgets, which are metered spend limits scoped to your team, a project, an API key, or a team member.

terminal
vercel ai-gateway budgets [subcommand]

Create or update the budget for a scope, or the scope's default budget with --default. Each scope except team takes an identifier after the scope name; a default takes none.

ScopeIdentifier
teamNone
projectProject name or ID
api-keyKey name or ID. A name shared by several keys errors and asks for the ID, which api-keys list shows
userMember email, username, or user ID
terminal
vercel ai-gateway budgets set team --limit 500 --refresh-period monthly
Cap team-wide AI Gateway spend at $500 per month.
terminal
vercel ai-gateway budgets set project my-project --limit 200
Cap one project at $200.
terminal
vercel ai-gateway budgets set api-key my-key --limit 50 --refresh-period weekly
Cap one API key at $50 per week.
terminal
vercel ai-gateway budgets set user teammate@example.com --limit 100 --refresh-period monthly
Cap one team member at $100 per month across every key attributed to them.
terminal
vercel ai-gateway budgets set user --default --limit 50 --refresh-period monthly
Give every team member without their own budget a $50 monthly limit.
OptionTypeDescription
--limit <AMOUNT>NumberBudget limit in dollars (minimum 1)
--refresh-period <PERIOD>StringBudget refresh cadence: daily, weekly, monthly, or none (default monthly)
--defaultBooleanTarget the scope's default budget, applied to resources of that scope without their own budget
--format <FORMAT>StringSet to json for the machine-readable payload

List the budgets for the current team, with each budget's scope, limit, current spend, and refresh cadence. User-scoped budgets are listed by member handle. Alias: ls. Filter to one scope with --scope-type, or list the team's default budget policy with --defaults.

terminal
vercel ai-gateway budgets ls
terminal
vercel ai-gateway budgets ls --scope-type user
List only the user-scoped budgets.
terminal
vercel ai-gateway budgets ls --defaults
List the team's budget defaults.
OptionTypeDescription
--scope-type <SCOPE>StringOnly list budgets for one scope: team, project, user, or api-key
--defaultsBooleanList the team's default budgets instead of individual budgets
--format <FORMAT>StringSet to json for the machine-readable payload

Show one budget for a scope, or a scope's default budget with --default, using the same scope names and identifiers as set.

terminal
vercel ai-gateway budgets inspect user teammate@example.com
Show one team member's budget and current spend.
terminal
vercel ai-gateway budgets inspect project my-project --format json
Print a project budget's machine-readable payload.
OptionTypeDescription
--defaultBooleanShow the scope's default budget
--format <FORMAT>StringSet to json for the machine-readable payload

Remove the budget for a scope, using the same scope names and identifiers as set, or a scope's default budget with --default. Aliases: rm, delete.

Removing a budget lifts that scope's own cap. A project, key, or member still covered by a default falls back to that default rather than becoming unlimited.

terminal
vercel ai-gateway budgets remove team
terminal
vercel ai-gateway budgets remove project my-project --yes
terminal
vercel ai-gateway budgets remove api-key my-key
terminal
vercel ai-gateway budgets remove user teammate@example.com
terminal
vercel ai-gateway budgets remove user --default
Remove the per-member default budget.
OptionTypeDescription
--yes, -yBooleanSkip the confirmation prompt
--defaultBooleanRemove the scope's default budget
--format <FORMAT>StringSet to json for the machine-readable payload

Manage budget defaults. A default applies to every resource of that scope that has no budget of its own, so new projects, new API keys, and new team members inherit a spend limit instead of starting unlimited.

Set or remove a default with the --default flag on set and remove, show one with inspect, and list the policy with list --defaults:

terminal
vercel ai-gateway budgets set project --default --limit 200 --refresh-period monthly
Give every project without its own budget a $200 monthly limit.
terminal
vercel ai-gateway budgets set api-key --default --limit 50
Give every API key without its own quota a $50 limit.
terminal
vercel ai-gateway budgets set user --default --limit 50 --refresh-period monthly
Give every team member without their own budget a $50 monthly limit.
terminal
vercel ai-gateway budgets ls --defaults
List the team's budget defaults.
terminal
vercel ai-gateway budgets remove user --default
Remove the per-member default budget.

The --default flag is available in Vercel CLI v59.13.0 and later. The nested budgets defaults command group it replaces still works but prints a deprecation warning; use the flag forms instead.

Manage AI Gateway routing rules for the current team. A rule rewrites a request from one model to another, or denies a model. See the routing rules documentation for concepts, request behavior, and propagation details.

AI Gateway routing rules are in beta and may change before general availability.

terminal
vercel ai-gateway rules [subcommand]

Add a routing rule. A rewrite rule requires --destination; a deny rule does not.

terminal
vercel ai-gateway rules add --type rewrite --source anthropic/claude-opus-5 --destination anthropic/claude-haiku-4.5
Route requests for one model to another.
terminal
vercel ai-gateway rules add --type deny --source openai/gpt-5.6-sol
Block requests for a model.
OptionTypeDescription
--type <TYPE>StringRule type: rewrite or deny (required)
--source <MODEL>StringModel the rule matches (required)
--destination <MODEL>StringTarget model a rewrite rule routes to
--reason <TEXT>StringReason surfaced when the rule applies
--description <TEXT>StringHuman-readable description of the rule
--format <FORMAT>StringSet to json for the machine-readable payload

List routing rules for the current team. Alias: ls. Pass --include-disabled to also show disabled rules.

terminal
vercel ai-gateway rules list

Edit a rule by its ID. Change the destination, reason, or description, or toggle the rule with --enable / --disable.

terminal
vercel ai-gateway rules edit rule_123 --disable

Remove a rule by its ID. Aliases: rm, delete. Pass --yes to skip the confirmation prompt.

terminal
vercel ai-gateway rules remove rule_123 --yes

Connect local coding agents to AI Gateway.

Run the setup command with npx:

terminal
npx vercel ai-gateway setup

npx runs Vercel CLI without installing it globally. To keep vercel available as a global command, install or update the CLI before running setup:

terminal
npm i -g vercel@latest
vercel ai-gateway setup

vercel ai-gateway setup is the canonical command. The older spelling, vercel ai-gateway coding-agents setup, still works as an alias, and managed shell blocks written under the old name are still recognized as configured.

Configure supported coding agents to route requests through AI Gateway. The command provisions or reuses an AI Gateway API key and writes each agent's config file so requests use the gateway with your key.

This is the recommended way to connect an agent because it picks the right compatibility URL per agent, keeps your key out of plaintext config on macOS, and preserves your existing desktop sessions. The coding agents guide covers the same agents from the other direction, with per-agent features and manual configuration for the tools this command doesn't handle.

terminal
vercel ai-gateway setup --yes

Connect the coding agents detected on this machine without any prompts.

Run the command without flags to step through each prompt in order:

  1. Agents to configure. The agents detected on your machine (their config directory exists) are pre-selected.
  2. Consent for any agent with a pre-flight warning, described in Warnings and consent. Declining skips that agent and continues with the others.
  3. Session migration, when you have Claude Desktop or Codex Desktop sessions that would otherwise disappear from the switched provider. See Desktop session migration.
  4. API key source: create a new key or paste an existing one. The prompt defaults to create, and to use an existing key when your agent configs already point at the gateway.
  5. API key name for a new key. The prompt suggests [<user>'s <device>] Coding Agents.
  6. Team that owns the key.
  7. Spend limit (quota) for the key.
  8. Expiration for the key.
  9. Keychain storage on macOS: whether to store the key in your Keychain (default yes).

When a selected agent isn't found at its default location, the command also offers to set a custom config path. It then prints a summary and the planned changes as a per-file diff with the key masked, and asks you to confirm. Declining writes nothing and never creates a key.

Agent--agent value
Aideraider
Claude Codeclaude-code
Clinecline
Codexcodex
Continue CLIcontinue
GitHub Copilot CLIcopilot
Crushcrush
Cursorcursor
Deep Agents CLIdeepagents
DeepSeek Harnessdeepseek
Factory Droiddroid
ForgeCodeforge
fxfx
Goosegoose
gptmegptme
Grok Buildgrok
Hermeshermes
Junie CLIjunie
Kilo Codekilo
Kimi CLIkimi
ompomp
OpenClawopenclaw
OpenCodeopencode
OpenHandsopenhands
Pipi
Qwen Codeqwen
Mistral Vibevibe
ZCodezcode
Zedzed

The command treats every agent the same way. Detection pre-selects the ones already installed on your machine, --all covers every agent in the table, and the interactive checklist lists them in this order. To connect a subset, name each one with --agent:

terminal
vercel ai-gateway setup --agent cursor --agent kilo

Connect specific agents by naming each one with --agent.

AI Gateway serves several compatibility surfaces, and each agent gets the one its client speaks. The command picks these for you, which is the main reason to prefer it over hand-editing a config file:

AgentURLWhy this surface
Claude Codehttps://ai-gateway.vercel.sh/claude-codeAnthropic-compatible surface with a Claude Code shaped model catalog, so gateway models appear in the /model picker. The Anthropic SDK appends /v1/messages itself, so the URL has no /v1
Codexhttps://ai-gateway.vercel.sh/codex/v1OpenAI-compatible surface that also serves /codex/v1/models in the ModelsResponse shape Codex decodes at startup. Every other path falls through to the standard /v1 handlers
Cursorhttps://ai-gateway.vercel.sh/cursor/v1OpenAI-compatible surface that normalizes the non-spec bodies Cursor's base URL override sends to /chat/completions, which the standard schema rejects. Every other path falls through to the standard /v1 handlers
Aider, Continue CLI, Copilot CLI, Deep Agents CLI, Factory Droid, gptme, Grok Build, Hermes, Kimi CLI, Kilo Code, OpenClaw, OpenHands, Qwen Code, Mistral Vibe, ZCode, Zedhttps://ai-gateway.vercel.sh/coding-agent/v1The coding agent surface, for agents with no dedicated endpoint of their own
ForgeCode, Goose, Junie CLIhttps://ai-gateway.vercel.sh/coding-agent/v1/chat/completionsThese configs require the full Chat Completions endpoint rather than a base URL. ForgeCode also uses https://ai-gateway.vercel.sh/coding-agent/v1/models for model discovery
Cline, Crush, OpenCode, PiNoneThese agents ship a first-party AI Gateway provider and already know the URL, so only the credential is written
DeepSeek HarnessNoneThe pi-based harness keeps its provider URL and reads the key from AI_GATEWAY_API_KEY
fx, ompNoneThese agents talk to the gateway natively and read the key from AI_GATEWAY_API_KEY

Pass --base-url <URL> to write a different base URL, for example a preview deployment of the gateway. Most agents write the value verbatim. ForgeCode, Goose, and Junie CLI append /chat/completions, and ForgeCode also appends /models for model discovery. The option has no effect on agents that use a first-party provider.

Every agent without a dedicated endpoint should point at the shared coding agent surface:

https://ai-gateway.vercel.sh/coding-agent/v1

It passes straight through to the standard /v1 handlers, so auth, routing, billing, CORS, and errors behave exactly as they do on the bare /v1 surface, and unknown paths return the same JSON 404. Use it anyway because it marks the traffic as coming from a coding agent. It also gives behavior shared across harnesses somewhere to live later, without requiring another config edit.

For a client that speaks the Anthropic protocol and appends /v1/messages itself, drop the /v1 and use https://ai-gateway.vercel.sh/coding-agent.

AgentFilesWhat's written
Claude Code~/.claude/settings.json (honors $CLAUDE_CONFIG_DIR); shell startup file in Keychain modeenv.ANTHROPIC_BASE_URL, env.ANTHROPIC_API_KEY="", and env.CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1; the key as env.ANTHROPIC_AUTH_TOKEN or a Keychain-resolved shell export
Codex~/.codex/config.toml (honors $CODEX_HOME) plus shell startup filemodel_provider=vercel and a vercel provider (base_url, wire_api=responses, env_key=AI_GATEWAY_API_KEY); the shell file exports AI_GATEWAY_API_KEY
OpenCode~/.config/opencode/opencode.json (honors $XDG_CONFIG_HOME); shell startup file in Keychain modeA vercel provider entry; the key as provider.vercel.options.apiKey or the AI_GATEWAY_API_KEY shell export
Pi~/.pi/agent/auth.json (mode 0600, honors $PI_CODING_AGENT_DIR)A vercel-ai-gateway API-key entry. Pi always stores the key in this file, even in Keychain mode
Cline~/.cline/data/settings/providers.json (mode 0600)A vercel-ai-gateway provider with your key, set as lastUsedProvider and given the default model below
CursorNoneCursor keeps API-key settings in its account-synced store, so the command exports AI_GATEWAY_API_KEY and prints the steps to finish in Settings -> Models, including the /cursor/v1 base URL to paste
Hermes~/.hermes/config.yamlA vercel-ai-gateway provider (key_env=AI_GATEWAY_API_KEY, discover_models: true) plus the default model below; the shell file exports the key
Kilo Code~/.config/kilo/kilo.json (honors $XDG_CONFIG_HOME)An openai-compatible provider whose apiKey is the {env:AI_GATEWAY_API_KEY} reference Kilo resolves at runtime; the shell file exports the key
OpenClaw~/.openclaw/openclaw.jsonA vercel-ai-gateway provider whose apiKey is an ${AI_GATEWAY_API_KEY} reference, a starter model list, and the default model below; the shell file exports the key
Aider~/.aider.conf.yml plus a sibling .aider.model.metadata.jsonThe gateway base URL and an openai/-prefixed default model, plus model metadata and settings generated from the gateway catalog so the prefixed IDs resolve with real context windows and diff edits; the shell file exports AIDER_OPENAI_API_KEY
Continue CLI~/.continue/config.yamlA gateway provider with a shortlist of the most-used models (see Model selection), the key referenced through Continue's secrets syntax, and the onboarding marker so an interactive cn doesn't rewrite the config
GitHub Copilot CLINoneConfigured entirely through the shell: COPILOT_PROVIDER_BASE_URL points at the gateway, COPILOT_PROVIDER_API_KEY carries the key, and COPILOT_MODEL selects the default gateway model
Crush~/.config/crush/crush.jsonA providers.vercel entry with an $AI_GATEWAY_API_KEY reference Crush resolves itself, and the large/small model roles pinned to gateway models
Deep Agents CLI~/.deepagents/config.tomlA vercel-ai-gateway provider with api_key_env naming AI_GATEWAY_API_KEY, a /model switcher shortlist, and per-model profile tables carrying display names and token limits
DeepSeek Harness$DSH_HOME/settings.yaml (default ~/.dsh)An llm-pi-ai section naming AI_GATEWAY_API_KEY as the key env var, plus a model shortlist that leads with the newest DeepSeek models
Factory Droid~/.factory/settings.jsonBYOK customModels entries referencing AI_GATEWAY_API_KEY through Droid's env-reference syntax
ForgeCode~/.forge/.forge.toml plus a sibling .credentials.json (mode 0600)A gateway [[providers]] entry and [session] defaults; the key goes in .credentials.json (the only key source Forge 2.13+ reads), with api_key_vars kept for older releases
fx~/.fx/settings.json; shell startup filecredential_source pinned to the exported AI_GATEWAY_API_KEY, ahead of a stored fx login session
Goose~/.config/goose/custom_providers/ plus config.yamlA declarative provider JSON that shadows Goose's built-in vercel_ai_gateway definition and resolves the key from AI_GATEWAY_API_KEY, and the default provider and model in config.yaml
gptme~/.config/gptme/config.tomlA vercel-ai-gateway entry in the [[providers]] array with api_key_env naming AI_GATEWAY_API_KEY, and [models].default pointed at the gateway default model
Grok Build~/.grok/config.toml (honors $GROK_HOME)endpoints.models_base_url pointed at the gateway and a default model entry whose env_key references AI_GATEWAY_API_KEY
Junie CLI$JUNIE_HOME/models/ (default ~/.junie)A stable vercel-ai-gateway profile pinned to the top model, plus one profile per shortlisted gateway model, each with an env reference to AI_GATEWAY_API_KEY
Kimi CLI$KIMI_SHARE_DIR/config.toml (default ~/.kimi, mode 0600)A gateway provider and a [models] shortlist; Kimi requires a literal api_key, so the key lands in this file
ompNoneomp reads AI_GATEWAY_API_KEY natively and fills /model from the gateway catalog, so only the shell export is written, never omp's SQLite store
OpenHands~/.openhands/agent_settings.jsonA minimal llm block pointing at the gateway with an openai/-prefixed model ID; an existing condenser LLM is repointed the same way, and the pinned model's per-token cost fields come from the gateway catalog
Qwen Code~/.qwen/settings.jsonmodelProviders.openai entries, each with an envKey reference to AI_GATEWAY_API_KEY so the key never lands in the file
Mistral Vibe$VIBE_HOME/config.toml (default ~/.vibe)The gateway provider and an unaliased [[models]] shortlist, with api_key_env_var keeping the key in the shell environment and active_model pinned to the leading Mistral model
ZCode~/.zcode/v2/config.json (mode 0600)A gateway provider entry with the base URL and a model shortlist. ZCode has no env-var lookup for custom providers, so the key is stored in this file
ZedZed's JSONC settings.json (honors $ZED_HOME and $APPDATA); shell startup fileZed's first-party vercel_ai_gateway provider (comment-preserving merge) pointed at the coding-agent endpoint, the Agent Panel default model, and a VERCEL_AI_GATEWAY_API_KEY shell export

The command edits existing files in place, preserving their formatting, and saves a .bak copy first. Disable backups with --no-backup. If it can't parse a file, it skips that file instead of overwriting it.

Shell exports live in a marked, removable block in your shell's startup file: ~/.zshrc for zsh (honors $ZDOTDIR), ~/.bash_profile on macOS or ~/.bashrc elsewhere for bash, config.fish for fish, or ~/.profile otherwise. Pass --shell-rc <path> to target a different file, or --agent-config <agent>=<path> to override an agent's config location. On Windows, there's no shell startup file to manage. The command tells you which environment variable to set and prints a newly created key once so you don't lose it.

Model lists come from the AI Gateway leaderboard instead of a hardcoded snapshot. The command ranks text models by spend and writes the top 10 into each agent's picker. A harness with a preferred model family, such as DeepSeek Harness, Kimi CLI, Qwen Code, or Mistral Vibe, leads its shortlist with the newest models from that family and follows with the leaderboard's most-used.

For Claude Code, Codex, OpenCode, Pi, Kilo Code, Cursor, fx, and omp, the command pins no model, so you keep choosing your own inside the agent. The other agents can't start without one, so they get the top-ranked model as a starting point, falling back to anthropic/claude-fable-5 when the leaderboard lookup fails. Change it at any time:

AgentHow to switch models
ClineIn-session, or cline auth -p vercel-ai-gateway -m <gateway-model-id>
Hermes/model custom:vercel-ai-gateway:<gateway-model-id>
OpenClawAdd the model to the provider's models array in openclaw.json, then select it
Aider/model openai/<gateway-model-id>, or edit ~/.aider.conf.yml
Continue CLIPick from the provider's models in-session, or edit ~/.continue/config.yaml
GitHub Copilot CLISet COPILOT_MODEL, or pass --model
CrushIn-session with ctrl+p
Deep Agents CLI/model switcher
ForgeCodeIn-session with :config-model (the picker fills from the gateway catalog)
GooseSet GOOSE_MODEL in config.yaml, or run goose configure
gptme-m vercel-ai-gateway/<gateway-model-id>
Junie CLIRun junie --model custom:vercel-ai-gateway, or pick the model with /model
OpenHandsEdit the llm block in agent_settings.json
ZCodePick the model in-session
ZedAgent Panel model picker (the full catalog loads from /models once the key is visible)

Switching providers hides the sessions that were recorded under the old one. When the command finds those sessions, it offers to copy them into the gateway provider so your history stays visible. Originals are never moved, edited, or deleted.

AgentWhat gets copied
Claude CodeClaude Desktop session records, copied into the gateway (Claude-3p) identity with each model rewritten to its gateway ID. The gateway identity only exists after Claude Desktop's first gateway launch, so re-run setup once you've switched providers in Developer -> Configure Third-Party Inference
CodexCodex Desktop rollout files under sessions and archived_sessions, copied with a deterministic new session ID and model_provider set to vercel

Copies are atomic, use mode 0600, and never clobber an existing destination. Re-running is safe because the command skips sessions that were already copied. If a copy fails, the command leaves your agent configuration untouched and exits 1 so you can retry.

Interactively, you get one prompt and can decline. With --yes or in non-interactive mode, eligible sessions are copied. Pass --no-session-migration to skip the whole step. Compressed Codex sessions (.jsonl.zst) can't be rewritten. Decompress them first, or pass --no-session-migration.

Connecting can break an agent's existing setup. Before asking any key questions, the command checks each selected agent for known conflicts and asks for explicit consent, so you can bail before a key is created. Detection only checks whether an app is installed; the command never reads your data.

Interactively, each warned agent gets its own confirmation, defaulting to no. Declining leaves that agent's files untouched, and the run continues with the other agents.

With --yes or in non-interactive mode, naming an agent with --agent (or passing --all) counts as consent, so the run proceeds and prints the warnings. The command skips a warned agent that was only selected by detection, with reason requires_consent and a hint to pass --agent <id>. If that skips every agent, the command exits 1 with reason requires_consent and a ready-to-run command that replays the invocation with the consent flags added. --dry-run never asks for consent; it prints the warnings and shows what a real run would do.

ZCode warns you to quit the desktop app before running setup because it rewrites its config file on exit and silently discards edits made while it runs. Codex used to warn that connecting broke the Codex desktop app. That warning is gone now that setup migrates desktop sessions instead.

On macOS, the command stores the API key in your login Keychain by default instead of writing it into plaintext config. It saves the key as a generic password with the service name "Vercel AI Gateway", and agents read it through shell exports that call security find-generic-password when a terminal starts. Some agents are the exception because they can't read the Keychain: Pi, Cline, ForgeCode, Kimi CLI, OpenHands, and ZCode always keep the key in their own config files.

Pass --no-keychain, or run on a non-macOS host, to write the key directly into each agent's config file, or into the shell startup file, instead. If the Keychain write fails during setup, the command falls back to this mode automatically.

The command uses a single Keychain item, so connecting a different team replaces the stored key. Human-readable output masks the key as vck_••••1234.

By default the command writes the files itself. On a Keychain setup, the confirmation prompt offers a third option. Instead of writing, it generates a prompt describing the exact edits and copies it to your clipboard, so you can hand the work to a coding agent you already have open. Because the key lives in the Keychain, that prompt carries no secret.

Pass --apply to choose without prompting:

ModeBehavior
--apply editWrite the files. This is the default
--apply promptEmit the agent prompt on stdout instead of writing. Requires the macOS Keychain, so the prompt never contains a plaintext key

Re-running the command against an already-configured setup doesn't mint a second key or orphan the working one. When your agent configs already point at the gateway, the command reuses the key it finds. Interactively, the key prompt defaults to Use an existing key so you can paste a different one; without prompts, the stored key (Keychain entry or managed shell export) is recovered and used. This also refreshes stale model lists, since the shortlists come from the leaderboard. When nothing needs to change, the command asks whether to reconfigure interactively (default no) and otherwise exits 0, reporting reason already_configured in non-interactive output. No new key is minted.

  • Pass --reconfigure to run setup again when agents are already configured, for example to rotate the key or switch teams.
  • Run setup --key <new-key> on a Keychain setup to swap in a rotated or expired key. The command refreshes the Keychain entry in place without touching config files.
  • When everything is already configured but sessions are still waiting to be copied, the run does the migration alone and leaves your key and config as they are.
OptionTypeDescription
--agent <NAME>StringCoding agent to configure. Repeatable. See supported coding agents for values. In runs without prompts, also grants consent for that agent's warnings
--allBooleanConfigure every supported coding agent, whether or not it's detected on this machine
--key <KEY>StringUse an existing AI Gateway API key instead of creating one. Skips key creation and the name, team, budget, and expiry prompts
--name <NAME>StringName for a newly created API key
--budget <AMOUNT>NumberSpend limit for a new key, in US dollars (minimum 1)
--refresh-period <PERIOD>StringQuota reset cadence for a new key: daily, weekly, monthly, or none
--expiration <PERIOD>StringExpiry for a new key: 7d, 30d, 60d, 90d, 1y, or none (default none)
--reconfigureBooleanRun setup again when agents are already configured, for example to rotate the key or switch teams
--agent-config <AGENT=PATH>StringOverride an agent's config file path, for example claude-code=/path/settings.json. Repeatable
--shell-rc <PATH>StringShell startup file that receives the managed export block
--base-url <URL>StringOverride the AI Gateway base URL written into agent configs, for example a preview deployment. ForgeCode, Goose, and Junie CLI append /chat/completions
--apply <MODE>StringHow to apply the changes: edit (default) or prompt
--dry-runBooleanShow what would change without writing files or creating a key
--no-backupBooleanDo not write .bak backups of changed files
--no-session-migrationBooleanDo not copy existing Claude Desktop or Codex Desktop sessions
--no-keychainBooleanWrite the key into the agent config files and shell startup file instead of the macOS Keychain
--yes, -yBooleanRun without prompts
--scope <SLUG>, --team <SLUG>StringTeam that owns a newly created key. Global options, also available as -S and -T

The --yes option skips every prompt, which makes the command fully non-interactive. Combined with the defaults below, vercel ai-gateway setup --yes is the shortest complete run:

PromptDefault
AgentsThe agents detected on your machine. If none are detected, the command errors and asks you to pass --agent or --all. The command skips agents with warnings unless you name them
API keyCreates a new key unless you pass --key, or the configs already point at the gateway and the stored key can be recovered
Key nameOmitted, so the server assigns a name. Interactively, the prompt suggests [<user>'s <device>] Coding Agents
Team or scopeUses --scope or --team, or your currently selected team. Without one, the command errors with missing_scope. Not needed with --key
Spend limitUnlimited, unless you pass --budget
RefreshOne-time limit with no reset, unless you pass --refresh-period
ExpirationNever (--expiration none)
Key storageYour macOS Keychain when available, otherwise the agent config files. Pass --no-keychain to always use config
Session migrationEligible desktop sessions are copied. Pass --no-session-migration to skip
Apply modeedit, so the files are written. Pass --apply prompt for the prompt instead
BackupsEnabled. The command writes .bak files unless you pass --no-backup

Pass --non-interactive to emit a single JSON object instead of human-readable output. The CLI also switches to this mode on its own when it detects it's running inside a coding agent and stdin isn't a TTY. Agent selection follows the same detected-agents default as --yes.

The payload includes status, a reason, a message, the list of configured files (changes for a dry run), any migrated sessions, any skipped entries, per-agent notes, and a warnings array of {agent, code, message} objects. On a consent failure, a next array carries a ready-to-run replay command. The success payload contains the full API key, and --apply prompt returns the generated prompt in prompt, so treat the output as a secret.

reasonMeaning
coding_agents_configuredFiles were written
already_configuredNothing to do; no key was created
sessions_migratedOnly desktop sessions were copied
agent_prompt--apply prompt returned a prompt instead of writing
dry_runPreview only
requires_consentEvery selected agent needs an explicit --agent
session_migration_failedA session copy failed, so no configuration was changed
unparseable_configNo agent config could be written
keychain_errorThe key couldn't be stored in the macOS Keychain
missing_scopeNo team was selected for a new key

If at least one agent config can be written, the run exits 0 and lists the rest under skipped. When nothing can be written, the command exits 1 and doesn't create a key.

  • Open a new terminal after connecting so the shell exports load. Codex always reads AI_GATEWAY_API_KEY from your environment; in Keychain mode, every agent except Pi, Cline, ForgeCode, Kimi CLI, OpenHands, and ZCode reads its key from the shell.
  • Restart Claude Code so it picks up the new settings, and restart the OpenClaw gateway process so it loads the new provider.
  • The command exits 0 on success or a no-op, 1 on an operational failure or invalid input, and 2 when it shows help (--help).

Your API key is sensitive. Human-readable output only shows it masked (for example vck_••••1234), but the JSON payload includes it in full, and the agent config files or shell startup file hold it whenever the macOS Keychain isn't used. Keep all of these secret.

Manage virtual models for the current team. A virtual model is a reusable model configuration you call as vmc/<slug>, so routing, credentials, and provider options live in one place instead of in every request. See the virtual models documentation for concepts and request behavior.

terminal
vercel ai-gateway virtual-models [subcommand]

Every subcommand accepts --format json (or --json) for machine-readable output.

Create a virtual model. Run it with no arguments to be prompted for the slug and target model.

terminal
vercel ai-gateway virtual-models create
Create a virtual model interactively.
terminal
vercel ai-gateway virtual-models create my-model --model openai/gpt-5.1
Create a virtual model in a single command.

Fields without a dedicated flag are set through --config, which takes a JSON object. Flags take precedence over the same key in --config.

terminal
vercel ai-gateway virtual-models create my-model --model openai/gpt-5.1 --config '{"sort":"cost","zeroDataRetention":true}'
Set provider options alongside the common flags.
OptionTypeDescription
--kind <KIND>StringVirtual model kind: alias or relay (default: alias). A relay also needs a baseUrl in --config, and the team has to be allowlisted for it
--model <SLUG>StringModel the virtual model points at. Required unless you set modelSlug in --config or answer the prompt
--display-name <NAME>StringHuman-readable name shown in the dashboard
--description <TEXT>StringDescription of the virtual model
--provider-order <LIST>StringComma-separated providers to try, in order
--provider-only <LIST>StringComma-separated providers to restrict routing to
--config <JSON>StringJSON object of any other virtual model fields

List virtual models for the current team. Alias: ls. Archived virtual models are hidden unless you pass --include-archived.

terminal
vercel ai-gateway virtual-models list

Show every field set on a virtual model, by slug.

terminal
vercel ai-gateway virtual-models inspect my-model

Edit a virtual model by its slug. Takes the same field flags and --config as create except --kind, which is create-only, and requires at least one of them.

terminal
vercel ai-gateway virtual-models edit my-model --model anthropic/claude-sonnet-4.5
Point an existing virtual model at a different model.

Remove a virtual model by its slug. Aliases: rm and delete. There is no confirmation prompt, so the virtual model is removed as soon as the command runs. Requests to vmc/<slug> stop resolving once it is removed, and the configuration is preserved so you can restore it later.

Removing is not the same as archiving. A removed virtual model stops resolving and no longer appears in list, even with --include-archived. An archived one still appears, labeled archived.

terminal
vercel ai-gateway virtual-models rm my-model

Restore a removed virtual model by its slug. Requests to vmc/<slug> resolve again, using the configuration the virtual model had before it was removed. Because a removed virtual model is not listed, you need to know its slug.

terminal
vercel ai-gateway virtual-models restore my-model

Browse the models available through AI Gateway and compare the providers that serve them. Both commands are read-only. Add --format json to either command for the full, machine-readable payload.

terminal
vercel ai-gateway models [subcommand]

List the models available through AI Gateway. The table shows each model's ID, name, owner, and type. Alias: ls. Your team's virtual models are listed alongside the catalog, and you can narrow the list to one or the other.

terminal
vercel ai-gateway models ls
List every model available through AI Gateway.
terminal
vercel ai-gateway models ls --virtual
List only your team's virtual models.
OptionTypeDescription
--virtualBooleanShow only your team's virtual models
--no-virtualBooleanHide virtual models
--format <FORMAT>StringSet to json to output the full model payload

List the provider endpoints that serve a model. The table shows each endpoint's context window, input and output pricing, time-to-first-token latency, and uptime. Run vercel ai-gateway models ls to find model IDs.

terminal
vercel ai-gateway models endpoints <model-id>
terminal
vercel ai-gateway models endpoints anthropic/claude-opus-5

Compare the providers that serve a model, with pricing, latency, and uptime.

OptionTypeDescription
--format <FORMAT>StringSet to json to output the full endpoints payload, including throughput and tags

Explore the AI Gateway leaderboards, the open, anonymized usage data published under CC BY 4.0. Alias: leaderboards. Every subcommand is read-only.

terminal
vercel ai-gateway leaderboard [subcommand]
SubcommandDescription
modelsThe most-used models
labsThe most-used model creators
appsThe top apps built on AI Gateway
providersThe top inference providers
terminal
vercel ai-gateway leaderboard models --modality text
Show the most-used text models.
terminal
vercel ai-gateway leaderboard labs --metric spend
Rank model creators by spend instead of request count.
terminal
vercel ai-gateway leaderboard models --format csv --out models.csv
Export the full model leaderboard as CSV.
OptionTypeDescription
--modality <MODALITY>StringFilter by modality: all, text, image, or video (default all). Applies to models and labs
--metric <METRIC>StringMetric for the table view: requests, tokens, spend, imageCount, or videoCount (default requests). Applies to models and labs
--date <YYYY-MM-DD>StringDay to show in the table view (default: most recent). Applies to models and labs
--format <FORMAT>, -FStringOutput format: table, json, or csv (default: table in a terminal, json otherwise)
--out <FILE>, -oStringWrite the payload to a file instead of stdout. Defaults to JSON; use --format csv for CSV
terminal
vercel ai-gateway api-keys create --name my-key --limit 500 --refresh-period monthly --alert-thresholds 75,100

Create an API key named my-key with a $500 monthly quota that alerts at 75% and 100% of the limit.

terminal
vercel ai-gateway budgets set project --default --limit 200 --refresh-period monthly

Apply a $200 monthly budget to any project that has no budget of its own.

terminal
vercel ai-gateway setup --yes

Connect the detected agents with a new, unlimited, non-expiring key.

terminal
vercel ai-gateway setup \
  --agent claude-code --agent codex \
  --name "My Coding Key" \
  --scope my-team \
  --budget 500 --refresh-period monthly \
  --expiration 30d \
  --yes

Connect Claude Code and Codex with a $500 monthly key that expires in 30 days.

terminal
vercel ai-gateway setup --all --yes

Configure every supported agent, including the ones not installed on this machine yet.

terminal
vercel ai-gateway setup --apply prompt --yes

Create the key, store it in the macOS Keychain, and emit a prompt that describes the edits.

terminal
vercel ai-gateway setup --key vck_... --dry-run

Reuse an existing key and preview the changes without writing any files.

terminal
vercel ai-gateway setup --reconfigure --yes

Run setup again on an already-configured machine, for example to rotate the key or switch teams.

terminal
vercel ai-gateway setup --agent codex --base-url https://preview.ai-gateway.vercel.sh/coding-agent/v1
Write a preview deployment's URL instead of the default surface.

The following global options can be passed when using the vercel ai-gateway command:

For more information on global options and their usage, refer to the options section.

Last updated September 17, 2026

Was this helpful?

supported.