Coding Agents on reAPI
Run Claude Code on reAPI's Claude models and pay with reAPI credits — setup, model mapping, limits and troubleshooting.
Claude Code can use reAPI as its model provider: it talks to reAPI's Anthropic-compatible Messages endpoint with your reAPI API key, and every request is billed to your reAPI credits.
| Agent | Status |
|---|---|
| Claude Code | Supported through https://reapi.ai/api/v1/messages |
| OpenAI Codex CLI | Not supported on reAPI — see OpenAI Codex CLI below |
To let an agent call reAPI's image, video and audio models instead, use the MCP server or see Use reAPI from AI agents.
Set up Claude Code
Run this in the terminal you start Claude Code from:
export ANTHROPIC_BASE_URL=https://reapi.ai/api
export ANTHROPIC_API_KEY=YOUR_REAPI_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 sonnet- Base URL ends in
/api. Claude Code appends/v1/messagesitself; do not use/api/v1or the full Messages URL. - The three
ANTHROPIC_DEFAULT_*_MODELvariables map Claude Code'sopus,sonnetandhaikualiases (and its background tasks, which use thehaikutier) to reAPI model ids. You can also pass an id directly, for exampleclaude --model claude-haiku-5-5. - Prefer a token header? Use
ANTHROPIC_AUTH_TOKEN=YOUR_REAPI_API_KEYinstead ofANTHROPIC_API_KEY(sent asAuthorization: Bearer). Set only one of the two; if both reach reAPI, thex-api-keyvalue fromANTHROPIC_API_KEYwins.
Add the same exports to your shell profile to make them permanent. Setting
ANTHROPIC_API_KEY makes Claude Code use the key instead of a claude.ai
login for that shell.
Models
| Model id | Use it for |
|---|---|
claude-opus-5-5 | Hardest tasks, long refactors |
claude-sonnet-5-5 | Everyday coding (good default) |
claude-haiku-5-5 | Fast, low-cost tasks and background work |
claude-fable-5, claude-fable-5-1 | Also available on the Messages endpoint |
Prices per million tokens are on each model's page, for example
Claude Sonnet 5.5. Other reAPI chat models (GPT,
Gemini, Kimi, DeepSeek) are served on the OpenAI-compatible
/api/v1/chat/completions endpoint and cannot be selected in Claude Code.
Check the connection
curl -N https://reapi.ai/api/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,
"stream": true,
"messages": [{"role": "user", "content": "Reply OK."}]
}'A working setup streams message_start, content_block_delta and
message_stop events.
Credits and limits
- Requests are billed by tokens after they complete. A new request needs a
balance of at least 10 credits ($0.01); below that reAPI answers HTTP
402
Insufficient credits. - Up to 20 chat requests can be in flight at once per user, shared by all your keys — enough for Claude Code with subagents, but not for many parallel sessions on one account.
- The per-user limit of 50 requests per second applies too. Both limits
answer HTTP 429 (with
Retry-Afterwhen reAPI sets the limit).
OpenAI Codex CLI
Recent Codex CLI versions only talk to the OpenAI Responses API, which reAPI does not offer, so reAPI cannot be Codex's model provider. Codex can still call reAPI's image, video and audio models through the MCP server. To run Codex on GPT models with usage-based billing, follow SeedRouter's Codex setup guide. SeedRouter is a separate service: it uses its own account, API key and balance, and reAPI keys and credits do not work there.
Troubleshooting
| Symptom | Fix |
|---|---|
401 authentication_error | Check the key, and that only one of ANTHROPIC_API_KEY / ANTHROPIC_AUTH_TOKEN is set. |
404 on every request | ANTHROPIC_BASE_URL must be https://reapi.ai/api. |
400 Unsupported model | Use one of the model ids above; GPT, Gemini and other chat models do not work in Claude Code. |
[claude-code:unrecognized_model] printed at start | Harmless: Claude Code does not know reAPI's model ids by name. Requests still go through. |
| A notice about auto mode classifier billing | Informational. Auto mode keeps working through reAPI. |
402 Insufficient credits | Top up so the balance is at least 10 credits. |
429 | Fewer parallel sessions or subagents; respect Retry-After when present. |