Fix 404 Not Found in Claude Code and Codex CLI
Step-by-step fixes for the "404 Not Found" error when connecting Claude Code or Codex CLI to DeepSeek, OpenRouter, and other providers.
Error output
POST https://api.deepseek.com/anthropic/v1/messages -> 404 Not Found
{"error":{"type":"not_found_error","message":"Not Found"}}
Common variations
GET https://api.deepseek.com/anthropic/v1/models -> 404
{"error":{"message":"Invalid URL path"}}
codex: error sending request: status 404 Not Found (url: https://api.deepseek.com/responses)
The exact text varies by agent version and provider. Match the status code and the message above.
Quick diagnosis
The failing URL is the single most useful clue. Check where the request actually goes.
Claude Code
echo $ANTHROPIC_BASE_URL Codex CLI
grep -A5 "model_providers" ~/.codex/config.toml Common causes
- The base URL is wrong — a typo, a missing or extra path segment, or a stale endpoint from an old guide.
- Codex: the wire protocol does not match what the provider serves (Responses vs Chat Completions).
- The endpoint path is mixed up between providers (using the OpenAI path with the Anthropic protocol or vice versa).
Fix by scenario
1 Fails right after the initial setup
- Copy the base URL from the setup guide verbatim — no trailing slash, no extra path segments.
- Claude Code must use the Anthropic endpoint (…/anthropic), never the OpenAI-style path.
- Codex: confirm wire_api = "responses" for DeepSeek and OpenRouter; a mismatch 404s on /responses.
2 Following an outdated guide
- Guides from before 2026-07-24 may reference retired model names or endpoints.
- Cross-check the endpoint against the provider official docs before changing anything.
- Trust the base URLs on the setup pages of this site over third-party blog posts.
3 Worked before, now fails
- Did the provider move or version the endpoint? Check the changelog.
- Did a config edit add a trailing slash or an extra segment?
- Did a tool auto-rewrite the config file (proxy installer, switcher app)?
Agent-specific fixes
Claude Code
- Fix
- Use exactly https://api.deepseek.com/anthropic or https://openrouter.ai/api. No trailing slash, no extra path.
- Verify
- `curl -I <base url>` returns a reachable response, then `claude /status`.
Codex CLI
- Fix
- base_url = "https://api.deepseek.com" with wire_api = "responses", or "https://openrouter.ai/api/v1". If /responses 404s on DeepSeek, drop the wire_api line to match the endpoint it serves.
- Verify
- The failing URL should end in /responses. Re-run `codex exec "hi"` after the fix.
Claude Code vs Codex CLI at a glance
| Claude Code | Codex CLI | |
|---|---|---|
| Base URL variable | ANTHROPIC_BASE_URL | base_url in config.toml |
| Endpoint path | /anthropic (Messages API) | /responses (Responses API) |
| Verify command | curl -I <url> | codex exec "hi" + error URL |
Prevent it from happening again
- Keep the provider official base URL pinned in your notes.
- Verify with a one-line request before starting a long session.
- Watch the provider changelog for endpoint and model-name changes.
Related errors
Related setup guides
Frequently asked questions
Why does https://api.deepseek.com/v1/messages 404 but /anthropic works?
Only the Anthropic-compatible endpoint at https://api.deepseek.com/anthropic serves the Messages API. The OpenAI-style path serves Chat Completions, which Claude Code does not speak.
Codex returns 404 — is it base_url or wire_api?
If the URL in the error ends in /responses and the provider serves Chat Completions only, it is a wire_api mismatch. If the host or path looks wrong, fix base_url first.