跳转到内容
EN

创建会话条目

先调用「创建对话」拿到 conv_ 开头的 ID,替换 conv_123。

POST/model/v1/conversations/{conversation_id}/items● 支持

官方文档 ↗

请求参数

  • conversation_idstring必填

    path: Id of the conversation, the id of the object returned by createConversation (it looks like conv_...). Another tenant's conversation, an unknown id and a deleted conversation all answer 404 conversation_not_found.

  • itemsarray必填

    Items to append, between 1 and 20 per request. Router support (supported): Verified to take effect.

    已验证生效。

返回

200 list

向一个会话追加 items(一次最多 20 条),返回刚追加的这些 items。

鉴权、限流、参数校验等平台错误按 problem+json 返回;OCR 的错误也为 problem+json,其它模型调用的错误按该端点所属格式(OpenAI 或 Anthropic)返回,参见 错误码

请求示例

curl
# 先调用「创建对话」拿到 conv_ 开头的 ID,替换 conv_123。
curl https://api.deepraxis.com/model/v1/conversations/conv_123/items \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"items":[{"role":"user","content":"你好"}]}'
Python
# 先调用「创建对话」拿到 conv_ 开头的 ID,替换 conv_123。
from openai import OpenAI

client = OpenAI(
    base_url="https://api.deepraxis.com/model/v1",
    api_key="$PRAXIS_API_KEY",
)

items = client.conversations.items.create(
    "conv_123",
    items=[{"role": "user", "content": "你好"}],
)
TypeScript
// 先调用「创建对话」拿到 conv_ 开头的 ID,替换 conv_123。
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.deepraxis.com/model/v1",
  apiKey: "$PRAXIS_API_KEY",
});

const items = await client.conversations.items.create("conv_123", {
  items: [{ role: "user", content: "你好" }],
});

响应示例 200

{
  "object": "list",
  "data": [
    {
      "type": "message",
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "你好"
        }
      ],
      "id": "item_c4f0566ddc4f4208b79a7c9c",
      "status": "completed"
    }
  ],
  "first_id": "item_c4f0566ddc4f4208b79a7c9c",
  "last_id": "item_c4f0566ddc4f4208b79a7c9c",
  "has_more": false
}

响应

HTTP 200

The items just added

application/json

名称 类型 说明
object string Object type; always list.
data array<object> Items of the conversation, in the order the list requested.
first_id string Id of the first item of this page; null for an empty page.
last_id string Id of the last item of this page; null for an empty page.
has_more boolean Whether more items exist beyond this page; pass last_id as after to read them.