Skip to main content
Use Cases
  • Extracting typed fields from unstructured text (invoices, emails, support tickets).
  • Pipelines where downstream code requires a guaranteed JSON schema.
  • Classification tasks with a controlled output set (enum values, boolean flags).
  • Generating config objects or API payloads directly from natural language.

Quick Start

Generate structured JSON responses with guaranteed schema compliance.

Configuration Options

Response Format Types

Text Mode (Default)

JSON Schema Mode

Simple JSON Mode

Schema Examples

Simple Data Extraction

Complex Nested Structure

Code examples

Common Use Cases

The examples in this section use the Chat Completions endpoint. Structured outputs work identically with the Responses API: use responses.create() with text: { format: { type: "json_schema", ... } } instead of response_format.

Data Extraction

Content Analysis

Form Generation

Advanced Patterns

Conditional Schemas

Dynamic Schema Generation

Validation and Error Handling

Best Practices

Schema design:
  • Use descriptive field names.
  • Add field descriptions for better results.
  • Mark essential fields as required.
  • Use appropriate data types and constraints. Error handling:
Performance optimization:

Troubleshooting

Schema validation fails
  • Simplify complex nested structures.
  • Ensure required fields are clearly specified.
  • Check field types match expected data.
  • Add field descriptions for clarity. Inconsistent outputs
  • Use more specific prompts.
  • Add examples in the prompt.
  • Increase model temperature for creativity.
  • Switch to a more capable model. Performance issues
  • Reduce schema complexity.
  • Cache schema definitions.
  • Use appropriate models for task complexity.
  • Consider breaking large schemas into smaller ones.

Limitations

Integration Examples

Database Integration

API Integration