Skip to content
DigitalNeuron
Tools & products

Claude and OpenAI each shipped a way to force valid JSON out of a model — here's how they differ

Both labs now offer a strict mode that guarantees schema-valid output instead of hoping the model formats it right. The setup rules are specific, and OpenAI's official guidance still caps how many tools you hand the model at once.

By DigitalNeuron Desk3 min read

Quick answer

How do Claude and OpenAI recommend getting structured output you don't have to validate and retry?

Both offer a strict mode: Claude's `strict: true` on a tool definition, OpenAI's Structured Outputs with `strict: true` in the response format. OpenAI requires `additionalProperties: false` and every field listed as required, with optional fields made nullable instead of omitted. Both guides also warn that vague function descriptions and too many available tools quietly lower accuracy.

Key takeaways

  • Structured Outputs on OpenAI's side and strict tool use on Claude's side both guarantee schema adherence — the older 'JSON mode' style does not, and can still return malformed output.
  • OpenAI's strict schema requires `additionalProperties: false` and every field in `required`; there is no such thing as an optional field left out of that list — you make it nullable instead.
  • OpenAI's own guidance suggests keeping the number of available functions under 20 at the start of a turn, because each definition counts as input tokens and more choices lower accuracy.
  • Claude documents a real reliability gap between models: when a required parameter is missing from the prompt, Opus is more likely to ask; Sonnet is more likely to guess a plausible value instead.
  • Both platforms bill tool/function definitions as ordinary input tokens on every call, and Claude publishes the exact per-model token overhead this adds.

Getting an LLM to call a function or return JSON has always worked most of the time, which is a worse problem than never working — the failures show up downstream, in a parser that crashes on the ten-thousandth call, not on the ninety-nine you tested by hand. Both Claude and OpenAI now publish a mode that removes the "most of the time" from that sentence, and the official setup rules for each are specific enough to follow directly rather than guess at.

Strict mode, on both sides

Claude's version: add strict: true to a custom tool definition, and Claude's tool call is guaranteed to match the schema. OpenAI's version, called Structured Outputs, is set through text: { format: { type: "json_schema", strict: true, schema: … } }. OpenAI frames this explicitly as the successor to the older "JSON mode" — JSON mode never guaranteed your schema was actually followed, Structured Outputs does.

Write the function description for a stranger

OpenAI's own advice is to write function names, parameter descriptions, and usage instructions clearly enough that what it calls "the intern test" applies: a new hire could use the function correctly from the documentation alone, with no other context. That includes saying explicitly, in the system prompt, when a function should and should not be called, with examples of edge cases — not just what the function does when it's obviously the right call.

Fewer tools, better accuracy

It's tempting to hand the model every tool you have and let it sort out which one applies. OpenAI's guidance pushes back on this directly: keep the number of available functions under roughly 20 at the start of a turn for higher accuracy, and remember that every function definition counts as input tokens whether or not it gets used that turn. If a set of functions is always called in the same sequence, OpenAI's suggestion is to merge them into one operation rather than making the model chain several calls correctly every time.

Claude's models don't fail the same way

Claude's documentation includes a specific, model-level reliability note that's worth planning around rather than discovering in production: when a required parameter is missing from what the user actually typed, Opus is considerably more likely to notice the gap and ask a clarifying question, while Sonnet is more likely to infer a plausible value on its own — guessing a location, for instance, instead of asking which one. This isn't guaranteed behavior in either direction, but it's the direction each model leans, and it gets worse on ambiguous prompts with a less capable model.

Forcing the call, and running several at once

Both platforms let you skip Claude's or OpenAI's default judgment call about whether to use a tool at all. Claude exposes tool_choice to force a call rather than leaving it on the default {"type": "auto"}. OpenAI supports parallel function calling on GPT-5 and later for its built-in tools, and parallel_tool_calls: false if you specifically want at most one call per turn — built-in tools, notably, can't be batched into a parallel group regardless of that setting.

Check the date. OpenAI's own docs recommend gpt-5.6 for new Structured Outputs projects and note tool search is only available on gpt-5.4 and later; Claude's tool-use token overhead is published per current model generation. Both numbers move as new models ship — read the linked pages directly rather than treating the figures above as permanent.

Frequently asked questions

Is Structured Outputs the same thing as the older JSON mode?
No. OpenAI describes Structured Outputs as an evolution of JSON mode: JSON mode does not guarantee your schema is followed, Structured Outputs does. OpenAI's own comparison table recommends legacy JSON mode only for models predating gpt-4o-2024-08-06.
What does strict mode actually require in the schema?
For OpenAI: `additionalProperties: false` on every object, and every property listed in `required` — optional fields are expressed as a nullable type instead of being dropped from the required list. For Claude: adding `strict: true` to the tool definition.
Does having more tools available always help the model?
No. OpenAI's guidance explicitly recommends staying under roughly 20 available functions per turn for accuracy, and notes each definition is billed as input tokens whether or not it gets used that turn.
Can I just force the model to call a specific tool?
Yes on both platforms. Claude exposes this through the `tool_choice` parameter documented under forcing tool use; OpenAI's `parallel_tool_calls: false` setting can also be combined with an explicit tool choice to get exactly one call.

Sources

  1. Tool use with ClaudeAnthropic
  2. Function callingOpenAI
  3. Structured model outputsOpenAI
  4. Introduction to Structured OutputsOpenAI
Tagsclaudechatgptfunction-callingstructured-outputapidocumentation

Related reading

Five prompting habits that Anthropic and OpenAI both put in their own documentation

Both labs publish the same core advice: write the instruction as a command rather than a question, give the model explicit permission to say it does not know, put the context before the question, keep one task per prompt, and tell the model how proactive to be. The common thread is that every one of them removes ambiguity — none of them is a phrase you paste in to unlock hidden quality.

4 min read

When a Claude Project or a ChatGPT Project actually earns its keep, per each company's own help pages

Both companies frame Projects the same way: a workspace that holds its own chat history, uploaded reference files, and standing instructions, so you stop re-explaining context every session. Claude caps free accounts at 5 projects and scales knowledge capacity up to 10x on paid plans; ChatGPT scopes a project's memory to chats inside that project only, not across your whole account.

3 min read

Anthropic launches Claude Science workbench for researchers

Anthropic introduced Claude Science, a research workbench that combines scientific tools, specialist agents, databases and computing resources. The beta is available on macOS and Linux for Claude Pro, Max, Team and Enterprise users, with features for reproducible analysis, literature work, figures, manuscripts and managed computing jobs.

2 min read