{"slug": "set-up-claude-code-and-codex-with-one-api-key-and-keep-the-bill-capped", "title": "Set up Claude Code and Codex with one API key (and keep the bill capped)", "summary": "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.", "body_md": "*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.*\n\nIf 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.\n\nThis post shows how to point both agents at a single API key, two ways:\n\n`https://api.rabah.ai`.\nRabah Desktop (Mac with Apple silicon, Windows 10/11) signs in to your account and writes the API settings for your local agents.\n\nThat's it. Restart the agents once so they read the new settings.\n\nAdd three entries to the `\"env\"` block of `~/.claude/settings.json` (keep any settings you already have):\n\n```\n{\n  \"env\": {\n    \"ANTHROPIC_BASE_URL\": \"https://api.rabah.ai\",\n    \"ANTHROPIC_AUTH_TOKEN\": \"YOUR_KEY\",\n    \"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC\": \"1\"\n  }\n}\n```\n\nTo try it in one terminal session first instead:\n\n```\nexport ANTHROPIC_BASE_URL=\"https://api.rabah.ai\"\nexport ANTHROPIC_AUTH_TOKEN=\"YOUR_KEY\"\nexport CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1\n```\n\nIn `~/.codex/config.toml`, add a provider that uses the Responses API:\n\n```\nmodel_provider = \"OpenAI\"\nmodel = \"MODEL_NAME\"\n\n[model_providers.OpenAI]\nname = \"OpenAI\"\nbase_url = \"https://api.rabah.ai/v1\"\nwire_api = \"responses\"\nrequires_openai_auth = false\nexperimental_bearer_token = \"YOUR_KEY\"\n```\n\nReplace `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.\n\nThen **quit Codex completely** and reopen it. A new conversation isn't enough, because Codex reads the config only at startup.\n\nThis 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.\n\nRabah 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.\n\nOne 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.\n\nDocs: [docs.rabah.ai/en/](https://docs.rabah.ai/en/)", "url": "https://wpnews.pro/news/set-up-claude-code-and-codex-with-one-api-key-and-keep-the-bill-capped", "canonical_source": "https://dev.to/_880ce54cf16efabc4d42b/set-up-claude-code-and-codex-with-one-api-key-and-keep-the-bill-capped-1793", "published_at": "2026-11-30 08:38:28+00:00", "updated_at": "2026-11-30 08:44:59.499998+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-infrastructure"], "entities": ["RABAH.AI", "Claude Code", "Codex", "Anthropic", "OpenAI"], "also_reported_by": [], "takeaway": "Pointing Claude Code and Codex at one gateway key requires setting ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN in ~/.claude/settings.json and a wire_api = \"responses\" provider in ~/.codex/config.toml, then fully restarting each agent, since Codex reads config only at startup.", "recommendation": {"advice": "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.", "playbook": "llm-cost", "playbook_url": "https://wpnews.pro/playbooks/llm-cost"}, "alternates": {"html": "https://wpnews.pro/news/set-up-claude-code-and-codex-with-one-api-key-and-keep-the-bill-capped", "markdown": "https://wpnews.pro/news/set-up-claude-code-and-codex-with-one-api-key-and-keep-the-bill-capped.md", "text": "https://wpnews.pro/news/set-up-claude-code-and-codex-with-one-api-key-and-keep-the-bill-capped.txt", "jsonld": "https://wpnews.pro/news/set-up-claude-code-and-codex-with-one-api-key-and-keep-the-bill-capped.jsonld"}}