Schemas are how the JSON API knows what you want. You describe the shape of your input and your output; Opper validates the model’s response against that shape and gives you back a typed object. Three ways to write them:Documentation Index
Fetch the complete documentation index at: https://docs.opper.ai/llms.txt
Use this file to discover all available pages before exploring further.
- Python: Pydantic models (recommended), dataclasses, TypedDicts, or raw JSON Schema dicts
- TypeScript: raw JSON Schema objects
- Anywhere else: raw JSON Schema sent as JSON over HTTP
output_schema: get typed JSON back
This is the one you’ll use most. Describe what you want, the model fills it in.
input_schema: validate what goes in
Optional. You only need it in two cases:
- To validate the caller, so the schema rejects malformed input before it reaches the model.
- To mark a field as media, using the JSON Schema
contentMediaTypeandcontentEncodingkeywords to tell the model that a string is a PDF or an image.
Python
Media types
SetcontentMediaType on any string field to send media. The model handles the rest.
| Media type | Use for |
|---|---|
image/png, image/jpeg, image/webp | Photos, screenshots, scans |
application/pdf | Documents |
audio/wav, audio/mpeg, audio/ogg | Recordings, voice messages |
video/mp4 | Short video clips (where the model supports it) |
contentEncoding is base64 for inline media. The actual bytes go in the field as a base64 string.
Not every model supports every type. See the models catalog for which models accept which inputs.
Common patterns
Optional fields
Enums (one of a fixed set)
Arrays
Nested objects
Field descriptions
Help the model by describing what each field is. Especially useful for ambiguous ones.What’s next
Calls
The basics of the JSON API.
Streaming
Stream fields as they come back.
Hints
Pick cost vs quality vs speed without naming a model.
Control Plane
Govern, score, and improve every call.