Python
Path Parameters
string
required
The conversation ID.
conv_xxx
List message items in a conversation.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1",
)
items = client.conversations.items.list("conv_xxx")
print(items.data){
"data": [
{
"content": [
{
"text": "Alice, a gentle and resilient woman, was born in Singapore. She is 20 years old, and her hobbies are music and chess.",
"type": "input_text"
}
],
"id": "msg_7639f8f6-484b-454a-8125-96a3f40eb9e8",
"role": "user",
"status": "completed",
"type": "message"
},
{
"content": [
{
"text": "Alice's best friend is Bob",
"type": "input_text"
}
],
"id": "msg_288594f6-6ef1-4519-94d4-a545ca311828",
"role": "user",
"status": "completed",
"type": "message"
}
],
"first_id": "msg_7639f8f6-484b-454a-8125-96a3f40eb9e8",
"has_more": false,
"last_id": "msg_288594f6-6ef1-4519-94d4-a545ca311828",
"object": "list"
}The conversation ID.
Message items.
Show child attributes
The message item ID.
Message content. A plain text string or a structured content list (such as ResponseInputText object array).
Message role: user, assistant, system, or developer.
Processing status: in_progress, completed, or incomplete.
Always message.
ID of the first message item.
Whether more data is available.
ID of the last message item.
Always list.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://dashscope-intl.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1",
)
items = client.conversations.items.list("conv_xxx")
print(items.data){
"data": [
{
"content": [
{
"text": "Alice, a gentle and resilient woman, was born in Singapore. She is 20 years old, and her hobbies are music and chess.",
"type": "input_text"
}
],
"id": "msg_7639f8f6-484b-454a-8125-96a3f40eb9e8",
"role": "user",
"status": "completed",
"type": "message"
},
{
"content": [
{
"text": "Alice's best friend is Bob",
"type": "input_text"
}
],
"id": "msg_288594f6-6ef1-4519-94d4-a545ca311828",
"role": "user",
"status": "completed",
"type": "message"
}
],
"first_id": "msg_7639f8f6-484b-454a-8125-96a3f40eb9e8",
"has_more": false,
"last_id": "msg_288594f6-6ef1-4519-94d4-a545ca311828",
"object": "list"
}