Skip to content
Docs

Command Code with AI Gateway

Use Command Code with AI Gateway for model access and spend monitoring. Command Code's bring your own key (BYOK) configuration, currently in beta, lets you set a custom provider endpoint and choose models.

Command Code requires manual configuration. The Vercel CLI setup command does not configure it.

  1. With Node.js 22 or later installed, run:

    Terminal
    npm i -g command-code@latest
    command-code --version

    The second command prints the installed version. See the Command Code installation instructions for platform-specific details.

    If you haven't signed in to Command Code, run:

    Terminal
    command-code login

    Complete the sign-in in your browser, then return to the terminal after Command Code confirms the login.

  2. Create an AI Gateway API key and export it in the terminal where you run Command Code:

    Terminal
    export AI_GATEWAY_API_KEY="your-ai-gateway-api-key"

    Replace your-ai-gateway-api-key with your key.

  3. Create ~/.commandcode/providers.json with the following configuration. If the file exists, add the vercel entry to its provider object:

    ~/.commandcode/providers.json
    {
      "provider": {
        "vercel": {
          "name": "Vercel AI Gateway",
          "baseURL": "https://ai-gateway.vercel.sh/coding-agent/v1",
          "apiKey": "$AI_GATEWAY_API_KEY",
          "models": {
            "deepseek/deepseek-v4.1-flash": {}
          }
        }
      }
    }

    The baseURL uses the coding agent endpoint. Command Code uses OpenAI-compatible Chat Completions by default. Add an entry under models for each model you want to use, with its AI Gateway model ID.

    Keep apiKey as an environment variable reference. Command Code rejects raw secrets in providers.json. A key previously saved for this provider through /connect takes precedence. Clear that saved key to use the environment variable.

  4. Start a session in the same terminal:

    Terminal
    command-code

    Run /model and select a model under Vercel AI Gateway. Requests for that model route through AI Gateway. Reopen /model after editing providers.json to load your changes.

    Send a prompt, then check AI Gateway logs to verify the request.

Last updated September 13, 2026

Was this helpful?

supported.