Skip to main content
Run Claude Code, Codex CLI, OpenCode or Pi on GLM-5.3, Kimi K3 and DeepSeek V4 with one Hedra API key. Every model has a context length of 1,048,576 tokens, and you pay per token from the same API wallet as your media jobs. Claude Code connects to 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:write scope and a funded API wallet. See Before you start in the chat completions guide.
  • The key in the HEDRA_KEY environment 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

The steps below use Claude Code 2.1.288.
1

Install Claude Code

2

Add a configuration directory for Hedra

Save this as ~/.claude-hedra/settings.json:
  • Claude Code runs the apiKeyHelper command and sends its output as your key, so the file contains no secret.
  • ANTHROPIC_MODEL names 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_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL name 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_SERVER set to 0 tells Claude Code that Hedra doesn’t run Anthropic’s auto mode checks, so Claude Code runs its own.
3

Start Claude Code

Claude Code reads its settings from the directory in 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 list prints your servers’ names, and -c mcp_servers.<name>.enabled=false turns one off for the session:
    In OpenCode, set "mcp": { "linear": { "enabled": false } } in opencode.json. By default, Pi adds no MCP tool definitions to the prompt.
  • Keep CLAUDE.md and AGENTS.md focused. Claude Code sends the repository’s CLAUDE.md with every request, and Codex, OpenCode and Pi send its AGENTS.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 ~/.claude into its prompt. Set OPENCODE_DISABLE_CLAUDE_CODE=1 to 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 401 response. When HEDRA_KEY is unset, Codex prints Missing environment variable: HEDRA_KEY, OpenCode prints Missing credentials and Pi prints No API key found for hedra. Set HEDRA_KEY in the terminal that starts the agent, and restart the agent.
  • A 402 response. Your API wallet’s balance cannot cover the request. Add funds and send the message again.