OpenCode
OpenCode is a terminal-based AI coding assistant that runs in your development environment. Here's how to use OpenCode with Vercel AI Gateway to access models from OpenAI, Anthropic, Google, xAI, and more through a unified endpoint.
Go to the AI Gateway tab of the Vercel dashboard and click API keys to create a new API key.
Run
opencodein your terminal to start OpenCode:TerminalopencodeRun the
/connectcommand and search for Vercel AI Gateway:Terminal/connectEnter your Vercel AI Gateway API key when prompted.
Run the
/modelscommand to select a model:Terminal/modelsYour requests will now be routed through Vercel AI Gateway.
You can customize models through your OpenCode config. Here's an example of specifying provider routing order in
opencode.json:opencode.json{ "$schema": "https://opencode.ai/config.json", "provider": { "vercel": { "models": { "anthropic/claude-sonnet-4.5": { "options": { "order": ["anthropic", "vertex"] } } } } } }See the provider options documentation for more details on supported routing options.
View your usage, spend, and request activity in the AI Gateway tab of the Vercel dashboard. See the observability documentation for more details.
Was this helpful?