Structured output
Return typed JSON from Jockey by providing a JSON Schema. Use structured output when downstream code needs predictable fields, when agents or services need typed responses, or when you want to extract structured metadata from a video collection. This guide covers how to define a schema, attach it to a request, and parse the structured response.
Key concepts
- JSON Schema: A standard for describing the structure of JSON data. You define the expected shape - properties, types, arrays - and Jockey constrains its output to match. Pass your schema in the
text.formatrequest field.
Prerequisites
- You’ve already uploaded your content, and the asset has reached the
readystatus. See the Upload content page for details. - You’ve already created a knowledge store. See the Create a knowledge store page for details.
- You’ve already added at least one asset to the knowledge store, and the item has reached the
readystatus. See the Add assets to a knowledge store page for details. - You’ve already read the Create a response page and understand the basic request and response format.
Basic usage
Define a JSON Schema describing the output you want, then pass it in the text field. This example extracts themes and entities from a video collection.
The response text is a JSON string that matches your schema:
Combine with instructions
Use instructions to apply a domain-specific lens and a schema to capture the results in a structured format. This example enriches videos through a brand strategy perspective.
Swap the instructions to enrich for different contexts - the schema stays the same:
Design a schema for organization discovery
You can use structured output to have Jockey recommend how to categorize your collection. The schema below captures each organization axis with a score, so you can compare approaches programmatically.
Common pitfalls
- Response text is a JSON string. You still need to call
json.loads()on the text content to get a Python object. - Schema must be valid JSON Schema. Invalid schemas cause request errors.
- Keep schemas simple. Deeply nested schemas may produce less reliable output.
Next steps
- Streaming - combine streaming with structured output for real-time typed responses
- Multi-turn sessions - use structured output across a multi-turn conversation
- Create a response - review the basic request and response format
Jupyter notebook
Download the notebook to run this guide interactively.