Crete Conversations and Create Create Responses
The Conversations API is a part of the OpenAI platform that helps you keep and manage long running chat state on the server. You can think of a conversation object as a stored chat thread. It remembers messages, files, tool calls, and other items across many requests so that you do not need to resend the full history every time you call the model. The goal is to give you a durable place where the complete context of a user session lives, while your app only sends the new turn and some options each time.
The Responses API is the main entry point when you want the model to actually think and generate output. A Responses request says which model you want, what inputs to give it, which tools it may call, and how you want the result to look. For example, you can ask for plain text, JSON, or tool calls. Under the hood, this API replaces the older Chat Completions style and adds stronger support for tools and multi step reasoning. For most new projects, you call Responses whenever you want the model to answer a question, write some content, run tools, or perform a reasoning task.
The relationship between these two pieces is simple. The Responses API does the thinking for a single request. The Conversations API keeps track of everything that has been said or done across many Responses calls. When you pass a conversation id into a Responses request, the server loads the stored items for that conversation, prepends them to your new inputs, lets the model generate a result, and then automatically appends the new input and output items back into the same conversation. This gives you a clean mental model. Responses is the brain that answers the current question. Conversations is the memory that stores the full story of the chat.
To see how this works in practice, imagine a simple web chat app that uses both APIs together. When a new user opens the app, your backend first creates a conversation. Each time the user sends a message, your server calls the Responses API with that message and the id of the conversation. The platform automatically includes all previous messages from this conversation so the model has context, and when the model replies, the new user message and the new assistant reply are both stored as items in the same conversation. You can later retrieve the conversation to show full history in your UI, or delete it when the session ends. This pattern gives you clean server side state without having to rebuild your own database schema for every token of the chat.
The following JavaScript example shows this pattern in code. It creates a conversation, sends the first user message through the Responses API, and then prints the latest assistant reply that is stored in the conversation. In a real app you would wrap this in your request handler and reuse the same conversation id for each turn from the same user.
You use the Responses API whenever you want the model to answer something, and you attach a conversation id when you want that answer to live inside a persistent chat history. The Conversations API then gives you endpoints to create, read, update, and delete that history as a first class object in the platform, which keeps your application logic much cleaner as your project grows.
So that one id becomes the handle for the full chat history on the server.
What you can do later with the same conversation id
First, you can keep using it for more responses.create calls. Every time you send a new request with the same conversation id, the API will load all existing items in that conversation as context, then append the new user input and the new model output back into the same conversation. Conversations store items such as messages, tool calls and tool outputs, so the thread grows over time.
Second, you can fetch the stored state via the Conversations API. In particular:
-
GET /conversations/{conversation_id}returns the conversation object and metadata such as creation time and any custom metadata. -
GET /conversations/{conversation_id}/itemsreturns a list of all items in that conversation. Items include user messages, assistant messages, tool call items and tool call output items, and they use the same schema as the output of a Response.
This is what you would use to rebuild the full chat history in your own UI.
About “multiple responses” and getting them back
If you call responses.create many times and always pass the same conversation id:
-
Each call creates a new Response object with its own
response.id -
At the same time, the outputs of that Response are written into the conversation as items
Later, if you want to see “all the responses” for that conversation, you usually do not query Responses by conversation id. Instead, you call GET /conversations/{conversation_id}/items and iterate through the items. The items give you everything the model has produced in that conversation, regardless of which Response object created them.
If you specifically need the Response objects themselves you have two options:
-
Store each
response.idin your own database when you create it, then callresponses.retrieve(responseId)later -
Or keep using only conversation items, which is the simpler pattern for a chat style app
There is also a previous_response_id field on the Responses API, but you do not use it together with conversation. You either use conversation for a durable server side thread, or you chain responses one by one with previous_response_id.
Small TypeScript example that reads all messages in a conversation
So in short: yes, if you always send the same conversation id, you can later use that id to fetch all the history for that chat. You do it by listing the conversation items, which represent all the responses and other events that happened in that conversation.
No comments:
Post a Comment