Repository Public
1# Assistants migration guide23> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.45The Assistants API was officially sunset on August 26, 2026, and is no longer available. Use the [Responses API](https://developers.openai.com/api/docs/guides/migrate-to-responses) for new integrations.678910Thank you to everyone who used the Assistants API. We appreciate everything you built and the feedback you shared along the way.1112Use this guide to migrate your integration to the [Responses API](https://developers.openai.com/api/docs/guides/migrate-to-responses).1314Responses are simpler—send input items and get output items back. With the Responses API, you also get better performance and new features like [deep research](https://developers.openai.com/api/docs/guides/deep-research), [MCP](https://developers.openai.com/api/docs/guides/tools-connectors-mcp), and [computer use](https://developers.openai.com/api/docs/guides/tools-computer-use). This change also lets you manage conversations instead of passing back `previous_response_id`.1516### What's changed?1718<table>19 <thead>20 <tr>21 <th>Before</th>22 <th>Now</th>23 <th>Why?</th>24 </tr>25 </thead>26 <tbody>27 <tr>28 <td>`Assistants`</td>29 <td>`Prompts`</td>30 <td>31 Prompts hold configuration (model, tools, instructions) and are easier32 to version and update33 </td>34 </tr>35 <tr>36 <td>`Threads`</td>37 <td>`Conversations`</td>38 <td>Streams of items instead of just messages</td>39 </tr>40 <tr>41 <td>`Runs`</td>42 <td>`Responses`</td>43 <td>44 Responses send input items or use a conversation object and receive45 output items; tool call loops are explicitly managed46 </td>47 </tr>48 <tr>49 <td>`Run steps`</td>50 <td>`Items`</td>51 <td>52 Generalized objects—can be messages, tool calls, outputs, and more53 </td>54 </tr>55 </tbody>56</table>5758## From assistants to prompts5960Assistants were persistent API objects that bundled model choice, instructions, and tool declarations—created and managed entirely through the API. Their replacement, prompts, can only be created in the dashboard, where you can version them as you develop your product.6162### Why this is helpful6364- **Portability and versioning**: You can snapshot, review, diff, and roll back prompt specs. You can also version a prompt, so your code can just point the latest version.65- **Separation of concerns**: Your application code now handles orchestration (history pruning, tool loop, retries) while your prompt focuses on high‑level behavior and constraints (system guidance, tool availability, structured output schema, temperature defaults).66- **Realtime compatibility**: The same prompt configuration can be reused when you connect through the Realtime API, giving you a single definition of behavior across chat, streaming, and low‑latency interactive sessions.67- **Tool and output consistency**: Using prompts, every Responses or Realtime session you start inherits a consistent contract because prompts encapsulate tool schemas and structured output expectations.6869### Practical migration steps70711. Identify each existing Assistant’s _instruction + tool_ bundle.722. In the dashboard, recreate that bundle as a named prompt.733. Store the prompt ID (or its exported spec) in source control so application code can refer to a stable identifier.744. During rollout, run A/B tests by swapping prompt IDs—no need to create or delete assistant objects programmatically.7576Think of a prompt as a **versioned behavioral profile** to plug into either Responses or Realtime API.7778---7980## From threads to conversations8182A thread was a collection of messages stored server-side. Threads could _only_ store messages. Conversations store items, which can include messages, tool calls, tool outputs, and other data.8384### Request example8586#### Python8788#### Go8990### Response example91929394#### Thread object9596```json97{98 "id": "thread_CrXtCzcyEQbkAcXuNmVSKFs1",99 "object": "thread",100 "created_at": 1752855924,101 "metadata": {102 "user_id": "peter_le_fleur"103 },104 "tool_resources": {}105}106```107108#### Conversation object109110```json111{112 "id": "conv_68542dc602388199a30af27d040cefd4087a04b576bfeb24",113 "object": "conversation",114 "created_at": 1752855924,115 "metadata": {116 "user_id": "peter_le_fleur"117 }118}119```120121122123---124125## From runs to responses126127Runs were asynchronous processes that executed against threads. See the example below. Responses are simpler: provide a set of input items to execute, and get a list of output items back.128129Responses are designed to be used alone, but you can also use them with prompt and conversation objects for storing context and configuration.130131### Request example132133#### Python134135#### Go136137### Response example138139140141#### Run object142143```json144{145 "id": "run_FKIpcs5ECSwuCmehBqsqkORj",146 "assistant_id": "asst_8fVY45hU3IM6creFkVi5MBKB",147 "cancelled_at": null,148 "completed_at": 1752857327,149 "created_at": 1752857322,150 "expires_at": null,151 "failed_at": null,152 "incomplete_details": null,153 "instructions": null,154 "last_error": null,155 "max_completion_tokens": null,156 "max_prompt_tokens": null,157 "metadata": {},158 "model": "gpt-4.1",159 "object": "thread.run",160 "parallel_tool_calls": true,161 "required_action": null,162 "response_format": "auto",163 "started_at": 1752857324,164 "status": "completed",165 "thread_id": "thread_CrXtCzcyEQbkAcXuNmVSKFs1",166 "tool_choice": "auto",167 "tools": [],168 "truncation_strategy": {169 "type": "auto",170 "last_messages": null171 },172 "usage": {173 "completion_tokens": 130,174 "prompt_tokens": 34,175 "total_tokens": 164,176 "prompt_token_details": {177 "cached_tokens": 0178 },179 "completion_tokens_details": {180 "reasoning_tokens": 0181 }182 },183 "temperature": 1.0,184 "top_p": 1.0,185 "tool_resources": {},186 "reasoning_effort": null187}188```189190#### Response object191192```json193{194 "id": "resp_687a7b53036c819baad6012d58b39bcb074adcd9e24850fc",195 "created_at": 1752857427,196 "conversation": {197 "id": "conv_689667905b048191b4740501625afd940c7533ace33a2dab"198 },199 "error": null,200 "incomplete_details": null,201 "instructions": null,202 "metadata": {},203 "model": "gpt-5.5",204 "object": "response",205 "output": [206 {207 "id": "msg_687a7b542948819ba79e77e14791ef83074adcd9e24850fc",208 "content": [209 {210 "annotations": [],211 "text": "The \"5 Ds of Dodgeball\" are a humorous set of rules made famous by the 2004 comedy film **\"Dodgeball: A True Underdog Story.\"** In the movie, dodgeball coach Patches O’Houlihan teaches these basics to his team. The **5 Ds** are:\n\n1. **Dodge**\n2. **Duck**\n3. **Dip**\n4. **Dive**\n5. **Dodge** (yes, dodge is listed twice for emphasis!)\n\nIn summary: \n> **“If you can dodge a wrench, you can dodge a ball!”**\n\nThese 5 Ds are not official competitive rules, but have become a fun and memorable pop culture reference for the sport of dodgeball.",212 "type": "output_text",213 "logprobs": []214 }215 ],216 "role": "assistant",217 "status": "completed",218 "type": "message"219 }220 ],221 "parallel_tool_calls": true,222 "temperature": 1.0,223 "tool_choice": "auto",224 "tools": [],225 "top_p": 1.0,226 "background": false,227 "max_output_tokens": null,228 "previous_response_id": null,229 "reasoning": {230 "effort": null,231 "generate_summary": null,232 "summary": null233 },234 "service_tier": "scale",235 "status": "completed",236 "text": {237 "format": {238 "type": "text"239 }240 },241 "truncation": "disabled",242 "usage": {243 "input_tokens": 17,244 "input_tokens_details": {245 "cached_tokens": 0246 },247 "output_tokens": 150,248 "output_tokens_details": {249 "reasoning_tokens": 0250 },251 "total_tokens": 167252 },253 "user": null,254 "max_tool_calls": null,255 "store": true,256 "top_logprobs": 0257}258```259260261262---263264## Migrating your integration265266Follow the migration steps below to move from the Assistants API to the Responses API, without losing any feature support.267268### 1. Create prompts from your assistants2692701. Identify the most important assistant objects in your application.2711. Find these in the dashboard and click `Create prompt`.272273This will create a prompt object out of each existing assistant object.274275Reusable prompt objects are also being deprecated. If you use this migration276 path, review the [prompts deprecation277 timeline](https://developers.openai.com/api/docs/deprecations#2026-06-03-reusable-prompts) before adopting278 prompt objects in a long-lived integration.279280### 2. Move new user chats over to conversations and responses281282Start new chats with the Conversations API and Responses API. To preserve earlier conversation history, use messages already stored by your application.283284The example below shows how thread history could be migrated before the sunset. The Assistants API call that retrieves thread messages no longer works; use your stored messages instead.285286```python287# Replace the illustrative IDs and URLs below with your own resource values.288289from openai import OpenAI290291openai = OpenAI()292messages = []293thread_id = "thread_123"294295for page in openai.beta.threads.messages.list(296 thread_id=thread_id, order="asc"297).iter_pages():298 messages += page.data299300items = []301for m in messages:302 item = {"role": m.role}303 item_content = []304305 for content in m.content:306 match content.type:307 case "text":308 item_content_type = "input_text" if m.role == "user" else "output_text"309 item_content += [310 {"type": item_content_type, "text": content.text.value}311 ]312 case "image_url":313 item_content += [314 {315 "type": "input_image",316 "image_url": content.image_url.url,317 "detail": content.image_url.detail,318 }319 ]320321 item |= {"content": item_content}322 items.append(item)323324# create a conversation with your converted items325conversation = openai.conversations.create(items=items)326```327328```ruby329# Replace the illustrative IDs and URLs below with your own resource values.330require "openai"331332client = OpenAI::Client.new333thread_id = "thread_123"334messages = client.beta.threads.messages.list(thread_id, order: :asc)335items = []336messages.auto_paging_each do |message|337 content = message.content.filter_map do |part|338 case part339 when OpenAI::Models::Beta::Threads::TextContentBlock340 type = if message.role == OpenAI::Models::Beta::Threads::Message::Role::USER341 :input_text342 else343 :output_text344 end345 {346 type: type,347 text: part.text.value348 }349 when OpenAI::Models::Beta::Threads::ImageURLContentBlock350 {351 type: :input_image,352 image_url: part.image_url.url,353 detail: part.image_url.detail354 }355 end356 end357 items << {358 role: message.role,359 content: content360 }361end362conversation = client.conversations.create(363 items: items364)365puts(conversation.id)366```367368369## Comparing full examples370371Here are a few examples of integrations using both the Assistants API and the Responses API so you can see how they compare.372373### User chat app374375376377Assistants API378379```python380# Replace the illustrative IDs and URLs below with your own resource values.381threads_by_session: dict[str, str] = {}382383384@app.post("/messages")385async def message(message: Message):386 thread_id = threads_by_session.get(message.session_id)387 if thread_id is None:388 thread_id = openai.beta.threads.create().id389 threads_by_session[message.session_id] = thread_id390391 openai.beta.threads.messages.create(392 thread_id=thread_id,393 role="user",394 content=message.content,395 )396397 example_assistant_id = "asst_123"398 run = openai.beta.threads.runs.create(399 assistant_id=example_assistant_id,400 thread_id=thread_id,401 )402 while run.status in ("queued", "in_progress"):403 await asyncio.sleep(1)404 run = openai.beta.threads.runs.retrieve(405 thread_id=thread_id,406 run_id=run.id,407 )408409 messages = openai.beta.threads.messages.list(410 order="desc",411 limit=1,412 thread_id=thread_id,413 )414415 return {"content": messages.data[0].content}416```417418```ruby419# Replace the illustrative IDs and URLs below with your own resource values.420require "openai"421422client = OpenAI::Client.new423assistant_id = "asst_123"424threads_by_session = {}425426handle_message = lambda do |session_id:, content:|427 thread_id = threads_by_session[session_id]428 unless thread_id429 thread_id = client.beta.threads.create.id430 threads_by_session[session_id] = thread_id431 end432433 client.beta.threads.messages.create(434 thread_id,435 role: :user,436 content: content437 )438 run = client.beta.threads.runs.create(439 thread_id,440 assistant_id: assistant_id441 )442 while [:queued, :in_progress].include?(run.status)443 sleep(1)444 run = client.beta.threads.runs.retrieve(run.id, thread_id: thread_id)445 end446447 messages = client.beta.threads.messages.list(448 thread_id,449 order: :desc,450 limit: 1451 )452 { content: messages.data&.first&.content }453end454455puts(456 handle_message.call(457 session_id: "example-session",458 content: "What are the five Ds of dodgeball?"459 )460)461```462463464 465466 467468 469Responses API470471```javascript472// Replace the illustrative IDs and URLs below with your own resource values.473import express from "express";474import OpenAI from "openai";475476const app = express();477const client = new OpenAI();478const conversationsBySession = new Map();479480app.use(express.json());481482app.post("/messages", async (request, response) => {483 const { content, session_id: sessionId } = request.body ?? {};484 if (485 typeof content !== "string" ||486 !content.trim() ||487 typeof sessionId !== "string" ||488 !sessionId.trim()489 ) {490 response.status(400).json({491 error: "content and session_id must be non-empty strings.",492 });493 return;494 }495496 let conversationIdPromise = conversationsBySession.get(sessionId);497498 if (!conversationIdPromise) {499 conversationIdPromise = client.conversations500 .create()501 .then((conversation) => conversation.id)502 .catch((error) => {503 conversationsBySession.delete(sessionId);504 throw error;505 });506 conversationsBySession.set(sessionId, conversationIdPromise);507 }508 const conversationId = await conversationIdPromise;509510 const promptId = "pmpt_123";511512 const result = await client.responses.create({513 prompt: { id: promptId },514 input: [{ role: "user", content }],515 conversation: conversationId,516 });517518 response.json({ content: result.output_text });519});520521app.listen(Number(process.env.OPENAI_EXAMPLE_PORT ?? 8000), "127.0.0.1");522```523524```python525# Replace the illustrative IDs and URLs below with your own resource values.526conversations_by_session: dict[str, str] = {}527528529@app.post("/messages")530async def message(message: Message):531 conversation_id = conversations_by_session.get(message.session_id)532 if conversation_id is None:533 conversation_id = openai.conversations.create().id534 conversations_by_session[message.session_id] = conversation_id535536 example_prompt_id = "pmpt_123"537 response = openai.responses.create(538 prompt={"id": example_prompt_id},539 input=[{"role": "user", "content": message.content}],540 conversation=conversation_id,541 )542543 return {"content": response.output_text}544```545546```ruby547# Replace the illustrative IDs and URLs below with your own resource values.548require "openai"549550client = OpenAI::Client.new551conversations_by_session = {}552553handle_message = lambda do |session_id:, content:|554 conversation_id = conversations_by_session[session_id]555 unless conversation_id556 conversation_id = client.conversations.create.id557 conversations_by_session[session_id] = conversation_id558 end559560 response = client.responses.create(561 prompt: { id: "pmpt_123" },562 input: [563 {564 role: :user,565 content: content566 }567 ],568 conversation: conversation_id569 )570 { content: response.output_text }571end572573puts(574 handle_message.call(575 session_id: "example-session",576 content: "What are the five Ds of dodgeball?"577 )578)579```