How Do You Use Different Models Together? Don't Unify the Base URL. Unify the Key, Account, and Usage Records

Explains where third-party model configuration actually lives in the Codex App, and how to verify that requests take effect using the Provider, Endpoint, and usage records.

10 min read
How Do You Use Different Models Together? Don't Unify the Base URL. Unify the Key, Account, and Usage Records

How Do You Use Codex, Claude Code, and Gemini CLI Together?

AI Code With · A Guide to Configuring and Troubleshooting Multiple AI Coding Tools

Once Codex, Claude Code, and Gemini CLI are all installed on the same machine, most people have the same first reaction: all three tools end up calling a model anyway, so why not unify the Key, Base URL, model, and even the config files?

That sounds like good engineering, but "forced unification" is exactly where things tend to break. The three tools don't speak the same protocol. Your Keys can come from one platform, your usage records can land in one dashboard, and your account and costs can be viewed in one place. But the Endpoint, environment variables, and config format that Codex, Claude Code, and Gemini CLI expect are all different.

What you should unify is the management layer, not the protocol layer.

This article walks through three scenarios in one pass: how to configure Codex CLI / Codex App, Claude Code, and Gemini CLI separately, why you can't copy a Base URL from one to another, and how, if you manage your model access through AI Code With, you can get "one unified backend, with each frontend using its own protocol."

1. The Short Version: What Can Be Unified and What Can't

If you use several AI coding tools at once, you can split "unification" into two layers.

What you can unify is management

• Create and manage multiple API Keys under a single AI Code With account.

• Name each Key after its tool, for example codex-main, claude-main, and gemini-main.

• In Usage Records, check calls by time, Key, service, model, token count, and cost.

• When needed, view model and channel status in the same dashboard instead of checking billing across multiple upstream accounts.

What you can't force into one is the protocol

• Codex's dedicated Endpoint and Responses Provider.

• The Anthropic-style environment variables and root URL that Claude Code uses.

• The Gemini-specific Base URL and variable names that Gemini CLI uses.

• Each tool's own config files, session context, permissions, and Agent capabilities.

So "the same platform" does not mean "the same Base URL." The platform can unify your account and usage records, but each client still has to send requests in the protocol it understands.

2. Why Can't One Base URL Serve All Three Tools?

An API Key only answers "who are you." The Base URL and protocol answer "where does the request go, and what format does the other side expect." When the Key, Endpoint, Provider, and model ID get mixed together, you hit the most confusing failure mode: the Key is valid and the network is fine, yet you still get a 404, a format error, or model not found. Sometimes the UI even shows the model name correctly, but the dashboard has no real call record at all.

Think of it as three courier companies sharing one payment account. You can certainly pay from one place, but each company still has its own label format, sorting rules, and entry point. Sticking Company A's address label on Company B's package doesn't make it compatible just because "the money came from the same account."

3. How Do Codex, Claude Code, and Gemini CLI Configurations Differ?

ToolConfig location / KeyAI Code With EndpointProtocol / key points
Codex CLI / App~/.codex/auth.json ~/.codex/config.toml Key: OPENAI_API_KEYhttps://api.aicodewith.ai/chatgpt/v1Responses / wire_api = responses
Claude Code~/.claude/settings.json Key: ANTHROPIC_AUTH_TOKENhttps://api.aicodewith.aiClaude Code reads Anthropic environment variables
Gemini CLI~/.gemini/.env ~/.gemini/settings.json Key: GEMINI_API_KEYhttps://api.aicodewith.ai/gemini_cliGemini CLI-specific URL and auth type

What's worth remembering from this table isn't the three addresses. It's that the three clients aren't reading the same configuration at all.

Codex CLI / App: Use the Codex-specific Endpoint

The Codex desktop app is the easiest one to misjudge. You open the App settings, look around, don't see a Base URL, and conclude that third-party Providers aren't supported on desktop. In fact, the current AI Code With Codex App docs take a different route: set up Codex's auth.json and config.toml first, then let the App reuse that configuration.

A minimal Codex Provider structure looks like this:

toml
model = "<CURRENT_MODEL_ID>"
model_provider = "aicodewith-codex"
[model_providers.aicodewith-codex]
name = "aicodewith"
base_url = "https://api.aicodewith.ai/chatgpt/v1"
wire_api = "responses"
requires_openai_auth = true

The most common mistake here isn't the Key. It's putting a regular API /v1 address into Codex, or borrowing another tool's Base URL. This path in Codex needs its own dedicated Endpoint, and the Provider has to match the Responses route.

Another practical issue: just because the CLI works doesn't mean the App has picked up the latest config. After making changes, fully quit the App and reopen it. That's more reliable than just closing the window.

Seeing a model name in the App only tells you the state of the UI. The real proof is an actual response, plus a matching request showing up in AI Code With Usage Records.

Claude Code: Use the Anthropic configuration route

Claude Code takes a completely different approach. The current AI Code With tutorial uses Claude's own environment variables:

json
"env": {
"ANTHROPIC_AUTH_TOKEN": "在这里替换成你的_API_KEY",
"ANTHROPIC_API_KEY": "",
"ANTHROPIC_BASE_URL": "https://api.aicodewith.ai"
}

Note that the Base URL here is the root URL, not the Codex one with https://api.aicodewith.ai/chatgpt/v1. One is long and the other is short. That isn't inconsistent documentation. The clients simply expect different paths and protocols.

So if Claude Code throws an error, don't copy the whole Codex Provider config over just because Codex works. Check only Claude Code's own settings.json, environment variables, Key, and the matching usage records.

Gemini CLI: Use the Gemini-specific Endpoint

Gemini CLI also has its own configuration entry point. The current AI Code With docs use:

bash
GEMINI_API_KEY=在这里替换成你的_API_KEY
GOOGLE_GEMINI_BASE_URL=https://api.aicodewith.ai/gemini_cli
GEMINI_MODEL=<CURRENT_MODEL_ID>

This is the same principle again: the Key can come from the same account, but Gemini CLI's Base URL still can't be swapped for the Codex or Claude Code address.

If the Key is valid but the Endpoint is wrong, you probably won't see "invalid Key" right away. Instead, you'll run into a 404, a format error, or an unavailable model later on. At that point, creating yet another new Key just adds more variables.

4. The Recommended Setup: One Dashboard, Three Keys

If you switch between Codex, Claude Code, and Gemini CLI every day, I'd recommend one dashboard with separate Keys, rather than one master Key shared by all three tools.

codex-main

claude-main

gemini-main

The point isn't to manage three more strings. It's to keep call attribution clean.

• When Codex throws an error, you only need to check whether codex-main has a matching request.

• When Claude Code costs suddenly spike, you can query by claude-main directly.

• If Gemini CLI leaves no record in the dashboard, the request may not have gone through the expected path at all.

• If a Key leaks or needs to be rotated, only the corresponding tool is affected.

That's far less painful than sharing one Key across all three tools and then guessing from timestamps which tool generated a given charge.

5. Two real troubleshooting cases

Case 1: All three tools start, but only two are actually routed correctly

Say you've just connected all three tools to the same AI Code With account. Codex answers normally, Claude Code answers too, and the Gemini CLI terminal shows no obvious red errors. On the surface, everything looks like it worked.

For the real check, open Usage Records and look:

10:01 codex-main has a record

10:03 claude-main has a record

10:05 gemini-main has no record

Don't reinstall Gemini CLI at this point, and don't regenerate all three Keys. Codex and Claude have already shown that the platform and the account work. The problem is narrowed down to the Gemini CLI path.

From here, check only:

• Whether ~/.gemini/.env is being read

• Whether GOOGLE_GEMINI_BASE_URL still points to the dedicated address

• Whether GEMINI_API_KEY corresponds to gemini-main

• Whether the current Model ID is valid

• Whether any other config overrides this .env

The core of this approach isn't memorizing more commands. It's making each tool leave its own independent evidence.

Case 2: Codex CLI works, but Codex App keeps returning 401

It's easy to conclude that the Provider itself is broken. But if the CLI already returns normally through the same account, then at least one working path exists for the platform address and the Key.

What you should check instead:

• Whether the App fully quit and reloaded the ~/.codex config;

• Whether the Key in auth.json is still valid;

• Whether the URL the App actually requests still points to https://api.aicodewith.ai/chatgpt/v1;

• Whether an old Provider or old session config is still in effect.

Don't keep swapping models every time you see a 401. A 401 is first of all an authentication, Key, or request path problem. The model ID is usually not the first suspect.

6. How to troubleshoot 401, 404, and Model not found layer by layer

SymptomCheck firstDon't do this first
401 / Invalid API keyThe tool's own Key, auth variables, and whether the request reaches the expected EndpointDon't change the Model ID first
404Whether the Base URL, path, and protocol belong to this clientDon't keep creating new Keys
model not foundThe current model ID, the Key's model restrictions, and default config overridesDon't edit another tool's config
UI looks normal but no Usage RecordsWhether the Provider actually took effect and whether the request reached AI Code WithDon't trust the model name shown in the frontend alone
Only one tool failsCheck only the failing tool's own local configDon't rewrite all three configs together

7. How should the three AI coding tools divide the work?

Once the setup works, there's a question that often gets overlooked: using the same dashboard doesn't automatically share the Agent capabilities, project context, or workflow of Codex, Claude Code, and Gemini CLI.

For example, you could split the work like this:

• Codex handles a well-defined code change;

• Claude Code does a different kind of analysis or review;

• Gemini CLI covers the model or task type you're more familiar with;

• The Git diff, tests, and manual review decide which version to keep.

But don't let two Agents make sweeping changes to the same files in the same uncommitted working tree and then expect a unified dashboard to resolve the conflicts. AI Code With unifies the model API, Keys, and call records. It doesn't unify the working tree, and it won't make the three CLIs share sessions.

8. When is the unification in AI Code With most valuable?

If you only use one tool and its official login fully meets your needs, there's no reason to add another layer just to look unified. An extra layer of config is a cost too.

But in these situations, a unified dashboard starts to pay off:

• You use Codex, Claude Code, Gemini CLI, or other tools that support custom APIs at the same time;

• You switch between multiple models often and don't want to maintain several upstream accounts separately;

• You want to separate calls and costs by tool, per Key;

• You need to verify models, channels, Tokens, and usage records in one place;

• When a config goes wrong, you want dashboard records to tell you whether the request reached the expected Provider.

This is also why this article recommends against "unifying the Base URL" and instead recommends "unified management, separate configuration."

9. One last three-tool acceptance check

After the first setup, don't test with a large project right away. The safest approach is to run one small, comparable, side-effect-free task in each of the three tools.

1. Codex: read a README and explain a section

2. Claude Code: read the same file or a similar small one and do a read-only analysis

3. Gemini CLI: do a comparable small Q&A or code explanation

4. Note the time of each

5. Open Usage Records and match the three calls by Key

6. Verify the model, channel, Tokens, and cost

7. If one fails, change only that tool's config

Once all seven steps repeat reliably, you've actually built a multi-tool workflow.

10. One last thing to remember

A mature multi-tool setup often doesn't look tidy: Codex has its own config.toml, Claude Code has settings.json, Gemini CLI has .env, and the three Base URLs differ.

But behind them, things can be very consistent:

One account

↓

Separate Keys per tool

↓

Each using the correct Endpoint / protocol

↓

Verified in one place through Usage Records

That's the kind of unification that actually matters in engineering.

Unified dashboard, separate protocols; separate configs, unified evidence.

As long as you hold to this principle, you won't need to hunt for a so-called "universal Base URL" whenever you add OpenCode, another CLI, or a new model entry point. First figure out which protocol the client uses, then give it the right address, then confirm it with a real call record.

Related reading

• Connecting Codex App to third-party models: Provider, Base URL, and 401 troubleshooting

• How to configure a Codex API Key: what the Key, Provider, Base URL, and model each do

• Connecting Claude Code to a third-party API: environment variables and Base URL setup

• Connecting Gemini CLI to third-party models: .env, Key, and Endpoint configuration

• Creating and managing API Keys in AI Code With

Sources

AI Code With Codex CLI:https://docs.aicodewith.ai/zh/docs/codex-cli

AI Code With Codex App:https://docs.aicodewith.ai/zh/docs/codex-app

AI Code With Claude Code CLI:https://docs.aicodewith.ai/zh/docs/claude-code-cli

AI Code With Gemini CLI:https://docs.aicodewith.ai/zh/docs/gemini-cli

OpenAI Codex / Responses API:https://developers.openai.com/

    How Do You Use Different Models Together? Don't Unify the Base URL. Unify the Key, Account, and Usage Records | AI Code With