- SDK
- Continuing conversations
SDK
Continuing conversations
Use thread_id to keep chat history in one place. Use assistant_id when you want the same AI profile (and memory) across multiple chats.
What this page is for
After your first message, you get back thread_id and assistant_id. This guide explains what to pass next so users stay in the same chat—or start a new chat without losing memory.
| Goal | Pass |
|---|---|
| Keep talking in the same chat | Same thread_id on every send_message / sendMessage |
| Start a new chat but keep memory & docs | Omit thread_id, pass the same assistant_id |
| Let the API pick defaults | Omit both (you get a new assistant + thread each time unless you reuse IDs from a prior response) |
Continue on the same thread
Pass thread_id from the last response. The model receives full prior context for that conversation.
Python
JavaScript
TypeScript
first = await client.send_message("My favorite color is blue.")
second = await client.send_message(
"What did I just tell you?",
thread_id=first.thread_id,
)
print(second.content)
New chat, same assistant (shared memory)
Memories are stored per assistant. To remember the user across different threads, reuse assistant_id and start a new thread (omit thread_id on that call).
Python
JavaScript
TypeScript
r1 = await client.send_message(
"I'm allergic to peanuts.",
assistant_id=my_assistant_id,
memory="Auto",
)
r2 = await client.send_message(
"Any dietary restrictions you remember?",
assistant_id=my_assistant_id,
memory="Auto",
)
Create a thread explicitly (optional)
If you already have an assistant_id, you can create an empty thread via the REST API, then send messages with that thread_id. Most integrations only need send_message and the IDs it returns—see Conversation threads for the HTTP shape.
Related
- Conversation threads — conceptual model
- Assistant profiles — what
assistant_idties into - Memory — how recall works with
assistant_id - First Message — parameters reference