May 1, 20263 min readSetupClaude Haiku 4.5Codex CLI

How to use Claude Haiku 4.5 in Codex CLI

Codex CLI is a fast, terminal-native coding agent — but it speaks the OpenAI API. Claude Haiku 4.5 is Anthropic's small, low-latency model, ideal for the high-volume, quick-turnaround tasks that a coding agent fires off constantly: edits, lints, test loops, and shell commands. The catch is the protocol mismatch. This guide shows how to bridge it with a single OpenAI-compatible gateway so Codex CLI can talk to Claude Haiku 4.5 without any vendor-specific glue.

Why Haiku 4.5 inside Codex CLI

Coding agents are chatty. Every file read, diff, and retry is another round trip. A small model keeps that loop snappy and cheap, while you reserve a larger model for the occasional hard reasoning step. Running Haiku 4.5 through Codex CLI gives you:

  • Low latency on iterative edits and command planning
  • Lower per-token cost for high-frequency calls
  • The same terminal workflow you already use — no new client to learn

The only thing standing in the way is that Codex CLI expects an OpenAI-style base_url and model id. That is exactly what AnyModel provides.

The one-endpoint approach

AnyModel exposes a single OpenAI-compatible endpoint:

  • base_url: https://anymodel.org/v1
  • One API key reaches every model — GPT, Claude, Gemini, DeepSeek, GLM, Kimi, Qwen, and Grok.

Switching models is a one-field change: you edit the model id and nothing else. Point Codex CLI at this base URL with your key and Claude Haiku 4.5 becomes just another model id you can select.

Install in one line

AnyModel ships a one-line installer for codex. Run it with your API key:

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

That configures Codex CLI to use the AnyModel base_url and your key. (The same installer supports claude, opencode, and hermes — swap the tool= value. For clients like Cursor, Windsurf, Zed, Cline, Aider, or Continue, use a manual OpenAI-compatible setup with the same base URL and key.)

Select Claude Haiku 4.5

Once Codex CLI is pointed at AnyModel, choosing Haiku 4.5 is just a matter of setting the model id. You can do it for a single run:

codex --model claude-haiku-4-5 "refactor this function and add a test"

Or set it as your default in the Codex config so every session uses Haiku 4.5. Because the gateway is OpenAI-compatible, the rest of your Codex flags, approval modes, and project settings work unchanged. Browse the full catalog of available ids on the models page, and if you are weighing Haiku against a larger model for a given task, the compare view helps you size cost versus capability.

A sensible model strategy

You do not have to commit to one model. A common pattern is to run Haiku 4.5 as the everyday driver and bump up to a larger Claude or GPT model only when a task needs deeper reasoning. Since switching means editing one model value, you can change mid-project without touching anything else.

Task type Good fit
Quick edits, test loops, shell planning Claude Haiku 4.5
Architecture, tricky debugging, long context A larger Claude / GPT model

Cost and privacy

AnyModel is free to start: 1,000,000 tokens on signup, and 6,000,000 total if you link Telegram — no credit card required. After that it is pay-per-token, with no subscription and no minimums, so a Haiku-heavy agent workflow stays cheap and predictable.

If you handle sensitive code, enable Ghost Mode: an opt-in setting that issues zero-retention API keys, so prompts and responses are not stored on our side (only a token counter runs). Note this is not "100% privacy" — the model provider still receives the prompt to generate a response — but it removes our-side retention.

Wrap up

Bridging Codex CLI to Claude Haiku 4.5 takes one install command and a single model id. From there you get a fast, low-cost coding agent and the freedom to switch to any other model whenever a task demands it. For more setup walkthroughs, see the blog.

Ready to try it? Create a free AnyModel account and get your key in under a minute.

Read next