Home / Learn / Using Claude in Codex
Using Claude in Codex — Codex Guide

Using Claude in Codex

Codex talks to any OpenAI-compatible endpoint, so the moment you have a Claude API key you can point it at Claude — no Anthropic account, no waitlist. Buy a key, drop it into config.toml, and Codex's agent loop runs on Claude.

Get a key, then add the provider

Buy a key on ClaudeAPIKey.dev — register, add credit with card or crypto, and generate it instantly. Then edit ~/.codex/config.toml and add a [model_providers.<name>] table with the base_url, the env_key for your key, and wire_api.

The CLI, SDK, and VS Code extension share this config, so one setup works everywhere.

Base URL and wire_api

Use the base URL with /v1; Codex appends the route. Set wire_api = "chat" for the OpenAI-compatible surface. Reserved provider ids are openai, ollama, lmstudio — name yours differently.

Export your purchased key into the variable named by env_key, and set model to a Claude id like claude-sonnet-4-5.

Why buy a key for Codex

You don't need an Anthropic account or its approval flow — a purchased gateway key works immediately with Codex's agent loop. Pay only for what you use, and top up with card or crypto whenever.

New accounts get a small free credit to test the setup before committing.

Run your first task

Once the provider is set, run Codex as usual and it drives Claude. Pick a Sonnet-class model for everyday agentic work or an Opus-class one for hard problems.

Verify wire_api against your Codex version — "chat" for OpenAI-compatible; some builds expect "responses".

# ~/.codex/config.toml
model = "claude-sonnet-4-5"
model_provider = "aiprime"

[model_providers.aiprime]
name = "AI Prime Gateway"
base_url = "https://claudeapikey.dev/v1"
env_key = "AIPRIME_API_KEY"
wire_api = "chat"
# export AIPRIME_API_KEY=<your key>

Frequently asked questions

Do I need an Anthropic account to use Claude in Codex?
No — buy a key on ClaudeAPIKey.dev, add it as a custom provider in config.toml, and Codex drives Claude immediately.

How do I buy a key?
Register, add credit with card or crypto, and generate a key instantly — no waitlist.

Does the base URL need /v1?
Yes — {SITE}/v1; Codex appends /chat/completions.

Is there a free trial?
New accounts get a small free credit (WELCOME5) to test before topping up.

Start using Claude in minutes

Get an API key — no Anthropic account or waitlist required.

Get your API key

Claude API Key is an independent API gateway. It is not affiliated with, endorsed by, or a reseller of Anthropic. Claude and related model names are trademarks of their respective owners.