March 31, 20263 min readGuide

How to use one API key across Codex, Cursor and Claude Code

If you live in the terminal and the editor, you probably juggle three coding agents: Codex, Cursor and Claude Code. Each one usually wants its own provider login, its own billing, and its own model list. That means three dashboards, three invoices, and three places to rotate keys when one leaks.

There is a simpler setup. Because all three tools speak the OpenAI API format, you can point them at a single OpenAI-compatible endpoint and use one API key everywhere. With AnyModel, that key reaches GPT, Claude, Gemini, DeepSeek, GLM, Kimi, Qwen and Grok — switching models is just changing a string.

Why one key beats three accounts

  • One bill, pay-per-token. No subscription, no minimums, no per-tool seat fees.
  • One model catalog. Run Claude in Claude Code, GPT-5 in Codex, and DeepSeek in Cursor — from the same credit balance.
  • One thing to rotate. Revoke a single key instead of hunting across vendors.
  • Easy A/B testing. Compare answers across providers by editing the model field. See the model comparison for tradeoffs.

The mechanism is the OpenAI standard. Set the base URL to https://anymodel.org/v1, supply your key, and pick a model id. To switch from Claude to Gemini, you change the model id — nothing else in your config moves.

Get a key (free to start)

Sign up and you get 1,000,000 tokens to start, with no credit card. Link your Telegram and the free allowance rises to a total of 6,000,000 tokens. After that you pay per token, only for what you use.

Codex and Claude Code: one-line install

For supported CLIs — codex, claude, opencode and hermes — there is an installer that writes the right config for you. Run it once per tool with your key:

## Codex
bash <(curl -fsSL "https://anymodel.org/i?tool=codex") <YOUR_API_KEY>

## Claude Code
bash <(curl -fsSL "https://anymodel.org/i?tool=claude") <YOUR_API_KEY>

That points the tool at https://anymodel.org/v1 and stores your key. Open the tool and select whichever model you want — the same key already covers the full catalog.

Cursor and other editors: manual setup

Cursor, Windsurf, Zed, Cline, Aider, Continue and Gemini CLI are not covered by the installer, but they all accept a custom OpenAI-compatible provider. The pattern is identical in every one:

Field Value
Base URL https://anymodel.org/v1
API key your AnyModel key
Model any supported id (e.g. a GPT, Claude or Gemini model)

Cursor, step by step

  1. Open Settings → Models (or Cursor Settings → AI).
  2. Find the OpenAI API section and enable a custom base URL.
  3. Set the base URL to https://anymodel.org/v1.
  4. Paste your key and save.
  5. Add the model ids you want to use, then pick one in the chat/composer.

The same three values — base URL, key, model — drop into Windsurf, Zed, Cline, Aider and the rest. Once configured, every editor draws from the one balance.

Verify it works

A quick request confirms the endpoint and key before you wire up tools:

curl https://anymodel.org/v1/chat/completions \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-5","messages":[{"role":"user","content":"ping"}]}'

Change "model" to a Claude, Gemini or DeepSeek id and rerun — same key, different brain.

A note on privacy

If your prompts include proprietary code, turn on Ghost Mode. It is opt-in zero-retention: your prompts and responses are not stored on our side, only a token counter for billing. To be clear, this is not "100% privacy" — the model provider you call still receives the prompt to generate the response. Ghost Mode removes AnyModel from the retention picture, not the upstream model.

Wrap-up

Three tools, three model families, one key. Install Codex and Claude Code with the one-liner, drop the base URL and key into Cursor and friends, and switch models by editing a single field. For more setup walkthroughs, browse the blog.

Ready to consolidate? Create your free AnyModel account and get a million tokens to test it across all three tools today.

Read next