OpenAI Agents SDK with Claude, Gemini and other models: cost tracking and run budgets through a gateway
Run OpenAI Agents SDK agents on any model by pointing the default client at an OpenAI-compatible gateway. Track cost per agent and per run, and stop runaway agents with a dollar budget.
The Agents SDK is built on the OpenAI client, so the gateway plugs in as the default client. Every agent, handoff and tool-calling turn then goes through it, on any model.
Setup
Each agent can use a different model and provider; the gateway records each call against its real model and price.
Cost per run
Tag a run by creating the client per run, or by passing headers through ModelSettings:
With X-Cost-Run-Budget the gateway stops the run with a 429 (run_budget_exceeded) once it has spent that amount. The SDK raises it as an exception from Runner.run, which you can catch and turn into a fallback answer. max_turns limits turns; the run budget limits dollars.
Responses API mode
You can keep the SDK on the Responses API with set_default_openai_api("responses"). The gateway's /v1/responses is stateless: the SDK's default behaviour of sending the full input each turn works, but previous_response_id and hosted tools don't. Chat Completions mode is the safer default for non-OpenAI models.
Related articles