API Error: Content block not found in Claude Code means the response stream lost an event: a later event pointed at a content block whose start never arrived. Claude Code's error reference files it under dropped stream events, and current versions usually show 'Part of the response never arrived' instead, so update first. Behind a proxy or gateway, the fix is a route that streams Anthropic's Messages events natively. At https://api.uplinkswitch.com/v1, the id claude-sonnet-5-5 lists the anthropic wire format.
Looking for "text content blocks must be non-empty" instead? That is a different, request-side error; see the empty text blocks fix.
What this means, per Claude Code's docs
Claude Code streams the Messages API as a sequence of events: a block starts, deltas fill it, the block stops. Content block not found is what you see when a delta or stop event references a block whose start event never reached the client. Claude Code's error reference documents this as an incomplete response, and since v2.1.281 the same case usually reads "Part of the response never arrived", which is why updating is the first move. The error still ends a turn when nothing had completed and the non-streaming fallback is turned off through CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK.
It has close siblings that point at the same layer: Content block already closed is a duplicated event, and Stream event unreadable is a damaged one. When a backend ends the body early, Claude Code tends to report "Connection lost mid-response" instead. Public issue reports connect Content block not found to proxies and non-Anthropic backends placed behind ANTHROPIC_BASE_URL, including projects such as ollama/ollama, maximhq/bifrost and cc-proxy; that is reported, not documented as the cause, so treat it as a strong hint rather than a verdict. Anthropic's gateway documentation states that Claude Code through any gateway is supported for Claude models only, which is the boundary that matters when you choose a backend.
What the gateway changes
On https://api.uplinkswitch.com/v1, the Claude ids that answer in Anthropic's own format are the ones whose wire_formats include anthropic: claude-sonnet-5-5, claude-opus-5-5 and claude-haiku-5-5. Those routes emit the Messages stream events Claude Code expects. Non-Claude ids may list /v1/messages as an endpoint while declaring wire_formats: [openai], which means the gateway translates formats for them; the catalog does not certify that a translated stream reproduces every Messages event in the same order, so it is the wrong target for Claude Code.
On the 2026-11-23 catalog the three read ok, ok and degraded in that order, each with anthropic among its wire formats.
Failover on the gateway happens before the first byte. A route that fails before any data reaches you is retried, and the next id in a models list is tried, but once the first byte of a stream has arrived a break in that stream comes back to you as an error rather than a silent switch. A 502 upstream_error here is the gateway's own answer when the last route it tried failed with nothing delivered, distinct from any error the upstream itself returned, and nothing is charged for it. A request id rides in each error's headers for support.
How to fix it
- Run
claude --version, then update. Many reports of this string are resolved by moving to a build that renders the clearer "Part of the response never arrived" and handles dropped events more gracefully. - Check whether
ANTHROPIC_BASE_URLis set, and read what it points at. If it targets a non-Claude model or a backend that does not emit native Messages events, that is the likely source. - If the base URL points at a non-Claude model, switch to a Claude id such as
claude-sonnet-5-5so the route streams Anthropic events natively. - Rule out a corporate proxy that buffers or rewrites server-sent events. Proxies that hold or reorder SSE chunks can strip the block-start event that the later events depend on.
- Leave the non-streaming fallback enabled. If
CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACKis set, unset it so Claude Code can retry without streaming when a stream breaks. - When partial output is already on screen, reply
continueso the session resumes from what did arrive.
If you are wiring Claude Code to the gateway for the first time, the setup steps live in the Claude Code guide; this page covers the stream error that shows up afterward.