cd /news/ai-agents/set-up-claude-code-and-codex-with-on… · home › topics › ai-agents › article
[ARTICLE · art-178475] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Set up Claude Code and Codex with one API key (and keep the bill capped)

A developer on the RABAH.AI team published a guide for routing both Claude Code and Codex through a single OpenAI- and Anthropic-compatible gateway API key at api.rabah.ai, with spend caps applied per key and per account. The setup requires editing ~/.claude/settings.json with ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN entries and adding a Responses-API provider block to ~/.codex/config.toml, then fully restarting each agent so it reads the new configuration. The author said the per-key budget cap is worth enabling even for a single agent because a retry loop can send many requests before anyone notices.

recommendation

Route multiple coding agents through one gateway key with per-key spend caps, and fully restart each agent after changing its config, since Codex only reads config at startup.

more in playbook: Controlling LLM cost
read2 min views4 publishedNov 30, 2026

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:

https://api.rabah.ai. Rabah Desktop (Mac with Apple silicon, Windows 10/11) signs in to your account and writes the API settings for your local agents.

That's it. Restart the agents once so they read the new settings.

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

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.

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.

Rabah Desktop also connects your computer to the Rabah phone app. From your phone you can send tasks, check progress, approve steps, or and resume the agents running on your machine. Remote sessions are end-to-end encrypted, and the computer needs to stay online and awake.

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/

── more in #ai-agents 4 stories · sorted by recency
── more on @rabah.ai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/set-up-claude-code-a…] indexed:0 read:2min 2026-11-30 · —