Connect
Claude Code and Codex
Measure coding agents from their own telemetry, or route their model calls through the gateway for an exact cost per call.
Coding agents are often the largest AI cost in an engineering team, and the hardest to see. There are two ways to measure them, and you can use both.
| Telemetry (observe-only) | Through the gateway | |
|---|---|---|
| Works with | Claude Code on a subscription or an API key | Claude Code or Codex with an API key |
| In the live path? | No | Yes |
| Cost | Claude Code's own estimate of the API-priced value | Measured from the provider's own reply, per call |
| You also get | sessions, prompts and tool runs counted, per signed-in email | tools, cache use and context size per call |
#Claude Code: telemetry
Claude Code exports its own usage over OpenTelemetry: tokens by type, its own cost estimate, sessions and tools,
attributed to the signed-in email. Set these where Claude Code runs (your shell profile, or the env block of its
settings file). Leave the export intervals at their defaults.
CLAUDE_CODE_ENABLE_TELEMETRY=1
OTEL_EXPORTER_OTLP_ENDPOINT=https://ai.odux.io/app
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_METRICS_EXPORTER=otlp
OTEL_LOGS_EXPORTER=otlp
OTEL_TRACES_EXPORTER=otlp
OTEL_EXPORTER_OTLP_HEADERS="X-API-Key=YOUR_IA_KEY"
OTEL_SERVICE_NAME=claude-codeWithout CLAUDE_CODE_ENABLE_TELEMETRY=1 and the three exporters, nothing is sent. The cost shown is Claude Code's
estimate of what the work would cost at API prices, never a bill: on a subscription you pay the plan, not that
figure. The Claude Code report in your workspace (and GET /report/claude-code)
shows the sessions, requests, tools run and failed, and errors.
#Claude Code: through the gateway
With an Anthropic API key, or a DeepSeek or Kimi model that speaks the Anthropic format, Claude Code's model calls can go through the gateway like any agent's. Add that provider's key on your Connect page, then:
ANTHROPIC_BASE_URL=https://ai.odux.io/gateway/agent/Claude%20Code
ANTHROPIC_API_KEY=YOUR_IA_KEYANTHROPIC_BASE_URL takes no /v1: Claude Code adds /v1/messages itself. The agent's name is in the address, so
every call is filed under Claude Code.
To keep your own provider key in ANTHROPIC_API_KEY instead of storing it, send your IA4AI key as a separate header:
ANTHROPIC_CUSTOM_HEADERS="x-ia-key: YOUR_IA_KEY"A Claude Code signed in with a Claude subscription talks to Anthropic directly and cannot be routed: use telemetry for it.
#Codex
Codex can send its model calls through the gateway in its own format (OpenAI Responses), with your stored OpenAI key. Add your OpenAI key on your Connect page, then add a provider to Codex's config:
model_provider = "ia4ai"
[model_providers.ia4ai]
name = "IA4AI"
base_url = "https://ai.odux.io/gateway/agent/Codex/v1"
env_key = "IA4AI_KEY"
wire_api = "responses"and set your IA4AI key where Codex runs:
IA4AI_KEY=YOUR_IA_KEYEach call is recorded with its model, tokens, cached input, reasoning tokens and tools. A Codex signed in with a ChatGPT plan talks to ChatGPT directly and cannot be routed.
#OpenCode
OpenCode can send its model calls through the gateway as a custom OpenAI-compatible provider, with a provider key you
stored on your Connect page (DeepSeek, for example). Add this provider to opencode.json, in your project or in
~/.config/opencode/opencode.json for every project:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ia4ai": {
"npm": "@ai-sdk/openai-compatible",
"name": "IA4AI gateway",
"options": {
"baseURL": "https://ai.odux.io/gateway/agent/OpenCode/v1",
"apiKey": "{env:IA4AI_KEY}"
},
"models": {
"deepseek-v4-pro": {
"name": "DeepSeek V4 Pro"
},
"deepseek-flash": {
"name": "DeepSeek Flash"
}
}
}
}
}and set your IA4AI key where OpenCode runs:
IA4AI_KEY=YOUR_IA_KEYRestart OpenCode and pick a model under IA4AI gateway. List the models you use: the gateway sends each call to the provider its model name belongs to. Each call is recorded with its model, tokens, cached input and tools, under the agent name OpenCode. OpenCode on a plan of its own (Zen, or a subscription) talks to that service directly and cannot be routed.
#Cline, Roo Code and other coding tools
Tools with an OpenAI-compatible provider setting use the gateway as any agent does: base URL
https://ai.odux.io/gateway/agent/Cline/v1 (any name in place of Cline), and your IA4AI key as the API key. See
the gateway.
Tip. If several editor windows share one provider setting, they all go through the gateway. Switching one window back to the provider does not switch the others.

