Multi-turn sessions
Maintain conversation context across multiple requests. Use multi-turn sessions when you want to ask follow-up questions, explore your videos and images iteratively, or build a chat interface that preserves context across turns. This guide shows you how to start a session, continue it with follow-up messages, and build a reusable chat pattern.
Key concepts
- Session: A server-side conversation state that Jockey maintains across requests. You do not need to resend previous messages. The session retains the full conversation history. Each response includes a session identifier that you pass on subsequent requests to continue the conversation.
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
Copy and paste the code below, replacing the placeholders surrounded by <> with your values.
Code explanation
Python
Node.js
Start a session
Omit the session_id field on the first request. Jockey creates a new session and returns its identifier in the response.
Function call: You call the responses.create method.
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.
Return value: An object of type ResponseObject. Read the session_id field and store it to continue the conversation.
Continue the conversation
Pass the session_id from the previous response to send a follow-up message. Jockey uses the full conversation history, so you do not resend earlier messages.
Function call: You call the responses.create method.
Parameters:
knowledge_store_id: The unique identifier of the knowledge store. Keep it the same across turns.session_id: The session identifier from the previous response.input: An array of input items. Each item is a message you send to Jockey.
Return value: An object of type ResponseObject. Reuse the same session_id for later turns.
Start a session
Omit the sessionId field on the first request. Jockey creates a new session and returns its identifier in the response.
Function call: You call the responses.create method.
Parameters: You pass all parameters as properties of a single object.
knowledgeStoreId: 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.
Return value: An HttpResponsePromise that resolves to an object of type ResponseObject. Read the sessionId field and store it to continue the conversation.
Continue the conversation
Pass the sessionId from the previous response to send a follow-up message. Jockey uses the full conversation history, so you do not resend earlier messages.
Function call: You call the responses.create method.
Parameters: You pass all parameters as properties of a single object.
knowledgeStoreId: The unique identifier of the knowledge store. Keep it the same across turns.sessionId: The session identifier from the previous response.input: An array of input items. Each item is a message you send to Jockey.
Return value: An HttpResponsePromise that resolves to an object of type ResponseObject. Reuse the same sessionId for later turns.
Build a reusable chat function
For chat UIs or interactive applications, wrap the session logic in a function. The function creates a new session on the first call and reuses it for subsequent calls.
Common pitfalls
- Store the session identifier. Without the
session_idvalue you cannot continue a conversation, and must start a new one. - Query the same knowledge store across turns. A session is tied to one store; pass the same
knowledge_store_idon every turn. - Do not resend conversation history. The session stores it server-side.
Next steps
- Streaming - combine multi-turn sessions with real-time streaming
- Structured output - receive typed JSON responses within a session
- Create a response - review the basic request and response format