Run Codex and Claude Code Side by Side
Running Codex and Claude Code side by side gives you two different AI coding assistants for the same project. You can ask Claude Code to explore a codebase or review an architecture, then use Codex to implement a change, generate tests, or investigate a failing command. The key is configuring each terminal independently so the tools do not use the wrong API credentials or overwrite each other’s work.
What you need before starting
Install both command-line tools using their current official installation instructions. You will also need a 59API account and an API key. 59API provides pay-as-you-go access to native Claude models, including Opus, Sonnet, Haiku, and Fable, as well as GPT models through an OpenAI-compatible interface. This can be considerably cheaper than maintaining separate subscriptions, while still using official-quality models rather than downgraded alternatives.
Create a separate terminal window for each assistant. Keeping the environments separate is more reliable than exporting every variable in your main shell profile.
Configure Claude Code
In Terminal 1, set Claude Code to use 59API. The exact authentication variable can vary by Claude Code version, but this is the common setup:
export ANTHROPIC_BASE_URL='https://api.59api.com'
export ANTHROPIC_AUTH_TOKEN='YOUR_59API_KEY'
claude
If your installation expects ANTHROPIC_API_KEY instead, use that variable according to the version’s help output or documentation. Once Claude Code starts, check its model selector and choose the Claude model that fits the task. Sonnet is often a practical default for everyday coding, while Opus is useful for difficult reasoning and large refactors.
Configure Codex
In Terminal 2, configure the OpenAI-compatible endpoint:
export OPENAI_BASE_URL='https://api.59api.com'
export OPENAI_API_KEY='YOUR_59API_KEY'
codex
Codex CLI versions can differ in how they define a custom provider. If OPENAI_BASE_URL is not detected, run codex --help and add the endpoint in the tool’s configuration file or provider settings. Use the base URL supplied by 59API exactly; do not add an extra path unless 59API’s current documentation tells you to.
A practical side-by-side workflow
- Use Claude Code for discovery: Ask it to map the repository, explain unfamiliar modules, identify risks, or propose a small implementation plan.
- Use Codex for execution: Give Codex a focused task, such as implementing one function, updating a test, or fixing a reported error.
- Run tests after each meaningful change: Keep the feedback loop short so you know which assistant introduced a regression.
- Use the second assistant as a reviewer: Ask Claude Code to inspect Codex’s diff, or ask Codex to challenge a proposed Claude Code implementation.
Give both tools precise instructions. State which files they may edit, which commands they can run, and what “done” means. Avoid asking both assistants to perform a broad rewrite simultaneously.
Prevent conflicting edits
Both tools can read and modify the same working tree, so check git diff and git status frequently. A safe pattern is to let only one assistant edit at a time. For larger experiments, create separate Git branches or worktrees, then compare the results before merging. Never assume an assistant will preserve uncommitted changes unless you explicitly tell it to.
Also avoid putting API keys in project files or committing shell history. Store credentials in environment variables, and use separate terminal sessions when switching between providers. If requests fail, first verify the base URL, key, selected model, and whether the installed CLI supports custom endpoints.
Keep costs predictable
Because 59API uses pay-as-you-go billing, you can choose a less expensive model for routine edits and reserve larger models for complex analysis. Review usage regularly, limit unnecessary repository-wide prompts, and ask assistants to summarize before requesting a large change. If you want to try this setup, sign up for 59API, create an API key, and check its referral rebate program before funding your account.
Ready to get started?
Connect Claude & GPT in minutes at the lowest prices — full-power, never downgraded. Sign up to get your API key.
Sign up free