For the complete documentation index, see llms.txt. This page is also available as Markdown.

Structured Outputs

Return structured data from your models.

Infron supports structured outputs for compatible models, ensuring responses follow a specific schema format. This feature is particularly useful when you need consistent, well-formatted responses that can be reliably parsed by your application.

Structured outputs allow you to:

  • Enforce specific JSON Schema validation on model responses

  • Get consistent, type-safe outputs

  • Avoid parsing errors and hallucinated fields

  • Simplify response handling in your application

Model Support

To ensure your chosen model supports structured outputs:

  1. Check the model's supported parameters on the models page

  2. Include response_format and set type: json_schema in the required parameters

Using Structured Outputs

To use structured outputs, include a response_format parameter in your request, with type set to json_schema and the json_schema object containing your schema:

json_scheme

The model will respond with a JSON object that strictly follows your schema:

CalendarEvent

The response example:

Streaming with Structured Outputs

Structured outputs are also supported with streaming responses. The model will stream valid partial JSON that, when complete, forms a valid response matching your schema.

To enable streaming with structured outputs, simply add stream: true to your request:

Best Practices

  1. Include descriptions: Add clear descriptions to your schema properties to guide the model

  2. Use strict mode: Always set strict: true to ensure the model follows your schema exactly

Error Handling

When using structured outputs, you may encounter these scenarios:

  1. Model doesn't support structured outputs: The request will fail with an error indicating lack of support

  2. Invalid schema: The model will return an error if your JSON Schema is invalid

Last updated