---
title: gptme with AI Gateway
product: vercel
url: /docs/ai-gateway/coding-agents/gptme
canonical_url: "https://vercel.com/docs/ai-gateway/coding-agents/gptme"
last_updated: 2018-10-20
type: how-to
prerequisites:
  - /docs/ai-gateway/coding-agents
  - /docs/ai-gateway
related:
  - /docs/cli/ai-gateway
  - /docs/ai-gateway/observability-and-spend/observability
  - /docs/ai-gateway/sdks-and-apis/openai-chat-completions
  - /docs/ai-gateway/observability-and-spend/budgets
summary: Connect gptme to AI Gateway with the Vercel CLI or a TOML provider configuration.
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---

# gptme with AI Gateway

[gptme](https://github.com/gptme/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.

## Set up with the Vercel CLI

Run the [Vercel CLI setup command](/docs/cli/ai-gateway#setup) for gptme:

```bash filename="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.

## Configuring gptme

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

- ### Create an API key
  Go to the [**AI Gateway**](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai-gateway\&title=Go+to+AI+Gateway) section in the Vercel dashboard sidebar and click **API keys** to create a new API key.

- ### Export the key
  Export the key in your shell:
  ```bash filename="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.

- ### Add the gateway provider
  Add a `[[providers]]` entry to `~/.config/gptme/config.toml`:
  ```toml filename="~/.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.

- ### Start gptme
  Open a new terminal so the key is loaded, then run:
  ```bash filename="Terminal"
  gptme
  ```
  Run other gateway models by name:
  ```bash filename="Terminal"
  gptme -m vercel-ai-gateway/anthropic/claude-sonnet-5
  ```

### Monitor usage and spend

View your usage, spend, and request activity in the [**AI Gateway**](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai-gateway\&title=Go+to+AI+Gateway) section in the Vercel dashboard sidebar. See the [observability documentation](/docs/ai-gateway/observability-and-spend/observability) for more details.

## Environment variables

| Variable             | Description                                       |
| -------------------- | ------------------------------------------------- |
| `AI_GATEWAY_API_KEY` | Your AI Gateway API key, named by `api_key_env`. Required |

> **💡 Note:** gptme calls AI Gateway through the [OpenAI-compatible Chat Completions
> API](/docs/ai-gateway/sdks-and-apis/openai-chat-completions), so any model
> that supports Chat Completions works.

## Next steps

- Browse the [models catalog](/ai-gateway/models) for available models
- Configure [spend limits](/docs/ai-gateway/observability-and-spend/budgets) on your API key
- Read the [gptme documentation](https://gptme.org/docs/) for tools and usage


---

[View full sitemap](/docs/sitemap)
