Quick start: connect Claude Code and Codex

One command signs you in and connects Claude Code and Codex. You keep your agent, your model and your provider account.

Key facts

What it is
One command, npx @context-mode/cli, that signs you in and writes one config change per agent.
Who it is for
Anyone connecting Claude Code or Codex to Context Mode Gateway.
Clients
Claude Code, in ~/.claude/settings.json, and Codex, in ~/.codex/config.toml.
Measured result
Not measured on its own. For the gateway as a whole, see Benchmarks.
Limits
Needs Node 20.12 or later. Codex sends a credential only from its own login, so an OPENAI_API_KEY that is only exported in your shell is not sent. Codex cost is not measured yet.
npx @context-mode/cli

It does five things:

  1. Signs you in, in the browser, if this terminal is not signed in yet.
  2. Finds Claude Code and Codex on this machine.
  3. Asks which of them to connect.
  4. Writes each one's config and keeps a backup of the old file.
  5. Sends one test request per agent, prints one line for each, then prints the console address.

Start free: 2,000 requests, every feature, no card. When the free requests run out, nothing breaks: see Plans and limits. Your own Claude or OpenAI account still pays the model.

Restart Claude Code, or start a new Codex session. Then open the console to watch each request's tokens, cost and saving.

What it writes

Claude Code, in ~/.claude/settings.json under env:

"ANTHROPIC_BASE_URL": "https://gateway.context-mode.com",
"ANTHROPIC_CUSTOM_HEADERS": "x-cm-device-key: cmdk_…",
"ENABLE_TOOL_SEARCH": "true"

Claude Code turns tool search off for any base URL that is not Anthropic's and then sends every tool in full. ENABLE_TOOL_SEARCH turns it back on.

Codex, in ~/.codex/config.toml:

model_provider = "context-mode"

[model_providers.context-mode]
name = "context-mode"
base_url = "https://gateway.context-mode.com"
wire_api = "responses"
requires_openai_auth = true
http_headers = { "x-cm-device-key" = "cmdk_…" }

Codex sends a credential only from its own login. A ChatGPT login and an API key both work. An OPENAI_API_KEY that is only exported in your shell is not sent, so the CLI tells you to run codex login --with-api-key.

Codex

Codex gets the same gateway as Claude Code: Context Saving, Cage, Memory, Skills, Search, Session resume and the context limit. Both clients share one store per account, so a fact you state in one is there in the other, and codex resume can open a session that started in Claude Code.

Cage and the Codex sandbox. OpenAI's Codex docs say sandboxing and approvals are different controls that work together: the sandbox defines technical boundaries, and the approval policy decides when the agent must stop and ask before crossing them (Codex sandboxing, read 2026-10-01). Cage is a third check, on the gateway. It checks each call Codex makes, including exec_command, apply_patch and tool-server calls inside one exec call, before Codex runs it. Cage reads the call, not the program, so keep the sandbox on, for example in workspace-write. See Cage docs.

Not done yet for Codex.

The device key

Sign-in gives this terminal a device key. It is stored in ~/.context-mode/credentials.json and never printed. If you switch Claude or OpenAI accounts, the key stays, so your data stays in one workspace. The gateway removes the header before a request goes to Anthropic or OpenAI.

What the CLI promises

Commands

CommandWhat it does
npx @context-mode/cliSign in and connect agents
loginSign in this terminal
setup --agent claude|codex|allWrite agent config again. --dry-run shows the change, --check only reports.
statusWho this terminal is signed in as, and each agent's setup
doctorCheck config, the gateway and the device key
logoutSign this terminal out and revoke its device key

Each command runs as npx @context-mode/cli <command>. It needs Node 20.12 or later.

FAQ

Does it install a plugin or a background service?

No. It edits one config file per agent and keeps a backup of the old file.

Can I see the change before it writes?

Yes. It shows the change and asks before it writes. setup --dry-run shows the change and writes nothing.

Does my OpenAI API key work with Codex?

Yes, once Codex has it in its own login. Run codex login --with-api-key. A ChatGPT login works too.

Does Cage replace the Codex sandbox?

No. Keep the sandbox on. Sandboxing and approvals limit what a command can touch; Cage decides which calls run at all.

Do Claude Code and Codex share memory?

Yes. Both read the same memory store, skills and reply style through the gateway.

How do I undo it?

Remove the lines it added, or restore the backup it left next to each file. Steps.