Skip to content

Coding clients

Coding agents talk to a model API; point them at the gateway and every model in the catalog is available to them, billed to one balance, with one key per tool so the request log shows what each one spends.

What the gateway side needs is the same everywhere: the base URL, a key from the API keys page, and model names exactly as GET /v1/models lists them. The setting names below come from each client’s own documentation and change between releases. If a menu or key has moved in your version, the values still go where the client asks for “base URL”, “API key” and “model”.

Two things that apply to all of them:

  • Give each tool its own key and a spend limit. An agent in a loop spends fast.
  • Agents ask for large outputs. The balance hold of a request is sized by its output ceiling (billing), so a low balance can refuse a request that would have been cheap. Keep a buffer, or turn on auto recharge.

Claude Code speaks the Anthropic Messages format. Set the base URL without /v1:

Terminal window
export ANTHROPIC_BASE_URL="https://api.test.whocare.xyz"
export ANTHROPIC_AUTH_TOKEN="sk-..." # sent as Authorization: Bearer; ANTHROPIC_API_KEY (x-api-key) works too
export ANTHROPIC_MODEL="claude-sonnet-5-5" # a name from GET /v1/models
claude

To make it permanent, put the same variables under env in ~/.claude/settings.json:

{
"env": {
"ANTHROPIC_BASE_URL": "https://api.test.whocare.xyz",
"ANTHROPIC_AUTH_TOKEN": "sk-...",
"ANTHROPIC_MODEL": "claude-sonnet-5-5"
}
}

The gateway accepts both header styles. Claude Code also uses a small, fast model for background work; if your catalog does not have the model name it asks for by default, set the variable that selects it (see Claude Code’s documentation for the current name) to a model that exists, or those calls fail with 404 model_not_found. The gateway does not serve /v1/messages/count_tokens.

Because any model works over the Messages format, you can run Claude Code on a non-Anthropic model by setting ANTHROPIC_MODEL to its catalog name. Tool use works through the conversion; how well depends on the model.

In Cursor’s settings, under Models, enter the key as the OpenAI API key, turn on the base URL override and set it to https://api.test.whocare.xyz/v1, then add the model names you want to the model list.

Cursor makes these calls from its own servers, not from your machine, so the gateway address must be reachable from the internet. A gateway on localhost or in a private network will not work.

In Cline’s settings choose the OpenAI Compatible provider:

Field Value
Base URL https://api.test.whocare.xyz/v1
API Key your gateway key
Model ID a name from GET /v1/models

Set the context window and maximum output to the model’s real values (shown in the model catalog); Cline does not know them for a custom endpoint. For Claude models you can use Cline’s Anthropic provider with a custom base URL of https://api.test.whocare.xyz instead.

Codex CLI reads ~/.codex/config.toml. Define the gateway as a provider and select it:

model = "gpt-4o-mini"
model_provider = "gateway"
[model_providers.gateway]
name = "Gateway"
base_url = "https://api.test.whocare.xyz/v1"
env_key = "GATEWAY_API_KEY"
wire_api = "responses"
Terminal window
export GATEWAY_API_KEY="sk-..."
codex

wire_api = "responses" uses /v1/responses; the gateway supports it (Endpoints). If your Codex version needs the Chat Completions format, set wire_api = "chat". The model must be one from GET /v1/models.

Any client with an “OpenAI-compatible” or “custom endpoint” setting works with the same three values (aider, Continue, Open WebUI, and others). Use https://api.test.whocare.xyz/v1 as the base URL for OpenAI-format clients and https://api.test.whocare.xyz for Anthropic-format ones.

Symptom Likely cause
401 invalid_api_key The key was copied with a trailing space or newline, or is for a different gateway.
404 model_not_found The model name is not in GET /v1/models for this key (check the key’s model allowlist).
400 unsupported_capability The model does not support something the client sends (images, tools, structured output). Pick a model that does.
402 insufficient_balance right after a top-up The request’s worst case is larger than the balance: see Billing basis.
403 ip_not_allowed The key has an IP allowlist that does not include the machine (or, for Cursor, Cursor’s servers).
Everything stalls on long answers A proxy between you and the gateway is buffering or cutting idle connections: Streaming.

Look up any failed request by its id in the request log.