AnyInt Docs
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.

  1. define the schema you need first
  2. tell the model exactly what keys and types to return
  3. validate the returned JSON in your application
  4. 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

FamilyRecommended pattern
OpenAI-compatibleask for a strict JSON object and validate it server-side
Anthropic-compatiblereturn JSON in a text block and validate it after parsing
Gemini-compatiblekeep 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.

On this page