# Coding Agents on SeedRouter

Coding agents can use SeedRouter as their model provider. They send requests with your SeedRouter API key, and every request is billed by tokens to your SeedRouter balance instead of a subscription.

| Agent       | Endpoint it uses                                            | Models |
| ----------- | ----------------------------------------------------------- | ------ |
| Claude Code | Anthropic Messages, `https://api.seedrouter.ai/v1/messages` | Claude |
| Codex CLI   | OpenAI Responses, `https://api.seedrouter.ai/v1/responses`  | GPT-6  |

To let an agent *call* SeedRouter's image and video models instead, use the [MCP server](https://seedrouter.ai/docs/api/mcp) or see [Use SeedRouter from AI agents](https://seedrouter.ai/docs/api/agents).

## Claude Code

Run this in the terminal you start Claude Code from:

```bash
export ANTHROPIC_BASE_URL=https://api.seedrouter.ai
export ANTHROPIC_API_KEY=YOUR_API_KEY
export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5-5
export ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5-5
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-5-5

claude --model claude-opus-5-5
```

* **The base URL has no path.** Claude Code adds `/v1/messages` itself.
* **The three `ANTHROPIC_DEFAULT_*_MODEL` variables** point Claude Code's `opus`, `sonnet` and `haiku` aliases, which it also uses for background work, at SeedRouter model IDs. You can also pass an ID directly, for example `claude --model claude-fable-5-1`.
* **The key replaces your Claude plan.** In an interactive session, Claude Code asks you once to approve the key; from then on, requests are billed to your SeedRouter balance. Unset the variables to go back to your plan.

To keep the settings for every launch, put the same variables in the `env` block of `~/.claude/settings.json`. That file then holds a key that spends your balance, so keep it private.

| Model ID            | Use it for                              |
| ------------------- | --------------------------------------- |
| `claude-opus-5-5`   | Everyday coding                         |
| `claude-fable-5-1`  | Long refactors and hard debugging       |
| `claude-fable-5`    | Setups that rely on forcing a tool call |
| `claude-sonnet-5-5` | The `sonnet` alias                      |
| `claude-haiku-5-5`  | The `haiku` alias and background work   |

Live rates per million tokens are on each model's page, for example [Claude Opus 5.5](https://seedrouter.ai/models/claude-opus-5-5). The [Claude Code guide](https://seedrouter.ai/blog/claude-fable-5-1-claude-code) records the full setup, prompt caching behavior and test results.

## Codex CLI

Add SeedRouter to your user-level `~/.codex/config.toml`, keeping your other settings:

```toml
model = "gpt-6-sol"
model_provider = "seedrouter"

[model_providers.seedrouter]
name = "SeedRouter"
base_url = "https://api.seedrouter.ai/v1"
env_key = "SEEDROUTER_API_KEY"
wire_api = "responses"
```

Then export your key and start Codex:

```bash
export SEEDROUTER_API_KEY=YOUR_API_KEY
codex
```

* **Use the user-level file.** Codex ignores `model_provider` and `model_providers` in a project's `.codex/config.toml`.
* **Pick the model** with `model`, or for one session with `codex -m gpt-6-astra`. GPT-6 Astra suits the hardest tasks, GPT-6 Sol everyday coding and GPT-6 Luna fast, cheaper steps.
* **The tested models are GPT-6.** Codex sends Responses requests; another text model needs to accept the Responses format, which its API reference lists, and has not been tested in Codex.

The [GPT-6 Codex guide](https://seedrouter.ai/blog/gpt-6-codex) records the context window and reasoning effort settings and the test results.

## Check the connection

```bash
curl https://api.seedrouter.ai/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-haiku-5-5",
    "max_tokens": 32,
    "messages": [{"role": "user", "content": "Reply OK."}]
  }'
```

A working key returns a message with a short reply. For Codex, run `codex exec "Reply OK."` after setting up the configuration above.

## Cost and limits

* Requests are billed by the tokens in each response. A coding session sends a long prompt prefix with every request: instructions, tool definitions and project files. Where the model supports prompt caching, later requests read that prefix from the cache at a lower rate.
* Every request appears in your [usage history](https://seedrouter.ai/usage). Add credit on the [billing page](https://seedrouter.ai/billing).
* HTTP `429` means too many requests at once. Run fewer parallel sessions or subagents, and wait for `Retry-After` when it is present.

## Troubleshooting

| Symptom                | Fix                                                                                                                        |
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `401`                  | Check the key. For Claude Code, set either `ANTHROPIC_API_KEY` or `ANTHROPIC_AUTH_TOKEN`, not both.                        |
| `404` on every request | Claude Code needs `ANTHROPIC_BASE_URL=https://api.seedrouter.ai`; Codex needs `base_url = "https://api.seedrouter.ai/v1"`. |
| Model not available    | Use a model ID listed above: Claude models for Claude Code, GPT-6 for Codex.                                               |
| Insufficient balance   | Add credit on the [billing page](https://seedrouter.ai/billing).                                                                                |
| `429`                  | Fewer parallel sessions or subagents; respect `Retry-After` when present.                                                  |
