[BUG] Upstream HTTP errors are masked as "selected model may not exist"
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When the configured inference gateway returns an HTTP error that is not model-related, Claude Code
reports it as a model availability problem:
There's an issue with the selected model (<model>). It may not exist or you may not have access
to it. Run --model to pick a different model.
In my case the gateway was returning a 404 for an unknown route — the configuredANTHROPIC_BASE_URL contained a stray /v1, so requests went to /provider/v1/v1/messages while
the correct path was /provider/v1/messages. The model itself was fully available (a directPOST /provider/v1/messages for that same model returned HTTP 200).
Two problems result:
- The message names the model and the account entitlements, so every reader investigates the model —
the [1m] suffix on the configured model id was the obvious suspect and the wrong one.
- The actionable upstream detail is discarded, even though the CLI demonstrably captures it
elsewhere (model sent to the API: …, as in #92715).
This is not gateway-specific: #94442 shows the same message wrapping a genuine 404 Not Found from
the Anthropic API, #94192 the same message wrapping a structured not_found_error, and #90652 the
same message wrapping a stale provider reference. --debug logs contain the real error; the
user-facing message does not.
What Should Happen?
For a non-model upstream failure, surface the upstream status and message instead of a model
entitlement claim:
API error 404 from https://<gateway>/provider/v1/v1/messages: 404 Not found. Check the docs for
available routes.
Reserve "It may not exist or you may not have access to it" for failures that are actually
attributable to the model (a model-scoped 404/403 whose body names the model, or a model-validation
response). When the failing URL contains a repeated path segment, saying so would be especially
useful, since a duplicated version segment is a common, self-inflicted cause of a 404 and is
completely invisible from the current wording.
Error Messages/Logs
User-facing:
There's an issue with the selected model (claude-opus-5-5). It may not exist or you may not have
access to it. Run --model to pick a different model.
Stored transcript entry:
"error":"model_not_found","isApiErrorMessage":true,"apiErrorStatus":404
--debug log (the real cause, never shown to the user):
[DEBUG] [API REQUEST] /provider/v1/v1/messages source=sdk
[ERROR] API error (attempt 1/11): 404 404 404 Not found. Check the docs for available routes.
[WARN] Streaming endpoint returned 404, falling back to non-streaming mode
[ERROR] Non-streaming fallback also failed: 404 404 Not found. Check the docs for available routes.
Steps to Reproduce
- Point Claude Code at any Messages-compatible gateway with a duplicated version segment:
ANTHROPIC_BASE_URL=https://<gateway>/provider/v1 — the CLI appends /v1/messages itself, so
requests go to /provider/v1/v1/messages.
- Run any prompt:
claude -p "hi". - Observe: `There's an issue with the selected model (…). It may not exist or you may not have
access to it.`
- Show the route, not the model, is at fault — with the same key:
curl -s -o /dev/null -w '%{http_code}\n' -X POST https://<gateway>/provider/v1/messages \
-H "x-api-key: $KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" \
-d '{"model":"<same model>","max_tokens":16,"messages":[{"role":"user","content":"hi"}]}'
→ 200, while the same request against /provider/v1/v1/messages → 404.
- Correct the base URL and re-run
claude -p "hi": the error disappears, confirming the model was
never involved.
Claude Model
Other
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.274
Platform
Other
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Non-interactive/CI environment
Additional Information
Same-message reports wrapping non-model failures:
- #94442 — a genuine Anthropic
404 Not Found(Pro account, no third-party gateway). - #94192 — a structured
not_found_errorforclaude-opus-5[1m]. - #92715 — a
404where the CLI does printmodel sent to the API: …, showing the detail exists
at the point the user-facing message is constructed.
- #90652 — a stale provider reference, same wording.
Scope: error reporting only. No request-shape or API-contract change is implied by this report.