Disclosure: I'm on the team that builds RABAH.AI, the gateway used in this post. The manual steps below work with any OpenAI- or Anthropic-compatible gateway.
If you run more than one coding agent, you know the routine: one key for Claude Code, another for Codex, two dashboards, two bills, and a small worry that an agent stuck in a loop will burn through your budget overnight.
This post shows how to point both agents at a single API key, two ways:
- One click with a desktop app.
- By hand, editing the config files yourself.
What you need
- Claude Code and/or Codex installed.
- An API key from a gateway that speaks both the OpenAI API (Codex uses the Responses endpoint) and the Anthropic Messages API (Claude Code uses it). I'll use RABAH.AI, where the base URL is
https://api.rabah.ai.
Option 1: one click with Rabah Desktop
Rabah Desktop (Mac with Apple silicon, Windows 10/11) signs in to your account and writes the API settings for your local agents.
- Download it from rabah.ai/en/ and sign in.
- Pick a key. The app applies it to Claude Code and Codex.
- Check the Overview page. Each agent should say Rabah API configured.
That's it. Restart the agents once so they read the new settings.
Option 2: configure it by hand
Claude Code
Add three entries to the "env" block of ~/.claude/settings.json (keep any settings you already have):
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.rabah.ai",
"ANTHROPIC_AUTH_TOKEN": "YOUR_KEY",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
To try it in one terminal session first instead:
export ANTHROPIC_BASE_URL="https://api.rabah.ai"
export ANTHROPIC_AUTH_TOKEN="YOUR_KEY"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
Codex
In ~/.codex/config.toml, add a provider that uses the Responses API:
model_provider = "OpenAI"
model = "MODEL_NAME"
[model_providers.OpenAI]
name = "OpenAI"
base_url = "https://api.rabah.ai/v1"
wire_api = "responses"
requires_openai_auth = false
experimental_bearer_token = "YOUR_KEY"
Replace MODEL_NAME with a model from the gateway's model list. Keep the top-level lines above the [model_providers...] section, or Codex ignores them.
Then quit Codex completely and reopen it. A new conversation isn't enough, because Codex reads the config only at startup.
If something fails
- 401 errors: the key is incomplete, disabled, expired or out of quota.
- Changes don't apply: you didn't fully restart the agent.
- Empty model list in Codex: update Codex, or check whether the key is limited to certain models.
Cap the spend
This is the part I'd do even if you only run one agent. An agent in a retry loop can send a lot of requests before you notice.
- Per key: create a separate key for each agent or script, and give each its own quota and rate limits (for example, a cap per 5 hours, per day and per 7 days). If a key leaks or an agent misbehaves, the damage stops at that cap.
- Per account: RABAH.AI plans start at $5 and come with daily, weekly and monthly caps, so the total can't run away either.
Bonus: keep agents running while you're away
Rabah Desktop also connects your computer to the Rabah phone app. From your phone you can send tasks, check progress, approve steps, or pause and resume the agents running on your machine. Remote sessions are end-to-end encrypted, and the computer needs to stay online and awake.
Wrap-up
One key, two agents, spend capped per key and per account. If you set this up a different way, or hit a snag, tell me in the comments. I'd like to hear what's missing.
Docs: docs.rabah.ai/en/


Top comments (0)