Structured outputs
Use response_format in the OpenAI-compatible format to make the model follow a JSON schema strictly. Verified with both GPT and Gemini models.
Using structured outputs
{
"model": "gpt-5.6-sol",
"messages": [{"role": "user", "content": "Give me a city and its country"}],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "city",
"strict": true,
"schema": {
"type": "object",
"properties": {"city": {"type": "string"}, "country": {"type": "string"}},
"required": ["city", "country"],
"additionalProperties": false
}
}
}
}
choices[0].message.content is a JSON string matching the schema, such as {"city":"Beijing","country":"China"}.
Model support
Verified: gpt-5.6-sol and gemini-3.5-flash (both through /v1/chat/completions).