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
- Codex CLI
- OpenCode
- Pi
The steps below use Codex CLI 0.159.2.
1
Install Codex
2
Add a Codex profile
Save this as Codex sends the tool definitions of your ChatGPT apps, such as GitHub and Slack, with every request, which can add tens of thousands of tokens.
~/.codex/hedra.config.toml:apps = false leaves them out of Hedra sessions.3
Start Codex
codex --profile hedra --model moonshotai/kimi-k3 switches models. Hedra maps Codex’s model_reasoning_effort values onto the models’ own: minimal to low, medium to the model’s default effort, and xhigh to max.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
AGENTS.mdfocused. Codex, OpenCode and Pi send the repository’sAGENTS.mdwith every request. -
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. - A
401response. 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.