Sometimes you want a chat response to be a JSON object you can parse, not a sentence. SetDocumentation Index
Fetch the complete documentation index at: https://docs.opper.ai/llms.txt
Use this file to discover all available pages before exploring further.
response_format with a JSON Schema and the model will produce JSON that matches it.
If you’re building a one-shot extraction or classification task, the JSON API is usually a better fit. Use this when you’re already in a chat flow and need structure for one specific turn.
A working example
content field is a JSON string. Parse it once to get a typed object.
When to use what
| Need | Reach for |
|---|---|
| One-shot extraction or classification from a single input | JSON API |
| Structured response inside an ongoing chat | response_format: json_schema (this page) |
| Tool that returns structured arguments to your code | Tool calling |
| Multimodal input (image, PDF, audio) with structured output | JSON API |
Tips
- When the answer is one of a fixed set, use enums. Add
"enum": ["low", "medium", "high"]to a property. The model is far more reliable on these than on free strings. - Add a
"description"to ambiguous properties. The model reads descriptions as guidance. - List required fields in the
requiredarray. Optional fields can come back asnull.
What’s next
JSON API: schemas
The richer schema system for one-shot tasks.
Tool calling
When the model should call your code, not just answer.