Menu

OpenCode

Last updated January 16, 2026

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.

  1. Go to the AI Gateway tab of the Vercel dashboard and click API keys to create a new API key.

  2. Run opencode in your terminal to start OpenCode:

    Terminal
    opencode
  3. Run the /connect command and search for Vercel AI Gateway:

    Terminal
    /connect

    Enter your Vercel AI Gateway API key when prompted.

  4. Run the /models command to select a model:

    Terminal
    /models

    Your requests will now be routed through Vercel AI Gateway.

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

  6. 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?

supported.