9io.ai / Blog

LLM refusal handling in production: detection, fallback and evals

LLM refusal handling for Claude, OpenAI, Gemini and Mistral: how each API signals a refusal, when to fall back to another model, and how refusals skew evals.

Key takeaways

  • A Claude refusal is an HTTP 200 with stop_reason refusal, so error-rate dashboards never count it.
  • OpenAI uses a refusal field, Gemini’s Interactions API a 400 error, and Mistral’s chat API has no refusal field.
  • Anthropic can retry a refused request on another Claude model, and fallback credit avoids paying for caching twice.
  • A refusal of genuinely harmful content should stand, whichever model your fallback chain could try next.
  • Score refusals separately from wrong answers, and credit fallback answers to the model that wrote them.

Many LLM refusals don’t arrive as errors, which is why LLM refusal handling needs its own code path. On current Claude models, a safety classifier’s decline is an HTTP 200 response with stop_reason: "refusal" and a policy category in stop_details.1 Anthropic documents a retry of the same request on another Claude model, run by the API or by your client, plus a fallback credit so the retry doesn’t pay to write the prompt cache twice.2 OpenAI marks a refusal with a refusal content part, Gemini’s Interactions API fails the request with an HTTP 400, and Mistral’s chat completions have no refusal field.345

Whichever vendor you use, read the structured signal, log the category, track a refusal rate for each feature, and fall back to another model only for legitimate requests that a classifier caught. Evals need the same care, because refusals move benchmark scores in both directions.

Below are each vendor’s refusal signals as of 5 November 2026, Claude’s fallback options and their costs, the detection code and metrics we’d build, the limits on fallback, and what refusals do to benchmarks. We haven’t measured refusal rates ourselves. Everything here comes from vendor documentation and benchmark pages read on 5 November 2026.

How each LLM API signals a refusal

As of 5 November 2026, the four vendors differ on whether a refusal is a success or an error, whether it names a category, and what to do next.

API How a refusal or block arrives Category given What the docs say to do
Claude Messages API HTTP 200 with stop_reason: "refusal" and stop_details cyber, bio, frontier_llm, reasoning_extraction, general_harms or null Retry on another Claude model: server-side fallback, SDK middleware, or a manual retry with fallback credit
OpenAI Responses API HTTP 200 with a refusal content part, or status: "incomplete" with reason content_filter None Handle the refusal in code; no fallback documented
OpenAI Chat Completions message.refusal, or finish_reason: "content_filter" None As above
OpenAI account safeguards Errors: cyber_policy, a 403 with misalignment_policy_violation, or identifier blocked Error code only Don’t retry a misalignment stop automatically; send a safety_identifier; appeal through support
Gemini Interactions API HTTP 400, without the blocked content Error code safety, jailbreak, prohibited_content or blocklist The sample error message asks you to change the input and retry
Gemini generateContent HTTP 200 with promptFeedback.blockReason and no candidates, or a finishReason such as SAFETY, PROHIBITED_CONTENT, BLOCKLIST or SPII Block or finish reason, plus safetyRatings For a blocked prompt, rephrase it
Mistral chat completions No refusal field and no safety finish reason; opt-in guardrails return HTTP 403 before the model runs Guardrail decision per category Nothing documented; safe_prompt is deprecated in favour of guardrails

Sources: Anthropic’s refusals and stop reasons pages; OpenAI’s structured outputs guide, API reference and safety guides; Google’s safety settings guide and generateContent reference; Mistral’s guardrailing guide and OpenAPI specification. All read 5 November 2026.167839101141213514

Anthropic is the only one of the four that documents retrying a refusal on another model. OpenAI’s refusal part carries the model’s explanation as a string and no category. Its structured outputs guide added the field because a refusal may not follow your JSON schema, so a parser that skips the check breaks on exactly those responses.7

Gemini’s Interactions API returns safety blocks as HTTP 400s, the status you’d normally read as your own bug, so group them by error.code before they land among malformed requests.4 Google recommends that API for new work but keeps generateContent fully supported.15 Mistral’s guardrails check only the input, and a block returns a 403 listing each category’s score, threshold and verdict.13

Claude’s stop_reason refusal, category by category

As of 5 November 2026, classifier refusals are always on in the Messages API for Claude Fable 5.1, Mythos 5.1, Fable 5, Opus 5.5, Opus 5, Sonnet 5.5 and Haiku 5.5.1 A refusal can arrive before any output, with empty content, or mid-stream, and Anthropic says to discard partial output either way. The explanation in stop_details isn’t stable text, so show it and don’t parse it.

category What it covers Benign work can trigger it Billed if refused before any output
cyber Requests that could enable cyber harm, such as malware or exploit development Yes No
bio Requests that could enable biological harm, such as dangerous lab methods Yes Yes
frontier_llm Help developing competing AI models, restricted under Anthropic’s commercial terms Yes Yes
reasoning_extraction Asking the model to write its internal reasoning into the response Usually your own prompt Yes
general_harms Other areas of the usage policy Yes No
null No named category Not stated No

Source: Anthropic, “Refusals and fallback”, read 5 November 2026.

A refusal before any output is billed only in bio, frontier_llm and reasoning_extraction, which Anthropic says are the categories where it measures low volumes of false positives, as of September 2026. It bills them to disrupt attempts to get round its safeguards at scale. A mid-stream refusal bills the input and the output already streamed, and every refusal counts against rate limits.1

Your own prompt is the likeliest cause of reasoning_extraction. It fires when a system prompt, skill or tool description asks for reasoning in the output, such as a scratchpad section or a reasoning field in JSON. It has no recommended fallback model. Anthropic’s fix is to ask for a short explanation instead, or to read summarised thinking blocks.1

A refused item in a Message Batch comes back with result.type: "succeeded", so batch success counts include refusals. After a refusal, Anthropic’s streaming guide says to remove or rephrase the turn that caused it, or clear the history, because continuing unchanged brings more refusals.116

Model fallback on Claude: three ways to retry

Resending a refused request to the same model usually earns another refusal, so Anthropic’s recovery is the same request on a different Claude model, run in one of three ways.1

  • Server-side fallback, in beta on the Claude API and on Claude Models on Google Cloud (Anthropic managed). With the server-side-fallback-2026-07-01 header, set fallbacks to "default" for the model Anthropic recommends per refusal category, or list up to three models yourself. Only a classifier decline triggers it, and Message Batches don’t support it.
  • The SDK refusal-fallback middleware, on any platform. Configure the list once on the client and share a BetaFallbackState across a conversation, so later turns stay on the model that answered. Use it or fallbacks, never both.
  • A manual retry, which should redeem a fallback credit.

As of 5 November 2026, server-side lists and credited retries are limited to each model’s permitted targets. Claude Fable 5.1, Fable 5 and Opus 5.5 can fall back to Opus 4.8 or Opus 5, Opus 5 to Opus 4.8, and Sonnet 5.5 to Sonnet 5.2 Because Anthropic sets safeguards per model and category in line with capability, a flagged request may land on a less capable model or be declined.1 Haiku 5.5 has neither server-side fallback nor fallback credit.

Prompt caches are per model, so a plain retry pays to write the whole conversation into the new model’s cache. With the fallback-credit-2026-07-01 header, the refusal’s stop_details carries a fallback_credit_token. A retry that sends it within 5 minutes, repeating the refused request’s prompt-shaping fields and beta headers exactly, is billed as if the conversation had been on the new model all along.2

Server-side fallback names the answering model in the top-level model, marks the handoff and its trigger category with a fallback content block, and lists every attempt in usage.iterations.1 Top-level usage covers only the attempt that answered, so cost reports have to read the iterations. Sticky routing then keeps the conversation on the fallback model for about an hour. If the fallback model is rate limited or overloaded, the original refusal comes back with stop_details.recommended_model set, so size its limits for your refusal volume.

Anthropic also warns that fallbacks doesn’t carry over to model calls made inside tool execution, so subagents need their own.1 Message threads have their own rules, covered in our Claude message threads post.

Detecting refusals from structured fields

Matching phrases like “I can’t help with that” breaks when a model changes its wording, misses other languages and flags answers that quote a refusal. The vendors above give you fields and error codes to branch on, so normalise them into one record where your code calls the API. This sketch, written for this post, handles parsed HTTP 200 bodies. Map safety errors, such as Gemini’s 400, OpenAI’s cyber_policy or a Mistral guardrail 403, to the same record in your exception handler.

GEMINI_BLOCKS = {"SAFETY", "PROHIBITED_CONTENT", "BLOCKLIST", "SPII"}

def refusal_record(vendor: str, body: dict) -> dict:
    """Map a parsed HTTP 200 body to one record for logs and metrics."""
    rec = {"vendor": vendor, "outcome": "answer", "category": None,
           "served_by": body.get("model") or body.get("modelVersion")}
    if vendor == "anthropic":
        iters = (body.get("usage") or {}).get("iterations") or []
        rescued = any(i.get("type") == "fallback_message" for i in iters)
        hops = [b for b in body.get("content", []) if b.get("type") == "fallback"]
        if body.get("stop_reason") == "refusal":
            rec.update(outcome="refused",
                       category=(body.get("stop_details") or {}).get("category"))
        elif rescued:  # a fallback model answered, so stop_reason looks normal
            rec.update(outcome="rescued" if hops else "sticky_fallback",
                       category=hops[0]["trigger"].get("category") if hops else None)
    elif vendor == "openai":  # Responses API
        parts = [p for item in body.get("output", []) if item.get("type") == "message"
                 for p in item.get("content", [])]
        if any(p.get("type") == "refusal" for p in parts):
            rec["outcome"] = "refused"
        elif (body.get("incomplete_details") or {}).get("reason") == "content_filter":
            rec["outcome"] = "filtered"
    elif vendor == "gemini":  # generateContent
        blocked = (body.get("promptFeedback") or {}).get("blockReason")
        finish = {c.get("finishReason") for c in body.get("candidates", [])} & GEMINI_BLOCKS
        if blocked or finish:
            rec.update(outcome="blocked", category=blocked or finish.pop())
    return rec

The Claude branch is the easiest to get wrong. With server-side fallback on, a rescued request ends with an ordinary stop_reason, so a counter that reads only stop_reason reports no refusals at all. Anthropic recommends one event per refusal and one per fallback-served response, with an alert on the gap between the two counts.1 The sticky_fallback outcome covers later turns that sticky routing sent straight to the fallback model, which carry no fallback block.

OpenAI’s refusal part has no category. To group refusals, the optional moderation object on a generation request returns category scores for the input and output, from a separate classifier that can flag a refusal itself if it discusses harmful content.17

Measuring refusal rate per feature and per model

A single refusal rate for a whole product hides the feature where it matters. Tag each call with the feature, prompt version, requested model and serving model, and keep four counts per tag.

  • First-attempt refusals. The requested model declined. These drive extra cost and latency.
  • Rescued refusals. A fallback model answered.
  • Final refusals. The user got no answer, which is the rate users feel.
  • Blocks and filters. Input blocked before the model ran, or output cut off by a filter.

Split each count by category where the vendor gives one, and keep null as its own bucket, since Anthropic calls a null category a normal, permanent value.1 After a model upgrade, a rise in cyber refusals on a code-review feature shows up in that feature’s numbers long before it moves a product-wide average.

Put costs next to the rates. A billed refusal is a full request with no answer, a fallback adds a second request at the fallback model’s prices, and each attempt counts against its own model’s rate limits.1 A server-side fallback before any output also delays the first byte of a stream. Recompute the rates at every model change, since each model has its own safeguards.

Telling over-refusals from policy refusals

An over-refusal is a legitimate request declined, and vendors say it happens. Anthropic’s table says benign work can trigger four of its five categories, and OpenAI says its cyber safeguards may occasionally flag legitimate security research.110

Research suites measure it with contrast sets. XSTest pairs 250 safe prompts that resemble unsafe ones with 200 unsafe prompts, and labels each response as full compliance, full refusal or partial refusal. A reply that only suggests alternatives counts as a full refusal.18 OR-Bench scales this to 80,000 prompts across 10 rejection categories, plus 600 toxic prompts so that a model can’t score well by answering everything.19

Build a small version for each feature. Take legitimate requests from real traffic that look risky, remove personal data, add requests the feature should refuse, and track the refusal rate on each set for every model you serve. Then read a sample of production refusals by category. A refusal on a feature whose input your own system writes, such as a summary of your documentation, points to over-refusal, and so does one your prompt causes, like reasoning_extraction.

Claude’s refusal stop reason covers only classifier declines. A reply in which the model declines in its own words ends like any other answer, so catch those with sampled review or a judge calibrated against hand labels.

Check your own settings too. Gemini’s adjustable filters are off by default from Gemini 2.5 onwards, so if your code sets safety_settings, check those thresholds first.4 For legitimate security work, OpenAI’s reviewed Trusted Access for Cyber programme can fit better than a fallback.10

What a model fallback must never be used for

A fallback chain is for legitimate requests that a classifier caught by mistake. It must never be used to get a genuinely harmful request answered by trying models until one complies. Where Anthropic’s routing has no recommended fallback for a category, the refusal stands.1 Anthropic’s Usage Policy prohibits intentionally bypassing the guardrails in its products, including by instructing a model to produce harmful outputs, and coordinating accounts to get round them.20

Other vendors enforce at the account level. OpenAI’s safety classifier guide, written for GPT-5, says an organisation that repeatedly crosses high-risk thresholds gets errors and a warning email, then loses access if it carries on past the stated period, usually seven days.9 Its cyber checks can temporarily cut off a whole organisation that sends no per-user safety_identifier.10 Gemini has a finish reason, PUP_LIMITED_DISABLED, for accounts limited or disabled under Google’s Prohibited Use Policy.12 A chain that shops policy refusals around vendors risks cutting off every customer of your product.

In code, we’d hold to four rules.

  1. Allow fallback per feature and category, once someone has reviewed what the feature legitimately needs. A security review tool may have a reason for cyber fallback that a homework helper never will.
  2. Never rewrite a refused request automatically to get it past a classifier. Fixing your own prompt is fine, as with reasoning_extraction, but rewording a user’s request so a classifier misses what it asks for is a jailbreak.
  3. Send a per-user identifier where the vendor takes one, such as OpenAI’s safety_identifier, so one bad actor doesn’t cost everyone access.
  4. When the final outcome is a refusal, show a clear message with a route to a person, and stop.

Refusals in benchmarks and your own evals

A single benchmark score can hide refusals. Mistral’s 6 October 2026 preview of Mistral Large 4 reports 82% on an Artificial Analysis Cyber Index test that asks a model to reproduce a real vulnerability in open-source software and then patch it. It says closed models including Claude Opus 5.5 and GPT-6 Astra score near zero there because they refuse.21 Those are Mistral’s figures, and the same page counts Large 4’s high refusal rate on malicious cyber prompts as a safety result.

Artificial Analysis’s launch article of 28 September 2026 supports the refusal claim. On CyberGym-E2E-AA, the index’s reproduce-and-patch test, GPT-6 Astra, GPT-6 Sol, Claude Fable 5.1, Claude Opus 5.5 and two Qwen3.8 models refused at least 98% of tasks, which the article says makes frontier performance hard to assess.22 The headline score is the share of all 131 tasks solved, and solving needs a proof-of-concept that crashes the unpatched build, a patch that stops the crash and passing project tests.23 A declined task can’t pass, so in the headline number “won’t” looks the same as “can’t”. Artificial Analysis reports declines separately, but a vendor table that copies only the score loses that column.

Fallback moves scores the other way. On version 2.2 of the Vals Index, updated 19 October 2026, Vals noted that some tasks for Claude Sonnet 5.5 and Opus 5.5 were served by a fallback model after a refusal. Counting those as failures lowered Sonnet 5.5 from 70.85% to 69.03% and Opus 5.5 from 70.18% to 64.16%, which would have put Gemini 4 Argon, on 69.24% with no fallbacks, first.24 The published scores credited two models with work that other models did.

For your own evals, label each item correct, wrong, refused or partially refused, and record which model answered. Report the pass rate with refusals counted as failures, plus refusal rates on items the feature should answer and on items it should refuse. Compare models with fallback off, or with one fallback setting for all. Our regression testing routine already blocks a model upgrade when refusals rise on an intent users need.

A checklist for LLM refusal handling

  1. Branch on the structured fields in the table above, never on response text.
  2. Count refusals as their own event, separate from errors, since many arrive as HTTP 200s.
  3. Log feature, prompt version, requested and serving model, and category, and track first-attempt, rescued and final refusal rates per feature.
  4. Discard partial output from a refused stream, and drop or fix the turn that caused it before continuing.
  5. On Claude, use server-side fallback or the SDK middleware, never both, and size the fallback model’s rate limits for your refusal volume.
  6. For a manual retry, redeem the fallback credit within 5 minutes with an identical request body.
  7. Allow fallback only for reviewed features and categories, and never reword a user’s request to pass a classifier.
  8. In evals, score refusals separately, credit each answer to the model that wrote it, and rerun contrast sets at every model change.

We’d ship steps 1 to 3 first. They need no vendor feature, and their numbers tell you whether a fallback chain is worth building.


  1. Anthropic, “Refusals and fallback”, Claude Platform Docs, read 5 November 2026, https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback ↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩

  2. Anthropic, “Fallback credit”, Claude Platform Docs, read 5 November 2026, https://platform.claude.com/docs/en/build-with-claude/fallback-credit ↩↩↩

  3. OpenAI, “Create a model response”, Responses API reference, read 5 November 2026, https://developers.openai.com/api/reference/resources/responses/methods/create ↩↩

  4. Google, “Safety settings”, Google AI Studio docs, read 5 November 2026, https://aistudio.google.com/docs/safety-settings ↩↩↩↩

  5. Mistral AI, OpenAPI specification, chat completion response schema, read 5 November 2026, https://docs.mistral.ai/openapi.yaml ↩↩

  6. Anthropic, “Stop reasons and fallback”, Claude Platform Docs, read 5 November 2026, https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons ↩

  7. OpenAI, “Structured model outputs”, OpenAI API docs, sections “Refusals with Structured Outputs” and “Handling edge cases”, read 5 November 2026, https://developers.openai.com/api/docs/guides/structured-outputs ↩↩

  8. OpenAI, “Retrieve chat completion”, Chat Completions API reference, read 5 November 2026, https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/retrieve ↩

  9. OpenAI, “Safety classifiers”, OpenAI API docs, read 5 November 2026, https://developers.openai.com/api/docs/guides/safety-checks ↩↩

  10. OpenAI, “Cybersecurity checks”, OpenAI API docs, read 5 November 2026, https://developers.openai.com/api/docs/guides/safety-checks/cybersecurity ↩↩↩↩

  11. OpenAI, “Misalignment monitoring”, OpenAI API docs, read 5 November 2026, https://developers.openai.com/api/docs/guides/safety-checks/misalignment-monitoring ↩

  12. Google, “Generating content”, Gemini API reference, GenerateContentResponse and Candidate, read 5 November 2026, https://aistudio.google.com/api-reference/generate-content ↩↩

  13. Mistral AI, “Moderation & Guardrailing”, Mistral docs, section “Custom Guardrails”, read 5 November 2026, https://docs.mistral.ai/studio/safety-moderation ↩↩

  14. Mistral AI, “Safe Prompt” (deprecated), Mistral docs, read 5 November 2026, https://docs.mistral.ai/resources/deprecated/guardrailing/safe_prompt ↩

  15. Google, “Migrating to the Interactions API”, Google AI Studio docs, read 5 November 2026, https://aistudio.google.com/docs/migrate-to-interactions ↩

  16. Anthropic, “Handle streaming refusals”, Claude Platform Docs, read 5 November 2026, https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/handle-streaming-refusals ↩

  17. OpenAI, “Moderation”, OpenAI API docs, section “Moderate generated content”, read 5 November 2026, https://developers.openai.com/api/docs/guides/moderation ↩

  18. Paul Röttger, Hannah Rose Kirk, Bertie Vidgen, Giuseppe Attanasio, Federico Bianchi and Dirk Hovy, “XSTest: A Test Suite for Identifying Exaggerated Safety Behaviours in Large Language Models”, NAACL 2024, arXiv:2308.01263, https://arxiv.org/abs/2308.01263 ↩

  19. Justin Cui, Wei-Lin Chiang, Ion Stoica and Cho-Jui Hsieh, “OR-Bench: An Over-Refusal Benchmark for Large Language Models”, ICML 2025, arXiv:2405.20947, https://arxiv.org/abs/2405.20947 ↩

  20. Anthropic, “Usage Policy”, section “Do Not Abuse Our Platform”, read 5 November 2026, https://www.anthropic.com/legal/aup ↩

  21. Mistral AI, “Introducing Mistral Large 4”, 6 October 2026, https://mistral.ai/news/mistral-large-4/ ↩

  22. Artificial Analysis, “Announcing the Artificial Analysis Cyber Index Alliance: toward better benchmarking of agentic cyber defense”, 28 September 2026, https://artificialanalysis.ai/articles/artificial-analysis-cyber-index ↩

  23. Artificial Analysis, “Artificial Analysis Cyber Index Benchmarking Methodology”, read 5 November 2026, https://artificialanalysis.ai/methodology/cyber-index ↩

  24. Vals AI, “Vals Index”, version 2.2, updated 19 October 2026, Internet Archive copy of 21 October 2026, https://web.archive.org/web/20261021083936/https://www.vals.ai/benchmarks/vals_index ↩

Frequently asked questions

What does stop_reason refusal mean in the Claude API?

A safety classifier declined the request. The response is a normal HTTP 200, and stop_details.category names the policy area: cyber, bio, frontier_llm, reasoning_extraction, general_harms, or null when no named category applies. Discard any partial output, and if the request is legitimate, retry it on another Claude model.

Are refused Claude API requests billed?

Sometimes. As of 5 November 2026, a refusal before any output is billed when its category is bio, frontier_llm or reasoning_extraction, and free otherwise. A mid-stream refusal bills the input and the output already streamed, and every refusal counts against your rate limits.

How do I detect a refusal in the OpenAI API?

In the Responses API, look for a message content part of type refusal, and treat status incomplete with incomplete_details.reason content_filter as filtered output. In Chat Completions, check message.refusal and finish_reason content_filter. Account-level safeguards arrive as errors, such as cyber_policy or a 403 with misalignment_policy_violation.

How does the Gemini API report a safety block?

The Interactions API fails the request with HTTP 400 and an error code of safety, jailbreak, prohibited_content or blocklist, and doesn’t return the blocked content. The older generateContent API returns promptFeedback.blockReason when the prompt was blocked, or a finishReason such as SAFETY or PROHIBITED_CONTENT on the candidate.

Should I fall back to another model when an LLM refuses?

For a legitimate request that a safety classifier caught, yes, ideally to the model the vendor recommends. Anthropic documents three ways to do it. Never use fallback to get genuinely harmful content from another model: Anthropic’s usage policy forbids bypassing its guardrails, and OpenAI and Google can limit or disable accounts over policy violations.

How do refusals affect LLM benchmark scores?

A refused task can’t pass a pass/fail check, so it lowers a score just as a wrong answer does. Artificial Analysis says six models refused at least 98% of tasks on its CyberGym-E2E-AA test. Fallback can inflate scores instead: Vals said in October that counting fallback-served tasks as failures would cut Claude Opus 5.5 from 70.18% to 64.16%.

Work with us

Building something like this?

9io is a small team of senior engineers with a fractional CTO. We work by the hour, and plans start at $5,000. Send us a note about your product. The reply comes from the person who'd do the work.