Spokes.wiki Search Graph Growth About

llm-providers-wiki

Tech Article source ↗ source url updated Thu Jun 11 2026 00:00:00 GMT+0000 (Coordinated Universal Time)

Claude API — Refusals and Fallback

Anthropic API documentation for how Claude returns safety-classifier refusals and how to retry a refused request on a fallback model. Routed here (the provider-API-access lens) from the hub on 2026-06-11; the SDK-middleware angle is a cross-spoke adjacency with agentic-tooling-wiki (see below).

What a refusal is

Claude’s safety classifiers can decline a request. A decline is not an HTTP error — it comes back as a normal HTTP 200 with stop_reason: "refusal" and (usually) a stop_details object:

A refusal can arrive before any output or mid-stream; treat partial output as incomplete.

The fallback pattern

The fix for a refusal is to re-send the same request to a different model — a request Claude declines can usually be served by another. The classic chain in the docs is claude-fable-5claude-opus-4-8. Three ways to wire it:

ApproachWhereMechanism
Server-side fallbackClaude API / Claude Platform on AWS (beta)fallbacks: [{model}] param + anthropic-beta: server-side-fallback-2026-06-01 header; the API retries inside one round trip (up to 3 fallbacks; each must be a published allowed_fallback_models target).
SDK middlewareTS/Python/Go/Java/C# SDKs, any platformBetaRefusalFallbackMiddleware on the client; a shared BetaFallbackState pins follow-ups to the model that accepted. (Not in Ruby/PHP SDKs — implement manually.)
Manual retryRuby/PHP/raw HTTPDetect "refusal", re-send on a fallback model, stay on it for the conversation.

Only a safety decline triggers fallback — rate-limit/overload/server errors are returned as-is. The response marks each handoff with a fallback content block (from/to model), and the top-level model field names whoever actually answered.

Billing & cost angle (why this lives in the providers wiki)

This is as much a cost/pricing feature as a reliability one:

Operational notes

Cross-spoke adjacency