跳转到主要内容
会话

查询消息列表

GET
/conversations/{conversation_id}/items
Python
import os
from openai import OpenAI

client = OpenAI(
  api_key=os.getenv("DASHSCOPE_API_KEY"),
  base_url="https://dashscope.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 Beijing. 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"
}

鉴权

string
header
必填

千问云 API Key。详见获取 API Key

路径参数

string
必填

会话 ID。

conv_xxx

查询参数

string

分页游标。返回指定消息 ID 之后创建的消息。

enum<string>
默认值"desc"

排序方式:asc(升序)或 desc(降序)。默认值:desc

asc,desc
integer
默认值20

返回的消息数量(1-100)。默认值:20。

1 <= x <= 100

响应

200-application/json
object[]

消息列表。

string

首条消息的 ID。

boolean

是否还有更多数据。

string

末条消息的 ID。

enum<string>

固定值 list

list