View all guides
8 min read

Route Claude Code, Codex, and Cursor through Vercel AI Gateway

Point Claude Code, Codex, and Cursor at one Vercel AI Gateway key, model picker, and spend view, then confirm your first request in Observability.

Route Claude Code, Codex, and Cursor through Vercel AI Gateway
GJ
Gregory John
Buildcamp Founder

What you will learn

  • How Vercel AI Gateway acts as one shared front door for Claude Code, Codex, and Cursor
  • How to run a single CLI setup that provisions (or reuses) an AI Gateway API key and configures those agents
  • How to finish Cursor by hand (the CLI cannot write its account-synced settings)
  • How to pick a model, run a small coding task, and confirm model plus cost in AI Gateway Observability

First success: one agent request visible in AI Gateway Observability with the model name and a cost figure.

Prerequisites

  • A Vercel account you can sign into from the CLI
  • Node.js and npm available in your terminal
  • At least one of: Claude Code, Codex (ChatGPT's coding agent), or Cursor installed the way you already use it in Buildcamp
  • Permission to edit local agent config (and, on macOS, Keychain access if the CLI offers to store the key there)

If you already use more than one of these agents day to day, still run the filtered setup once. Sharing the gateway early is the point: you practise one spend view instead of three separate provider habits.

Official docs you will lean on:

Core concepts

AI Gateway is Vercel's shared routing layer for model calls. Instead of giving each agent its own provider key and invoice, you point the agents at gateway endpoints and use one API key (a secret string that proves the request is yours). Spend, models, and traces land in one place.

Observability here means the AI Gateway dashboards that show requests, which model ran, and how much it cost. That is your proof the setup worked.

BYOK means bring your own key: Cursor's custom OpenAI key and base URL override, so traffic can reach the gateway instead of only Cursor's default models.

Mental model:

PieceRole
One AI Gateway API keyShared credential for Claude Code, Codex, and Cursor
Dedicated endpointsEach agent talks to a gateway path that understands its protocol
Model IDsGateway format creator/model-name (for example anthropic/claude-opus-5.5)
ObservabilitySingle spend and request view after you run a task

Dedicated endpoints (useful if you ever configure by hand):

  • Claude Code: https://ai-gateway.vercel.sh/claude-code
  • Codex: https://ai-gateway.vercel.sh/codex/v1
  • Cursor: https://ai-gateway.vercel.sh/cursor/v1

You do not need to memorise those for the main path. The CLI writes them for Claude Code and Codex. Cursor still needs a short manual finish.

Step-by-step: one shared gateway setup

1. Install or update the Vercel CLI

Either install globally:

npm i -g vercel@latest

Or keep using npx (no global install required) in the commands below.

Sign in if the CLI asks you to (vercel login), so it can create or reuse an AI Gateway key on your account.

2. Run setup for the Buildcamp allowlisted agents only

Limit the command to Claude Code, Codex, and Cursor:

npx vercel ai-gateway setup --agent claude-code --agent codex --agent cursor

What this does:

  1. Detects which of those agents are installed on your machine
  2. Provisions a new AI Gateway API key, or reuses one if your configs already point at the gateway
  3. Shows a diff of planned file changes before it writes anything
  4. On macOS, may store the key in Keychain instead of leaving it in plaintext

Approve the diff only when it matches the agents you intended. If an agent is not installed, the CLI will skip what it cannot configure.

For Cursor, the CLI provisions the key and prints the values you still need. Cursor keeps API key settings in an account-synced store, not a normal local config file, so the CLI cannot finish that part for you.

3. Finish Cursor manually

In Cursor:

  1. Open Settings with Cmd+Shift+J (macOS), then go to Models
  2. Under OpenAI API Key, paste your AI Gateway API key
  3. Enable Override OpenAI Base URL and set it to:
https://ai-gateway.vercel.sh/cursor/v1
  1. Use Add model to register gateway model IDs you care about, for example:
  • anthropic/claude-opus-5.5
  • openai/gpt-6-sol

If you ran the CLI on macOS and the key is in the environment, you can copy it without printing it:

printf %s "$AI_GATEWAY_API_KEY" | pbcopy

If the variable is empty, create or copy a key from the AI Gateway section in the Vercel dashboard (API keys), then paste it into Cursor.

Honest Cursor limits (short): while the base URL override is on, Cursor's own non-OpenAI models are unavailable. Tab completions do not use your custom key. Some Agent or Auto modes may bypass the override. Traffic still passes through Cursor's backend on the way to the gateway.

4. Pick a model worth trying today

In Claude Code or Codex, run /model (or your agent's equivalent picker) and choose a gateway model ID.

Two strong "why try today" options on AI Gateway:

Model IDWhy try it
anthropic/claude-opus-5.5Strong agentic coding model on the gateway catalog; adaptive thinking is always on
openai/gpt-6-solSolid pick for complex, sustained coding work (Luna is the lower-cost sibling: openai/gpt-6-luna)

Opus 5.5 habits that break older prompts:

  • Adaptive thinking is always on. You cannot disable thinking or set a fixed thinking budget. Steer depth with effort and prompting instead.
  • Forced tool use is retired. Do not require a specific tool call the old way. Prefer structured outputs, or prompt for the tool and retry if it misses.

5. Run a small coding task, then confirm Observability

  1. In any configured agent, run a tiny, real task in a scratch folder (for example: "Add a README section that lists the three scripts in this repo").
  2. Open the Vercel dashboard, go to AI Gateway, then Observability (sidebar).
  3. Find your request. Confirm you can see the model and a cost (or usage that implies cost).

That single visible request is your first success. You now share one key, one model catalog style, and one spend view across the agents you connected.

Tip: keep the Observability tab open in a browser while you run the agent task. Refresh after the reply finishes. Seeing the row appear is more convincing than trusting the terminal alone.

Optional hand config (only if the CLI path is blocked)

Claude Code environment variables:

export ANTHROPIC_BASE_URL="https://ai-gateway.vercel.sh/claude-code"
export ANTHROPIC_AUTH_TOKEN="your-ai-gateway-api-key"
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1

Codex config sketch:

model_provider = "vercel"

[model_providers.vercel]
name = "Vercel AI Gateway"
base_url = "https://ai-gateway.vercel.sh/codex/v1"
env_key = "AI_GATEWAY_API_KEY"
wire_api = "responses"

Prefer the CLI when you can. Hand config is the escape hatch, not the main path.

Check your understanding / common mistakes

Quick checks

  1. After setup, can you name which agent still needed a manual Settings change?
  2. What two things must you see in Observability to call the lab done?
  3. Why point Cursor at /cursor/v1 instead of a generic /v1 URL?

Common mistakes

  • Running bare vercel ai-gateway setup without --agent filters, then accepting configs for tools outside this course path. Stick to claude-code, codex, and cursor.
  • Pasting the gateway key into Cursor but forgetting to enable the base URL override (or using the wrong URL).
  • Looking for spend in a provider console instead of AI Gateway Observability.
  • Expecting Opus 5.5 to honour "turn thinking off" or forced tool-choice settings from older examples.
  • Assuming Cursor Tab completions or every Agent/Auto mode will show up in the gateway while the override is on.

If Observability is empty, re-check that the agent you used was one of the three you configured, that Cursor's override URL is exactly the /cursor/v1 endpoint when you tested from Cursor, and that you are looking at the same Vercel team that owns the API key.

What’s next / Going further

You have a working shared path: one CLI setup, Cursor finished by hand, and a confirmed Observability row.

Going further (optional, after the first success):

  • Set budgets on AI Gateway API keys so student or project spend cannot surprise you
  • Explore regional inference and zero data retention (ZDR) options when a client or coursework brief needs them
  • Use BYOK patterns where you bring provider credentials into the gateway for specific models
  • Browse the wider gateway model catalog once Opus 5.5 and GPT-6 Sol/Luna feel familiar

When you are ready to publish agent workflows that watch a Supabase project rather than only write code, continue with the Buildcamp guide on hiring a read-only monitoring agent in Cursor, Claude, or Codex.

Share this guide: