Skip to main content

创建 Dream

触发一次异步记忆整理任务。

POST /api/v1/cloud/dreams 创建一个 Dream,系统将异步整理指定的 Memory Store。返回 Dream 对象。

请求头

头部必选说明
Authorization是Bearer <PAT 或 SAT>
Content-Type是application/json

请求体

字段类型必选说明
inputsarray是输入列表。必须包含一个 memory_store 类型输入,可选包含 sessions 类型输入
modelstring | object | null否模型 ID 或 Dream model 对象,可同时指定思考深度和上下文窗口。省略或传 null/空字符串时使用 auto
instructionsstring否自定义整理指令,UTF-8 编码后最多 4096 字节(多字节字符会占用多个字节)

inputs 元素

字段类型说明
typestring"memory_store" 或 "sessions"
memory_store_idstring当 type 为 memory_store 时必填
session_idsarray当 type 为 sessions 时必填,最多 100 个 Session ID

model 对象

旧字符串请求仍受支持,例如 "model": "auto"。也可传对象:
{"model":{"id":"dfmodel","effort":"high","context_window":400000}}
字段类型必选说明
idstring是非空模型 ID。使用 列出模型 返回的可用且启用的 ID;不限定为固定档位
effortstring否思考深度:none、low、medium、high、xhigh、max。除 none 外,必须在所选模型的 efforts 中;none 表示显式关闭思考
context_windowinteger否上下文窗口 token 数,必须为正整数。模型有非空 available_context_windows 时必须选其中一个值;目录未声明档位时不做档位限制
  • 两个选项可独立省略;省略表示不指定覆盖值,响应不会补成用户显式选择。显式传 null、空 effort、零或负窗口等非法值返回 400。
  • 整个 model 省略、为 null、空字符串或纯空白字符串时按 auto 处理;对象必须包含非空 id,{} 不等价于 auto。
  • auto 不带选项时保留自动路由;带 effort 或 context_window 时,模型目录必须存在可用且支持相应选项的 auto 条目,否则返回 400。
  • 对象只支持 id、effort、context_window;speed 及其他未知字段返回 400。错误响应的 error.param 指向对应字段。
  • 上例仅演示格式;使用前查询当前身份可用的模型及参数,不假定 dfmodel、high 或 400000 始终可用。

示例请求

curl -s -X POST 'https://api.qoder.com.cn/api/v1/cloud/dreams' \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      { "type": "memory_store", "memory_store_id": "memstore_019e5cdb9c3f71c3b6505eba937a40b4" },
      { "type": "sessions", "session_ids": ["sess_019e7a1b2c3d4e5f6a7b8c9d0e1f2a3b"] }
    ],
    "model": { "id": "dfmodel", "effort": "high", "context_window": 400000 },
    "instructions": "重点关注用户对代码风格的偏好修正"
  }'

示例响应

HTTP 201 Created
{
  "id": "drm_019e86b4a8f070a3b6c5d4e3f2a1b0c9",
  "type": "dream",
  "status": "pending",
  "inputs": [
    { "type": "memory_store", "memory_store_id": "memstore_019e5cdb9c3f71c3b6505eba937a40b4" },
    { "type": "sessions", "session_ids": ["sess_019e7a1b2c3d4e5f6a7b8c9d0e1f2a3b"] }
  ],
  "outputs": [],
  "model": { "id": "dfmodel", "effort": "high", "context_window": 400000 },
  "instructions": "重点关注用户对代码风格的偏好修正",
  "session_id": null,
  "usage": { "input_tokens": 0, "output_tokens": 0, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0 },
  "error": null,
  "created_at": "2026-06-15T10:00:00Z",
  "ended_at": null,
  "archived_at": null
}

错误码

HTTPType触发条件
400invalid_request_errorinputs 为空或无效、缺少或重复 memory_store 输入、引用的源 Store 不存在或不可访问、sessions 总数超过 100、模型不可用或未启用、模型选项类型/组合无效或含未知字段、instructions 超过 4096 UTF-8 字节
401authentication_error缺少或无效的认证令牌
409conflict_error当前身份在该工作空间已有活跃 Dream(pending 或 running)
完整错误信封说明详见 错误参考。