Structured output
Retrieve predictable, typed JSON responses by providing a JSON Schema with your request.
Key concepts
- JSON Schema: A standard for describing the structure of JSON data. You define the expected shape (properties, types, arrays), and the platform constrains its output to match.
Prerequisites
- You’ve already uploaded your videos and images, and the assets have 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.
Example
Define a JSON Schema describing the output you want, then pass it in the text parameter. This example extracts themes and entities from your videos and images. Replace the placeholders surrounded by <> with your values.
Code explanation
Python
Node.js
To receive typed JSON output, call the responses.create method with a text parameter that describes your JSON Schema. This example parses the returned JSON string and prints the extracted themes and entities to the standard output.
Parameters:
knowledge_store_id: The unique identifier of the knowledge store to reason over. Every request requires exactly one.input: An array of input items. Each item is a message you send to Jockey.text: An object that specifies the response format. To return structured JSON, set theformatfield: itsschema_field defines the structure the output must match, and itsnamefield identifies the schema. See the JSON schema requirements section for the schema rules.
Return value: An object of type ResponseObject. Iterate the output array and read the text field of each content part in a message item to obtain a JSON string that matches your schema. Parse it with json.loads() into a native object.
Example response
The response text is a JSON string that matches your schema:
Combine with instructions
Use the instructions field to apply a domain-specific lens, and a schema to capture the results in a structured format. This example enriches videos and images through a brand strategy perspective.
Swap the instructions field to apply a different analysis lens. The schema stays the same:
JSON schema requirements
Note
The constraints in this section apply to the Responses API. The schema the platform uses during ingestion supports different keywords and rejects unknown keywords with a 422 error.
Your schema must adhere to the JSON Schema Draft 2020-12 specification and must meet the requirements below:
- Supported data types:
array,boolean,integer,null,number,object, andstring. - Automatic schema changes: The platform adds all object properties to
requiredand setsadditionalPropertiestofalseon every object. You do not need to includerequiredoradditionalPropertiesin your schema. - Unsupported keywords: Do not use
oneOf,default,if/then/else,not,patternProperties,contains, orprefixItems. They may produce incomplete or malformed output without returning an error. UseanyOfinstead ofoneOf, andpropertiesinstead ofpatternProperties. Omit the others. - Subschema references: You can reference subschemas using
$ref. Define subschemas within$defsat the root of the schema. External URIs and relative-path references are not supported. For details, see the JSON Schema documentation on $defs.
For complete specifications, see the schema field in the API Reference section.
Common pitfalls
- Large schemas can reduce output quality. Keep nesting to 5 levels of objects or fewer. Keep the total number of properties across all objects to 100 or fewer. These are best-practice guidelines, not enforced limits.
- Response text is a JSON string. You still need to parse the text content with
json.loads()(Python) orJSON.parse()(Node.js) into a native object. - Truncated responses may fail to parse. Even with a valid schema, the platform may truncate the response at the token limit. If the
statusfield isincomplete, simplify your schema or break the request into smaller queries.
Next steps
- Recipes - complete examples that combine structured output with real tasks like entity extraction, content organization, and enrichment
- 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