response_format to a JSON Schema. The model produces JSON that matches it, and the gateway validates the response against the schema before returning it. This is the standard OpenAI-compatible parameter, so it works from any SDK you point at Opper.
Reach for structured output to parse a receipt, extract fields from a contract, classify a support ticket, or any job where you describe the shape you want back.
A working example
content field comes back as a JSON string. Parse it once to get a typed object. If the model can’t produce something that matches the schema, the call fails with a validation error rather than silently returning malformed JSON.
Writing the schema
The schema is plain JSON Schema. A handful of patterns cover almost everything you’ll need.Enums (one of a fixed set)
When the answer is one of a fixed set of values, use an enum. The model is far more reliable on these than on free strings.Optional fields
List required fields in therequired array. Anything left out can come back as null.
Arrays
Nested objects
Field descriptions
Describe ambiguous fields. The model reads descriptions as guidance.Structured output from images, PDFs, and audio
Structured output composes with multimodal input. Put the image, PDF, or audio in the message content and setresponse_format to the shape you want back. See Vision & PDFs for how to attach media.
When to use what
| Need | Reach for |
|---|---|
| Typed JSON from a model | response_format: json_schema (this page) |
| Model that calls your code mid-conversation | Tool calling |
| Multimodal input with structured output | Vision & PDFs + response_format |
What’s next
Tool calling
When the model should call your code, not just answer.
Vision & PDFs
Send images and documents, get structure back.
Streaming
Stream the response as it’s generated.
Control Plane
Govern, score, and improve every call.