Conversations
Create and manage conversations to store and retrieve conversation state across Response API calls.
Create a conversation
Create a conversation.
Request body
Initial items to include in the conversation context. You may add up to 20 items at a time.
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
Returns
Returns a Conversation object.
1
2
3
4
5
6
7
8
9
10
11
12
13
curl https://api.openai.com/v1/conversations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"metadata": {"topic": "demo"},
"items": [
{
"type": "message",
"role": "user",
"content": "Hello!"
}
]
}'1
2
3
4
5
6
{
"id": "conv_123",
"object": "conversation",
"created_at": 1741900000,
"metadata": {"topic": "demo"}
}Retrieve a conversation
Get a conversation
Returns
Returns a Conversation object.
1
2
curl https://api.openai.com/v1/conversations/conv_123 \
-H "Authorization: Bearer $OPENAI_API_KEY"1
2
3
4
5
6
{
"id": "conv_123",
"object": "conversation",
"created_at": 1741900000,
"metadata": {"topic": "demo"}
}Update a conversation
Update a conversation
Request body
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
Returns
Returns the updated Conversation object.
1
2
3
4
5
6
curl https://api.openai.com/v1/conversations/conv_123 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"metadata": {"topic": "project-x"}
}'1
2
3
4
5
6
{
"id": "conv_123",
"object": "conversation",
"created_at": 1741900000,
"metadata": {"topic": "project-x"}
}Delete a conversation
Delete a conversation. Items in the conversation will not be deleted.
Returns
A success message.
1
2
curl -X DELETE https://api.openai.com/v1/conversations/conv_123 \
-H "Authorization: Bearer $OPENAI_API_KEY"1
2
3
4
5
{
"id": "conv_123",
"object": "conversation.deleted",
"deleted": true
}List items
List all items for a conversation with the given ID.
Query parameters
Specify additional output data to include in the model response. Currently supported values are:
web_search_call.action.sources: Include the sources of the web search tool call.code_interpreter_call.outputs: Includes the outputs of python code execution in code interpreter tool call items.computer_call_output.output.image_url: Include image urls from the computer call output.file_search_call.results: Include the search results of the file search tool call.message.input_image.image_url: Include image urls from the input message.message.output_text.logprobs: Include logprobs with assistant messages.reasoning.encrypted_content: Includes an encrypted version of reasoning tokens in reasoning item outputs. This enables reasoning items to be used in multi-turn conversations when using the Responses API statelessly (like when thestoreparameter is set tofalse, or when an organization is enrolled in the zero data retention program).
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
Returns
Returns a list object containing Conversation items.
1
2
curl "https://api.openai.com/v1/conversations/conv_123/items?limit=10" \
-H "Authorization: Bearer $OPENAI_API_KEY"1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"object": "list",
"data": [
{
"type": "message",
"id": "msg_abc",
"status": "completed",
"role": "user",
"content": [
{"type": "input_text", "text": "Hello!"}
]
}
],
"first_id": "msg_abc",
"last_id": "msg_abc",
"has_more": false
}Create items
Create items in a conversation with the given ID.
Query parameters
Additional fields to include in the response. See the include
parameter for listing Conversation items above for more information.
Request body
Returns
Returns the list of added items.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
curl https://api.openai.com/v1/conversations/conv_123/items \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"items": [
{
"type": "message",
"role": "user",
"content": [
{"type": "input_text", "text": "Hello!"}
]
},
{
"type": "message",
"role": "user",
"content": [
{"type": "input_text", "text": "How are you?"}
]
}
]
}'1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
"object": "list",
"data": [
{
"type": "message",
"id": "msg_abc",
"status": "completed",
"role": "user",
"content": [
{"type": "input_text", "text": "Hello!"}
]
},
{
"type": "message",
"id": "msg_def",
"status": "completed",
"role": "user",
"content": [
{"type": "input_text", "text": "How are you?"}
]
}
],
"first_id": "msg_abc",
"last_id": "msg_def",
"has_more": false
}Retrieve an item
Get a single item from a conversation with the given IDs.
Path parameters
Query parameters
Additional fields to include in the response. See the include
parameter for listing Conversation items above for more information.
Returns
Returns a Conversation Item.
1
2
curl https://api.openai.com/v1/conversations/conv_123/items/msg_abc \
-H "Authorization: Bearer $OPENAI_API_KEY"1
2
3
4
5
6
7
8
9
{
"type": "message",
"id": "msg_abc",
"status": "completed",
"role": "user",
"content": [
{"type": "input_text", "text": "Hello!"}
]
}Delete an item
Delete an item from a conversation with the given IDs.
Path parameters
Returns
Returns the updated Conversation object.
1
2
curl -X DELETE https://api.openai.com/v1/conversations/conv_123/items/msg_abc \
-H "Authorization: Bearer $OPENAI_API_KEY"1
2
3
4
5
6
{
"id": "conv_123",
"object": "conversation",
"created_at": 1741900000,
"metadata": {"topic": "demo"}
}The conversation object
The time at which the conversation was created, measured in seconds since the Unix epoch.
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.