POST /v3/anthropic/v1/messages, Codex connects to POST /v3/responses, and OpenCode and Pi connect to POST /v3/chat/completions, each with a few lines of configuration.
Before you start
- A key with the
chat:writescope and a funded API wallet. See Before you start in the chat completions guide. - The key in the
HEDRA_KEYenvironment variable of the terminal that starts the agent:
Choose a model
On 2026-09-30 we had OpenCode, on each model, write unit tests for one module of a large Python repository and run them until they passed. Every model finished in 8 to 14 requests.
GET /v3/models returns each model’s current per-token prices.
Connect an agent
- Claude Code
- Codex CLI
- OpenCode
- Pi
The steps below use Claude Code 2.1.288.Claude Code reads its settings from the directory in
1
Install Claude Code
2
Add a configuration directory for Hedra
Save this as
~/.claude-hedra/settings.json:- Claude Code runs the
apiKeyHelpercommand and sends its output as your key, so the file contains no secret. ANTHROPIC_MODELnames the model. The[1m]suffix tells Claude Code that the model’s context length is 1,000,000 tokens; without it, Claude Code assumes 200,000 for a model it does not know and compacts the conversation as it nears that. Claude Code sends the id without the suffix.ANTHROPIC_DEFAULT_OPUS_MODEL,ANTHROPIC_DEFAULT_SONNET_MODELandANTHROPIC_DEFAULT_HAIKU_MODELname the model Claude Code picks for each tier. In auto mode, Claude Code checks tool calls with the Sonnet tier’s model, and it runs background tasks such as session titles on the Haiku tier’s model.CLAUDE_CODE_AUTO_MODE_SERVERset to0tells Claude Code that Hedra doesn’t run Anthropic’s auto mode checks, so Claude Code runs its own.
3
Start Claude Code
CLAUDE_CONFIG_DIR, so only the sessions you start this way use Hedra. In those sessions, Claude Code loads none of your MCP servers or plugins, which keeps their tool definitions out of every request. /status shows the base URL and the credential in use.CLAUDE_CONFIG_DIR=~/.claude-hedra claude --model 'moonshotai/kimi-k3[1m]' switches models for one session. Claude Code’s /effort levels become the model’s reasoning_effort, and the model’s reasoning appears as thinking. In print mode (claude -p), Claude Code writes [claude-code:unrecognized_model] to stderr for a Hedra model id, and the session runs normally.Claude Code’s cost figures, in /cost and in the total_cost_usd of claude -p --output-format json, don’t match Hedra’s charges. Hedra’s charge for each request is in the response’s usage.cost, on the Jobs tab of the developer console, and in GET /v3/jobs/{job_id}.Keep sessions inexpensive
An agent sends its instructions, its tool definitions and the conversation so far with every request, and Hedra bills each request’s tokens at the model’s prices. A shorter prompt lowers the price of every request in the session:-
Turn off the MCP servers a session does not need. Each MCP server adds its tool definitions to every request. In Codex,
codex mcp listprints your servers’ names, and-c mcp_servers.<name>.enabled=falseturns one off for the session:In OpenCode, set"mcp": { "linear": { "enabled": false } }inopencode.json. By default, Pi adds no MCP tool definitions to the prompt. -
Keep
CLAUDE.mdandAGENTS.mdfocused. Claude Code sends the repository’sCLAUDE.mdwith every request, and Codex, OpenCode and Pi send itsAGENTS.md. Claude Code also sends the name and description of every skill it has loaded. -
Leave Claude Code’s files out of OpenCode. OpenCode also reads Claude Code’s instructions and skills from
~/.claudeinto its prompt. SetOPENCODE_DISABLE_CLAUDE_CODE=1to leave them out.
GET /v3/usage reports your spend on each model since start, with a key that has the usage:read scope:
Troubleshooting
- Codex prints
Model metadata for zai-org/glm-5.3 not found. Codex has no metadata for Hedra’s models, and the session runs normally without it. - Claude Code’s WebSearch tool fails. WebSearch runs on Anthropic’s web search server tool, which Hedra answers with
400. WebFetch reads pages itself and works. - A missing key, or a
401response. WhenHEDRA_KEYis unset, Codex printsMissing environment variable: HEDRA_KEY, OpenCode printsMissing credentialsand Pi printsNo API key found for hedra. SetHEDRA_KEYin the terminal that starts the agent, and restart the agent. - A
402response. Your API wallet’s balance cannot cover the request. Add funds and send the message again.