Get chat messages
GEThttps:/api.openai.com/v1/chat/completions/{completion_id}/messages
Get the messages in a stored chat completion. Only Chat Completions that have been created with the store
parameter set to true
will be returned.
Path parameters
completion_id
string
Required
The ID of the chat completion to retrieve messages from.
Query parameters
after
string
Identifier for the last message from the previous pagination request.limit
integer
Defaults: 20
Number of messages to retrieve.order
string
Defaults: asc
Sort order for messages by timestamp. Use
asc
for ascending order ordesc
for descending order. Defaults toasc
.
Response
A list of messages for the specified chat completion.
Example request
1 curl https://api.openai.com/v1/chat/completions/chat_abc123/messages \2 -H "Authorization: Bearer $OPENAI_API_KEY" \3 -H "Content-Type: application/json"
Example response
1 {2 "object": "list",3 "data": [4 {5 "id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",6 "role": "user",7 "content": "write a haiku about ai",8 "name": null,9 "content_parts": null10 }11 ],12 "first_id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",13 "last_id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",14 "has_more": false15 }
Built with