Guides
Structured Outputs
Structured output is a product pattern, not one dedicated AnyInt endpoint. The exact mechanism depends on the compatibility family and model you choose.
Structured output is a product pattern, not one dedicated AnyInt endpoint. The exact mechanism depends on the compatibility family and model you choose.
Recommended approach
- define the schema you need first
- tell the model exactly what keys and types to return
- validate the returned JSON in your application
- keep a repair or retry path for malformed output
Good use cases
- extraction pipelines
- workflow orchestration
- agent state handoff
- form or UI generation
Cross-family guidance
| Family | Recommended pattern |
|---|---|
| OpenAI-compatible | ask for a strict JSON object and validate it server-side |
| Anthropic-compatible | return JSON in a text block and validate it after parsing |
| Gemini-compatible | keep contents[].parts[] simple and ask for a JSON-only answer |
Example prompt pattern
{
"task": "extract_invoice",
"fields": {
"invoice_number": "string",
"currency": "string",
"total": "number"
}
}Use a prompt that clearly says:
- return valid JSON only
- do not add markdown fences
- do not add explanatory text
Important note
Support for strict JSON control can differ by model. Confirm the behavior with the specific model ID you plan to run in production, then enforce schema validation on your side.