Use AI gateway with coding agents Early availability
Point your coding agent like Claude Code or Codex at the AI gateway to send requests using your API key.
project:ai_gateway_keys:write, project:ai_gateway_keys:read, role:project:admin, or role:project:managerPrerequisites
- AI Gateway enabled for your organization.
- An API key.
Use Claude Code with AI gateway models
To use Claude Code with the AI Gateway, set the gateway address, your API key, and the model names in the terminal or in Claude Code's configuration file.
| Variable | Value |
|---|---|
ANTHROPIC_BASE_URL | https://ai.aiven.io |
ANTHROPIC_AUTH_TOKEN | Your AI Gateway API key |
ANTHROPIC_MODEL | aiven-model |
ANTHROPIC_DEFAULT_OPUS_MODEL | claude-opus-5 |
ANTHROPIC_DEFAULT_SONNET_MODEL | claude-sonnet-5 |
ANTHROPIC_DEFAULT_HAIKU_MODEL | claude-haiku-4-5 |
aiven-model is the Aiven router, and usage on it is free. To use a specific model, set ANTHROPIC_MODEL to that model's name. Named models are billed at the rates shown in the model list.
Claude Code sends smaller jobs, such as session titles and some subagent work, to its Opus, Sonnet, and Haiku aliases. Those aliases default to the model you pin.
- Terminal
- Claude Code configuration
Export the variables for the session. Exports last for that terminal session and for programs you start from it.
export ANTHROPIC_BASE_URL="https://ai.aiven.io"
export ANTHROPIC_AUTH_TOKEN="API_KEY"
export ANTHROPIC_MODEL="aiven-model"
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-5"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4-5"
Put the values in the env block of the ~/.claude/settings.json file.
To use these settings in only one project, add them to the
.claude/settings.local.json file in that project.
{
"env": {
"ANTHROPIC_BASE_URL": "https://ai.aiven.io",
"ANTHROPIC_AUTH_TOKEN": "API_KEY",
"ANTHROPIC_MODEL": "aiven-model",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5"
}
}
Test Claude Code with AI Gateway
- To start Claude Code, run
claude.
If you exported the variables, run all commands in the same terminal where you exported the variables.
-
To confirm the gateway is configured, run
/status. The Auth token is the variableANTHROPIC_AUTH_TOKENand the Anthropic base URL ishttps://ai.aiven.io. -
Close the status and send a test prompt.
-
To verify the request was sent to the AI Gateway, go to the Aiven Console.
-
Click AI Gateway.
-
To see the request, view the usage metrics on the page for the API key you used. A new request can take about 15 minutes to appear.
Use Codex with AI gateway models
-
Export the API key.
export AIVEN_AI_GATEWAY_KEY="API_KEY" -
Add a provider to the
~/.codex/config.tomlfile.model = "aiven-model"model_provider = "aiven"[model_providers.aiven]name = "Aiven AI Gateway"base_url = "https://ai.aiven.io/v1"env_key = "AIVEN_AI_GATEWAY_KEY"wire_api = "responses"
aiven-model is the Aiven router, and usage on it is free. To use a specific model, set model to that model's name. Named models are billed at the rates shown in the model list.
Test Codex with AI Gateway
In the same terminal where you exported the API key:
-
To start Codex, run
codex. -
To confirm the active model is
aiven-model, run/status. -
Send a test prompt.
-
To verify the request was sent to the AI Gateway, go to the Aiven Console.
-
Click AI Gateway.
-
To see the request, view the usage metrics on the page for the API key you used. A new request can take about 15 minutes to appear.