Skip to main content

Persistent Multi-Turn State — Conversations API

[ ABORT TO HUD ]
SEQ. 1

Persistent Multi-Turn State

💬 Conversations API 15 min 250 BASE XP⌨ HANDS-ON LAB

What Is the Conversations API?

The Conversations API is OpenAI's dedicated endpoint for managing persistent, server-side conversation state. It replaces the manual pattern of tracking message arrays client-side or using the legacy Assistants API Threads.

Why It Exists

With Chat Completions, developers had to store and re-send the entire message history on every request - leading to token waste, context truncation bugs, and complex client-side state management. The Conversations API eliminates this by letting OpenAI manage the conversation server-side.

Relationship to the Responses API

The Conversations API works hand-in-hand with the Responses API. You can either chain responses using store: true and previous_response_id, or explicitly create a Conversation object via POST /v1/conversations and pass conversation: conv.id in your Responses API requests.

API Usage Patterns

import OpenAI from "openai";
const openai = new OpenAI();

// Create an explicit server-side conversation container
const conv = await openai.conversations.create({
  metadata: { user_id: "usr_882" }
});

// Start a conversation via the Responses API
const r1 = await openai.responses.create({
  model: "gpt-6.1-sol",
  conversation: conv.id,
  store: true,
  input: "I need help planning a product launch."
});

// Or chain directly via previous_response_id
const r2 = await openai.responses.create({
  model: "gpt-6.1-sol",
  store: true,
  previous_response_id: r1.id,
  input: "What marketing channels should I prioritize?"
});

// Retrieve or delete a stored response when no longer needed
const stored = await openai.responses.retrieve(r1.id);
await openai.responses.delete(r1.id);

Key Benefits

  • Zero client-side state: No message arrays, no truncation logic, no local databases.
  • Automatic prompt caching: Stored conversations get automatic prefix caching for 90%–95% input token savings on GPT-6 models (and 50%–75% on earlier generations).
  • Seamless migration: Replaced Assistants API Threads (which shut down August 26, 2026) - use Conversations API + Responses API instead.
  • Full audit trail: Every response is stored with metadata for compliance and debugging.
🚨 Post-Sunset Migration Note: The Assistants API and its Threads endpoints were permanently shut down on August 26, 2026 (and dashboard Reusable Prompt objects at /v1/prompts also sunset on November 30, 2026). OpenAI did not provide an automated Thread-to-Conversation migration tool; pass instructions inline in your application code and use conversation or store: true + previous_response_id.
⌨ HANDS-ON LABInitialize a Stateful Conversation
⭐ +200 XP

Offload chat history to OpenAI servers. Initialize a persistent conversation session via /v1/conversations.

1POST to https://api.openai.com/v1/conversations to create a new persistent conversation thread.
lab-sandbox — simulated environment
INFINITY LAB SANDBOX v2.6 — simulated shell
Type the command for the current objective. Helpers: "hint", "solution", "clear".
$
OBJECTIVE 1 / 1 — type "hint" if stuck
SYNAPSE VERIFICATION
QUERY 1 // 3
What does the Conversations API replace?
The Embeddings API
Manual client-side message history management and Assistants API Threads
The Batch API
Function calling