Skip to content
Docs

gptme with AI Gateway

gptme is an open-source, terminal-based AI coding agent with shell, file, and browser tools. It supports custom providers through its TOML config, which you can point at AI Gateway for unified model access and spend monitoring.

Run the Vercel CLI setup command for gptme:

terminal
npx vercel ai-gateway setup --agent gptme

The command upserts a vercel-ai-gateway entry into the [[providers]] array of ~/.config/gptme/config.toml with api_key_env naming AI_GATEWAY_API_KEY, and points [models].default at the gateway's default model.

If you can't use the Vercel CLI, configure gptme manually:

  1. Go to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a new API key.

  2. Export the key in your shell:

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

    To persist the key, add the same line to your shell's startup file.

  3. Add a [[providers]] entry to ~/.config/gptme/config.toml:

    ~/.config/gptme/config.toml
    [[providers]]
    name = "vercel-ai-gateway"
    base_url = "https://ai-gateway.vercel.sh/coding-agent/v1"
    api_key_env = "AI_GATEWAY_API_KEY"
    default_model = "openai/gpt-6-astra"
     
    [models]
    default = "vercel-ai-gateway/openai/gpt-6-astra"

    api_key_env keeps the key in the shell environment, so it never lands in the config file.

  4. Open a new terminal so the key is loaded, then run:

    Terminal
    gptme

    Run other gateway models by name:

    Terminal
    gptme -m vercel-ai-gateway/anthropic/claude-sonnet-5

View your usage, spend, and request activity in the AI Gateway section in the Vercel dashboard sidebar. See the observability documentation for more details.

VariableDescription
AI_GATEWAY_API_KEYYour AI Gateway API key, named by api_key_env. Required

gptme calls AI Gateway through the OpenAI-compatible Chat Completions API, so any model that supports Chat Completions works.

Last updated September 13, 2026

Was this helpful?

supported.