What Are Structured Outputs?
Instead of free-form text:Setting Up Structured Outputs
In the Web App
1
Create a Schema
Define the output structure in the Schemas section.
2
Set as Structured Output
Mark the schema as “Structured Output” (not “Tool”).
3
Attach to Prompt
Attach the schema to your prompt’s structured output setting.
Schema Example
Provider Support
| Provider | Structured Output Support |
|---|---|
| Anthropic | Yes (beta) |
| OpenAI | Yes |
| Yes |
Using in Code
Basic Usage
Parsing the Response
Provider-Specific Handling
Anthropic
Requires beta header:OpenAI
Works out of the box:Validation Patterns
Basic Validation
With Telemetry
Retry on Failure
Schema Design Tips
Use Enums for Categories
Set Bounds for Numbers
Use Required Fields
Allow Additional Context
Include a reasoning field for explainability:Tools vs Structured Outputs
| Aspect | Tools (Function Calling) | Structured Outputs |
|---|---|---|
| Use when | LLM decides to use a tool | Always want JSON |
| Control | LLM chooses when | Guaranteed |
| Response | May include tool calls | Pure JSON |
| Multiple schemas | Yes (multiple tools) | One schema |
Combining with Tools
You can have both tools and structured output:- Tools for actions (search, calculate, etc.)
- Structured output for the final response format