Structured outputs: choosing JSON mode, schemas and tool calling
Parseable JSON does not guarantee the right fields—or mean a tool has run. A single support-ticket workflow shows when to use JSON mode, schema constraints or tool calling, and what to recheck when switching APIs.

Choose structured outputs by purpose: return data or request an action
Before passing a model's answer to a program, decide what the next step needs: a result with fixed fields, or a tool call that must be executed. Structured outputs with JSON Schema suit the former; function calling suits the latter. Consider JSON mode when the field structure can vary. If the target API does not support the schema constraints you need, JSON mode with application-side validation can also serve as a fallback. These options are not mutually exclusive: tool arguments can be schema-constrained, and the final answer after a tool runs can also be structured data.
This article compares API mechanisms using official documentation read on October 30, 2026. It does not rank model performance. The ticket workflow and data below are illustrative examples created for this article, not production logs or results from live API tests.
| What the next step needs | What to consider first | What this does not establish |
|---|---|---|
| Parseable JSON with a flexible structure, or a fallback when the API lacks the required schema support | JSON mode, with validation in the receiving application | That every specified field is present |
| Classification or extraction results for a fixed data structure | Structured outputs supporting the target schema | That field values match the source |
| A model to choose a query or action function and generate arguments | Tool calling, with argument constraints where supported | That the tool has run or the request is authorized |
| A query to a business system followed by a fixed-field answer | Tool calling plus a structured final output | That either stage can omit error handling |
OpenAI's documentation distinguishes JSON syntax constraints from schema constraints, and tool arguments from the format of a final answer. Mistral's documentation also separates JSON mode from custom structures; even with the mode enabled, the prompt should explain the intended output.
Why one support ticket can need two mechanisms
Suppose a user writes: “The export job for ticket T-204 is stuck again. Please check its progress.” A product can send that message through different workflows, changing which API mechanism is appropriate.
If the goal is simply to route the message to a support team, the model needs to return a classification. The application already has the source text; it does not need to invent a function with side effects just to produce a record. The following result object illustrates that purpose. Its field names and category enum were created for this article.
{
"category": "export_issue",
"ticket_id": "T-204",
"needs_lookup": true
}This object says that a lookup is needed. It has not queried any system. If the interface immediately displays “Exporting; should finish soon,” it has treated a classification as live status. Passing schema validation cannot supply the lookup that never happened.
When the product actually needs to check progress, it enters the tool workflow: the model requests the ticket, the application checks whether the current user may read T-204, executes the query, and passes the result back to the model. If the tool reports that no record was found, the answer should preserve that outcome or ask for more information. The model should not guess the current progress from earlier conversation.
After the query, the frontend may still need fixed fields such as status and summary for display. Structured outputs can serve this stage too. Claude's documentation explicitly describes JSON outputs and strict tool use as features that can be used independently or together. Separating them helps locate failures in argument generation, execution or answer formatting.
We recommend designing read permissions separately from write permissions. If the workflow later adds “resubmit export,” running it twice could create a second job. The application should retain request-deduplication, authorization and execution records. Well-formed model-generated arguments are no reason to skip those checks.
A schema should express uncertainty, not force an answer
Before fixing the fields, define what empty values mean in the business workflow. A message may say only “The export keeps getting stuck,” without a ticket number. If the schema requires ticket_id to be a string and the prompt insists that every field be filled, the model might supply a plausible-looking number or conceal the omission with an empty string.
A clearer design allows the number to be a string or null, with a separate status indicating that more information is needed. First check whether the target API's schema subset supports that design. Here, null means “not provided in the source”; an empty string does not automatically mean the same thing. The database, prompt and consuming code should share this convention.
In the JSON Schema object specification, properties defines field rules, required determines which fields must appear, and additionalProperties controls whether undeclared fields are allowed. Listing fields under properties does not automatically make them mandatory. An absent field is also different from a present field whose value is null.
For the ticket example, make at least three things explicit: the allowed categories, how to represent a missing number, and whether the model may add an explanation field. A description such as “please be accurate” can help, but it cannot replace checks in the receiving application. Whether T-204 exists and belongs to the current user still requires a business-system lookup.
Avoid copying a general-purpose schema unchanged across every service. The standard's expressive power and a model service's supported subset are different things. Starting with fields that are easy to validate and checking complex relationships between them in business code is usually easier to debug than repeatedly lengthening the prompt.
The same feature name does not mean the same constraints
As of the documentation review date, providers differ in configuration and limitations. The table lists differences that affect migration decisions, not a complete compatibility matrix.
| Documentation | Difference to watch | Integration step |
|---|---|---|
| OpenAI | Chat Completions and Responses place format parameters at different levels | Build requests for the API you actually use; do not mix the two parameter structures |
| Claude | JSON output and strict tool arguments have separate configuration; the documentation also lists refusals, truncation and enum-casing exceptions | Check completion status and validate enums against business conventions; do not rewrite them blindly |
| Gemini | Only a JSON Schema subset is supported, and some constraints are not enforced during generation | Keep full data validation in the application |
| Mistral | JSON mode and custom schemas provide different degrees of constraint | Confirm which is enabled rather than judging by whether the result looks like JSON |
Gemini's documentation specifically warns that a compliant structure does not establish that field values are semantically correct. Constraints such as some length limits still need application-side enforcement. Claude's documentation also explains that some SDK helpers move unsupported constraints into descriptions; only helpers that validate responses continue checking the original constraints on the client. Check the constraints actually sent and the parser's behavior, not just the types you defined.
Frameworks can hide further differences. For example, LangChain's withStructuredOutput offers multiple methods. Seeing the same method name in application code does not establish that the underlying capability is always the same. Record the actual provider, model, API path, SDK version and mode when troubleshooting so that results can be compared.
Recheck these details when using an aggregation service or switching providers too. This article has not tested structured outputs across all Orbis models and routes, and makes no claim that any particular route supports a parameter. The existing multi-provider aggregation guide addresses connection management; individual request capabilities still need separate verification.
Test counterexamples, not just successful screenshots
The following acceptance checklist was designed for the ticket workflow above. It is not a report of tests already run. Adapt it into your own test data and record the expected outcome for each case.
| Input or event | Behavior to check | Problem it exposes |
|---|---|---|
| A clear ticket number and problem are provided | Both the classification and number can be checked against the source | Correct formatting conceals an extraction error |
| No ticket number is provided | Return the agreed missing-value status or ask for more information | The model invents a number to satisfy field requirements |
| The number belongs to another user | The application rejects the unauthorized lookup | Argument validation is mistaken for authorization |
| The tool returns “not found” | The final answer preserves that result | The model presents a failure as completed work |
| Generation is truncated or refused | Use a separate error branch; do not store it as a normal record | Only the successful HTTP status is checked |
| The same write operation is requested twice | The application detects the duplicate and retains execution records | Retries cause duplicate side effects |
| A parameter is ignored or rejected after switching providers | Mark it as a compatibility issue and recheck the request and documentation | A successful chat request is treated as proof that every capability works |
Distinguish eventual success from first-attempt success in your records. A request that succeeds after several retries should not leave the same lone screenshot as one that worked immediately. This article sets no universal passing rate: the business should choose one based on tolerable consequences of errors, human-review capacity and actual samples.
Route failures by cause as well. Unsupported schemas or parameters require request changes; missing source information requires more input; insufficient permissions require execution to stop. Handle rate limits using the AI API 429 troubleshooting guide. Do not send every failure into an unconditional retry loop.
To begin implementation, draw four steps: source text, classification record, tool lookup and final display. Connect tools only where external information is actually needed. Write one rule for what happens when each step fails, then choose its output mechanism. The API feature name no longer has to be the starting point.
Further reading
This article synthesizes official documentation around a support-ticket workflow, reorganizing the concepts, migration checks and acceptance questions. All examples are illustrative designs; no comparative model experiments were conducted.