Organize a video library
This recipe shows you how to organize an entire video library in a multi-turn session. The final output is a complete library catalog as structured JSON. Every video is assigned to a group, ready for your CMS or DAM system.
Use cases:
- Library management: Categorize a new or growing video collection
- Content audit: Discover natural groupings before restructuring a library
- Pipeline automation: Generate a machine-readable catalog for a CMS or DAM system
Key concepts
- Knowledge store: A persistent store of your videos and images plus the understanding the platform derives from them — spatiotemporal context, a typed ontology, and embeddings — that together enable corpus-level reasoning.
- Multi-turn session: A conversation where each request builds on previous turns. The first request creates a session, and follow-up requests reference that session to continue the conversation. For details, see the Multi-turn sessions page.
- Structured output: A JSON schema you provide with your request. Jockey constrains its output to match your schema, so you retrieve machine-readable results instead of plain text. For a guide on designing schemas and parsing responses, see the Structured output page.
Workflow
This recipe uses a multi-turn session in which each call builds on the previous ones. The first call requests a plain-text overview of the collection. The second call passes a JSON schema and asks Jockey to discover and rank categorization strategies. The third call takes the top-ranked strategy and categorizes every video. Jockey refines its analysis as the session progresses. You can adapt this recipe to organize by different criteria or target a specific domain.
Prerequisites
- You’ve already created a knowledge store with at least one item in
readystatus. See the Quickstart page for details. - You’re familiar with the request and response format. See the Create a response page for details.
- For best results, use a knowledge store with 10 or more videos.
Complete example
Copy and paste the code below, replacing the placeholders surrounded by <> with your values.
Code explanation
Python
Node.js
Request a collection overview
Ask for a high-level overview. This first request creates the session that the later turns build on.
Function call: You call the responses.create method with a prompt that requests an overview.
Parameters:
knowledge_store_id: The unique identifier of the knowledge store to reason over.input: An array of input items. Each item is a message you send to Jockey. This example requests a high-level overview of themes, subjects, and patterns.
Return value: An object of type ResponseObject. Read the overview text from the output items, and keep the session_id for the follow-up turns. Jockey retains this overview as session context, so later turns build on it. The response also includes id, status, and usage.
Discover organization strategies
Continue the session with a prompt that ranks categorization strategies. Jockey uses the collection context from the previous turn.
Function call: You call the responses.create method with the session_id and a text parameter that describes your axes schema.
Parameters:
knowledge_store_id: The unique identifier of the knowledge store. Must match the store used to create the session.session_id: The session identifier from the first response.input: An array of input items. Each item is a message you send to Jockey. This example asks Jockey to rank the top three categorization strategies by effectiveness.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. Design the schema to fit your use case; the inline comments in the example describe each field. For the schema rules, see the Structured output page.
Return value: An object of type ResponseObject. The text field of each content part in a message item is a JSON string that matches your axes schema.
Process the strategies
Parse the text field of each content part in a message item with json.loads(), then iterate the recommended_axes array to read each ranked strategy. Keep the best_axis value; the next step uses it to categorize the videos.
Categorize videos
Continue the session with a prompt that organizes every video by the top-ranked axis.
Function call: You call the responses.create method with the session_id and a text parameter that describes your catalog schema.
Parameters:
knowledge_store_id: The unique identifier of the knowledge store. Must match the store used to create the session.session_id: The session identifier from the first response.input: An array of input items. Each item is a message you send to Jockey. This example inserts thebest_axisvalue from the previous step into the prompt, so Jockey organizes every video by that axis.text: The catalog schema, in the same form as the previous step.
Return value: An object of type ResponseObject. The text field of each content part in a message item is a JSON string that matches your catalog schema.
Example response
The text field inside each content part is a JSON string that matches your schema. After parsing, a typical result from the final categorization step looks like this:
Notes
- The
referencefield in each video entry contains the asset identifier of the knowledge store item. - Jockey generates the
titlefield from the content of the video, not from a filename or metadata field. - Jockey evaluates the actual content in your knowledge store. Results change depending on the videos you have indexed.
Variations
Change the prompts or add the instructions parameter to adapt this recipe for different organizational needs.
-
Multi-axis catalog: Run step 7 multiple times with different axes from step 5 to produce catalogs along different dimensions.
-
Hierarchical organization: After the first categorization, send a follow-up prompt: “Now sub-organize the [category] group by difficulty level.”
-
Export: Pipe the JSON output to a file for use in your CMS or DAM system.
-
Known criteria: Skip the discovery steps and send a single request. Set the
instructionsparameter to a librarian role (for example, “You are a content librarian. Organize videos into clear, mutually exclusive categories.”) and specify the categories directly in the prompt.Example:
Jupyter notebook
See also
- Generate a corpus overview - the standalone version of steps 1–2
- Find organization axes - the standalone version of steps 3–5
- Multi-turn sessions - more on session-based conversations
- Structured output - more on JSON Schema responses
- Create a response - API reference for the Responses endpoint