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:
npx vercel ai-gateway setup --agent gptmeThe 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:
Go to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a new API key.
Export the key in your shell:
Terminalexport AI_GATEWAY_API_KEY="your-ai-gateway-api-key"To persist the key, add the same line to your shell's startup file.
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_envkeeps the key in the shell environment, so it never lands in the config file.Open a new terminal so the key is loaded, then run:
TerminalgptmeRun other gateway models by name:
Terminalgptme -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.
| Variable | Description |
|---|---|
AI_GATEWAY_API_KEY | Your AI Gateway API key, named by api_key_env. Required |
- Browse the models catalog for available models
- Configure spend limits on your API key
- Read the gptme documentation for tools and usage
Was this helpful?