Get chat messages
client.chat.completions.messages.list(stringcompletionID, MessageListParams { after, limit, order } query?, RequestOptionsoptions?): CursorPage<ChatCompletionStoreMessage { id, content_parts } >
GET/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.
Get chat messages
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});
// Automatically fetches more pages as needed.
for await (const chatCompletionStoreMessage of client.chat.completions.messages.list(
'completion_id',
)) {
console.log(chatCompletionStoreMessage);
}{
"object": "list",
"data": [
{
"id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",
"role": "user",
"content": "write a haiku about ai",
"name": null,
"content_parts": null
}
],
"first_id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",
"last_id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",
"has_more": false
}
Returns Examples
{
"object": "list",
"data": [
{
"id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",
"role": "user",
"content": "write a haiku about ai",
"name": null,
"content_parts": null
}
],
"first_id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",
"last_id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",
"has_more": false
}