Structured Outputs
FastRouter supports structured JSON outputs, allowing you to enforce a specific schema in LLM responses. This feature ensures that responses are machine-readable and conform to a predefined structure.
Overview
Supported Format
Example: Enforcing Weather Data Schema
curl --location 'https://api.fastrouter.ai/api/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API-KEY' \
--data '{
"model": "openai/gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant that responds in JSON format."
},
{
"role": "user",
"content": "What is the weather like in London?"
}
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "weather",
"strict": true,
"schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City or location name"
},
"temperature": {
"type": "number",
"description": "Temperature in Celsius"
},
"conditions": {
"type": "string",
"description": "Weather conditions description"
}
},
"required": ["location", "temperature", "conditions"],
"additionalProperties": false
}
}
}
}' Response Example
Schema Validation Options
Parameter
Description
Best Practices
Last updated
