Claude Code doesn't have to run on Claude: how coding agents switch models
A coding agent is a harness plus a model, connected by an API. Switching models comes down to a base URL, a key, a model name and the right API format.
Claude Code ships set up for Claude and Codex for OpenAI's models, but neither is tied to them. Both, and most other coding agents, can run on a different model with a few settings. This post explains what those settings do.
A harness and a model
A coding agent has two parts:
- The harness reads files, edits code, runs commands and shows you what's happening. This is the program you install.
- The model decides what to do next and writes the code. It runs on a server somewhere else.
They talk over an HTTP API. At every step the harness sends the conversation so far to an address, with a key, and asks for a named model. Change the address, the key and the model name, and the same harness drives a different model.
Three API formats
There is one catch: the request has to be in a format the harness speaks and the server understands. Coding agents use one of three:
| Format | Path | Agents that use it |
|---|---|---|
| Anthropic Messages | /v1/messages |
Claude Code |
| OpenAI Responses | /v1/responses |
Codex CLI |
| OpenAI Chat Completions | /v1/chat/completions |
OpenCode, Cline, Kilo Code, Aider, goose, Qwen Code, Hermes Agent, Pi, oh-my-pi |
Before you switch, check that your provider serves the format your agent speaks. If it doesn't, the agent can't connect, however the rest is set up.
Claude Code
Claude Code reads its connection from environment variables:
export ANTHROPIC_BASE_URL="https://api.paramhub.com"
export ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY"
export ANTHROPIC_MODEL="kimi-k3.1-pro"
export ANTHROPIC_DEFAULT_OPUS_MODEL="kimi-k3.1-pro"
export ANTHROPIC_DEFAULT_SONNET_MODEL="kimi-k3.1-pro"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="kimi-k3.1-pro"
claude
The base URL has no /v1: Claude Code adds /v1/messages itself.
The last three variables are the part people miss. Claude Code asks for models by alias: opus, sonnet, and haiku for background work. If you set only ANTHROPIC_MODEL, those background requests still ask for a Claude model, and your provider returns an error.
To keep the setup, put the same variables in the env block of ~/.claude/settings.json. Inside Claude Code, /status shows the base URL and model in use.
Codex
Codex reads providers from ~/.codex/config.toml:
model = "kimi-k3.1-pro"
model_provider = "paramhub"
web_search = "disabled"
[model_providers.paramhub]
name = "ParamHub"
base_url = "https://api.paramhub.com/v1"
env_key = "PARAMHUB_API_KEY"
wire_api = "responses"
Codex speaks only the Responses format, so wire_api = "responses" is required. At startup it prints "Model metadata for … not found"; that's expected for models that aren't OpenAI's. Its built-in web search isn't part of the model API, so the setup turns it off.
Everything else
The other nine agents speak Chat Completions. Each has its own config file, but they all want the same three things:
- A base URL ending in
/v1. - An API key. Most agents read it from an environment variable you name.
- A model name, spelled exactly as your provider lists it. Names are case-sensitive.
When it doesn't connect
- 401: the key is missing or wrong.
- 404: usually the base URL. Check whether your agent wants it with or without
/v1. model_not_found: the model name doesn't match, often only in capitalization.- Claude Code reports a model error: check that all four model variables are set, not only
ANTHROPIC_MODEL.
Our setup guides have the exact configuration for each of the 11 agents we've tested.
Setup guides and test results for 11 coding agents.
Agent setup, model evaluations, security testing: if it runs on LLM tokens, we take it on.