The refusal came back as a 200

Schema-guaranteed output is a guarantee about one code path, and every documented way off that path returns HTTP 200. A refusal arrives with stop_reason "refusal", a 200, a bill for the tokens generated, and output that need not match your schema. A max_tokens cut-off hands you a valid prefix of an invalid document. And the third exit sets no special stop_reason at all: enum capitalization is not guaranteed, so Anthropic's own example shows an enum of three values returning a fourth that differs only in a capital letter — completing normally, with no error. Worth knowing before you add a field: asking a property for the model's step-by-step reasoning can itself trigger a reasoning_extraction refusal.

By Agentic AI Wiki 11 min read

Turn on structured outputs and you buy a guarantee about one code path. Every documented way off that path returns HTTP 200 — the refusal, the truncation, and the one that sets no special stop_reason at all. If your client branches on status codes and exceptions, it has been told nothing in all three cases, and in the third it will never be told anything.

At a glance

Four exits from a grammar-constrained request, and what your client actually receives on each.

ExitHTTPstop_reasonDoes the schema hold?
Success200end_turnYes — this is the guarantee
Refusal200refusalMay not; the refusal takes precedence
Token limit200max_tokensA valid prefix of an invalid document
Enum casing200Nothing specialNo — the value is not in your enum
What your client sees on each exit from a schema-constrained request A four-column comparison of the success path, a refusal, a max-tokens truncation and an enum-casing divergence, across three rows: HTTP status, stop_reason, and whether the schema still holds. All four return HTTP 200, and only two of them set a stop_reason you can branch on. Exit Success Refusal Truncation Enum case HTTP status 200 200 200 200 stop_reason end_turn refusal max_tokens nothing special Schema still holds? Yes the guarantee May not refusal takes over Prefix only incomplete document Value not in enum
Three of the four columns are failures. The HTTP row cannot tell them apart.

None of this is undocumented or surprising to the people who wrote it — Anthropic's structured-outputs page has a section called "Invalid outputs" that lays out the first three plainly. What is surprising is how the error handling most teams already have interacts with it, because the standard shape of that handling is a try around the call and a status check, and neither one fires.

Exit one: the refusal

A refusal arrives as stop_reason: "refusal", with a 200 status code, billed for the tokens generated, and with output that — in the documentation's own words — might not match your schema, because the refusal message takes precedence over the schema constraints.

Read that as three separate problems. The 200 means your transport layer saw success. The billing means a refusal loop is a cost event, not just a quality one, and it will not show up in your error rate to explain the spend. And the schema exemption means that the one thing you stopped validating — because the platform promised to validate it — is exactly what is no longer valid.

This is a reasonable design once you see what it is protecting. A model that could be forced into a schema regardless of content would be a model whose safety behaviour you could delete with a JSON Schema. The platform's answer is that the refusal wins, and the cost of that answer is a branch in your code. But it is a branch almost nobody writes on the first pass, because the happy path and the refusal path differ by a field you have to look for rather than an exception you can catch.

The trigger that will catch people out

There is a specific way to cause refusals by accident, and it looks like good schema design. Asking a property for the model's thinking or step-by-step reasoning can produce a reasoning_extraction refusal; the documented guidance is to ask for a short explanation or the supporting evidence instead, and to keep reasoning in thinking blocks.

So the instinct to add a rationale or chain_of_thought field to your output schema — in order to get explainability, or to give a judge model something to grade — is the instinct that converts a working extractor into one that intermittently refuses. The fix is a wording change, which is a strange sentence to write about a type definition, and a good illustration of how much of a schema is read as prose.

Exit two: the truncation that validates right up until it doesn't

If the response hits max_tokens, you get stop_reason: "max_tokens" and output that may be incomplete and not match the schema. The documented remedy is to retry with a higher limit.

What makes this one nastier than it sounds is the interaction with streaming and with partial parsing. A grammar-constrained generation that stops early is not garbage — it is a well-formed prefix. Every token emitted before the cut was schema-legal, so a tolerant parser, a lenient JSON repair step, or a streaming consumer that renders fields as they arrive will all succeed on a document that is missing its tail. You get the first three of five required fields, each perfectly typed, and the absence reads as "the model chose not to fill these" rather than "the response was cut off".

The practical consequence is that a strict-mode pipeline needs its truncation check before its parse, not after. Checking stop_reason first costs one comparison and removes an entire class of silently-partial records.

Exit three: no signal at all

One schema-constrained request, four ways out A single grammar-constrained request fans out to four exits, and every one of them returns HTTP 200: the success path where the schema holds, a refusal whose output need not match the schema, a max-tokens truncation that yields only a valid prefix, and an enum-casing divergence that sets no special stop reason at all. One request, one grammar Constrained generation 200 · end_turn · the schema holds 200 · refusal · schema may not hold 200 · max_tokens · a valid prefix only 200 · no stop_reason · enum case differs
The fourth exit is the one with nothing to branch on.

The sharpest item in the list has no error, no special stop reason, and nothing anywhere in the response to distinguish it from success. Structured outputs do not guarantee the capitalization of string enum and const values. The documentation's own example is worth quoting in full, because it is more specific than a caveat usually is: given the enum ["Conversation Topic 1", "Conversation Topic 2", "Conversation topic 3"], the output might contain "Conversation Topic 3" — capital T — even though that exact value is not in the enum. The response completes normally, with no error and no special stop_reason. This applies to both JSON outputs and strict tool use.

Think about where that lands in a real system. An enum is the one construct that reliably compiles into the grammar — it is the recommended way to express a bounded range, since numeric constraints are not supported at all. So the enum is simultaneously the most trustworthy thing in your schema and the one whose exact bytes are not guaranteed. Downstream, enum values are what you switch on, use as dictionary keys, write to a database column with a check constraint, or compare for equality in a test. A capital letter in any of those is a KeyError, a constraint violation, or a silently-dropped branch.

The documented mitigations are both cheap and both easy to forget: compare enum values case-insensitively, and never mint two enum values that differ only in capitalization. The second one matters more than it looks — case-insensitive comparison is only safe if your enum does not contain two members that collapse to the same string, and the example above is itself one keystroke away from being such a set.

The exits that happen before you start

Two combinations fail up front rather than mid-flight, which is the merciful kind. Structured outputs are incompatible with citations — the API returns a 400 if citations are enabled alongside output_config.format — and incompatible with message prefilling. Both are worth knowing before you design a pipeline that assumed "constrain the output" composes freely with "cite the sources".

One scoping detail is genuinely reassuring and often misread as a limitation. Grammars apply only to the model's direct output — not to tool-use calls, not to tool results, and not to thinking blocks. Grammar state resets between sections, which is what lets a model reason freely and still land in your shape. That is the right design: it means turning on structured outputs does not constrain the reasoning that produces the answer, only the answer. Constrained Decoding argues this is the line you always want — constrain the shape, never the thinking.

And on the cost side, two facts pull in opposite directions. Structured outputs work with batch processing at the 50 percent discount, and token counting works without triggering compilation. But the schema itself is compiled and cached for up to 24 hours from last use, in storage held separately from message content — which is why the feature is zero-data-retention-qualified for prompts and responses while the schema is explicitly excluded from the PHI protections those get. Keep protected health information out of property names, enum values, const values and pattern regexes.

What to actually check

The whole post collapses into a short list, in this order, before any parsing:

  • Check stop_reason before you parse. refusal and max_tokens are both 200s and both mean the document in your hand may not conform. A parse-first pipeline turns each of them into a different, more confusing bug.
  • Count refusals as a first-class metric, with their token spend attached. They are billed and they are invisible in an error rate. Refusal Monitoring in Production covers the measurement side.
  • Normalise enum comparisons to case-insensitive, and audit your enums for case-only collisions. This is the only exit with no signal, so it has to be handled by construction rather than detection.
  • Do not ask a schema property for step-by-step reasoning. Ask for a short explanation or the evidence; leave the reasoning in thinking blocks.
  • Keep the validator you were about to delete. Not because the grammar is unreliable, but because its guarantee is scoped to one of four exits, and the other three are indistinguishable from it at the transport layer.

That last point is the one worth internalising. Schema enforcement genuinely deletes the broken-JSON failure, and it is a real advance. What it does not do is reduce the number of places you have to look — it relocates them, from a parse error you could not miss to a field you have to go and read.

FAQ

Does a refusal return an error status?

No. A refusal returns HTTP 200 with stop_reason: "refusal", you are billed for the tokens generated, and the output might not match your schema because the refusal message takes precedence over the schema constraints.

Why did adding a reasoning field to my schema cause refusals?

A property that asks for the model's thinking or step-by-step reasoning can trigger a reasoning_extraction refusal. Ask for a short explanation or the supporting evidence instead, and keep reasoning in thinking blocks.

Can a structured output violate my enum?

Yes, in one specific way: capitalization is not guaranteed for string enum and const values. The documented example shows a three-value enum returning a value that differs only in a capital letter, completing normally with no error and no special stop reason. Compare case-insensitively and avoid enum values that differ only in case.

What happens if the response hits max_tokens under strict mode?

You get stop_reason: "max_tokens" and a response that may be incomplete and not match the schema — in practice a schema-legal prefix of an incomplete document, which tolerant parsers will happily accept. Retry with a higher max_tokens, and check stop_reason before parsing.

Do structured outputs constrain the model's reasoning too?

No. Grammars apply only to the model's direct output, not to tool-use calls, tool results or thinking blocks, and grammar state resets between sections so the model can think freely and still produce the required shape.

Can I combine structured outputs with citations?

No. The API returns a 400 if citations are enabled with output_config.format, and message prefilling is incompatible as well. Batch processing and token counting both work.

Is it safe to put identifiers in enum values or property names?

Not if they are regulated data. Compiled schemas are cached for up to 24 hours from last use, separately from message content, and do not receive the PHI protections that prompts and responses do. Keep protected health information out of property names, enum values, const values and pattern regexes.

Further reading

On this wiki:

Primary sources:

  • Structured outputs — the "Invalid outputs" section, the enum-casing example, the complexity limits and the compatibility list.
  • Strict tool use — the two guarantees strict mode makes, and the schema-caching and PHI notes.
  • Refusals and fallback — the guidance on keeping reasoning in thinking blocks.