Docs · Guide

Vercel AI Gateway in Claude Code, Codex and other agents

Vercel AI Gateway serves every maker's models with one key, as maker/model ids. magpie's vercel preset brings it to Claude Code, Codex, OpenCode and other agents, with all three APIs set and no address to type.

Add it

  1. Get a key.Create one under AI Gateway → API Keys in the Vercel dashboard.
  2. Add it.Pick Vercel AI Gateway in the app and paste the key into API key, or from the CLI:
Terminal
magpie provider add vercel 
magpie provider test vercel

The preset points Chat Completions and Responses at https://ai-gateway.vercel.sh/v1 and Anthropic Messages at https://ai-gateway.vercel.sh. By Vercel's docs, each of them serves every model.

Use it in an agent

Model ids are vercel/<Vercel's model id>, which already names the maker:

Terminal
magpie claude vercel/anthropic/claude-sonnet-4.6
magpie codex vercel/openai/gpt-5.5

A Claude model goes to Vercel's Anthropic Messages whatever API the agent spoke: a relay serving both drops cache_control on Chat, so every turn was billed uncached, and thinking with it. Other models go on the agent's own API: Responses for Codex, Chat Completions for a Chat client.

The model list

Vercel's /v1/models says each row's type, and magpie sorts by it:

Notes

FAQ

Does magpie support Vercel AI Gateway?

Yes, with the vercel preset. Give an AI Gateway key; Chat Completions, Responses and Anthropic Messages are set, and a model id is vercel//.

Does Claude Code hit the cache with Claude on Vercel?

Yes. A Claude model always goes to Vercel's Anthropic Messages with cache_control as sent, so the cache isn't lost on Chat.

Can Codex use Vercel AI Gateway?

Yes. Codex speaks Responses, which magpie sends to Vercel's /v1 Responses API; the model is vercel//.

Why are some models missing from the list?

magpie sorts by Vercel's types: evaluation models, realtime voices and -batch ids answer no synchronous chat and stay out of agents' lists; image, video, embedding and speech models go to their own APIs.

Related: OpenRouter in Claude Code, Codex, Gemini CLI and OpenCode, Round robin and failover across accounts, keys and providers. If something fails, see Fixing common errors: 401, 429, 502, 504 and more or ask on Discord.