API 概览

2026-10-14

概览

Praxis 是智能体云平台。API 按服务组织:智能体、模型、沙箱、搜索、自动化,各在自己的前缀下。请求与响应用 JSON,流式响应用 SSE,使用标准的 HTTP 动词与状态码。所有前缀共用一个地址和一个 Key。

基础地址

https://api.deepraxis.ai

客户端库

使用服务 API 页列出的客户端库。兼容接口使用对应协议的官方 SDK;自动化提供 TypeScript SDK,本地安装方式见自动化 API。

服务前缀API 页
智能体/agentAgent API
模型/modelModel API
沙箱/sandboxSandbox API
搜索/searchSearch API
自动化/automationAutomation API

兼容接口

已经在用 OpenAI、Anthropic、Google、E2B 或 Tavily 的代码,不需要改成 Praxis 的接口:平台提供与这些厂商官方 API 一致的兼容前缀,只改地址就能用。

厂商前缀API 页
OpenAI/openaiOpenAI 兼容
Anthropic/anthropicAnthropic 兼容
Google/googleGoogle 兼容
E2B/e2bE2B 兼容
Tavily/tavilyTavily 兼容

一个 Key

所有前缀共用在控制台创建的 API Key,随请求放在 Authorization 头里。详见鉴权。

全局约定

  • 错误用标准 HTTP 状态码表达类别,错误体按前缀的格式给出原因。详见错误。
  • 超出额度返回 429,响应头告诉你何时可以重试。详见限流。
  • 版本号写在地址里,弃用提前 90 天以标准头通知。详见版本。
  • 关于 API 本身的信息(OpenAPI 描述、健康状态)在 /meta 前缀下。

第一个请求

curl https://api.deepraxis.ai/model/v1/chat/completions \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek-flash", "messages": [{"role": "user", "content": "你好"}]}'

鉴权

所有接口用同一种凭证:在控制台创建的 API Key,随请求放在 Authorization 头里。没有别的鉴权方式,也没有按接口不同的规则。

一个头

Authorization: Bearer {key}
段含义例子
Bearer固定字样Bearer
{key}你的 API Key,以 sk-praxis- 开头sk-praxis-a1b2…

一个 Key 通所有前缀下的接口。Key 在控制台 → API Key 创建、轮换和吊销;吊销立即生效。

各家 SDK 把 Key 放在哪

你不需要自己拼这个头——官方 SDK 会放;我们同时接受各家 SDK 默认使用的头名。

SDK你传什么实际发出的头
OpenAI SDKapiKeyAuthorization: Bearer …
Anthropic SDKapiKeyX-API-Key: …
Google GenAI SDKapiKeyx-goog-api-key: …
E2B SDKapiKeyX-API-Key: …
Tavily SDK / HTTPapiKeyAuthorization: Bearer …

试一条

curl https://api.deepraxis.ai/model/v1/models \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

鉴权失败长什么样

Key 缺失、无效或已吊销,返回 401,错误体按该前缀的格式(见错误)。收到 401 不要重试——换对 Key 再发。

保管

  • 只在服务端使用;不要放进浏览器、移动端或公开仓库。
  • 用环境变量(示例里的 PRAXIS_API_KEY),不要写进代码。
  • 怀疑泄露时在控制台吊销并新建,旧 Key 立即失效。

错误

出错时,HTTP 状态码告诉你错误属于哪一类;错误体按该前缀的格式给出具体原因;每个错误响应还带四个 x-praxis-problem-* 头和一个 x-praxis-recovery-action(限流错误再多带一个 x-praxis-problem-scope,见限流),不论错误体长什么样,重试逻辑只看头就够。

状态码

状态码含义你该做什么
400请求字段或格式不合法修正参数,不要原样重试
401缺少或无效的凭证检查 API Key
402余额或付费额度不足补充余额或联系账户管理员
403无权访问该资源或操作核对 Key 权限与资源归属;必要时联系支持
404资源、模型或路径不存在检查 ID、模型名和路径
408请求超时检查网络后重试;写操作先确认是否已完成
409资源状态或并发修改冲突重新读取状态,再调整请求
413请求体或文件超过大小限制减小内容或改用端点支持的 URL 输入
422请求内容无法处理根据错误详情修正参数或输入
429请求速率、并发或模型额度超限按 retry-after 等待;并发超限时等待在途请求结束
500平台内部错误稍后重试;持续出现请附 X-Request-Id 联系支持
501功能尚未支持换用已支持的端点,不要重试
502上游调用失败或返回无效响应退避重试,持续失败时换模型或联系支持
503服务或可用线路暂不可用退避重试,或选择其它模型
504上游响应超时退避重试;写操作先确认结果,避免重复创建

错误码

以下是常见的机器可读错误码,不是所有端点的封闭枚举。兼容接口的错误体可能使用协议自己的 code/type;跨协议判断可读取 x-praxis-problem-code,其值可能与错误体 code 不同。大小写按返回值区分。

code什么时候出现、该怎么办
AUTHENTICATION_ERRORKey 缺失或无效;检查并更换凭证。
VALIDATION_ERROR参数不符合格式、类型或范围要求;按详情改参数。
INPUT_NOT_REPRESENTABLE所选模型或协议无法表达输入选项;删除该选项或换模型。
NOT_FOUND资源不存在或对当前账户不可见;核对 ID 与账户。
MODEL_NOT_FOUND模型不存在或不可见;从模型列表选取可用名称。
MODEL_PROTOCOL_NOT_OFFERED模型不提供所请求的协议;换用其支持的端点或模型。
MODEL_PROTOCOL_LINE_UNAVAILABLE支持该协议的合格线路暂不可用;退避重试或换模型。
GENERATION_NOT_FOUND生成记录不存在或不属于当前账户;核对响应头中的生成 ID 与 Key。
RATE_LIMITED超过速率或并发限额;按 retry-after 等待并降低速率或并发。
UPSTREAM_ERROR上游调用失败或响应不合法;按 retryable 退避重试,持续失败时换模型或联系支持。
PROVIDER_SELECTION_NOT_ALLOWED指定供应商 order/only 时没有携带 BYOK;移除供应商选择或提供自己的上游 Key。
not_implemented该端点或能力未实现;换用已支持的能力,不要原样重试。
model_protocol_not_offeredHTTP 404;模型未声明所请求的协议。查询 GET /model/v1/models 的 supported_apis,改用相应入口,例如声明 Google 协议的模型使用 /google/v1beta/models/{model}:generateContent;不要只换前缀而保留另一协议的请求体。
provider_unavailableHTTP 502;本次请求的可用线路全部失败。退避重试,持续失败时换模型,并附 X-Request-Id 联系支持。
thinking_disable_unsupportedHTTP 400;模型不能关闭思考,例如对 glm-5.3 设置 reasoning_effort="none"。移除关闭设置或选择支持的思考等级;需要关闭思考时换模型。
insufficient_quota / INSUFFICIENT_BALANCEHTTP 402;余额不足,错误体或响应头的代码因入口而异。充值或联系账户管理员后再重试,不要立即循环重试。
validation_error(response_format)HTTP 400;例如 Model "deepseek-flash" does not support json_schema on this API.。换用在该入口支持 json_schema 的模型;若只需要合法 JSON,可改用 json_object,但它不保证 schema 约束。
validation_error(参数被点名)HTTP 400;设置 provider.require_parameters=true 时,所选模型仍可能无法支持请求参数,例如 param: "logprobs"、does not support the requested logprobs value。按 param 和消息调整参数或换模型;不要只关闭检查后假定参数已生效。

错误体

错误体的格式跟着地址第一段走,和成功响应一致——你的 SDK 不需要为错误特殊处理。

厂商前缀(/openai /anthropic /google /e2b /tavily):和该前缀对应的官方 API 错误体一模一样。

// /openai
{ "error": { "code": 401, "message": "Invalid API key." } }
// /anthropic
{ "type": "error", "error": { "type": "authentication_error", "message": "Invalid API key." } }

Praxis 前缀(/agent /model /sandbox /search /meta):标准的 Problem Details(RFC 9457),Content-Type: application/problem+json。

{
  "type": "https://deepraxis.ai/problems/authentication_error",
  "title": "authentication_error",
  "status": 401,
  "detail": "Invalid API key.",
  "instance": "problem_eqfnxu",
  "code": "AUTHENTICATION_ERROR",
  "retryable": false
}
字段含义
type错误类型的 URL,稳定,可用来分支
title / detail给人读的摘要与具体原因
status同 HTTP 状态码
instance本次错误的 ID,联系支持时附上
code机器可读的错误码
retryable原样重试是否可能成功

错误响应头(五个通用头 + 一个限流头)

五个通用头与错误体格式无关;第六个 scope 头仅适用于限流错误:

头含义例子
x-praxis-problem-code跨协议分类码;可能与错误体的 code 不同AUTHENTICATION_ERROR
x-praxis-problem-kind错误大类——出了什么事authentication_failure
x-praxis-problem-origin错误归谁——谁能解决它:user(你的请求或凭证)、platform(我们)、upstream_provider(上游厂商)等unknown
x-praxis-problem-retryable原样重试是否可能成功false
x-praxis-problem-scope仅限流错误:触发的保护层——platform 平台层、model 模型层platform
x-praxis-recovery-action建议的处理动作relogin

重试

  • retryable 为 true(或状态码 429 502 503):指数退避重试;429 优先按 retry-after。
  • 其它一律不要原样重试——先改请求或 Key。

限流

Praxis 的限流分两层:平台层按你的 Key 限每秒请求数和同时进行的请求数;模型层按模型限每分钟请求数(RPM)和每分钟 token 数(TPM)。每个响应——不论成功还是 429——都带三个 x-ratelimit-* 头,写明当前额度和重置时间,你不需要猜,也不需要为读额度多发请求。

两层限额

层按什么计限什么超出的表现
平台层你的 Key(没带凭证时按来源 IP)每秒请求数、同时进行的请求数429 + retry-after,等待后重试
模型层模型 × 租户每分钟请求数(RPM)、每分钟 token 数(TPM)、月度预算429,见下文模型层

两层的 429 都带同样的三个限流头;是哪一层触发的,看错误体的说明(错误)。

平台层:每秒请求数与并发数

默认每个 API Key 每秒最多 5 个请求,同时最多 4 个在途请求。流式请求在流结束前占用并发槽位。超过任一默认限额返回 429,响应带 ratelimit-limit、ratelimit-remaining、ratelimit-reset 和 retry-after;并发超限须等已有请求结束。

实际限额可能因账户而异;以响应头和并发错误详情为准。

三个响应头

x-ratelimit-limit-requests: 5
x-ratelimit-remaining-requests: 4
x-ratelimit-reset-requests: 850ms
头含义
x-ratelimit-limit-requests该凭证每秒的请求上限
x-ratelimit-remaining-requests本秒还剩多少个请求
x-ratelimit-reset-requests距离额度重置的时间:不满一秒写作 850ms,一秒及以上写作 1s

同样的三个数也以 IETF 标准名 RateLimit-Limit / RateLimit-Remaining / RateLimit-Reset(整数秒)同时给出。以上 5 次/秒、4 个并发为默认限额;配置覆盖后的请求速率以响应头显示为准。

超出每秒上限

一秒内的第 N+1 个请求(N 为该 Key 的每秒上限)返回 429,并带 retry-after(整数秒,通常是 1)。被拒绝的请求不消耗额度:x-ratelimit-remaining-requests 保持 0,等窗口重置即可恢复。

超出并发上限

同时进行的请求(包括尚未结束的流式响应——流结束前一直占坑)超过该 Key 的并发上限时,多出的请求返回 429,retry-after 为 1。这种情况下仅等待秒级窗口重置不会释放并发槽位:须等一个进行中的请求结束。是并发还是每秒触发的,错误说明里写得很清楚("Concurrent request limit …" / "Requests per second limit …")。

错误体

错误体跟着地址第一段走(见错误)。/model/v1/chat/completions 等原生端点是 Problem Details:

{
  "type": "https://deepraxis.ai/problems/rate_limit",
  "title": "rate_limited",
  "status": 429,
  "detail": "Requests per second limit of 5 exceeded for this credential. Retry after the listed wait.",
  "instance": "problem_eqfnxu",
  "kind": "rate_limit",
  "scope": "platform",
  "retryable": true
}

scope: "platform" 表示是平台层触发的(模型层限额的错误不带此字段或为 model)。/openai/v1/chat/completions 等厂商前缀按该家的错误格式,例如 OpenAI 兼容端点:

{ "error": { "code": 429, "type": "rate_limit_error", "message": "Requests per second limit of 5 exceeded for this credential. Retry after the listed wait." } }

没带凭证的请求

公开端点(如 GET /model/v1/models)允许不带 Key 调用,这时按来源 IP 计入一个较小的匿名额度,响应头同样给出。带了 Key 就按 Key 计,与 IP 无关。

GET /meta/v1/health 不限流,探活监控可以任意频率调用。

模型层:每分钟请求数与 token 数

限额维度是模型 × 租户 × 分钟,不是 API Key:

  • 每个模型在模型元数据里配置自己的 RPM(每分钟请求数)与 TPM(每分钟 token 数);未配置或为 0 表示不限制。
  • 命中任一限额返回 429,type 为 rate_limit_error,Retry-After: 60,problem.details.rateLimit 给出当前值与限额。
  • BYOK 调用自带供应商凭证,不占平台模型限额。
  • 上游供应商限流由平台自动 failover 到其他供应商;全部供应商不可用时按返回的 429 处理。

模型另有月度预算:按模型当月累计收入计,超出返回 429,type 为 budget_error(QUOTA_EXHAUSTED),无 Retry-After——等待无效,需要提升该模型的预算。

错误体与状态码见错误;账号额度见配额与限流。

版本

版本号写在地址里,紧跟第一段;每个前缀各自计版本,没有全站统一的版本号。

地址里的版本段

https://api.deepraxis.ai/{protocol}/{version}/…
前缀版本段由谁决定
/openai /anthropicv1跟随厂商
/googlev1beta跟随厂商
/e2b /tavily无版本段跟随厂商
/agent /model /sandbox /search /metav1Praxis

厂商前缀下,版本相关的头(如 Anthropic 的 anthropic-version)原样透传给厂商,行为与官方一致。

什么算破坏性变更

删字段、改字段类型或含义、改默认值、收紧校验、改错误码含义。加字段、加端点、放宽校验不算。

Beta 与正式

  • Beta:端点页标有「Beta」。可能随时改动,不做兼容承诺;适合试用,不建议放进生产。
  • 正式:破坏性变更只会以新版本段发布(如 /model/v2/…),旧版本继续可用。

弃用怎么通知

旧版本或端点弃用时:

  1. 更新日志公告,并给出替代方案;
  2. 该端点的响应带两个标准头:Deprecation(RFC 9745,何时弃用)与 Sunset(RFC 8594,何时下线),Link 头指向迁移说明;
  3. 从公告到下线至少 90 天;下线后返回 404。
Deprecation: @1767225600
Sunset: Sat, 04 Apr 2026 00:00:00 GMT
Link: </docs/changelog>; rel="deprecation"

OpenAI 兼容接口

基础地址

加载中…

接入

加载中…

端点

方法路径说明支持
POST/v1/chat/completions对话● 支持
POST/v1/responses生成响应● 支持
GET/v1/responses/{response_id}读取响应● 支持
DELETE/v1/responses/{response_id}删除响应● 支持
POST/v1/responses/{response_id}/cancel取消响应◐ 部分支持
GET/v1/responses/{response_id}/input_items列出响应输入项● 支持
POST/v1/responses/compact压缩响应○ 未支持
POST/v1/responses/input_tokens统计输入 token○ 未支持
POST/v1/conversations创建会话● 支持
GET/v1/conversations/{conversation_id}读取会话● 支持
POST/v1/conversations/{conversation_id}更新会话● 支持
DELETE/v1/conversations/{conversation_id}删除会话● 支持
POST/v1/conversations/{conversation_id}/items创建会话条目● 支持
GET/v1/conversations/{conversation_id}/items列出会话条目● 支持
GET/v1/conversations/{conversation_id}/items/{item_id}读取会话条目● 支持
DELETE/v1/conversations/{conversation_id}/items/{item_id}删除会话条目● 支持
POST/v1/images/generations生成图像● 支持
GET/v1/models列出模型● 支持
GET/v1/models/{model}读取模型● 支持
POST/v1/embeddings文本向量● 支持
POST/v1/videos创建视频● 支持
GET/v1/videos列出视频● 支持
GET/v1/videos/{video_id}读取视频● 支持
GET/v1/videos/{video_id}/content下载视频内容● 支持
DELETE/v1/videos/{video_id}删除视频● 支持
POST/v1/videos/{video_id}/remix混剪视频○ 未支持
POST/v1/audio/transcriptions转写音频● 支持
POST/v1/files上传文件◐ 部分支持
GET/v1/files列出文件● 支持
GET/v1/files/{file_id}检索文件● 支持
DELETE/v1/files/{file_id}删除文件● 支持
GET/v1/files/{file_id}/content检索文件内容● 支持
POST/v1/audio/speech生成语音● 支持
POST/v1/images/edits编辑图片● 支持

知识库(16 个操作):创建知识库、添加文件、批量入库与搜索。

不支持的端点

以下端点在 /openai/v1 下未提供,调用返回 404。替代流程不等同于原端点。

端点替代
/v1/moderations无替代端点
/v1/batches逐次调用所需模型端点
/v1/fine_tuning使用模型目录中已有的模型
/v1/assistants使用 Responses 与 Conversations 构建会话
/v1/completions改用 chat/completions
/v1/audio/translations先用 audio/transcriptions 转写,再用 chat/completions 翻译
/v1/uploads改用 files 上传文件
/v1/images/variations使用 images/edits 提交图片与编辑提示词

与官方的差异

  • 对话:未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。
  • 生成响应:未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。
  • 读取响应:按 ID 读取一条已保存的响应。如果创建时 store 为 false,我们不会保存这次响应,读取会返回 404 response_not_found;超过保留期(默认 30 天)后读取也会返回同样的 404。
  • 删除响应:按 ID 立即删除一条已保存的响应。如果创建时 store 为 false,我们不会保存这次响应,删除会返回 404 response_not_found。
  • 取消响应:仅对以 background:true 创建、且路由到具备后台生成能力的模型的响应可用:取消是 幂等的,重复调用返回同一个终态响应;我方的取消只能停止我方对上游流的继续读取, 不能保证已发往上游的算力停止计算,用量按实际收到的部分结算。对一个非后台 (同步)响应调用 cancel:如果这个响应 id 不存在(未持久化、已过期或 id 有误), 返回 404 object_not_found;如果响应存在但其来源 provider 没有声明支持 cancel 操作(我们目前没有接入任何为同步响应声明该能力的上游),返回 400 native_responses_operation_unsupported。这两种情况都不是尚未实现的 501 gate。
  • 列出响应输入项:列出一条已保存响应的输入项。支持 limit(1–100,默认 20)、order(asc/desc, 默认 desc,与官方一致)与基于条目 id 的 after 游标分页;has_more/first_id/ last_id 均与实际返回页一致,可据此翻页且不重不漏。每个条目都带服务端签发的 id(message 为 msg_ 前缀,function_call/function_call_output/reasoning 各自 对应前缀),本次上线前已保存、尚无服务端 id 的旧数据在读取时按确定性规则补 id,不做破坏性迁移,同一游标反复读取保持稳定。以 previous_response_id 续接 创建的响应,其输入项列出解析后的完整输入:前序响应链已有的输入与输出条目 再加本轮自己提交的输入;若该祖先响应在我方平台未保存(例如创建时 store 为 false)或已过期删除,则只列出本轮自己提交的输入。如果创建时 store 为 false,我们不会保存这次响应,列出会返回 404 response_not_found。
  • 压缩响应:把响应的输入压缩成摘要,依赖 OpenAI Responses 官方的服务端存储(store)语义,我们目前还没有实现;调用会返回 501(message 为 “This platform has not implemented … yet.”,响应头 x-should-retry 为 false),不产生副作用,官方 SDK 不会重试。
  • 统计输入 token:只统计请求输入会消耗的 token 数、不生成内容,依赖 OpenAI Responses 官方的服务端存储(store)语义,我们目前还没有实现;调用会返回 501(message 为 “This platform has not implemented … yet.”,响应头 x-should-retry 为 false),不产生副作用,官方 SDK 不会重试。
  • 创建会话:创建一个会话,可选携带初始 items(一次最多 20 条)与 metadata。会话按租户分区,创建者是唯一能引用它的租户。
  • 读取会话:按 ID 读取一个会话。不存在或属于其他租户都返回 404 conversation_not_found。
  • 更新会话:更新一个会话的 metadata——整体替换,不与已有 metadata 合并。
  • 删除会话:删除一个会话。删除后该会话与其 items 都不能再被引用(包括作为 Responses create 的 conversation 参数)。
  • 创建会话条目:向一个会话追加 items(一次最多 20 条),返回刚追加的这些 items。
  • 列出会话条目:按创建顺序列出会话的 items,支持 limit/after/order 分页参数。
  • 读取会话条目:按 ID 读取会话里的单条 item。
  • 删除会话条目:删除会话里的单条 item,返回该会话对象(不是被删除的 item)。
  • 读取模型:返回与列表中同一条目相同的模型对象。只有声明了 OpenAI 协议的模型可见;模型 ID 可以带斜杠分隔的发布方前缀。不存在或没有声明 OpenAI 协议的模型返回 404。
  • 文本向量:转发方式与对话(chat completions)一致,用量算在同一份计费里。 未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。
  • 创建视频:异步生成视频:创建任务后轮询状态,完成后下载内容。按输出秒数计费,每秒价格见 GET /model/v1/models 的 pricing.video_second(USD/秒)。请显式选择已注册的视频模型,例如 wan2.7-t2v。
  • 列出视频:列出本账号的视频任务。limit 为 1 到 100,order 为 asc 或 desc,after 必须引用存在的任务。
  • 读取视频:读取任务的当前状态和进度。status 为 queued 或 in_progress 时继续轮询,failed 时查看 error,completed 后才能下载内容。任务不存在返回 404。
  • 下载视频内容:任务 completed 后下载视频文件(video,MP4)或缩略图(thumbnail);spritesheet 返回 400,index 只支持 0。任务不存在返回 404。
  • 删除视频:删除任务及其生成的内容。任务不存在返回 404。
  • 混剪视频:未支持,调用固定返回 400(invalid_request_error,消息为 Video remix is not supported);不要重试。
  • 转写音频:标准请求字段;不能表达的参数返回 input_not_representable。
  • 上传文件:单文件最多 100 MB(104857600 字节);按内容识别 PDF、Office、图片、音频、视频与 UTF-8 文本。purpose 支持 user_data / assistants / vision;其他用途、空文件、不支持类型和超限均返回 400。不支持 Uploads 分片。只接受表单 file、purpose、expires_after[anchor]、expires_after[seconds];其他表单字段或任何查询参数返回 400 invalid_request_error,消息为 "Unrecognized request argument supplied: <字段>",param 为该字段。
  • 列出文件:只接受查询参数 after、order、limit、purpose;其他查询参数返回 400 invalid_request_error,消息为 "Unrecognized request argument supplied: <参数>",param 为该参数。

参数与字段的权威定义以 OpenAI 官方文档为准。

错误按 OpenAI 格式返回,参见错误;额度与响应头参见限流。

对话

POST /openai/v1/chat/completions● 支持

OpenAI 官方文档 ↗

请求参数

  • X-OpenRouter-Metadatastring可选○ 当前不生效

    header: Opt-in to surface routing metadata on the response under `openrouter_metadata`. Defaults to `disabled`. The legacy header `X-OpenRouter-Experimental-Metadata` is also accepted for backward compatibility.

    接受但当前不生效;不会返回请求的路由元数据。

    取值 disabledenabled
  • messagesarray必填◐ 部分支持

    List of messages for the conversation

    文本、角色、历史和工具往返生效;图片受模型尺寸限制;file_id 可引用 user_data 图片、文本和 PDF;模型读取能力与失败处理见[文件引用指南](/docs/cloud/services/model/guides/files)。

    ▸ 展开子字段(12)

    元素按 role 区分(assistant / developer / system / tool / user),此处展开其中一种的形状

    • configuration_updateobject可选

      OpenRouter extension. Same as the system message `configuration_update`: changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns.

    • contentstring | array可选

      Tool response content

    • namestring可选

      Optional name for the assistant

    • rolestring可选

      Role of the message author; always tool.

      取值 tool
    • audioobject可选

      Audio output data or reference

    • imagesarray可选

      Generated images from image generation models

    • modelstring可选

      Model that generated this assistant message

    • reasoningstring可选

      Reasoning output

    • reasoning_detailsarray可选

      Reasoning details for extended thinking models

    • refusalstring可选

      Refusal message if content was refused

    • tool_callsarray可选

      Tool calls made by the assistant

    • tool_call_idstring可选

      ID of the assistant message tool call this message responds to

  • modelstring可选

    Model to use for completion

    主模型;提供非空 models 时可省略,使用列表首项。

  • streamboolean可选◐ 部分支持
    默认 false

    Enable streaming response

    流式正文和工具增量生效;gemini-2.5-flash 可能缺少结束标记,预算耗尽时 finish_reason 可能不准确。

  • temperaturenumber可选◐ 部分支持

    Sampling temperature (0-2)

    在 /openai 的 deepseek-v4-flash 观察到效果;其余模型的采样差异无法确认。

  • max_tokensinteger可选◐ 部分支持

    Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16.

    deepseek-v4-flash、glm-5.3-flash 生效;qwen3.8-flash 的小预算可能不生效。与 max_completion_tokens 同传时本字段优先。

  • top_pnumber可选◐ 部分支持

    Nucleus sampling parameter (0-1)

    仅 /model 的 glm-5.3-flash 观察到效果;其余已测模型或协议面接受但未见效果。

  • stopstring | array可选◐ 部分支持

    Stop sequences (up to 4)

    qwen3.8-flash 生效;deepseek-v4-flash、glm-5.3-flash 可能截断思考并返回空正文。

  • toolsarray可选

    Available tools for function calling

    已验证生效。

  • tool_choicestring | object可选◐ 部分支持

    Tool choice configuration

    auto 生效;deepseek-v4-flash 忽略 none/required/具名函数;qwen3.8-flash 的 required/具名函数在思考模式报错;glm-5.3-flash 的具名函数结果不稳定。

    ▸ 展开子字段(2)
    • functionobject必填

      The function the model must call.

    • typestring必填

      OpenRouter server-tool type to force (e.g. `openrouter:web_search`, `web_search`, `web_search_preview`).

  • ▸ 更多参数(48)
    • response_formatobject可选◐ 部分支持

      Response format configuration

      json_object 生效;json_schema 在 deepseek-v4-flash、qwen3.8-flash 生效,glm-5.3-flash 接受但未遵守。

      ▸ 展开子字段(3)

      按 type 区分(grammar / json_object / json_schema / python / text),此处展开其中一种的形状

      • typestring必填

        Always `python`. Discriminator that marks this object as a ChatFormatPythonConfig in a `type`-tagged union.

        取值 python
      • json_schemaobject必填

        JSON Schema configuration object

      • grammarstring必填

        Custom grammar for text generation

    • cache_controlobject可选

      Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format.

      ▸ 展开子字段(2)
      • ttlstring可选

        Lifetime of an Anthropic-style cache breakpoint.

        取值 5m1h
      • typestring必填

        Always `ephemeral`. Discriminator that marks this object as a AnthropicCacheControlDirective in a `type`-tagged union.

        取值 ephemeral
    • debugobject可选

      Debug options for inspecting request transformations (streaming only)

      ▸ 展开子字段(1)
      • echo_upstream_bodyboolean可选○ 当前不生效

        If true, includes the transformed upstream request body in a debug chunk at the start of the stream. Only works with streaming mode.

        接受但当前不生效。流式请求不会回显上游请求体。

    • frequency_penaltynumber可选◐ 部分支持

      Frequency penalty (-2.0 to 2.0)

      deepseek-v4-flash、glm-5.3-flash 部分请求生效;qwen3.8-flash 在部分取值或协议面返回 400。

    • image_configobject可选

      Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details.

    • logit_biasobject可选

      Token logit bias adjustments

    • logprobsboolean可选◐ 部分支持

      Return log probabilities

      qwen3.8-flash 生效;deepseek-v4-flash 仅 /openai 生效,glm-5.3-flash 的两面结果不一致;gemini-2.5-flash 返回 400。

    • max_completion_tokensinteger可选◐ 部分支持

      Maximum tokens in completion

      deepseek-v4-flash、glm-5.3-flash 生效;qwen3.8-flash 的小预算可能不生效或报超限。

    • metadataobject可选

      Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)

    • min_pnumber可选○ 当前不生效

      Minimum probability threshold relative to the most likely token. Tokens with probability below min_p * (probability of top token) are filtered out. Not all providers support this parameter.

      接受但当前不生效。

    • modalitiesarray可选

      Output modalities for the response. Supported values are "text", "image", and "audio".

    • modelsarray可选

      Models to use for completion

      按顺序回退:主模型不存在、无同协议线路或上游失败均尝试下一项。可只给 models;响应 model 和费用归属最终完成请求的模型。

    • parallel_tool_callsboolean可选◐ 部分支持

      Whether to enable parallel function calling during tool use. When true, the model may generate multiple tool calls in a single response.

      false 在 qwen3.8-flash 生效;deepseek-v4-flash 接受但不生效;glm-5.3-flash 的两面结果不一致。

    • pluginsarray可选◐ 部分支持

      Plugins you want to enable for this request, including their settings.

      支持 file-parser(pdf.engine 为 native、mistral-ocr→ocr、ocr、auto)和平台 guardrails。请求覆盖账户默认,锁定设置保留。web 等未实现插件、未知引擎或非法形状返回 400 并点名字段。

      ▸ 展开子字段(27)

      元素按 id 区分(auto-beta-router / auto-router / context-compression / file-parser / fusion / moderation / pareto-router / response-healing / web / web-fetch),此处展开其中一种的形状

      • allowed_modelsarray可选

        List of model patterns to filter which models the auto-beta-router can route between. Supports wildcards (e.g., "anthropic/*" matches all Anthropic models). Up to 1024 patterns, each at most 1024 characters, with 65536 total characters across all patterns. When not specified, every model ranked for the classified task type is a candidate, falling back to a default model set when rankings are unavailable.

      • cost_quality_tradeoffinteger可选

        Deprecated: Use cost_tier instead. Balances routing between cost and quality on a 0-10 scale. The auto-beta-router ranks models for the classified task type by community spend share, then filters candidates by their average cost per generation for that task. Higher values favor cheaper models: 10 keeps only models around the cheapest 10th percentile, while 0 permits models up to the 90th percentile for cost. Defaults to 9 when no cost setting is provided. It remains supported and retains ceiling behavior, but cost_tier takes precedence when both are provided.

      • cost_tierstring可选

        Named cost/quality setting. For auto-beta-router, tiers select cost-percentile bands: low = [0, 20), medium = [20, 40), high = [40, 60), xhigh = [60, 80), and max = [80, 100]. Takes precedence over the deprecated numeric cost_quality_tradeoff when both are provided.

        取值 lowmediumhighxhighmax
      • enabledboolean可选

        Set to false to disable Fusion configuration for a run started by the `openrouter/fusion` model slug or `openrouter:fusion` server tool. Defaults to true.

      • excluded_modelsarray可选

        List of model patterns to exclude from auto-beta-router selection. Supports wildcards (e.g., "meta-llama/*" excludes all Llama models). Up to 1024 patterns, each at most 1024 characters, with 65536 total characters across all patterns. Applied after allowed_models, so an excluded pattern always wins over an allowed one.

      • idstring可选

        Plugin id; always fusion.

        取值 fusion
      • pin_modelboolean可选

        When true, reuses the model from the most recent assistant message's `model` attribute for subsequent turns. Defaults to false.

      • enginestring可选

        The compression engine to use. Defaults to "middle-out".

        取值 middle-out
      • exclude_domainsarray可选

        A list of domains to exclude from web search results. Supports wildcards (e.g. "*.substack.com") and path filtering (e.g. "openai.com/blog").

      • include_domainsarray可选

        A list of domains to restrict web search results to. Supports wildcards (e.g. "*.substack.com") and path filtering (e.g. "openai.com/blog").

      • max_resultsinteger可选

        Maximum number of search results to use.

      • max_usesinteger可选

        Maximum number of web fetches per request. Once exceeded, the tool returns an error.

      • modestring可选

        Engine-native search mode. Exa supports instant, fast, auto (default), deep-lite, deep, and deep-reasoning. Parallel supports turbo, fast, basic (default), and advanced. Modes unsupported by the selected engine are ignored.

        取值 instantfastautodeep-litedeepdeep-reasoningturbobasicadvanced
      • search_promptstring可选

        Prompt that introduces the search results to the model.

      • user_locationobject可选

        Approximate user location for location-biased search results.

      • allowed_domainsarray可选

        Only fetch from these domains.

      • blocked_domainsarray可选

        Never fetch from these domains.

      • max_content_tokensinteger可选

        Maximum content length in approximate tokens. Content exceeding this limit is truncated.

      • pdfobject可选

        Options for PDF parsing.

      • max_pricenumber可选

        Maximum input price in USD per million tokens. When set, quality-tier selection (min_coding_score) is bypassed: the router computes the Pareto frontier over the top coding models and routes to the best-scoring frontier model priced at or below this cap, falling back through cheaper frontier models, then non-frontier models. Enforced against the price source given by price_source. Returns 404 when no candidate satisfies the cap.

      • min_coding_scorenumber可选

        Minimum coding quality score between 0 and 1. Maps to internal quality tiers: >= 0.66 → high (top coding models), >= 0.33 → medium (strong modern flagships), < 0.33 → low (capable coders above the median). Omit to default to the highest tier (equivalent to >= 0.66). Not used when max_price is set (price-based selection takes over).

      • price_sourcestring可选

        Price source for the Pareto frontier cost axis and for enforcing max_price. "prompt" uses catalog list price (endpoint.pricing.prompt). "weighted_avg" uses traffic-weighted effective input price from ClickHouse, falling back to prompt price for models without traffic data. Defaults to "prompt".

        取值 promptweighted_avg
      • analysis_modelsarray可选

        For a Fusion run started by the `openrouter/fusion` model slug or `openrouter:fusion` server tool, slugs of models to run in parallel as the "expert panel" the analyst analyzes. Each model receives the same user prompt with web_search + web_fetch enabled. Capped at 8 models to bound cost amplification. When omitted, defaults to the Quality preset from the /labs/fusion UI (~anthropic/claude-opus-latest, ~openai/gpt-sol-latest, ~google/gemini-pro-latest).

      • max_tool_callsinteger可选

        For a Fusion run started by the `openrouter/fusion` model slug or `openrouter:fusion` server tool, the maximum number of tool-calling steps each panelist (analysis model) and the analyst model may take during their agentic web-research loop. Models with web_search/web_fetch enabled iterate until they produce a text response or hit this ceiling. Defaults to 4. Capped at 16.

      • modelstring可选

        For a Fusion run started by the `openrouter/fusion` model slug or `openrouter:fusion` server tool, the slug of the model that performs both the analyst step (with web_search + web_fetch) and the final synthesis. When omitted, defaults to the first model in the Quality preset.

      • presetstring可选

        Configuration for a Fusion run started by the `openrouter/fusion` model slug or `openrouter:fusion` server tool. A curated OpenRouter preset (slugs follow `<task>-<tier>`, e.g. `general-high`). Expands server-side into the preset's analysis_models panel and analyst model, so callers never name individual models. Explicitly provided `analysis_models` / `model` take precedence.

        取值 general-highgeneral-budgetgeneral-fast
      • toolsarray可选

        For a Fusion run started by the `openrouter/fusion` model slug or `openrouter:fusion` server tool, server tools available to panelist and analyst inner calls. Each entry uses the same `{ type, parameters? }` shorthand as the outer Chat Completions request. When omitted, defaults to `[{ type: "openrouter:web_search" }, { type: "openrouter:web_fetch" }]`. Pass an empty array to disable tools entirely (panelists answer from parametric knowledge only).

    • predictionobject可选

      Static predicted output content. Supported models can use this to reduce latency when much of the response is known in advance.

      ▸ 展开子字段(2)
      • contentstring | array必填

        Predicted output: a string or an array of text parts.

      • typestring必填

        Always `content`. Discriminator that marks this object as a Prediction in a `type`-tagged union.

        取值 content
    • presence_penaltynumber可选◐ 部分支持

      Presence penalty (-2.0 to 2.0)

      deepseek-v4-flash 的 /openai 面观察到效果;qwen3.8-flash 部分请求返回 400,其余不可观测。

    • prompt_cache_keystring可选
    • prompt_cache_optionsobject可选

      Request-level prompt-cache controls. `mode: "explicit"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. Only supported by OpenAI GPT-5.6 and newer.

      ▸ 展开子字段(2)
      • modestring必填

        Prompt cache mode; explicit caches only the blocks marked with prompt_cache_breakpoint.

        取值 explicit
      • ttlstring可选

        Lifetime of cache entries, for example 30m; null leaves the provider default.

    • providerobject可选◐ 部分支持

      When multiple model providers are available, optionally indicate your routing preference.

      只有选择具体供应商(order / only / ignore)仅限 BYOK、返回 400;require_parameters 生效,其余选项接受但不生效。

      ▸ 展开子字段(13)
      • allow_fallbacksboolean可选○ 当前不生效

        Whether to allow backup providers to serve requests - true: (default) when the primary provider (or your custom providers in "order") is unavailable, use the next best provider. - false: use only the primary/custom provider, and return the upstream error if it's unavailable.

        接受但当前不生效(不属于供应商选择,平台凭证下可用)。

      • data_collectionstring可选○ 当前不生效

        Data collection setting. If no available model provider meets the requirement, your request will return an error. - allow: (default) allow providers which store user data non-transiently and may train on it - deny: use only providers which do not collect user data.

        接受但当前不生效(不属于供应商选择,平台凭证下可用)。

        取值 denyallownull
      • enforce_distillable_textboolean可选

        Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used.

      • ignorearray可选○ 未支持

        List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request.

        选择具体供应商(order / only / ignore)仅限 BYOK,平台凭证下返回 400 PROVIDER_SELECTION_NOT_ALLOWED。

      • max_priceobject可选○ 当前不生效

        The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.

        接受但当前不生效(不属于供应商选择,平台凭证下可用)。

      • onlyarray可选○ 未支持

        List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request.

        选择具体供应商(order / only / ignore)仅限 BYOK,平台凭证下返回 400 PROVIDER_SELECTION_NOT_ALLOWED。

      • orderarray可选○ 未支持

        An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message.

        选择具体供应商(order / only / ignore)仅限 BYOK,平台凭证下返回 400 PROVIDER_SELECTION_NOT_ALLOWED。

      • preferred_max_latencynumber | object可选

        Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold.

      • preferred_min_throughputnumber | object可选

        Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold.

      • quantizationsarray可选○ 当前不生效

        A list of quantization levels to filter the provider by.

        接受但当前不生效(不属于供应商选择,平台凭证下可用)。

      • require_parametersboolean可选

        Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest.

        只走能表达全部参数的线路;平台凭证下可用。

      • sortstring | object可选○ 当前不生效

        The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed.

        接受但当前不生效(不属于供应商选择,平台凭证下可用)。

      • zdrboolean可选○ 当前不生效

        Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used.

        接受但当前不生效(不属于供应商选择,平台凭证下可用)。

    • reasoningobject可选

      Configuration options for reasoning models

      ▸ 展开子字段(2)
      • effortstring可选◐ 部分支持

        Constrains effort on reasoning for reasoning models

        none 仅在 qwen3.8-flash 可靠关闭思考;deepseek-v4-flash 和 glm-5.3-flash 未遵守。

        取值 maxxhighhighmediumlowminimalnonenull
      • summarystring可选○ 当前不生效

        How detailed the reasoning summary should be.

        接受但当前不生效。deepseek-v4-flash 未返回请求的摘要。

        取值 autoconcisedetailednull
    • reasoning_effortstring可选◐ 部分支持

      Shorthand for setting reasoning effort. Equivalent to setting reasoning.effort. Cannot be used simultaneously with reasoning.effort if they differ.

      none 在 qwen3.8-flash 关闭思考;deepseek-v4-flash 仍思考,glm-5.3-flash 的档位效果不符合预期。

      取值 maxxhighhighmediumlowminimalnonenull
    • repetition_penaltynumber可选

      Penalizes tokens based on how much they have already appeared in the text. A value of 1.0 means no penalty. Values above 1.0 penalize repeated tokens more strongly. Not all providers support this parameter.

    • routestring可选

      **DEPRECATED** Use providers.sort.partition instead. Backwards-compatible alias for providers.sort.partition. Accepts legacy values: "fallback" (maps to "model"), "sort" (maps to "none").

      取值 fallbacksortnull
    • seedinteger可选○ 当前不生效

      Random seed for deterministic outputs

      接受但当前不生效。deepseek-v4-flash、glm-5.3-flash、qwen3.8-flash 同 seed 不能复现输出。

    • service_tierstring可选

      The service tier to use for processing this request. `fast` is accepted as an alias for `priority`.

      取值 autodefaultfastflexpriorityscalenull
    • session_idstring可选

      A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.

    • stop_server_tools_whenarray可选

      Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`. When a condition fires while the model is still emitting tool calls, the pending tool calls are executed and one final turn is made with tool calls disabled so the response ends with a natural-language answer instead of an unfinished tool call.

      ▸ 展开子字段(6)

      元素按 type 区分(finish_reason_is / has_tool_call / max_cost / max_tokens_used / step_count_is),此处展开其中一种的形状

      • step_countinteger可选

        Number of steps after which the loop stops.

      • typestring可选

        Always `finish_reason_is`. Discriminator that marks this object as a StopServerToolsWhenFinishReasonIs in a `type`-tagged union.

        取值 finish_reason_is
      • tool_namestring可选

        Name of the tool whose call stops the loop.

      • max_tokensinteger可选

        Cumulative token count after which the loop stops.

      • max_cost_in_dollarsnumber可选

        Cumulative cost in USD after which the loop stops.

      • reasonstring可选

        Finish reason that stops the loop.

    • stream_optionsobject可选

      Streaming configuration options

      ▸ 展开子字段(1)
      • include_usageboolean可选○ 当前不生效

        Deprecated: This field has no effect. Full usage details are always included.

        接受但当前不生效。无论 true、false 或省略,流末尾都会返回 usage。

    • top_anumber可选○ 当前不生效

      Consider only tokens with "sufficiently high" probabilities based on the probability of the most likely token. Not all providers support this parameter.

      接受但当前不生效。

    • top_kinteger可选◐ 部分支持

      Limits the model to choose from the top K most likely tokens at each step. A value of 1 means the model will always pick the most likely next token. Not all providers support this parameter.

      已测模型接受但未见采样效果;/model 的 deepseek-v4-flash 返回错误。

    • top_logprobsinteger可选◐ 部分支持

      Number of top log probabilities to return (0-20)

      需与 logprobs=true 同传;支持度随 logprobs 和所选模型而异。

    • traceobject可选

      Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.

      ▸ 展开子字段(5)
      • generation_namestring可选

        Name of this generation in the trace.

      • parent_span_idstring可选

        Id of the parent span in the trace.

      • span_namestring可选

        Name of this request's span in the trace.

      • trace_idstring可选

        Id that groups several requests into one trace.

      • trace_namestring可选

        Name of the trace.

    • userstring可选

      Per-end-user identifier for abuse isolation. Use a stable ID, hash, or pseudonym. When a provider requires a user identity, OpenRouter folds it into the hashed identity sent upstream and never forwards it raw. If omitted, requests use an account-level identity, so provider policy blocks can affect the whole account.

    • storeboolean可选○ 当前不生效

      接受但当前不生效。此结论仅适用于 Chat Completions。

    • max_output_tokensinteger可选○ 当前不生效

      接受但当前不生效。此结论仅适用于 Chat Completions。

    • thinkingobject可选○ 当前不生效

      接受但当前不生效。此结论仅适用于 Chat Completions。

    • web_search_optionsobject可选○ 当前不生效

      接受但当前不生效。此结论仅适用于 Chat Completions。

    • functionsarray可选○ 当前不生效

      接受但当前不生效。此结论仅适用于 Chat Completions。

    • audioobject可选○ 当前不生效

      接受但当前不生效。此结论仅适用于 Chat Completions。

    • ninteger可选◐ 部分支持

      glm-5.3-flash 生效;deepseek-v4-flash 接受但当前不生效;qwen3.8-flash 返回错误。

    • usageobject可选○ 当前不生效

      接受并忽略;用量默认始终返回,include 不改变行为。

    • transformsarray可选○ 当前不生效

      接受并忽略;不执行 middle-out 或其他消息变换,保留原消息。

    • deferred_toolsobject可选○ 当前不生效

      接受并忽略;尚未实现 OpenRouter 延迟工具协议。

    • promptstring可选○ 当前不生效

      接受并忽略;Chat 仍须提供 messages,本字段不替代消息。

    • structured_outputsboolean可选○ 当前不生效

      接受并忽略此开关;结构化输出使用 response_format,支持度见该字段。

    • include_reasoningboolean可选○ 当前不生效

      接受并忽略此旧别名;思考配置使用 reasoning,支持度见该字段。

    • safe_promptboolean可选○ 当前不生效

      接受并忽略;未实现 Mistral 的 safe_prompt 开关。

    • raw_modeboolean可选○ 当前不生效

      接受并忽略;未实现 Hyperbolic 的 raw_mode 开关。

返回

200 chat.completion

stream=true 时以 SSE 增量返回(text/event-stream)。

未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Successful chat completion response

application/json

名称类型说明
choicesarray<object>List of completion choices
choices[].finish_reasonstring | null
choices[].indexintegerChoice index
choices[].logprobsobject | nullLog probabilities for the completion
choices[].messageobjectAssistant message for requests and responses
createdintegerUnix timestamp of creation
idstringUnique completion identifier
modelstringModel used for completion
objectstring
openrouter_metadataobjectRouting report: what was requested, how the router chose, and what was attempted.
openrouter_metadata.attemptintegerNumber of the attempt that served the request, starting at 1.
openrouter_metadata.attemptsarray<object>Every attempt that was made, in order.
openrouter_metadata.endpointsobjectWhich endpoints were available and which one was chosen.
openrouter_metadata.generation_timeintegerMilliseconds measured for the generation, from dispatching the upstream request until its response body ended. Divide the completion token count by this for throughput. Absent when no upstream request was dispatched.
openrouter_metadata.is_byokbooleanWhether the request used a key supplied by the caller.
openrouter_metadata.paramsobjectRouter parameters that applied to the request.
openrouter_metadata.pipelinearray<object>Stages the request went through before and after the model call.
openrouter_metadata.regionstring | nullRegion that served the request; null when unknown.
openrouter_metadata.requestedstringThe model or alias the request asked for.
openrouter_metadata.strategystringHow the router picked the model or provider for this request.
openrouter_metadata.summarystringOne-line summary of the routing decision.
service_tierstring | nullThe service tier used by the upstream provider for this request
system_fingerprintstring | nullSystem fingerprint
usageobjectToken usage statistics
usage.completion_tokensintegerNumber of tokens in the completion
usage.completion_tokens_detailsobject | nullDetailed completion token usage
usage.costnumber | nullCost of the completion
usage.cost_detailsobject | nullBreakdown of upstream inference costs
usage.is_byokbooleanWhether a request was made using a Bring Your Own Key configuration
usage.prompt_tokensintegerNumber of tokens in the prompt
usage.prompt_tokens_detailsobject | nullDetailed prompt token usage
usage.server_tool_use_detailsobject | nullUsage for server-side tool execution (e.g., web search)
usage.total_tokensintegerTotal number of tokens

text/event-stream — chunk / 事件对象

名称类型说明
dataobjectStreaming chat completion chunk
data.choicesarray<object>List of streaming chunk choices
data.createdintegerUnix timestamp of creation
data.errorobjectError information
data.idstringUnique chunk identifier
data.modelstringModel used for completion
data.objectstring
data.openrouter_metadataobjectRouting report: what was requested, how the router chose, and what was attempted.
data.service_tierstring | nullThe service tier used by the upstream provider for this request
data.system_fingerprintstringSystem fingerprint
data.usageobjectToken usage statistics

生成响应

POST /openai/v1/responses● 支持

OpenAI 官方文档 ↗

请求体

  • modelstring必填◐ 部分支持

    已验证支持 glm-5.3-flash、deepseek-flash;没有 Responses 协议的模型返回 404。

  • streamboolean可选◐ 部分支持
    默认 false

    deepseek-flash 生效;glm-5.3-flash 返回 400。

  • temperaturenumber可选◐ 部分支持

    glm-5.3-flash 部分生效,2 可能返回空文本或乱码;deepseek-flash 的效果不可观测。

  • top_pnumber可选◐ 部分支持

    glm-5.3-flash 观察到采样变化;deepseek-flash 不可观测。

  • toolsarray可选◐ 部分支持

    function 生效;web_search、code_interpreter、image_generation、mcp、computer_use 接受但当前不生效;file_search 返回 404。

  • tool_choicestring | object可选◐ 部分支持

    How the model picks tools: a mode string or a specific tool.

    auto 生效;deepseek-flash 的 required/具名函数需 reasoning.effort=none;allowed_tools 在 glm-5.3-flash 被忽略,在 deepseek-flash 返回 422。

    ▸ 展开子字段(4)
    • namestring必填

      Name of the function or tool the model must call.

    • typestring必填

      Kind of tool the model must call.

      取值 shell
    • modestring必填

      auto lets the model pick among the allowed tools or none; required forces a call to one of them.

    • toolsarray必填

      The allowed tools, each as a tool reference such as {type: function, name}.

  • backgroundboolean可选◐ 部分支持

    是否让模型在后台生成响应。仅当路由到的模型具备 Router 自建后台能力时可用——Router 会立即返回 status queued,随后自行以流式方式调用上游、跑到终态并恰好一次结算用量, 客户端通过 GET /v1/responses/{id} 轮询(这不代表上游原生支持 OpenAI 的 background 参数)。不具备该能力的 provider 设置为 true 仍返回 400(错误码 native_responses_background_unsupported)。取消(POST /v1/responses/{id}/cancel) 只能停止我方对上游流的继续读取,不能保证已发往上游的算力停止计算;用量按实际收到的 部分结算,未收到用量时按平台通用的"上游未报用量"规则处理。

    deepseek-flash 生效;glm-5.3-flash 返回 400。background 与 stream 同传时返回 JSON。

  • includearray可选◐ 部分支持

    原样转发给上游模型;只对该模型具备的能力生效(例如推理内容、联网搜索来源),模型不具备的项会被忽略。

    deepseek-flash 返回 logprobs;reasoning.encrypted_content 仅为占位串。glm-5.3-flash 接受但当前不生效。

  • inputstring | array可选◐ 部分支持

    Input for a response request - can be a string or array of items

    字符串、消息数组、input_text、input_image 和函数往返生效;input_file 在 glm-5.3-flash 报错、deepseek-flash 忽略;托管文件引用返回 400。

  • instructionsstring可选

    已验证生效。

  • ▸ 更多参数(21)
    • max_output_tokensinteger可选

      正数控制输出预算;0 返回 400。

    • metadataobject可选◐ 部分支持

      Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed.

      glm-5.3-flash 回显;deepseek-flash 接受但当前不生效,响应及读取均为空对象。

    • parallel_tool_callsboolean可选◐ 部分支持

      true 可返回多个调用;false 接受但当前不生效,仍可能返回多个调用。

    • previous_response_idany可选

      要续接的上一条响应 ID。仅所有者可续接,续接时可以省略 model 字段;平台会展开保存的历史后再请求上游。

      平台将祖先的输入与输出和本轮 input 合并,发往上游前移除 previous_response_id;没有活副本或不属于当前租户时返回 404 previous_response_not_found。

    • promptobject可选○ 未支持

      引用一个已保存的提示词模板及其变量。我方目前没有 Prompts(提示词模板)资源,传入任何 id 都会返回 404 object_not_found。

      当前没有可引用的提示词模板;传入模板 id 返回 404。

      ▸ 展开子字段(2)
      • idstring必填

        Id of the stored prompt template.

      • variablesobject可选

        Values for the template variables, keyed by variable name; a value is a string or an input text, image or file part.

    • prompt_cache_keystring可选
    • prompt_cache_optionsobject可选

      Request-level prompt-cache controls. `mode: "explicit"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. Only supported by OpenAI GPT-5.6 and newer.

      ▸ 展开子字段(2)
      • modestring必填

        Prompt cache mode; explicit caches only the blocks marked with prompt_cache_breakpoint.

        取值 explicit
      • ttlstring可选

        Lifetime of cache entries, for example 30m; null leaves the provider default.

    • reasoningobject可选

      Configuration for reasoning mode in the response

      ▸ 展开子字段(6)
      • contextstring可选

        Controls which reasoning is available to the model. `auto` uses the model default (same as omitting); `all_turns` includes reasoning from earlier turns passed in input; `current_turn` limits to the current turn only. Only supported by OpenAI GPT-5.6 and newer.

        取值 autoall_turnscurrent_turnnull
      • effortstring可选◐ 部分支持

        How much reasoning the model should spend.

        deepseek-flash 的 none 可关闭思考,其余档位不保证单调;glm-5.3-flash 接受但当前不生效,none 仍思考。

        取值 maxxhighhighmediumlowminimalnonenull
      • modestring可选

        Selects the reasoning mode. `standard` is the default; `pro` engages deeper reasoning on models that support it, billed at standard token rates. Only supported by OpenAI GPT-5.6 and newer.

        取值 standardpronull
      • summarystring可选◐ 部分支持

        How detailed the reasoning summary should be.

        glm-5.3-flash 的 concise 偶发有摘要,auto/detailed 未见;deepseek-flash 接受但当前不生效。

        取值 autoconcisedetailednull
      • enabledboolean可选
      • max_tokensinteger可选
    • safety_identifierstring可选

      建议为终端用户设置的稳定标识符,用于滥用隔离。使用稳定的 ID、哈希值或化名。若上游 provider 需要用户身份,我们会把它折算进转发的哈希身份、不会原样转发;省略时请求使用账号级身份,滥用处置可能影响整个账号。

    • service_tierstring可选
      默认 "auto"

      请求使用的服务档位;当前效果不可观测。

      取值 autodefaultfastflexpriorityscalenull
    • storeboolean可选
      默认 true

      是否在服务端保存这条响应,以便之后通过 previous_response_id 读取或续接。默认 true;传 false 可关闭保存。

      true 保存响应供读取;false 不保存,读取返回 404。

    • textobject可选

      Text output configuration including format and verbosity

      ▸ 展开子字段(2)
      • formatobject可选◐ 部分支持

        Text response format configuration

        json_object、json_schema 生效(预算需足够);text 在 glm-5.3-flash 偶发 400,在 deepseek-flash 生效。

      • verbositystring可选○ 当前不生效

        接受但当前不生效。glm-5.3-flash、deepseek-flash 均未观察到长度变化。

        取值 lowmediumhighxhighmaxnull
    • top_logprobsinteger可选◐ 部分支持

      deepseek-flash 生效,允许 0–20;glm-5.3-flash 返回空 logprobs。

    • truncationstring可选

      How to handle input that exceeds the context window.

      取值 autodisablednull
    • userstring可选

      A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 256 characters.

    • conversationstring可选

      该响应所属的对话(会话 id 字符串,或 `{id}` 对象)。发往上游前,我们会把这个对话里已有的条目拼接到本次 input 前面;响应完成后,本次的输入与输出条目会被追加回这个对话。只有对话的所有者可以引用它,否则返回 404 object_not_found;不能和 previous_response_id 同时使用,同传返回 400。

      会话历史进入本次输入,响应条目追加到会话;不能与 previous_response_id 同传。

    • context_managementarray可选

      本次请求的上下文管理配置(例如输入超过阈值时自动压缩)。

    • moderationobject可选

      对本次响应的输入和输出运行审核(moderation)的配置。

    • prompt_cache_retentionstring可选

      提示词缓存的保留策略;设为 24h 可以让缓存前缀存活更久,最长 24 小时。

    • stream_optionsobject可选

      流式响应的附加选项,只在 stream=true 时生效(例如流末尾是否附带用量统计)。

    • access_programsobject可选○ 未支持

      已识别的官方字段;平台未实现访问计划,传入返回 400 并明确说明不支持。

返回

200 response

stream=true 时以 SSE 增量返回(text/event-stream)。

未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
backgroundboolean | nullWhether the response was started in background mode.
completed_atinteger | nullUnix time in seconds at which the response finished; null while it has not finished.
created_atintegerUnix time in seconds at which the response was created.
errorobject | nullError information returned from the API
error.codestringMachine-readable error code.
error.messagestringHuman-readable error message.
frequency_penaltynumber | nullThe frequency penalty that applied to the request, if any.
idstringUnique id of the response; use it as response_id to retrieve, cancel or delete it, or as previous_response_id to continue the conversation.
incomplete_detailsobject | nullWhy the response stopped before finishing; null for complete responses.
incomplete_details.reasonstringWhy the response is incomplete.
instructionsstring | array<object> | nullInput of the request: a string or an array of input items.
max_output_tokensinteger | nullUpper bound on generated tokens that applied to the request; null when none was set.
max_tool_callsinteger | nullUpper bound on built-in tool calls that applied to the request; null when none was set.
metadataobject | nullMetadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed.
modelstringModel that produced the response.
objectstringObject type; always `response`.
outputarray<object>Items the model produced, in order: messages, reasoning, tool calls and tool results.
output[].contentarray<object> | array | null | stringContent parts of the message: output text or refusal. / Reasoning text parts, when the provider returns them. / Text content of the fetched page.
output[].idstringId of the message item. / Id of the reasoning item. / Id of the function call item. / Id of the web search call item. / Id of the file search call item. / Id of the image generation call item. / Id of the code interpreter call item. / Id of the computer call item. / Id of the datetime server tool item. / Id of the web search server tool item. / Id of the code interpreter server tool item. / Id of the file search server tool item. / Id of the image generation server tool item. / Id of the browser use server tool item. / Id of the bash server tool item. / Id of the text editor server tool item. / Id of the apply_patch server tool item. / Id of the apply_patch call item. / Id of the shell call item. / Id of the shell call output item. / Id of the shell server tool item. / Id of the web fetch server tool item. / Id of the tool search server tool item. / Id of the memory server tool item. / Id of the MCP server tool item. / Id of the model search server tool item. / Id of the fusion server tool item. / Id of the advisor server tool item. / Id of the subagent server tool item. / Id of the files server tool item. / Id of the custom tool call item.
output[].phasestring | nullThe phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages.
output[].rolestringRole of the author; always assistant.
output[].statusstringStatus of the message item. / Status of the reasoning item. / Status of the function call item. / Status of a web search call. / Status of a web search call. / Status of an image generation call. / Status of the code interpreter call. / Status of the computer call item. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call that can fail. / Status of a tool call. / Status of a tool call. / Lifecycle state of an `apply_patch_call` output item. / Status of a shell call or its output. / Status of a shell call or its output. / Status of a tool call that can fail. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call that can fail. / Status of a tool call that can fail. / Status of a tool call. / Status of the custom tool call item.
output[].typestringAlways `message`. Discriminator that marks this object as a OutputMessage in a `type`-tagged union. / Always `reasoning`. Discriminator that marks this object as a OutputItemReasoning in a `type`-tagged union. / Always `function_call`. Discriminator that marks this object as a OutputItemFunctionCall in a `type`-tagged union. / Always `web_search_call`. Discriminator that marks this object as a OutputItemWebSearchCall in a `type`-tagged union. / Always `file_search_call`. Discriminator that marks this object as a OutputItemFileSearchCall in a `type`-tagged union. / Always `image_generation_call`. Discriminator that marks this object as a OutputItemImageGenerationCall in a `type`-tagged union. / Always `code_interpreter_call`. Discriminator that marks this object as a OutputItemCodeInterpreterCall in a `type`-tagged union. / Always `computer_call`. Discriminator that marks this object as a OutputComputerCallItem in a `type`-tagged union. / Always `openrouter:datetime`. Discriminator that marks this object as a OutputDatetimeItem in a `type`-tagged union. / Always `openrouter:web_search`. Discriminator that marks this object as a OutputWebSearchServerToolItem in a `type`-tagged union. / Always `openrouter:code_interpreter`. Discriminator that marks this object as a OutputCodeInterpreterServerToolItem in a `type`-tagged union. / Always `openrouter:file_search`. Discriminator that marks this object as a OutputFileSearchServerToolItem in a `type`-tagged union. / Always `openrouter:image_generation`. Discriminator that marks this object as a OutputImageGenerationServerToolItem in a `type`-tagged union. / Always `openrouter:browser_use`. Discriminator that marks this object as a OutputBrowserUseServerToolItem in a `type`-tagged union. / Always `openrouter:bash`. Discriminator that marks this object as a OutputBashServerToolItem in a `type`-tagged union. / Always `openrouter:text_editor`. Discriminator that marks this object as a OutputTextEditorServerToolItem in a `type`-tagged union. / Always `openrouter:apply_patch`. Discriminator that marks this object as a OutputApplyPatchServerToolItem in a `type`-tagged union. / Always `apply_patch_call`. Discriminator that marks this object as a OutputApplyPatchCallItem in a `type`-tagged union. / Always `shell_call`. Discriminator that marks this object as a OutputShellCallItem in a `type`-tagged union. / Always `shell_call_output`. Discriminator that marks this object as a OutputShellCallOutputItem in a `type`-tagged union. / Always `openrouter:shell`. Discriminator that marks this object as a OutputShellServerToolItem in a `type`-tagged union. / Always `openrouter:web_fetch`. Discriminator that marks this object as a OutputWebFetchServerToolItem in a `type`-tagged union. / Always `openrouter:tool_search`. Discriminator that marks this object as a OutputToolSearchServerToolItem in a `type`-tagged union. / Always `openrouter:memory`. Discriminator that marks this object as a OutputMemoryServerToolItem in a `type`-tagged union. / Always `openrouter:mcp`. Discriminator that marks this object as a OutputMcpServerToolItem in a `type`-tagged union. / Always `openrouter:experimental__search_models`. Discriminator that marks this object as a OutputSearchModelsServerToolItem in a `type`-tagged union. / Always `openrouter:fusion`. Discriminator that marks this object as a OutputFusionServerToolItem in a `type`-tagged union. / Always `openrouter:advisor`. Discriminator that marks this object as a OutputAdvisorServerToolItem in a `type`-tagged union. / Always `openrouter:subagent`. Discriminator that marks this object as a OutputSubagentServerToolItem in a `type`-tagged union. / Always `openrouter:files`. Discriminator that marks this object as a OutputFilesServerToolItem in a `type`-tagged union. / Always `custom_tool_call`. Discriminator that marks this object as a OutputCustomToolCallItem in a `type`-tagged union.
output[].encrypted_contentstring | nullOpaque encrypted reasoning; send it back unchanged to let the model continue its reasoning on the next turn.
output[].summaryarray<object>Summary parts of the reasoning.
output[].formatstring | nullWire format of the reasoning details, which names the provider family that produced them.
output[].signaturestring | nullA signature for the reasoning content, used for verification
output[].argumentsstring | string | null | string | null | string | null | string | string | nullJSON-encoded arguments the model produced for the function. / The raw tool-call arguments string as emitted by the model. / The raw tool-call arguments string as emitted by the model. Echo back unchanged when replaying history; used verbatim to preserve provider prompt-cache prefixes. / The raw tool-call arguments string as emitted by the model. / The JSON arguments submitted to the search tool (e.g. {"query":"Claude"}) / The raw tool-call arguments string as emitted by the model.
output[].asyncbooleanTrue when the model called a tool declared with `async: true` and may continue its turn before the output is returned. Return the result in a later request as a `function_call_output` with this `call_id`.
output[].call_idstring | string | null | string | string | string | string | string | null | string | string | null | stringId of the call; the function_call_output item that answers it repeats it as call_id. / Id of the call; the computer_call_output item that answers it repeats it as call_id. / The model-generated tool call id from the originating turn. / Id of the apply_patch tool call. / Id of the call; the apply_patch_call_output item that answers it repeats it as call_id. / Id of the call; the shell_call_output item that answers it repeats it as call_id. / Id of the shell call this output answers. / The model-generated tool call id from the originating turn. / EXPERIMENTAL — subject to change without notice. The `call_id` of the tool call that spawned this subagent. This id will also be included as the `subagent_id` on any `function_call` items created by the subagent. This must be returned in the request so the `function_call` can be matched with the correct subagent. A suspended `in_progress` item is announced once and never re-emitted or terminally closed — completion arrives as a new item with the same `call_id`. / The model-generated tool call id from the originating turn. / Id of the call; the custom_tool_call_output item that answers it repeats it as call_id.
output[].namestringName of the function being called. / Configured name of the subagent that executed the task (the `name` on its tool entry). Present only for named subagents; omitted for an unnamed (default) subagent. / Name of the custom tool being called.
output[].namespacestringNamespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)
output[].subagent_idstringEXPERIMENTAL — subject to change without notice. String id that matches the `call_id` of the `openrouter:subagent` server tool call that spawned the subagent. Present on every `function_call` item the subagent projects; absent on ordinary function calls.
output[].subagent_itemsarray<object>EXPERIMENTAL — subject to change without notice. The subagent's output items produced on this turn. Treat this as an opaque object; you must replay it in the request so that the subagent can continue execution of the tool with the same context. If a subagent created multiple parallel tool calls, only the first tool call will have this field. The other tool calls will only have `subagent_id`. Present only if the tool call originates from a subagent spawned by the `openrouter:subagent` server tool.
output[].actionobject | any | object | string | object | object | stringThe search action the model took: a search, opening a page, or finding a pattern in a page. / The action the model asks the client to perform on the computer. / The search action performed, matching OpenAI web_search_call.action shape. Includes the query the model issued and optional source URLs returned by the search provider. / The browser action that was performed. / The commands the model asks the client to run. / The commands that were run. / Memory action that was performed.
output[].queriesarray<string>Queries the model ran against the vector stores. / Queries that ran against the vector stores.
output[].resultstring | null | stringBase64-encoded generated image; null while generation has not finished. / The generated image as a base64-encoded string or URL, matching OpenAI image_generation_call format / JSON-serialized result of the file operation.
output[].promptstringThe prompt (possibly rewritten) that the image was generated from. / The prompt the executor sent to the advisor.
output[].codestring | null | stringThe code the interpreter ran; null while it is still being written. / The code that ran.
output[].container_idstringId of the container the code ran in. / The canonical container id the command ran under — the `{container_id}` for the Container Files API, reusable as a `container_reference` in later requests. Present on every sandbox-executed call, even when no files changed. / The canonical container id the command ran under — the `{container_id}` for the Container Files API, reusable as a `container_reference` in later requests. Present on every sandbox-executed call, even when no files changed. / The canonical container id the command ran under — the `{container_id}` for the Container Files API, reusable as a `container_reference` in later requests. Present on every sandbox-executed call, even when no files changed.
output[].outputsarray | nullOutputs of the run: logs and images; null while the run has not finished.
output[].pending_safety_checksarray<object>Safety checks that must be acknowledged before the action is performed.
output[].datetimestringISO 8601 datetime string
output[].timezonestringIANA timezone name
output[].exitCodeintegerExit code of the run; 0 means success. / Exit code of the command; 0 means success.
output[].languagestringLanguage of the code that ran.
output[].stderrstringStandard error output of the code. / Standard error output of the command.
output[].stdoutstringStandard output of the code. / Standard output of the command.
output[].imageB64stringBase64-encoded generated image.
output[].imageUrlstringURL of the generated image.
output[].revisedPromptstringPrompt after the image model rewrote it.
output[].screenshotB64stringBase64-encoded screenshot taken after the action.
output[].commandstringThe bash command that ran. / Editor command that ran.
output[].errorstringThe error message when the sandbox call failed before producing a result (for example, the per-user container limit was reached). Set together with `status: 'failed'`; absent on a successful call. A non-zero `exitCode` is a command failure, not a tool failure. / The error message when the sandbox call failed before producing a result (for example, the per-user container limit was reached). Set together with `status: 'incomplete'` and an empty `output`; absent on a successful call. / The error message when the sandbox call failed before producing a result (for example, the per-user container limit was reached). Set together with `status: 'failed'`; absent on a successful call. `output` is omitted when `error` is set. / The error message if the fetch failed. / Error message when the fusion run did not produce an analysis result. / Error message when the advisor call did not produce advice. Set together with `status: 'failed'` on the terminal item. / Error message when the subagent task did not produce an outcome. Set together with `status: 'failed'` on the terminal item. / Error message when the file operation failed.
output[].filesarray<object>Citations for the files the sandbox command created or modified, most-recently-touched first (at most 10). Retrieve them via the Container Files API.
output[].filePathstringPath of the file the command worked on.
output[].operationobject | stringThe patch operation requested by an `apply_patch_call`. `create_file` and `update_file` carry a V4A diff; `delete_file` omits it. / The file operation performed (list, read, write, or edit).
output[].max_output_lengthinteger | nullMaximum number of characters of output that was kept; null for no limit.
output[].outputarray<object>Output of each command, in the order the commands ran.
output[].httpStatusintegerThe HTTP status code returned by the upstream URL fetch.
output[].titlestringTitle of the fetched page.
output[].urlstringURL that was fetched.
output[].querystringThe tool search query. / The model search query.
output[].keystringKey of the memory entry.
output[].valueanyValue of the memory entry; absent for reads that found nothing and for deletes.
output[].serverLabelstringLabel of the MCP server.
output[].toolNamestringName of the MCP tool that was called.
output[].analysisobjectStructured analysis produced by the fusion analyst model.
output[].failed_modelsarray<object>Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel.
output[].failure_reasonstringTyped failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, invalid_model, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion. The four analysis-stage codes keep their pre-rename `judge_` spelling so existing consumers keep matching. The consumer-cancellation code is `cancelled`.
output[].responsesarray<object>Analysis models that produced a response in this fusion run, with each model's full panel content.
output[].sourcesarray<object>Web pages the analysis panels and analyst retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source.
output[].advicestringThe advisor model's response (the advice text returned to the executor).
output[].instance_namestringProvider-safe function name of the specific advisor instance that produced this item (e.g. `openrouter_advisor__1`). Present only when more than one advisor tool is configured; omitted for the default single advisor. Echo this field back unchanged so the advisor's cross-request memory stays namespaced to the correct instance. This identity is positional: it is derived from the index of the advisor entry in the request `tools` array, so clients must keep the order of advisor tool entries stable across requests in a conversation. Reordering or inserting advisor entries shifts these names and causes each advisor's cross-request memory to be attributed to the wrong instance. / Provider-safe function name of the specific subagent instance that produced this item (e.g. `openrouter_subagent__1`). Present only on items from non-default instances — the second and later subagent entries in the request `tools` array. The first (default) instance omits it, even when multiple subagents are configured. When a replayed item echoes this field back, the transcript rehydrates the call under that instance's tool. This identity is positional: it is derived from the index of the subagent entry in the request `tools` array, so keep the order of subagent entries stable across requests in a conversation.
output[].modelstringSlug of the advisor model that was consulted. / Slug of the worker model that executed the task.
output[].outcomestringThe worker model's result (the outcome text returned to the delegating model).
output[].task_descriptionstringThe task description the delegating model sent to the worker.
output[].task_namestringThe short task identifier the delegating model supplied.
output[].file_idstringThe target file id supplied in the tool-call arguments.
output[].filenamestringThe target filename supplied in the tool-call arguments.
output[].inputstringFree-form input the model produced for the custom tool.
output_textstringConvenience concatenation of all output text of the response.
parallel_tool_callsbooleanWhether the model was allowed to call several tools in one turn.
presence_penaltynumber | nullThe presence penalty that applied to the request, if any.
previous_response_idstring | nullId of the response this one continued; null when it started a new conversation.
promptobject | nullReference to a stored prompt template with its variables.
prompt.idstringId of the stored prompt template.
prompt.variablesobject | nullValues for the template variables, keyed by variable name; a value is a string or an input text, image or file part.
prompt_cache_keystring | nullCache key the request supplied to improve prompt cache hits; null when none was set.
prompt_cache_optionsobject | nullRequest-level prompt-cache controls. `mode: "explicit"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. Only supported by OpenAI GPT-5.6 and newer.
prompt_cache_options.modestringPrompt cache mode; explicit caches only the blocks marked with prompt_cache_breakpoint.
prompt_cache_options.ttlstring | nullLifetime of cache entries, for example 30m; null leaves the provider default.
reasoningobject | nullReasoning settings that applied: effort, summary verbosity, mode and context.
reasoning.contextstring | nullControls which reasoning is available to the model. `auto` uses the model default (same as omitting); `all_turns` includes reasoning from earlier turns passed in input; `current_turn` limits to the current turn only. Only supported by OpenAI GPT-5.6 and newer.
reasoning.effortstring | nullHow much reasoning the model should spend.
reasoning.modestring | nullSelects the reasoning mode. `standard` is the default; `pro` engages deeper reasoning on models that support it, billed at standard token rates. Only supported by OpenAI GPT-5.6 and newer.
reasoning.summarystring | nullHow detailed the reasoning summary should be.
safety_identifierstring | nullEnd-user identifier the request supplied for abuse monitoring; null when none was set.
service_tierstring | nullService tier the provider used for the response; null when not reported.
statusstringLifecycle status of the response.
storebooleanWhether the response is stored so it can be retrieved later.
temperaturenumber | nullSampling temperature that applied to the request, if any.
textobjectText output configuration including format and verbosity
text.formatobjectText response format configuration
text.verbositystring | nullHow long the answer should be.
tool_choicestring | objectHow the model picks tools: a mode string or a specific tool.
tool_choice.namestringName of the function or tool the model must call.
tool_choice.typestringKind of tool the model must call. / Always `allowed_tools`. Discriminator that marks this object as a ToolChoiceAllowed in a `type`-tagged union. / Kind of tool the model must call. / Kind of tool the model must call.
tool_choice.modestringauto lets the model pick among the allowed tools or none; required forces a call to one of them.
tool_choice.toolsarray<object>The allowed tools, each as a tool reference such as {type: function, name}.
toolsarray<object>Tools that were available to the model for this response.
tools[].descriptionstring | null | string | stringWhat the function does and when to use it; the model reads this to decide whether to call it. / What the custom tool does and when to use it. / What the group of tools is for.
tools[].namestringName of the function; the model uses it in function_call items. / Name of the custom tool. / Name of the namespace that groups the tools.
tools[].parametersobject | nullJSON Schema of the function arguments; null when the function takes none.
tools[].strictboolean | nullWhether to enforce strict argument validation against the schema; null leaves the provider default.
tools[].typestringAlways `function`. Discriminator that marks this object as a FunctionTool in a `type`-tagged union. / Always `web_search_preview`. Discriminator that marks this object as a Preview_WebSearchServerTool in a `type`-tagged union. / Always `web_search_preview_2025_03_11`. Discriminator that marks this object as a Preview_20250311_WebSearchServerTool in a `type`-tagged union. / Always `web_search`. Discriminator that marks this object as a Legacy_WebSearchServerTool in a `type`-tagged union. / Always `web_search_2025_08_26`. Discriminator that marks this object as a WebSearchServerTool in a `type`-tagged union. / Comparison operator. / Always `computer_use_preview`. Discriminator that marks this object as a ComputerUseServerTool in a `type`-tagged union. / Always `code_interpreter`. Discriminator that marks this object as a CodeInterpreterServerTool in a `type`-tagged union. / Always `mcp`. Discriminator that marks this object as a McpServerTool in a `type`-tagged union. / Always `image_generation`. Discriminator that marks this object as a ImageGenerationServerTool in a `type`-tagged union. / Always `local_shell`. Discriminator that marks this object as a CodexLocalShellTool in a `type`-tagged union. / Always `shell`. Discriminator that marks this object as a ShellServerTool in a `type`-tagged union. / Always `apply_patch`. Discriminator that marks this object as a ApplyPatchServerTool in a `type`-tagged union. / Always `custom`. Discriminator that marks this object as a CustomTool in a `type`-tagged union. / Always `namespace`. Discriminator that marks this object as a NamespaceTool in a `type`-tagged union.
tools[].asyncbooleanLets the model keep working after calling this tool instead of waiting for its output. The tool is still executed by the client; return the result in a later request as a `function_call_output` with the original `call_id`. Only honored by providers whose Responses API supports async tools; ignored elsewhere.
tools[].defer_loadingbooleanWithhold this tool from the model until `openrouter:tool_search` finds it. Requires the tool search server tool; at least one tool must remain non-deferred.
tools[].enginestringWhich search engine to use. "auto" (default) uses native if the provider supports it, otherwise Exa. "native" forces the provider's built-in search. "exa" forces the Exa search API. "firecrawl" uses Firecrawl (requires BYOK). "parallel" uses the Parallel search API. "perplexity" uses the Perplexity Search API (raw ranked results).
tools[].filtersobject | nullRestricts web search by domain. / Attribute filter applied to the search: a comparison or a compound filter.
tools[].max_resultsintegerMaximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped.
tools[].max_usesintegerMaximum number of web searches the model may perform in a single request. Once reached, further search calls return an error result instead of executing. Applies to the Exa, Firecrawl, Parallel, and Perplexity engines. With native provider search, forwarded only to Anthropic (as `max_uses`); other native search providers have no equivalent parameter and ignore it.
tools[].modestringEngine-native search mode. Exa supports instant, fast, auto (default), deep-lite, deep, and deep-reasoning. Parallel supports turbo, fast, basic (default), and advanced. Modes unsupported by the selected engine are ignored.
tools[].search_context_sizestringSize of the search context for web search tools
tools[].user_locationobject | nullApproximate location of the user, used to bias web search results. / User location information for web search / User location information for web search
tools[].max_num_resultsintegerMaximum number of results to return, between 1 and 50.
tools[].ranking_optionsobjectRanking options for the search.
tools[].vector_store_idsarray<string>Ids of the vector stores to search.
tools[].display_heightintegerHeight of the computer display in pixels.
tools[].display_widthintegerWidth of the computer display in pixels.
tools[].environmentstringKind of environment that is controlled.
tools[].containerstring | objectContainer for the code to run in: a container id or an automatic container with files.
tools[].allowed_toolsarray<string> | object | nullTools of the server the model may use: a list of names or a filter.
tools[].authorizationstringOAuth access token for the MCP server.
tools[].connector_idstringId of a built-in connector; give this or server_url.
tools[].headersobject | nullHTTP headers sent to the MCP server; null for none.
tools[].require_approvalobject | string | nullWhether tool calls need approval before they run: always, never, or a filter per tool.
tools[].server_descriptionstringWhat the MCP server is for, which helps the model decide when to use it.
tools[].server_labelstringLabel that names the MCP server in the conversation.
tools[].server_urlstringURL of the MCP server; give this or connector_id.
tools[].backgroundstringBackground of the generated image.
tools[].input_fidelitystring | nullHow closely to preserve details of input images; null uses the default.
tools[].input_image_maskobjectMask that marks the region of the input image to edit.
tools[].modelstringImage model to use.
tools[].moderationstringModeration level applied to the generated image.
tools[].output_compressionintegerCompression level from 0 to 100 for jpeg and webp output.
tools[].output_formatstringFile format of the generated image.
tools[].partial_imagesintegerNumber of partial images to stream while generating, from 0 to 3.
tools[].qualitystringQuality of the generated image.
tools[].sizestringSize of the generated image; auto lets the model choose.
tools[].formatobjectFormat of the tool input: free text or a grammar.
tools[].toolsarray<object>Function tools in the namespace.
top_logprobsintegerNumber of most likely tokens whose log probabilities were requested per position.
top_pnumber | nullNucleus sampling value that applied to the request, if any.
truncationstring | nullHow to handle input that exceeds the context window.
usageobject | nullToken usage information for the response
usage.input_tokensintegerNumber of input tokens, cached tokens included.
usage.input_tokens_detailsobjectBreakdown of the input tokens.
usage.output_tokensintegerNumber of output tokens, reasoning tokens included.
usage.output_tokens_detailsobjectBreakdown of the output tokens.
usage.total_tokensintegerInput plus output tokens.
usage.costnumber | nullCost of the completion
usage.cost_detailsobjectBreakdown of the upstream inference cost.
usage.is_byokbooleanWhether a request was made using a Bring Your Own Key configuration
usage.server_tool_use_detailsobject | nullUsage for server-side tool execution (e.g., web search)
userstring | nullEnd-user identifier the request supplied; null when none was set.
error_typestringCanonical OpenRouter error type, stable across all API formats
openrouter_metadataobjectRouting report: what was requested, how the router chose, and what was attempted.
openrouter_metadata.attemptintegerNumber of the attempt that served the request, starting at 1.
openrouter_metadata.attemptsarray<object>Every attempt that was made, in order.
openrouter_metadata.endpointsobjectWhich endpoints were available and which one was chosen.
openrouter_metadata.generation_timeintegerMilliseconds measured for the generation, from dispatching the upstream request until its response body ended. Divide the completion token count by this for throughput. Absent when no upstream request was dispatched.
openrouter_metadata.is_byokbooleanWhether the request used a key supplied by the caller.
openrouter_metadata.paramsobjectRouter parameters that applied to the request.
openrouter_metadata.pipelinearray<object>Stages the request went through before and after the model call.
openrouter_metadata.regionstring | nullRegion that served the request; null when unknown.
openrouter_metadata.requestedstringThe model or alias the request asked for.
openrouter_metadata.strategystringHow the router picked the model or provider for this request.
openrouter_metadata.summarystringOne-line summary of the routing decision.

text/event-stream — chunk / 事件对象

名称类型说明
dataobjectUnion of all possible event types emitted during response streaming
data.responseobjectComplete non-streaming response from the Responses API
data.sequence_numberintegerPosition of this event in the stream. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream.
data.typestringAlways `response.created`. Discriminator that marks this object as a CreatedEvent in a `type`-tagged union. / Always `response.in_progress`. Discriminator that marks this object as a InProgressEvent in a `type`-tagged union. / Always `response.completed`. Discriminator that marks this object as a CompletedEvent in a `type`-tagged union. / Always `response.incomplete`. Discriminator that marks this object as a IncompleteEvent in a `type`-tagged union. / Always `response.failed`. Discriminator that marks this object as a FailedEvent in a `type`-tagged union. / Always `error`. Discriminator that marks this object as a BaseErrorEvent in a `type`-tagged union. / Always `response.output_item.added`. Discriminator that marks this object as a OutputItemAddedEvent in a `type`-tagged union. / Always `response.output_item.done`. Discriminator that marks this object as a OutputItemDoneEvent in a `type`-tagged union. / Always `response.content_part.added`. Discriminator that marks this object as a BaseContentPartAddedEvent in a `type`-tagged union. / Always `response.content_part.done`. Discriminator that marks this object as a BaseContentPartDoneEvent in a `type`-tagged union. / Always `response.output_text.delta`. Discriminator that marks this object as a BaseTextDeltaEvent in a `type`-tagged union. / Always `response.output_text.done`. Discriminator that marks this object as a BaseTextDoneEvent in a `type`-tagged union. / Always `response.refusal.delta`. Discriminator that marks this object as a BaseRefusalDeltaEvent in a `type`-tagged union. / Always `response.refusal.done`. Discriminator that marks this object as a BaseRefusalDoneEvent in a `type`-tagged union. / Always `response.output_text.annotation.added`. Discriminator that marks this object as a BaseAnnotationAddedEvent in a `type`-tagged union. / Always `response.function_call_arguments.delta`. Discriminator that marks this object as a BaseFunctionCallArgsDeltaEvent in a `type`-tagged union. / Always `response.function_call_arguments.done`. Discriminator that marks this object as a BaseFunctionCallArgsDoneEvent in a `type`-tagged union. / Always `response.reasoning_text.delta`. Discriminator that marks this object as a BaseReasoningDeltaEvent in a `type`-tagged union. / Always `response.reasoning_text.done`. Discriminator that marks this object as a BaseReasoningDoneEvent in a `type`-tagged union. / Always `response.reasoning_summary_part.added`. Discriminator that marks this object as a BaseReasoningSummaryPartAddedEvent in a `type`-tagged union. / Always `response.reasoning_summary_part.done`. Discriminator that marks this object as a BaseReasoningSummaryPartDoneEvent in a `type`-tagged union. / Always `response.reasoning_summary_text.delta`. Discriminator that marks this object as a BaseReasoningSummaryTextDeltaEvent in a `type`-tagged union. / Always `response.reasoning_summary_text.done`. Discriminator that marks this object as a BaseReasoningSummaryTextDoneEvent in a `type`-tagged union. / Always `response.image_generation_call.in_progress`. Discriminator that marks this object as a OpenAIResponsesImageGenCallInProgress in a `type`-tagged union. / Always `response.image_generation_call.generating`. Discriminator that marks this object as a OpenAIResponsesImageGenCallGenerating in a `type`-tagged union. / Always `response.image_generation_call.partial_image`. Discriminator that marks this object as a OpenAIResponsesImageGenCallPartialImage in a `type`-tagged union. / Always `response.image_generation_call.completed`. Discriminator that marks this object as a OpenAIResponsesImageGenCallCompleted in a `type`-tagged union. / Always `response.code_interpreter_call.in_progress`. Discriminator that marks this object as a OpenAIResponsesCodeInterpreterCallInProgress in a `type`-tagged union. / Always `response.code_interpreter_call.interpreting`. Discriminator that marks this object as a OpenAIResponsesCodeInterpreterCallInterpreting in a `type`-tagged union. / Always `response.code_interpreter_call.completed`. Discriminator that marks this object as a OpenAIResponsesCodeInterpreterCallCompleted in a `type`-tagged union. / Always `response.code_interpreter_call_code.delta`. Discriminator that marks this object as a OpenAIResponsesCodeInterpreterCallCodeDelta in a `type`-tagged union. / Always `response.code_interpreter_call_code.done`. Discriminator that marks this object as a OpenAIResponsesCodeInterpreterCallCodeDone in a `type`-tagged union. / Always `response.web_search_call.in_progress`. Discriminator that marks this object as a OpenAIResponsesWebSearchCallInProgress in a `type`-tagged union. / Always `response.web_search_call.searching`. Discriminator that marks this object as a OpenAIResponsesWebSearchCallSearching in a `type`-tagged union. / Always `response.web_search_call.completed`. Discriminator that marks this object as a OpenAIResponsesSearchCompleted in a `type`-tagged union. / Always `response.custom_tool_call_input.delta`. Discriminator that marks this object as a BaseCustomToolCallInputDeltaEvent in a `type`-tagged union. / Always `response.custom_tool_call_input.done`. Discriminator that marks this object as a BaseCustomToolCallInputDoneEvent in a `type`-tagged union. / Always `response.apply_patch_call_operation_diff.delta`. Discriminator that marks this object as a ApplyPatchCallOperationDiffDeltaEvent in a `type`-tagged union. / Always `response.apply_patch_call_operation_diff.done`. Discriminator that marks this object as a ApplyPatchCallOperationDiffDoneEvent in a `type`-tagged union. / Always `response.fusion_call.in_progress`. Discriminator that marks this object as a FusionCallInProgressEvent in a `type`-tagged union. / Always `response.fusion_call.panel.added`. Discriminator that marks this object as a FusionCallPanelAddedEvent in a `type`-tagged union. / Always `response.fusion_call.panel.delta`. Discriminator that marks this object as a FusionCallPanelDeltaEvent in a `type`-tagged union. / Always `response.fusion_call.panel.reasoning.delta`. Discriminator that marks this object as a FusionCallPanelReasoningDeltaEvent in a `type`-tagged union. / Always `response.fusion_call.panel.completed`. Discriminator that marks this object as a FusionCallPanelCompletedEvent in a `type`-tagged union. / Always `response.fusion_call.panel.failed`. Discriminator that marks this object as a FusionCallPanelFailedEvent in a `type`-tagged union. / Always `response.fusion_call.analysis.in_progress`. Discriminator that marks this object as a FusionCallAnalysisInProgressEvent in a `type`-tagged union. / Always `response.fusion_call.analysis.completed`. Discriminator that marks this object as a FusionCallAnalysisCompletedEvent in a `type`-tagged union. / Always `response.fusion_call.completed`. Discriminator that marks this object as a FusionCallCompletedEvent in a `type`-tagged union. / Always `response.debug`. Discriminator that marks this object as a DebugEvent in a `type`-tagged union.
data.codestring | null | stringError code; null when the upstream gave none. / The complete code the interpreter runs.
data.messagestringHuman-readable error message.
data.paramstring | nullName of the request parameter the error is about; null when it is not about a parameter.
data.itemobjectAn output item from the response
data.output_indexintegerIndex of the item in the response output array that this event belongs to.
data.content_indexintegerIndex of the content part inside the output item that this event belongs to.
data.item_idstringId of the output item this event belongs to; it equals the id of that item in the response output.
data.partobjectThe content part as it starts: output text or refusal. / The content part in its final form: output text or refusal. / A reasoning summary part. / A reasoning summary part.
data.deltastringText fragment to append to the output text of this content part. / Refusal text fragment to append. / Fragment of the JSON-encoded function arguments to append. / Reasoning text fragment to append. / Reasoning summary text fragment to append. / Fragment of the code the interpreter will run, to append. / Fragment of the custom tool call input to append. / Fragment of the patch diff to append. / Text fragment the panel model produced. / Reasoning text fragment the panel model produced.
data.logprobsarray<object>Log probabilities of the tokens in this fragment, when requested. / Log probabilities of the tokens in the complete text, when requested.
data.textstringThe complete output text of this content part. / The complete reasoning text of this content part. / The complete reasoning summary text of this part.
data.refusalstringThe complete refusal text.
data.annotationobjectAnnotation attached to output text: a file citation, URL citation or file path.
data.annotation_indexintegerIndex of the new annotation inside the content part's annotations array.
data.argumentsstringThe complete JSON-encoded arguments of the function call.
data.namestringName of the function being called.
data.summary_indexintegerIndex of the reasoning summary part inside the reasoning item that this event belongs to.
data.partial_image_b64stringBase64-encoded partial image produced while generation is still running.
data.partial_image_indexintegerZero-based index of this partial image among the partial images of the call.
data.inputstringThe complete input of the custom tool call.
data.diffstringThe complete patch diff.
data.modelstringSlug of the panel model that started. / Slug of the panel model that produced the fragment. / Slug of the panel model that produced the fragment. / Slug of the panel model that finished. / Slug of the panel model that failed.
data.contentstringThe complete answer of the panel model.
data.errorstringError message that explains why the panel model failed.
data.status_codeintegerHTTP status code of the failed upstream call, when one is available.
data.analyst_modelstringSlug of the model producing the structured analysis.
data.judge_modelstringDeprecated alias of `analyst_model`, kept so existing consumers keep working. Always carries the same value. Use `analyst_model`.
data.analysisobjectStructured analysis produced by the fusion analyst model.
data.debugobjectDebug information.

读取响应

先调用「生成响应」,用返回的 ID 替换 resp_123。

GET /openai/v1/responses/{response_id}● 支持

OpenAI 官方文档 ↗

请求参数

  • response_idstring必填

    path:

返回

200 response

按 ID 读取一条已保存的响应。如果创建时 store 为 false,我们不会保存这次响应,读取会返回 404 response_not_found;超过保留期(默认 30 天)后读取也会返回同样的 404。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Native Responses API response

application/json

名称类型说明
$object

删除响应

先调用「生成响应」,用返回的 ID 替换 resp_123。

DELETE /openai/v1/responses/{response_id}● 支持

OpenAI 官方文档 ↗

请求参数

  • response_idstring必填

    path:

返回

200 response

按 ID 立即删除一条已保存的响应。如果创建时 store 为 false,我们不会保存这次响应,删除会返回 404 response_not_found。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Native Responses API delete response

application/json

名称类型说明
$object

先调用「生成响应」,用返回的 ID 替换 resp_123。

POST /openai/v1/responses/{response_id}/cancel◐ 部分支持

OpenAI 官方文档 ↗

请求参数

  • response_idstring必填

    path:

返回

200 response

仅对以 background:true 创建、且路由到具备后台生成能力的模型的响应可用:取消是 幂等的,重复调用返回同一个终态响应;我方的取消只能停止我方对上游流的继续读取, 不能保证已发往上游的算力停止计算,用量按实际收到的部分结算。对一个非后台 (同步)响应调用 cancel:如果这个响应 id 不存在(未持久化、已过期或 id 有误), 返回 404 object_not_found;如果响应存在但其来源 provider 没有声明支持 cancel 操作(我们目前没有接入任何为同步响应声明该能力的上游),返回 400 native_responses_operation_unsupported。这两种情况都不是尚未实现的 501 gate。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Native Responses API cancel response

application/json

名称类型说明
$object

列出响应输入项

先调用「生成响应」,用返回的 ID 替换 resp_123。

GET /openai/v1/responses/{response_id}/input_items● 支持

OpenAI 官方文档 ↗

请求参数

  • response_idstring必填

    path:

返回

200 list

列出一条已保存响应的输入项。支持 limit(1–100,默认 20)、order(asc/desc, 默认 desc,与官方一致)与基于条目 id 的 after 游标分页;has_more/first_id/ last_id 均与实际返回页一致,可据此翻页且不重不漏。每个条目都带服务端签发的 id(message 为 msg_ 前缀,function_call/function_call_output/reasoning 各自 对应前缀),本次上线前已保存、尚无服务端 id 的旧数据在读取时按确定性规则补 id,不做破坏性迁移,同一游标反复读取保持稳定。以 previous_response_id 续接 创建的响应,其输入项列出解析后的完整输入:前序响应链已有的输入与输出条目 再加本轮自己提交的输入;若该祖先响应在我方平台未保存(例如创建时 store 为 false)或已过期删除,则只列出本轮自己提交的输入。如果创建时 store 为 false,我们不会保存这次响应,列出会返回 404 response_not_found。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Native Responses API input item list

application/json

名称类型说明
$object

POST /openai/v1/responses/compact○ 未支持

OpenAI 官方文档 ↗

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

把响应的输入压缩成摘要,依赖 OpenAI Responses 官方的服务端存储(store)语义,我们目前还没有实现;调用会返回 501(message 为 “This platform has not implemented … yet.”,响应头 x-should-retry 为 false),不产生副作用,官方 SDK 不会重试。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Native Responses API compact response

application/json

名称类型说明
$object

POST /openai/v1/responses/input_tokens○ 未支持

OpenAI 官方文档 ↗

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

只统计请求输入会消耗的 token 数、不生成内容,依赖 OpenAI Responses 官方的服务端存储(store)语义,我们目前还没有实现;调用会返回 501(message 为 “This platform has not implemented … yet.”,响应头 x-should-retry 为 false),不产生副作用,官方 SDK 不会重试。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Native Responses API input token count

application/json

名称类型说明
$object

创建会话

POST /openai/v1/conversations● 支持

OpenAI 官方文档 ↗

请求体

  • itemsarray可选

    已验证生效。

  • metadataobject可选

    已验证生效。

返回

200 conversation

创建一个会话,可选携带初始 items(一次最多 20 条)与 metadata。会话按租户分区,创建者是唯一能引用它的租户。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

The created conversation

application/json

名称类型说明
idstringId of the conversation, such as `conv_...`; use it as `conversation_id` in conversation calls and as `conversation` in createResponse.
objectstringObject type; always `conversation`.
created_atintegerUnix time in seconds at which the conversation was created.
metadataobjectUp to 16 string key/value pairs; keys at most 64 characters and values at most 512.

读取会话

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

GET /openai/v1/conversations/{conversation_id}● 支持

OpenAI 官方文档 ↗

请求参数

  • conversation_idstring必填

    path:

返回

200 conversation

按 ID 读取一个会话。不存在或属于其他租户都返回 404 conversation_not_found。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

The conversation

application/json

名称类型说明
idstringId of the conversation, such as `conv_...`; use it as `conversation_id` in conversation calls and as `conversation` in createResponse.
objectstringObject type; always `conversation`.
created_atintegerUnix time in seconds at which the conversation was created.
metadataobjectUp to 16 string key/value pairs; keys at most 64 characters and values at most 512.

更新会话

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

POST /openai/v1/conversations/{conversation_id}● 支持

OpenAI 官方文档 ↗

请求参数

  • conversation_idstring必填

    path:

  • metadataobject必填

    已验证生效。

返回

200 conversation

更新一个会话的 metadata——整体替换,不与已有 metadata 合并。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

The updated conversation

application/json

名称类型说明
idstringId of the conversation, such as `conv_...`; use it as `conversation_id` in conversation calls and as `conversation` in createResponse.
objectstringObject type; always `conversation`.
created_atintegerUnix time in seconds at which the conversation was created.
metadataobjectUp to 16 string key/value pairs; keys at most 64 characters and values at most 512.

删除会话

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

DELETE /openai/v1/conversations/{conversation_id}● 支持

OpenAI 官方文档 ↗

请求参数

  • conversation_idstring必填

    path:

返回

200 conversation.deleted

删除一个会话。删除后该会话与其 items 都不能再被引用(包括作为 Responses create 的 conversation 参数)。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Deletion confirmation

application/json

名称类型说明
idstring
objectstring
deletedboolean

创建会话条目

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

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

OpenAI 官方文档 ↗

请求参数

  • conversation_idstring必填

    path:

  • itemsarray必填

    已验证生效。

返回

200 list

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

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

The items just added

application/json

名称类型说明
objectstringObject type; always `list`.
dataarray<object>Items of the conversation, in the order the list requested.
first_idstringId of the first item of this page; null for an empty page.
last_idstringId of the last item of this page; null for an empty page.
has_morebooleanWhether more items exist beyond this page; pass `last_id` as `after` to read them.

列出会话条目

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

GET /openai/v1/conversations/{conversation_id}/items● 支持

OpenAI 官方文档 ↗

请求参数

  • conversation_idstring必填

    path:

  • limitinteger可选
    默认 20

    query: Maximum items per page (values above 100 are clamped).

  • afterstring可选

    query: Item ID from the previous page; returns items after this cursor.

  • orderstring可选
    默认 "desc"

    query: Sort by stored creation order.

    取值 ascdesc

返回

200 list

按创建顺序列出会话的 items,支持 limit/after/order 分页参数。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

The conversation's items

application/json

名称类型说明
objectstringObject type; always `list`.
dataarray<object>Items of the conversation, in the order the list requested.
first_idstringId of the first item of this page; null for an empty page.
last_idstringId of the last item of this page; null for an empty page.
has_morebooleanWhether more items exist beyond this page; pass `last_id` as `after` to read them.

读取会话条目

先调用「创建对话」拿到 conv_ 开头的 ID,替换 conv_123。 条目 ID 取自「添加对话条目」或「列出对话条目」,替换 item_123。

GET /openai/v1/conversations/{conversation_id}/items/{item_id}● 支持

OpenAI 官方文档 ↗

请求参数

  • conversation_idstring必填

    path:

  • item_idstring必填

    path:

返回

200

按 ID 读取会话里的单条 item。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

The item

application/json

名称类型说明
$object

删除会话条目

先调用「创建对话」拿到 conv_ 开头的 ID,替换 conv_123。 条目 ID 取自「添加对话条目」或「列出对话条目」,替换 item_123。

DELETE /openai/v1/conversations/{conversation_id}/items/{item_id}● 支持

OpenAI 官方文档 ↗

请求参数

  • conversation_idstring必填

    path:

  • item_idstring必填

    path:

返回

200 conversation

删除会话里的单条 item,返回该会话对象(不是被删除的 item)。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

The conversation, with the item removed

application/json

名称类型说明
idstringId of the conversation, such as `conv_...`; use it as `conversation_id` in conversation calls and as `conversation` in createResponse.
objectstringObject type; always `conversation`.
created_atintegerUnix time in seconds at which the conversation was created.
metadataobjectUp to 16 string key/value pairs; keys at most 64 characters and values at most 512.

生成图像

POST /openai/v1/images/generations● 支持

OpenAI 官方文档 ↗

请求体

  • modelstring必填

    已验证生效。

  • response_formatstring可选○ 未支持

    Omit for GPT Image models, which return native base64 data. Only send for models that explicitly support response_format; platform hosting is a separate Image extension.

    gpt-image-2 传 b64_json 或 url 均返回 400;请省略此字段。

    取值 urlb64_json
  • promptstring必填

    已验证生效。

  • ninteger可选
    默认 1

    控制图片数量,0 返回 400,允许 1–10。

  • sizestring可选◐ 部分支持

    gpt-image-2 已验证 1024x1024、1024x1536;512x512 返回 400。

    取值 1024x10241024x15361536x1024auto
  • qualitystring可选

    已验证生效。

    取值 lowmediumhighauto
  • backgroundstring可选

    gpt-image-2 的 transparent 返回透明 PNG。

  • output_formatstring可选

    gpt-image-2 的 jpeg 返回 JPEG。

返回

200

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Image generation response

application/json

名称类型说明
createdinteger
dataarray<object>
data[].urlstring
data[].b64_jsonstring
data[].revised_promptstring

列出模型

GET /openai/v1/models● 支持

OpenAI 官方文档 ↗

请求参数

  • offsetinteger可选
    默认 0

    query: Number of records to skip for pagination. When both offset and limit are omitted, the full list is returned

    已验证生效。

  • limitinteger可选

    query: Maximum number of records to return (max 1000). When both offset and limit are omitted, the full list is returned

    已验证生效。

  • categorystring可选○ 当前不生效

    query: Filter models by use case category

    接受但当前不生效。当前不会按此条件过滤或排序模型。

    取值 programmingroleplaymarketingmarketing/seotechnologysciencetranslationlegalfinancehealthtriviaacademia
  • supported_parametersstring可选○ 当前不生效

    query: Filter models by supported parameter (comma-separated)

    接受但当前不生效。当前不会按此条件过滤或排序模型。

  • output_modalitiesstring可选

    query: Filter models by output modality. Accepts a comma-separated list of modalities (text, image, embeddings, audio, video, rerank, decisions, speech, transcription) or "all" to include all models. When omitted, all models are included; comma-separated modalities match any output.

    已验证生效。

  • sortstring可选

    query: Sort by newest creation date or lowest declared USD unit rate (not estimated request cost). Unpriced models sort last; ties retain catalog order.

    已验证生效。

    取值 newestprice_low
  • qstring可选

    query: Free-text search by model name or slug.

    已验证生效。

  • input_modalitiesstring可选○ 当前不生效

    query: Filter models by input modality. Comma-separated list of: text, image, audio, file.

    接受但当前不生效。当前不会按此条件过滤或排序模型。

  • contextinteger可选○ 当前不生效

    query: Minimum context length (tokens). Models with smaller context are excluded.

    接受但当前不生效。当前不会按此条件过滤或排序模型。

  • min_pricenumber可选○ 当前不生效

    query: Minimum prompt price in $/M tokens.

    接受但当前不生效。当前不会按此条件过滤或排序模型。

  • ▸ 更多参数(20)
    • max_pricenumber可选○ 当前不生效

      query: Maximum prompt price in $/M tokens.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • archstring可选○ 当前不生效

      query: Filter models by architecture/model family (e.g. GPT, Claude, Gemini, Llama).

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • model_authorsstring可选○ 当前不生效

      query: Filter models by the organization that created the model. Comma-separated list of author slugs.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • providersstring可选○ 当前不生效

      query: Filter models by hosting provider. Comma-separated list of provider names.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • distillablestring可选○ 当前不生效

      query: Filter by distillation capability. "true" returns only distillable models, "false" excludes them.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

      取值 truefalse
    • zdrstring可选○ 当前不生效

      query: When set to "true", return only models with zero data retention endpoints.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

      取值 true
    • regionstring可选○ 当前不生效

      query: Filter to models with endpoints in the given data region ("eu" or "us").

      接受但当前不生效。当前不会按此条件过滤或排序模型。

      取值 euus
    • min_output_pricenumber可选○ 当前不生效

      query: Minimum completion (output) price in $/M tokens.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • max_output_pricenumber可选○ 当前不生效

      query: Maximum completion (output) price in $/M tokens.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • min_age_daysinteger可选○ 当前不生效

      query: Minimum model age in days since its creation date.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • max_age_daysinteger可选○ 当前不生效

      query: Maximum model age in days since its creation date.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • min_intelligence_indexnumber可选○ 当前不生效

      query: Minimum Artificial Analysis intelligence index.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • max_intelligence_indexnumber可选○ 当前不生效

      query: Maximum Artificial Analysis intelligence index.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • min_coding_indexnumber可选○ 当前不生效

      query: Minimum Artificial Analysis coding index.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • max_coding_indexnumber可选○ 当前不生效

      query: Maximum Artificial Analysis coding index.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • min_agentic_indexnumber可选○ 当前不生效

      query: Minimum Artificial Analysis agentic index.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • max_agentic_indexnumber可选○ 当前不生效

      query: Maximum Artificial Analysis agentic index.

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • min_tool_success_ratenumber可选○ 当前不生效

      query: Minimum tool-calling success rate, as a fraction in [0, 1] (e.g. 0.9 = 90% of requests finishing with a tool_calls finish reason).

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • max_tool_success_ratenumber可选○ 当前不生效

      query: Maximum tool-calling success rate, as a fraction in [0, 1].

      接受但当前不生效。当前不会按此条件过滤或排序模型。

    • apiarray可选

      query: Match any comma-separated API family: chat selects openai.chat.completions; responses selects openai.responses; embeddings selects openai.embeddings; images selects openai.images.*; audio selects openai.audio.*; videos selects openai.videos. Omitted or empty includes all OpenAI-offered models. Other filters combine using AND, before pagination. Invalid values return 400 with all legal values.

      按声明的 OpenAI 协议筛选,逗号分隔匹配任一协议族,在分页前生效。

返回

200 list

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Returns a list of models or RSS feed

application/json

名称类型说明
dataarray<object>List of available models
data[].alias_targetobjectConcrete model targeted by this tilde-latest alias, when applicable
data[].architectureobjectModel architecture information
data[].benchmarksobjectThird-party benchmark rankings for this model. Omitted when no benchmark data is available.
data[].canonical_slugstringCanonical slug for the model
data[].context_lengthinteger | nullMaximum context length in tokens
data[].createdintegerUnix timestamp of when the model was created
data[].default_parametersobject | nullDefault parameters for this model
data[].descriptionstringDescription of the model
data[].expiration_datestring | nullThe date after which the model may be removed. ISO 8601 date string (YYYY-MM-DD) or null if no expiration.
data[].hugging_face_idstring | nullHugging Face model identifier, if applicable
data[].idstringUnique identifier for the model
data[].knowledge_cutoffstring | nullThe date up to which the model was trained on data. ISO 8601 date string (YYYY-MM-DD) or null if unknown.
data[].linksobjectRelated API endpoints and resources for this model.
data[].namestringDisplay name of the model
data[].per_request_limitsobject | nullPer-request token limits
data[].pricingobjectPricing information for the model
data[].reasoningobjectReasoning effort configuration. Omitted for non-reasoning models and dynamic router models.
data[].supported_parametersarray<string>List of supported parameters for this model
data[].supported_voicesarray | nullList of supported voice identifiers for TTS models. Null for non-TTS models.
data[].top_providerobjectInformation about the top provider for this model
linksobjectPagination links
links.nextstring | nullURL for the next page of results, or null if this is the last page
total_countintegerTotal number of models matching the query

读取模型

GET /openai/v1/models/{model}● 支持

OpenAI 官方文档 ↗

请求参数

  • modelstring必填

    path: Model ID from GET /openai/v1/models, including any publisher prefix.

返回

200 model

返回与列表中同一条目相同的模型对象。只有声明了 OpenAI 协议的模型可见;模型 ID 可以带斜杠分隔的发布方前缀。不存在或没有声明 OpenAI 协议的模型返回 404。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

The matching OpenRouter model list entry.

application/json

名称类型说明
alias_targetobjectConcrete model targeted by this tilde-latest alias, when applicable
alias_target.namestringHuman-readable name of the concrete model targeted by this alias
alias_target.slugstringRoutable model ID of the concrete target, matching that model row's id
architectureobjectModel architecture information
architecture.input_modalitiesarray<string>Supported input modalities
architecture.instruct_typestring | nullInstruction format type
architecture.modalitystring | nullPrimary modality of the model
architecture.output_modalitiesarray<string>Supported output modalities
architecture.tokenizerstringTokenizer type used by the model
benchmarksobjectThird-party benchmark rankings for this model. Omitted when no benchmark data is available.
benchmarks.artificial_analysisobjectArtificial Analysis benchmark index scores.
benchmarks.design_arenaarray<object>Design Arena ELO rankings across arena+category pairs.
canonical_slugstringCanonical slug for the model
context_lengthinteger | nullMaximum context length in tokens
createdintegerUnix timestamp of when the model was created
default_parametersobject | nullDefault parameters for this model
default_parameters.frequency_penaltynumber | null
default_parameters.presence_penaltynumber | null
default_parameters.repetition_penaltynumber | null
default_parameters.temperaturenumber | null
default_parameters.top_kinteger | null
default_parameters.top_pnumber | null
descriptionstringDescription of the model
expiration_datestring | nullThe date after which the model may be removed. ISO 8601 date string (YYYY-MM-DD) or null if no expiration.
hugging_face_idstring | nullHugging Face model identifier, if applicable
idstringUnique identifier for the model
knowledge_cutoffstring | nullThe date up to which the model was trained on data. ISO 8601 date string (YYYY-MM-DD) or null if unknown.
linksobjectRelated API endpoints and resources for this model.
links.detailsstringURL for the model details/endpoints API
namestringDisplay name of the model
per_request_limitsobject | nullPer-request token limits
per_request_limits.completion_tokensnumberMaximum completion tokens per request
per_request_limits.prompt_tokensnumberMaximum prompt tokens per request
pricingobjectPricing information for the model
pricing.audiostringPrice in USD per audio input token
pricing.audio_outputstringPrice in USD per audio output token
pricing.completionstringPrice in USD per token for completion (output) generation
pricing.discountnumberFractional discount applied to this endpoint's pricing; the price is multiplied by (1 - discount) (0 = no discount, 1 = free)
pricing.imagestringPrice in USD per image; present only for a flat registry price
pricing.image_outputstringPrice in USD per output image
pricing.image_tokenstringPrice in USD per image token
pricing.input_audio_cachestringPrice in USD per cached audio input token
pricing.input_cache_readstringPrice in USD per cached input token (read)
pricing.input_cache_writestringPrice per cache-write token, in USD per token. For providers with multiple cache TTLs (e.g. Anthropic), this is the default (5-minute) cache-write rate.
pricing.input_cache_write_1hstringPrice per 1-hour cache-write token, in USD per token. Only present for providers that price an extended (1-hour) cache TTL separately, such as Anthropic.
pricing.internal_reasoningstringPrice in USD per internal reasoning token
pricing.overridesarray<object>Conditional overrides of the base pricing (e.g. long-context or time-based pricing). An entry applies when all of its condition fields (e.g. min_prompt_tokens, or the utc_start/utc_end time window) match the request; among applicable entries, later entries win per key; price keys absent from an entry inherit the base price. The top-level pricing keys always reflect the price that applies under default conditions.
pricing.promptstringPrice in USD per token for prompt (input) processing
pricing.requeststringPrice in USD per request
pricing.web_searchstringPrice in USD per web search
pricing.video_secondstringPraxis extension: USD per second of output video.
pricing.audio_input_minutestringPraxis extension: USD per minute of input audio.
pricing.audio_output_minutestringPraxis extension: USD per minute of output audio.
pricing.input_characterstringPraxis extension: USD per input character.
pricing.pagestringPraxis extension: USD per OCR page.
reasoningobjectReasoning effort configuration. Omitted for non-reasoning models and dynamic router models.
reasoning.default_effortstring | nullDefault reasoning effort when the client enables reasoning without specifying effort. Maps to `reasoning.effort` in chat requests. When `"none"`, prefer omitting effort unless the user explicitly disables reasoning.
reasoning.default_enabledbooleanDefault reasoning enabled state when the client does not set `reasoning.enabled`.
reasoning.mandatorybooleanWhen true, reasoning cannot be disabled and effort "none" is rejected.
reasoning.supported_effortsarray | nullAllowed reasoning effort values for this model, in descending effort order (highest first). Null means no allowlist — all gateway effort values are accepted.
reasoning.supports_max_tokensbooleanPresent and `true` when the model accepts `reasoning.max_tokens` in requests (Anthropic-style) instead of or in addition to `reasoning.effort`. Omitted otherwise.
supported_parametersarray<string>List of supported parameters for this model
supported_voicesarray | nullList of supported voice identifiers for TTS models. Null for non-TTS models.
top_providerobjectInformation about the top provider for this model
top_provider.context_lengthinteger | nullContext length from the top provider
top_provider.is_moderatedbooleanWhether the top provider moderates content
top_provider.max_completion_tokensinteger | nullMaximum completion tokens from the top provider. Input and output tokens share the context window, so the effective maximum output for a request is further limited by the context remaining after input tokens.

文本向量

POST /openai/v1/embeddings● 支持

OpenAI 官方文档 ↗

请求体

  • modelstring必填

    The model to use for embeddings

    已验证生效。

  • dimensionsinteger可选◐ 部分支持

    The number of dimensions for the output embeddings

    仅 text-embedding-3-small、qwen3-vl-embedding 支持已测的 256 维;text-embedding-3-small 也支持 512,100 返回 400。bge-m3、qwen3-embedding-0.6b、doubao-embedding-vision 的 256 维返回 400。

  • encoding_formatstring可选

    The format of the output embeddings

    float 与 base64 均支持;base64 为向量的二进制编码。

    取值 floatbase64
  • inputstring | array必填◐ 部分支持

    Text, token, or multimodal input(s) to embed

    文本及文本数组生效;token 整数数组返回 400。图片仅 qwen3-vl-embedding、doubao-embedding-vision 支持;text-embedding-3-small 的 16 条批量返回 400。

  • input_typestring可选◐ 部分支持

    The type of input (e.g. search_query, search_document)

    query/document 在 bge-m3、qwen3-embedding-0.6b 生效;search_query 返回 400;text-embedding-3-small 接受但当前不生效。

  • providerobject可选◐ 部分支持

    Provider routing preferences for the request.

    bge-m3、qwen3-embedding-0.6b 返回 400;text-embedding-3-small 接受,但效果不可观测。

    ▸ 展开子字段(13)
    • allow_fallbacksboolean可选

      Whether to allow backup providers to serve requests - true: (default) when the primary provider (or your custom providers in "order") is unavailable, use the next best provider. - false: use only the primary/custom provider, and return the upstream error if it's unavailable.

    • data_collectionstring可选

      Data collection setting. If no available model provider meets the requirement, your request will return an error. - allow: (default) allow providers which store user data non-transiently and may train on it - deny: use only providers which do not collect user data.

      取值 denyallownull
    • enforce_distillable_textboolean可选

      Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used.

    • ignorearray可选

      List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request.

    • max_priceobject可选

      The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.

    • onlyarray可选

      List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request.

    • orderarray可选

      An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message.

    • preferred_max_latencynumber | object可选

      Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold.

    • preferred_min_throughputnumber | object可选

      Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold.

    • quantizationsarray可选

      A list of quantization levels to filter the provider by.

    • require_parametersboolean可选

      Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest.

    • sortstring | object可选

      The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed.

    • zdrboolean可选

      Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used.

  • session_idstring可选◐ 部分支持

    A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.

    bge-m3、qwen3-embedding-0.6b 返回 400;text-embedding-3-small 接受,但效果不可观测。

  • traceobject可选◐ 部分支持

    Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.

    bge-m3、qwen3-embedding-0.6b 返回 400;text-embedding-3-small 接受,但效果不可观测。

    ▸ 展开子字段(5)
    • generation_namestring可选

      Name of this generation in the trace.

    • parent_span_idstring可选

      Id of the parent span in the trace.

    • span_namestring可选

      Name of this request's span in the trace.

    • trace_idstring可选

      Id that groups several requests into one trace.

    • trace_namestring可选

      Name of the trace.

  • userstring可选◐ 部分支持

    A unique identifier for the end-user

    bge-m3、qwen3-embedding-0.6b 返回 400;text-embedding-3-small 接受,但效果不可观测。

返回

200 list

转发方式与对话(chat completions)一致,用量算在同一份计费里。 未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Embedding response

application/json

名称类型说明
dataarray<object>List of embedding objects
data[].embeddingarray<number> | stringEmbedding vector as an array of floats or a base64 string
data[].indexintegerIndex of the embedding in the input list
data[].objectstring
idstringUnique identifier for the embeddings response
modelstringThe model used for embeddings
objectstring
usageobjectToken usage statistics
usage.costnumberCost of the request in credits
usage.cost_detailsobject | nullBreakdown of upstream inference costs
usage.is_byokbooleanWhether a request was made using a Bring Your Own Key configuration
usage.prompt_tokensintegerNumber of tokens in the input
usage.prompt_tokens_detailsobjectPer-modality token breakdown. Only present when the input contains 2+ modalities (e.g. text + image) and the upstream provider returns modality-level usage data. Only non-zero modality counts are included.
usage.total_tokensintegerTotal number of tokens used

text/event-stream — chunk / 事件对象

名称类型说明
$stringNot used for embeddings - embeddings do not support streaming

创建视频

POST /openai/v1/videos● 支持

OpenAI 官方文档 ↗

请求体

  • modelstring可选◐ 部分支持

    Video model id, for example `wan2.7-t2v`; list candidates with listModels?type=video. Router support (partial): Select a registered video model explicitly, for example wan2.7-t2v (size=1280x720, seconds=4). Capability preflight errors are reported before creation.

    请显式选择已注册的视频模型,例如 wan2.7-t2v(size=1280x720,seconds=4)。能力预检失败会在创建前报错。

  • promptstring必填

    Text description of the video, at least 1 character. Router support (supported): Controls video content; missing or empty values return 400.

    控制视频内容;缺失或空值返回 400。

  • secondsstring | integer可选

    同时提供时优先于 duration。

    已验证 wan2.7-t2v 的时长生效;不合法或超出模型能力的值在预检阶段返回 400。

  • durationinteger可选

    Length of the video in whole seconds. `seconds` takes precedence when both are given.

  • sizestring可选◐ 部分支持

    Output resolution as `WIDTHxHEIGHT`, for example `1280x720`. Router support (partial): Subject to model capability preflight. Earlier wan2.7-t2v samples always produced 1280x720; accepted sizes are not guaranteed pixel-for-pixel.

    受模型能力预检限制;早期 wan2.7-t2v 样本始终输出 1280x720,不保证所有接受的尺寸都会按像素兑现。

  • input_referencestring | object可选

    Reference image for image-to-video: a URL or base64 data URL, an object with `image_url`, or an uploaded image file (multipart, at most 20 MiB).

    ▸ 展开子字段(1)
    • image_urlstring | object必填

      URL or base64 data URL of the reference image, as a string or an object with `url`.

  • input_referencesarray可选

    Several reference images; each entry is a URL or base64 data URL, or an object with `image_url`.

    ▸ 展开子字段(1)
    • image_urlstring | object可选

      URL or base64 data URL of the reference image, as a string or an object with `url`.

  • frame_imagesarray可选

    Images that pin the first and last frame; at most 2 entries.

    ▸ 展开子字段(3)
    • typeany可选

      Always `image_url`. Discriminator of the `type`-tagged union this object belongs to.

    • frame_typeany必填

      Frame to constrain with the supplied image: first_frame or last_frame. Each frame type may occur at most once.

      取值 first_framelast_frame
    • image_urlobject必填

      The image to pin.

  • resolutionstring可选

    Output resolution label such as `720p`, for models that take a label instead of `size`.

  • aspect_ratiostring可选

    Aspect ratio of the video such as `16:9`.

  • ▸ 更多参数(4)
    • generate_audioboolean可选

      Whether the video carries a generated audio track. Router support (supported): false produces no audio track on wan2.7-t2v; the default output includes audio.

      wan2.7-t2v 的 false 输出无音轨,默认输出含音轨。

    • seedinteger可选

      Seed for reproducible generation, on models that support it.

    • callback_urlstring可选

      HTTP or HTTPS callback URL, forwarded to models that support completion callbacks.

    • qualitystring可选

      Provider-specific quality setting.

返回

200 video

异步生成视频:创建任务后轮询状态,完成后下载内容。按输出秒数计费,每秒价格见 GET /model/v1/models 的 pricing.video_second(USD/秒)。请显式选择已注册的视频模型,例如 wan2.7-t2v。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Success

application/json

名称类型说明
idstringId of the video job; pass it as `video_id` to retrieve, download or delete it.
objectstringObject type; always `video`.
modelstringModel that generates the video.
statusstringLifecycle of the job. Poll until it is `completed` or `failed`.
progressintegerProgress from 0 to 100. It is 0 until the job completes and 100 once it has.
created_atintegerUnix time in seconds at which the job was created.
completed_atinteger | nullUnix time in seconds at which the job completed; null until then.
expires_atinteger | nullUnix time in seconds after which the output expires; null because outputs currently have no expiry.
secondsstringLength of the video in seconds, as a string; for a completed job it is the delivered length.
sizestringResolution of the video as `WIDTHxHEIGHT`; null when the provider did not report one.
promptstring | nullPrompt the job was created with.
remixed_from_video_idnullAlways null; remix is not supported.
errorobject | nullWhy the job failed; null unless status is `failed`.
error.codestringMachine-readable failure code.
error.messagestringHuman-readable failure message.
polling_urlstringRelative URL to poll for the job state; same as retrieveVideo for this job.
unsigned_urlsarray<string>Relative URLs of the finished output; empty until the video is ready. Download them with the same API key.
usageobjectCost of the job; present once a price applies.
usage.costnumberCost of the job in USD: delivered seconds times the per-second price once completed, 0 while running.

列出视频

GET /openai/v1/videos● 支持

OpenAI 官方文档 ↗

请求参数

  • afterstring可选

    query: Cursor: the id of the video job after which the page starts, normally the `last_id` of the previous page. It must refer to an existing job of yours, otherwise the call fails.

    分页参数生效;limit 为 1–100,order 为 asc/desc,after 必须引用存在的任务。

  • limitinteger可选
    默认 20

    query: Maximum number of jobs per page, from 1 to 100; defaults to 20.

    分页参数生效;limit 为 1–100,order 为 asc/desc,after 必须引用存在的任务。

  • orderany可选
    默认 "desc"

    query: Sort order by creation time: desc (default) lists the newest job first, asc the oldest first.

    分页参数生效;limit 为 1–100,order 为 asc/desc,after 必须引用存在的任务。

    取值 ascdesc

返回

200 list

列出本账号的视频任务。limit 为 1 到 100,order 为 asc 或 desc,after 必须引用存在的任务。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Success

application/json

名称类型说明
objectstringObject type; always `list`.
dataarray<object>Video jobs of the caller, newest first by default.
data[].idstringId of the video job; pass it as `video_id` to retrieve, download or delete it.
data[].objectstringObject type; always `video`.
data[].modelstringModel that generates the video.
data[].statusstringLifecycle of the job. Poll until it is `completed` or `failed`.
data[].progressintegerProgress from 0 to 100. It is 0 until the job completes and 100 once it has.
data[].created_atintegerUnix time in seconds at which the job was created.
data[].completed_atinteger | nullUnix time in seconds at which the job completed; null until then.
data[].expires_atinteger | nullUnix time in seconds after which the output expires; null because outputs currently have no expiry.
data[].secondsstringLength of the video in seconds, as a string; for a completed job it is the delivered length.
data[].sizestringResolution of the video as `WIDTHxHEIGHT`; null when the provider did not report one.
data[].promptstring | nullPrompt the job was created with.
data[].remixed_from_video_idnullAlways null; remix is not supported.
data[].errorobject | nullWhy the job failed; null unless status is `failed`.
data[].polling_urlstringRelative URL to poll for the job state; same as retrieveVideo for this job.
data[].unsigned_urlsarray<string>Relative URLs of the finished output; empty until the video is ready. Download them with the same API key.
data[].usageobjectCost of the job; present once a price applies.
has_morebooleanWhether more jobs exist beyond this page; pass `last_id` as `after` to read them.
first_idstring | nullId of the first job in this page; null for an empty page.
last_idstring | nullId of the last job in this page; null for an empty page.

读取视频

先调用「创建视频」,用返回的 ID 替换 video_123;下载前须轮询至 completed。

GET /openai/v1/videos/{video_id}● 支持

OpenAI 官方文档 ↗

请求参数

  • video_idstring必填

    path: Id of the video job whose output you want, the `id` returned by createVideo. The job must be completed; before that the call answers 400.

返回

200 video

读取任务的当前状态和进度。status 为 queued 或 in_progress 时继续轮询,failed 时查看 error,completed 后才能下载内容。任务不存在返回 404。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Success

application/json

名称类型说明
idstringId of the video job; pass it as `video_id` to retrieve, download or delete it.
objectstringObject type; always `video`.
modelstringModel that generates the video.
statusstringLifecycle of the job. Poll until it is `completed` or `failed`.
progressintegerProgress from 0 to 100. It is 0 until the job completes and 100 once it has.
created_atintegerUnix time in seconds at which the job was created.
completed_atinteger | nullUnix time in seconds at which the job completed; null until then.
expires_atinteger | nullUnix time in seconds after which the output expires; null because outputs currently have no expiry.
secondsstringLength of the video in seconds, as a string; for a completed job it is the delivered length.
sizestringResolution of the video as `WIDTHxHEIGHT`; null when the provider did not report one.
promptstring | nullPrompt the job was created with.
remixed_from_video_idnullAlways null; remix is not supported.
errorobject | nullWhy the job failed; null unless status is `failed`.
error.codestringMachine-readable failure code.
error.messagestringHuman-readable failure message.
polling_urlstringRelative URL to poll for the job state; same as retrieveVideo for this job.
unsigned_urlsarray<string>Relative URLs of the finished output; empty until the video is ready. Download them with the same API key.
usageobjectCost of the job; present once a price applies.
usage.costnumberCost of the job in USD: delivered seconds times the per-second price once completed, 0 while running.

下载视频内容

先调用「创建视频」,用返回的 ID 替换 video_123;下载前须轮询至 completed。

GET /openai/v1/videos/{video_id}/content● 支持

OpenAI 官方文档 ↗

请求参数

  • video_idstring必填

    path: Id of the video job whose output you want, the `id` returned by createVideo. The job must be completed; before that the call answers 400.

  • variantany可选◐ 部分支持
    默认 "video"

    query: Spritesheet is not available in this release (400).

    video、thumbnail 生效;spritesheet 返回 400。

    取值 videothumbnailspritesheet
  • indexinteger可选◐ 部分支持

    query: Output index; this release produces index 0. variant takes precedence.

    视频仅支持 index=0;大于 0 或负数返回 400。variant=thumbnail 时 index 接受但当前不生效。

返回

200

任务 completed 后下载视频文件(video,MP4)或缩略图(thumbnail);spritesheet 返回 400,index 只支持 0。任务不存在返回 404。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Video or thumbnail bytes

video/mp4

名称类型说明
$string (binary)

image/jpeg

名称类型说明
$string (binary)

删除视频

先调用「创建视频」,用返回的 ID 替换 video_123;下载前须轮询至 completed。

DELETE /openai/v1/videos/{video_id}● 支持

OpenAI 官方文档 ↗

请求参数

  • video_idstring必填

    path: Id of the video job whose output you want, the `id` returned by createVideo. The job must be completed; before that the call answers 400.

返回

200 video.deleted

删除任务及其生成的内容。任务不存在返回 404。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Success

application/json

名称类型说明
idstringId of the deleted video job.
objectstringObject type; always `video.deleted`.
deletedbooleanAlways true; the job is no longer readable.

先调用「创建视频」,用返回的 ID 替换 video_123;下载前须轮询至 completed。

POST /openai/v1/videos/{video_id}/remix○ 未支持

OpenAI 官方文档 ↗

请求参数

  • video_idstring必填

    path: Id of the video job whose output you want, the `id` returned by createVideo. The job must be completed; before that the call answers 400.

返回

400 混剪尚未支持,请勿重试。

未支持,调用固定返回 400(invalid_request_error,消息为 Video remix is not supported);不要重试。

错误按 OpenAI 格式返回,参见 错误码

响应

此端点没有声明成功响应。

转写音频

POST /openai/v1/audio/transcriptions● 支持

OpenAI 官方文档 ↗

请求体

  • modelstring必填

    已验证生效。

  • temperaturenumber可选○ 未支持

    whisper-large-v3-turbo、qwen3-asr-flash 均返回 400。

  • response_formatstring可选◐ 部分支持
    默认 "json"

    json/text 均生效;verbose_json 仅 whisper-large-v3-turbo 支持。srt/vtt 均返回 400。

    取值 jsontextverbose_json
  • filestring必填

    已验证生效。

  • languagestring可选◐ 部分支持

    两模型接受 ISO 语言码;qwen3-asr-flash 可能按指定语言翻译输出,whisper-large-v3-turbo 用作输入语言提示。非 ISO 名称可能报 502。

  • promptstring可选◐ 部分支持

    仅 whisper-large-v3-turbo 的词表提示已验证生效;qwen3-asr-flash 返回 400。

  • timestamp_granularities[]array可选◐ 部分支持

    仅 whisper-large-v3-turbo 在 verbose_json 下支持 segment;word 返回 400;qwen3-asr-flash 不支持时间戳。

返回

200

标准请求字段;不能表达的参数返回 input_not_representable。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

Transcription in the requested format.

text/plain

名称类型说明
$string

application/json

名称类型说明
textstring
taskstring
languagestring
durationnumber
segmentsarray<object>
segments[].idinteger
segments[].startnumber
segments[].endnumber
segments[].textstring
segments[].temperaturenumber
segments[].avg_logprobnumber
segments[].compression_rationumber
segments[].no_speech_probnumber

POST /openai/v1/files◐ 部分支持

OpenAI 官方文档 ↗

请求体

  • filestring必填

    The File object (not file name) to be uploaded.

    已验证生效。

  • purposestring必填◐ 部分支持

    文件用途:user_data、assistants 或 vision(vision 只接受 PNG、JPEG、GIF、WebP 图片)。OpenAI 的 batch、fine-tune、evals 等其余用途不支持,返回 400 PURPOSE_UNSUPPORTED。

    支持 user_data、assistants、vision;batch、fine-tune、evals 等其余值返回 400。

    取值 user_dataassistantsvision
  • expires_afterobject可选

    The expiration policy for a file. By default, files with `purpose=batch` expire after 30 days and all other files are persisted until they are manually deleted.

    anchor=created_at,seconds=3600–2592000。

    ▸ 展开子字段(2)
    • anchorstring必填

      Anchor timestamp after which the expiration policy applies. Supported anchors: `created_at`.

      取值 created_at
    • secondsinteger必填

      The number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).

返回

200 file

单文件最多 100 MB(104857600 字节);按内容识别 PDF、Office、图片、音频、视频与 UTF-8 文本。purpose 支持 user_data / assistants / vision;其他用途、空文件、不支持类型和超限均返回 400。不支持 Uploads 分片。只接受表单 file、purpose、expires_after[anchor]、expires_after[seconds];其他表单字段或任何查询参数返回 400 invalid_request_error,消息为 "Unrecognized request argument supplied: <字段>",param 为该字段。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

OK

application/json

名称类型说明
idstringThe file identifier, which can be referenced in the API endpoints.
bytesintegerThe size of the file, in bytes.
created_atintegerThe Unix timestamp (in seconds) for when the file was created.
expires_atintegerThe Unix timestamp (in seconds) for when the file will expire.
filenamestringThe name of the file.
objectstringThe object type, which is always `file`.
purposestringThe intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.
statusstringDeprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
status_detailsstringDeprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.

列出文件

GET /openai/v1/files● 支持

OpenAI 官方文档 ↗

请求参数

  • purposestring可选

    query: Only return files with the given purpose.

    已验证生效。

  • limitinteger可选
    默认 10000

    query: A limit on the number of objects to be returned. Limit can range between 1 and 10,000, and the default is 10,000.

    已验证生效。

  • orderstring可选
    默认 "desc"

    query: Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

    已验证生效。

    取值 ascdesc
  • afterstring可选

    query: A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

    已验证生效。

返回

200 list

只接受查询参数 after、order、limit、purpose;其他查询参数返回 400 invalid_request_error,消息为 "Unrecognized request argument supplied: <参数>",param 为该参数。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

OK

application/json

名称类型说明
objectstring
dataarray<object>
data[].idstringThe file identifier, which can be referenced in the API endpoints.
data[].bytesintegerThe size of the file, in bytes.
data[].created_atintegerThe Unix timestamp (in seconds) for when the file was created.
data[].expires_atintegerThe Unix timestamp (in seconds) for when the file will expire.
data[].filenamestringThe name of the file.
data[].objectstringThe object type, which is always `file`.
data[].purposestringThe intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.
data[].statusstringDeprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
data[].status_detailsstringDeprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.
first_idstring
last_idstring
has_moreboolean

检索文件

先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。

GET /openai/v1/files/{file_id}● 支持

OpenAI 官方文档 ↗

请求参数

  • file_idstring必填

    path: The ID of the file to use for this request.

返回

200 file

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

OK

application/json

名称类型说明
idstringThe file identifier, which can be referenced in the API endpoints.
bytesintegerThe size of the file, in bytes.
created_atintegerThe Unix timestamp (in seconds) for when the file was created.
expires_atintegerThe Unix timestamp (in seconds) for when the file will expire.
filenamestringThe name of the file.
objectstringThe object type, which is always `file`.
purposestringThe intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.
statusstringDeprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
status_detailsstringDeprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.

删除文件

先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。

DELETE /openai/v1/files/{file_id}● 支持

OpenAI 官方文档 ↗

请求参数

  • file_idstring必填

    path: The ID of the file to use for this request.

返回

200 file

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

OK

application/json

名称类型说明
idstring
objectstring
deletedboolean

检索文件内容

先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。

GET /openai/v1/files/{file_id}/content● 支持

OpenAI 官方文档 ↗

请求参数

  • file_idstring必填

    path: The ID of the file to use for this request.

返回

200

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

OK

application/octet-stream

名称类型说明
$string (binary)

知识库

官方 openai Python SDK 可直接使用知识库、文件和批次操作。两个地址访问同一份数据。

https://api.deepraxis.ai/openai/v1

快速开始:官方 Python SDK

当前差异

搜索按块返回,同一文件可能出现多次;max_num_results 计算块数。rewrite_query 为 true 时先用小模型改写查询(按模型用量计费,失败时回退原查询),改写所用模型只能在原生 API 的 models 中设置,兼容接口传 models 返回 400。搜索 has_more 恒为 false、next_page 恒为 null。description 接受后丢弃。expand=files 与 expand[]=files 为 Praxis 扩展;未知值忽略。

删除知识库后保留 7 天,读取仍可返回 200 completed,但写入和搜索返回 409。恢复、失败重试、分段、事件和混合搜索权重请使用原生 API;兼容接口不返回 praxis、chunk_id、page 或 span。usage_bytes 为抽取文本块的字节数。未知请求字段当前会被忽略。

原生 API · 错误码

方法路径操作
POST/openai/v1/vector_stores创建知识库
GET/openai/v1/vector_stores列出知识库
GET/openai/v1/vector_stores/{vector_store_id}读取知识库
POST/openai/v1/vector_stores/{vector_store_id}更新知识库
DELETE/openai/v1/vector_stores/{vector_store_id}删除知识库
POST/openai/v1/vector_stores/{vector_store_id}/search搜索知识库
POST/openai/v1/vector_stores/{vector_store_id}/files添加文件
GET/openai/v1/vector_stores/{vector_store_id}/files列出文件
GET/openai/v1/vector_stores/{vector_store_id}/files/{file_id}读取文件
POST/openai/v1/vector_stores/{vector_store_id}/files/{file_id}更新文件属性
DELETE/openai/v1/vector_stores/{vector_store_id}/files/{file_id}移除文件
GET/openai/v1/vector_stores/{vector_store_id}/files/{file_id}/content读取抽取内容
POST/openai/v1/vector_stores/{vector_store_id}/file_batches创建文件批次
GET/openai/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}读取文件批次
POST/openai/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel取消文件批次
GET/openai/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/files列出批次文件

创建知识库

POST /openai/v1/vector_stores

创建知识库。可用 file_ids 添加已有 File 并异步入库;后续调用使用返回的 id。最小请求体:{"name":"Refund policies"}。

请求体

字段类型说明
namestring可选; 省略时为空字符串;不接受 null。; 最长字符数: 256; 默认: ""
metadataobject / null可选; 知识库自定义字符串元数据;省略或 null 得到空对象。; 默认: {}
expires_afterobject / null可选; 从最近活动计算的过期策略;省略或 null 表示不自动过期。; 默认: null
expires_after (1).anchor"last_active_at"必填; last_active_at 表示从最近活动时间开始计算过期。
expires_after (1).daysinteger必填; 自最近活动起的天数;添加文件和搜索会刷新活动时间。; 最小: 1; 最大: 365
file_idsstring[]可选; 要加入的已有文件 ID;每库最多 10,000 个文件。
chunking_strategyobject / object可选; auto 等同于每段 800 token、重叠 400 token。; 默认: {"type":"auto"}
chunking_strategy (1).type"auto"必填; auto 使用默认静态分段:800 个估算 token,重叠 400 个。
chunking_strategy (2).type"static"必填; static 表示使用显式分段大小与重叠设置。
chunking_strategy (2).staticobject必填; 以估算 token 数表示的分段大小与重叠限制。
chunking_strategy (2).static.max_chunk_size_tokensinteger必填; 每段的估算 token 数。; 最小: 100; 最大: 4096
chunking_strategy (2).static.chunk_overlap_tokensinteger必填; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
descriptionstring可选; 不生效: 接受后丢弃,不保存也不返回;当前不校验类型。

请求示例

curl -X POST "https://api.deepraxis.ai/openai/v1/vector_stores" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"name\":\"Refund policies\"}"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store"必有; 对象标记;vector_store 表示知识库。
namestring必有; 知识库显示名称;空字符串表示未设置名称。; 最长字符数: 256
status"in_progress" / "completed" / "expired"必有; in_progress 表示仍有文件入库中;completed 表示没有入库中的文件,不保证全部成功;expired 表示过期策略已生效。
usage_bytesinteger必有; 已完成源文件的字节数之和。; 最小: 0
file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。
last_active_atinteger / null必有; 最近创建、添加文件或搜索的 Unix 秒时间戳;不可用时为 null。
expires_afterobject / null必有; 从最近活动开始计算的过期策略;null 表示不自动过期。
expires_after (1).anchor"last_active_at"必有; last_active_at 表示从最近活动时间开始计算过期。
expires_after (1).daysinteger必有; 自最近活动起的天数;添加文件和搜索会刷新活动时间。; 最小: 1; 最大: 365
expires_atinteger / null必有; 预计过期的 Unix 秒时间戳;未设置过期策略时为 null。
metadataobject必有; 最多 16 个键;键最多 64 字符;字符串值最多 512 字符。; 最多键数: 16; 键最多 64 字符; 值: string

错误码与错误对象

列出知识库

GET /openai/v1/vector_stores

列出调用方可见的知识库,默认最新在前。将 last_id 作为 after 读取下一页,例如 ?limit=20。

参数

名称位置与类型说明
afterquery: string上一页的 ID 游标。 最短字符数: 1
beforequery: string返回此 ID 之前的条目。 最短字符数: 1
limitquery: integer每页条数。 最小: 1; 最大: 100; 默认: 20
orderquery: "asc" / "desc"知识库和文件默认按创建时间降序;分段默认按序号升序。 默认: "desc"

请求示例

curl -X GET "https://api.deepraxis.ai/openai/v1/vector_stores" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
object"list"必有; 对象标记;list 表示游标分页集合。
dataobject[]必有; 按请求顺序返回的当前页条目。
data[].idstring必有; 资源 ID。; 最短字符数: 1
data[].object"vector_store"必有; 对象标记;vector_store 表示知识库。
data[].namestring必有; 知识库显示名称;空字符串表示未设置名称。; 最长字符数: 256
data[].status"in_progress" / "completed" / "expired"必有; in_progress 表示仍有文件入库中;completed 表示没有入库中的文件,不保证全部成功;expired 表示过期策略已生效。
data[].usage_bytesinteger必有; 已完成源文件的字节数之和。; 最小: 0
data[].file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
data[].file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
data[].file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
data[].file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
data[].file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
data[].file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
data[].created_atinteger必有; Unix 时间戳,单位秒。
data[].last_active_atinteger / null必有; 最近创建、添加文件或搜索的 Unix 秒时间戳;不可用时为 null。
data[].expires_afterobject / null必有; 从最近活动开始计算的过期策略;null 表示不自动过期。
data[].expires_after (1).anchor"last_active_at"必有; last_active_at 表示从最近活动时间开始计算过期。
data[].expires_after (1).daysinteger必有; 自最近活动起的天数;添加文件和搜索会刷新活动时间。; 最小: 1; 最大: 365
data[].expires_atinteger / null必有; 预计过期的 Unix 秒时间戳;未设置过期策略时为 null。
data[].metadataobject必有; 最多 16 个键;键最多 64 字符;字符串值最多 512 字符。; 最多键数: 16; 键最多 64 字符; 值: string
first_idstring / null必有; 本页首项的 ID;空页为 null。
last_idstring / null必有; 本页末项的 ID,可作为 after 继续查询;空页为 null。
has_moreboolean必有; 当前游标范围内,本页之后是否还有条目。

错误码与错误对象

读取知识库

GET /openai/v1/vector_stores/{vector_store_id}

使用创建或列表返回的 id 读取知识库。添加 ?expand=files 可同时返回附件首页。已删除的库返回 404。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
expandquery: "files"[]两个地址均支持的 Praxis 扩展:files 附带文件首页;未知值忽略。
expand[]query: "files"[]两个地址均支持的 Praxis 扩展:files 附带文件首页;未知值忽略。

请求示例

curl -X GET "https://api.deepraxis.ai/openai/v1/vector_stores/${VECTOR_STORE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
(1).idstring必有; 资源 ID。; 最短字符数: 1
(1).object"vector_store"必有; 对象标记;vector_store 表示知识库。
(1).namestring必有; 知识库显示名称;空字符串表示未设置名称。; 最长字符数: 256
(1).status"in_progress" / "completed" / "expired"必有; in_progress 表示仍有文件入库中;completed 表示没有入库中的文件,不保证全部成功;expired 表示过期策略已生效。
(1).usage_bytesinteger必有; 已完成源文件的字节数之和。; 最小: 0
(1).file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
(1).file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
(1).file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
(1).file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
(1).file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
(1).file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
(1).created_atinteger必有; Unix 时间戳,单位秒。
(1).last_active_atinteger / null必有; 最近创建、添加文件或搜索的 Unix 秒时间戳;不可用时为 null。
(1).expires_afterobject / null必有; 从最近活动开始计算的过期策略;null 表示不自动过期。
(1).expires_after (1).anchor"last_active_at"必有; last_active_at 表示从最近活动时间开始计算过期。
(1).expires_after (1).daysinteger必有; 自最近活动起的天数;添加文件和搜索会刷新活动时间。; 最小: 1; 最大: 365
(1).expires_atinteger / null必有; 预计过期的 Unix 秒时间戳;未设置过期策略时为 null。
(1).metadataobject必有; 最多 16 个键;键最多 64 字符;字符串值最多 512 字符。; 最多键数: 16; 键最多 64 字符; 值: string
(2).filesobject可选; 仅在 expand=files 时返回文件首页。
(2).files.object"list"必有; 对象标记;list 表示游标分页集合。
(2).files.dataobject[]必有; 按请求顺序返回的当前页条目。
(2).files.data[].idstring必有; 与源文件相同的 ID。; 最短字符数: 1
(2).files.data[].object"vector_store.file"必有; 对象标记;vector_store.file 表示知识库中的附件。
(2).files.data[].vector_store_idstring必有; 资源 ID。; 最短字符数: 1
(2).files.data[].status"in_progress" / "completed" / "cancelled" / "failed"必有; in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。
(2).files.data[].last_errorobject / null必有; 入库失败详情;未失败、成功完成或重新入库时为 null。
(2).files.data[].last_error (1).code"server_error" / "unsupported_file" / "invalid_file"必有; unsupported_file 表示不支持的文件类型;invalid_file 表示加密、空文件或超过解析 token 上限;server_error 表示其它入库失败或超过截止时间。
(2).files.data[].last_error (1).messagestring必有; 与 code 对应的入库失败说明。
(2).files.data[].usage_bytesinteger必有; 完成后计入源文件字节数;处理中、失败或已取消时为零。; 最小: 0
(2).files.data[].created_atinteger必有; Unix 时间戳,单位秒。
(2).files.data[].chunking_strategyobject / object必有; 此附件已保存的分段策略;auto 输入返回为具体 static 设置。
(2).files.data[].chunking_strategy (1).type"static"必有; static 表示使用显式分段大小与重叠设置。
(2).files.data[].chunking_strategy (1).staticobject必有; 以估算 token 数表示的分段大小与重叠限制。
(2).files.data[].chunking_strategy (1).static.max_chunk_size_tokensinteger必有; 每段的估算 token 数。; 最小: 100; 最大: 4096
(2).files.data[].chunking_strategy (1).static.chunk_overlap_tokensinteger必有; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
(2).files.data[].chunking_strategy (2).type"other"必有
(2).files.data[].attributesobject / null必有; 用于搜索筛选的文件属性;null 表示未设置。
(2).files.first_idstring / null必有; 本页首项的 ID;空页为 null。
(2).files.last_idstring / null必有; 本页末项的 ID,可作为 after 继续查询;空页为 null。
(2).files.has_moreboolean必有; 当前游标范围内,本页之后是否还有条目。

错误码与错误对象

更新知识库

POST /openai/v1/vector_stores/{vector_store_id}

使用返回的 id 修改活跃知识库。省略的字段不变;metadata 替换整个对象。请求体示例:{"name":"Refund policies"}。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1

请求体

字段类型说明
namestring / null可选; null 将名称清空为空字符串;省略的字段不变。
metadataobject / null可选; 替换全部元数据;null 清空为一个空对象。
expires_afterobject / null可选; null 取消自动过期。
expires_after (1).anchor"last_active_at"必填; last_active_at 表示从最近活动时间开始计算过期。
expires_after (1).daysinteger必填; 自最近活动起的天数;添加文件和搜索会刷新活动时间。; 最小: 1; 最大: 365

请求示例

curl -X POST "https://api.deepraxis.ai/openai/v1/vector_stores/${VECTOR_STORE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"name\":\"Support policies\"}"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store"必有; 对象标记;vector_store 表示知识库。
namestring必有; 知识库显示名称;空字符串表示未设置名称。; 最长字符数: 256
status"in_progress" / "completed" / "expired"必有; in_progress 表示仍有文件入库中;completed 表示没有入库中的文件,不保证全部成功;expired 表示过期策略已生效。
usage_bytesinteger必有; 已完成源文件的字节数之和。; 最小: 0
file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。
last_active_atinteger / null必有; 最近创建、添加文件或搜索的 Unix 秒时间戳;不可用时为 null。
expires_afterobject / null必有; 从最近活动开始计算的过期策略;null 表示不自动过期。
expires_after (1).anchor"last_active_at"必有; last_active_at 表示从最近活动时间开始计算过期。
expires_after (1).daysinteger必有; 自最近活动起的天数;添加文件和搜索会刷新活动时间。; 最小: 1; 最大: 365
expires_atinteger / null必有; 预计过期的 Unix 秒时间戳;未设置过期策略时为 null。
metadataobject必有; 最多 16 个键;键最多 64 字符;字符串值最多 512 字符。; 最多键数: 16; 键最多 64 字符; 值: string

错误码与错误对象

删除知识库

DELETE /openai/v1/vector_stores/{vector_store_id}

删除后读取和重复 DELETE 返回 404 not_found_error,列表不含已删除库;自有面可在 7 天内恢复。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1

请求示例

curl -X DELETE "https://api.deepraxis.ai/openai/v1/vector_stores/${VECTOR_STORE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store.deleted"必有; 对象标记;vector_store.deleted 表示此操作回执。
deletedtrue必有; 确认兼容面的知识库删除;后续访问返回未找到。

错误码与错误对象

搜索知识库

POST /openai/v1/vector_stores/{vector_store_id}/search

每文件一条,content 为按分数降序的命中块;max_num_results 计文件,从最多 50 个召回分段聚合。has_more 表示文件结果截断,next_page 仍为 null。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1

请求体

字段类型说明
querystring / string[]必填; 非空白文本;多个查询以换行连接后共同搜索。
filtersobject / object / object可选; 按类型严格匹配文件属性;根条件以下最多嵌套 20 层。
filters (1).type"eq" / "ne" / "gt" / "gte" / "lt" / "lte"必填; eq 等于,ne 不等于,gt 大于,gte 大于等于,lt 小于,lte 小于等于;属性必须存在且值类型一致。
filters (1).keystring必填; 要比较的文件属性原始键名,标点也是键名的一部分。; 最短字符数: 1
filters (1).valuestring / number / boolean必填; 不进行类型转换的比较值。
filters (2).type"in" / "nin"必填; in 匹配数组中的值;nin 匹配不在数组中的值。属性不存在时均不匹配。
filters (2).keystring必填; 要比较的文件属性原始键名,标点也是键名的一部分。; 最短字符数: 1
filters (2).valuestring / number[]必填; 不进行类型转换的字符串或数值成员列表。
filters (3).type"and" / "or"必填; and 要求所有子条件匹配;or 要求至少一个子条件匹配。
filters (3).filtersobject / object / object[]必填; 按选定 and/or 运算符组合的非空子条件列表。; 最少条数: 1
filters (3).filters[]object / object / object递归使用同一筛选结构,嵌套上限 20 层。
max_num_resultsinteger可选; 从最多 50 个召回分段聚合后,最多返回的不同文件数。; 最小: 1; 最大: 50; 默认: 10
rewrite_queryboolean可选; 支持: 为 true 时,先用该库 query_rewrite 角色的模型把每条查询改写为简洁的检索查询;检索使用改写结果,search_query 返回改写后的查询。每次改写是一次小模型调用,按模型用量计费。改写失败、超时(5 秒)或为空时,该条查询回退为原文,搜索照常完成。省略或为 false 时不调用模型。
next_pagestring可选; 不生效: 搜索不支持翻页;提供游标不生效。
ranking_optionsobject可选; 控制结果排序与纳入结果的最低分数。
ranking_options.ranker"none" / "auto" / "default-2024-11-15"可选; 只有 default-2024-11-15 请求重排;none、auto 和省略时使用初始排序。尚未单独实测重排效果。
ranking_options.score_thresholdnumber可选; 最低分数;分数不是相关性概率。尚未单独实测阈值效果。; 最小: 0; 最大: 1; 默认: 0
ranking_options.hybrid_searchobject可选; 不支持: 在 /openai/v1 返回 400 INVALID_PARAMS;设置权重请使用 /knowledge/v1。; Praxis 扩展
ranking_options.hybrid_search.embedding_weightnumber必填; 语义检索相对权重;零表示禁用语义检索。; 最小: 0; 默认: 0.7
ranking_options.hybrid_search.text_weightnumber必填; 关键词检索相对权重;零表示禁用关键词检索。; 最小: 0; 默认: 0.3
praxisobject可选; 不生效: 兼容响应会删除 praxis,包括搜索解释。
praxis.explainboolean可选; 请求生成解释;兼容响应不返回这些解释。

请求示例

curl -X POST "https://api.deepraxis.ai/openai/v1/vector_stores/${VECTOR_STORE_ID}/search" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"query\":\"When will I receive my refund?\",\"max_num_results\":5}"

响应

HTTP 200

字段类型说明
object"vector_store.search_results.page"必有; 对象标记;vector_store.search_results.page 表示搜索结果页。
search_querystring[]必有; 实际用于检索的查询,与输入一一对应;rewrite_query 为 true 时为改写后的查询,否则原样返回。
dataobject[]必有; 每个文件返回一条;content 包含该文件命中的分段。
data[].file_idstring必有; 资源 ID。; 最短字符数: 1
data[].filenamestring必有; 命中文件的源文件名。
data[].scorenumber必有; 该文件命中分段的最高分数。; 最小: 0; 最大: 1
data[].attributesobject / null必有; 用于筛选的当前文件属性;未设置时为 null。
data[].contentobject[]必有; 按分段分数降序排列的命中分段。
data[].content[].type"text"必有; text 表示提取出的文本分段。
data[].content[].textstring必有; 命中分段的提取文本,可能与相邻分段重叠。
has_moreboolean必有; 过滤后的文件数超过 max_num_results 时为 true;next_page 仍为 null。; 支持:
next_pagenull必有; 不生效: 恒为 null,没有下一页搜索结果。

错误码与错误对象

添加文件

POST /openai/v1/vector_stores/{vector_store_id}/files

异步处理。重复加入同一文件返回已有记录,不应用新的属性或分段策略。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1

请求体

字段类型说明
file_idstring必填; 上传文件返回的已有源 File ID;文件必须对调用方可见。; 最短字符数: 1
attributesobject / null可选; 新附件的搜索筛选属性;省略或 null 表示不设置。重复加入已有文件不改变属性。
chunking_strategyobject / object可选; auto 等同于每段 800 token、重叠 400 token。; 默认: {"type":"auto"}
chunking_strategy (1).type"auto"必填; auto 使用默认静态分段:800 个估算 token,重叠 400 个。
chunking_strategy (2).type"static"必填; static 表示使用显式分段大小与重叠设置。
chunking_strategy (2).staticobject必填; 以估算 token 数表示的分段大小与重叠限制。
chunking_strategy (2).static.max_chunk_size_tokensinteger必填; 每段的估算 token 数。; 最小: 100; 最大: 4096
chunking_strategy (2).static.chunk_overlap_tokensinteger必填; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048

请求示例

curl -X POST "https://api.deepraxis.ai/openai/v1/vector_stores/${VECTOR_STORE_ID}/files" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"file_id\":\"${FILE_ID}\"}"

响应

HTTP 200

字段类型说明
idstring必有; 与源文件相同的 ID。; 最短字符数: 1
object"vector_store.file"必有; 对象标记;vector_store.file 表示知识库中的附件。
vector_store_idstring必有; 资源 ID。; 最短字符数: 1
status"in_progress" / "completed" / "cancelled" / "failed"必有; in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。
last_errorobject / null必有; 入库失败详情;未失败、成功完成或重新入库时为 null。
last_error (1).code"server_error" / "unsupported_file" / "invalid_file"必有; unsupported_file 表示不支持的文件类型;invalid_file 表示加密、空文件或超过解析 token 上限;server_error 表示其它入库失败或超过截止时间。
last_error (1).messagestring必有; 与 code 对应的入库失败说明。
usage_bytesinteger必有; 完成后计入源文件字节数;处理中、失败或已取消时为零。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。
chunking_strategyobject / object必有; 此附件已保存的分段策略;auto 输入返回为具体 static 设置。
chunking_strategy (1).type"static"必有; static 表示使用显式分段大小与重叠设置。
chunking_strategy (1).staticobject必有; 以估算 token 数表示的分段大小与重叠限制。
chunking_strategy (1).static.max_chunk_size_tokensinteger必有; 每段的估算 token 数。; 最小: 100; 最大: 4096
chunking_strategy (1).static.chunk_overlap_tokensinteger必有; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
chunking_strategy (2).type"other"必有
attributesobject / null必有; 用于搜索筛选的文件属性;null 表示未设置。

错误码与错误对象

列出文件

GET /openai/v1/vector_stores/{vector_store_id}/files

列出附件及入库状态,默认最新附件在前。使用 last_id 作为 after 继续查询;?filter=failed 筛选可重新入库的失败文件。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
afterquery: string上一页的 ID 游标。 最短字符数: 1
beforequery: string返回此 ID 之前的条目。 最短字符数: 1
limitquery: integer每页条数。 最小: 1; 最大: 100; 默认: 20
orderquery: "asc" / "desc"知识库和文件默认按创建时间降序;分段默认按序号升序。 默认: "desc"
filterquery: "in_progress" / "completed" / "failed" / "cancelled"in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。省略时包含全部状态。

请求示例

curl -X GET "https://api.deepraxis.ai/openai/v1/vector_stores/${VECTOR_STORE_ID}/files" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
object"list"必有; 对象标记;list 表示游标分页集合。
dataobject[]必有; 按请求顺序返回的当前页条目。
data[].idstring必有; 与源文件相同的 ID。; 最短字符数: 1
data[].object"vector_store.file"必有; 对象标记;vector_store.file 表示知识库中的附件。
data[].vector_store_idstring必有; 资源 ID。; 最短字符数: 1
data[].status"in_progress" / "completed" / "cancelled" / "failed"必有; in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。
data[].last_errorobject / null必有; 入库失败详情;未失败、成功完成或重新入库时为 null。
data[].last_error (1).code"server_error" / "unsupported_file" / "invalid_file"必有; unsupported_file 表示不支持的文件类型;invalid_file 表示加密、空文件或超过解析 token 上限;server_error 表示其它入库失败或超过截止时间。
data[].last_error (1).messagestring必有; 与 code 对应的入库失败说明。
data[].usage_bytesinteger必有; 完成后计入源文件字节数;处理中、失败或已取消时为零。; 最小: 0
data[].created_atinteger必有; Unix 时间戳,单位秒。
data[].chunking_strategyobject / object必有; 此附件已保存的分段策略;auto 输入返回为具体 static 设置。
data[].chunking_strategy (1).type"static"必有; static 表示使用显式分段大小与重叠设置。
data[].chunking_strategy (1).staticobject必有; 以估算 token 数表示的分段大小与重叠限制。
data[].chunking_strategy (1).static.max_chunk_size_tokensinteger必有; 每段的估算 token 数。; 最小: 100; 最大: 4096
data[].chunking_strategy (1).static.chunk_overlap_tokensinteger必有; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
data[].chunking_strategy (2).type"other"必有
data[].attributesobject / null必有; 用于搜索筛选的文件属性;null 表示未设置。
first_idstring / null必有; 本页首项的 ID;空页为 null。
last_idstring / null必有; 本页末项的 ID,可作为 after 继续查询;空页为 null。
has_moreboolean必有; 当前游标范围内,本页之后是否还有条目。

错误码与错误对象

读取文件

GET /openai/v1/vector_stores/{vector_store_id}/files/{file_id}

使用添加附件或附件列表返回的 id 读取文件。可轮询此操作,直到 status 离开 in_progress 后确认入库结果。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
file_idpath: string必填;添加附件或附件列表返回的源 File ID。 最短字符数: 1

请求示例

curl -X GET "https://api.deepraxis.ai/openai/v1/vector_stores/${VECTOR_STORE_ID}/files/${FILE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
idstring必有; 与源文件相同的 ID。; 最短字符数: 1
object"vector_store.file"必有; 对象标记;vector_store.file 表示知识库中的附件。
vector_store_idstring必有; 资源 ID。; 最短字符数: 1
status"in_progress" / "completed" / "cancelled" / "failed"必有; in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。
last_errorobject / null必有; 入库失败详情;未失败、成功完成或重新入库时为 null。
last_error (1).code"server_error" / "unsupported_file" / "invalid_file"必有; unsupported_file 表示不支持的文件类型;invalid_file 表示加密、空文件或超过解析 token 上限;server_error 表示其它入库失败或超过截止时间。
last_error (1).messagestring必有; 与 code 对应的入库失败说明。
usage_bytesinteger必有; 完成后计入源文件字节数;处理中、失败或已取消时为零。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。
chunking_strategyobject / object必有; 此附件已保存的分段策略;auto 输入返回为具体 static 设置。
chunking_strategy (1).type"static"必有; static 表示使用显式分段大小与重叠设置。
chunking_strategy (1).staticobject必有; 以估算 token 数表示的分段大小与重叠限制。
chunking_strategy (1).static.max_chunk_size_tokensinteger必有; 每段的估算 token 数。; 最小: 100; 最大: 4096
chunking_strategy (1).static.chunk_overlap_tokensinteger必有; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
chunking_strategy (2).type"other"必有
attributesobject / null必有; 用于搜索筛选的文件属性;null 表示未设置。

错误码与错误对象

更新文件属性

POST /openai/v1/vector_stores/{vector_store_id}/files/{file_id}

替换已有附件的搜索筛选属性,不重新入库。使用附件 id。请求体示例:{"attributes":{"category":"refund"}};null 清空属性。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
file_idpath: string必填;添加附件或附件列表返回的源 File ID。 最短字符数: 1

请求体

字段类型说明
attributesobject / null可选; 替换全部搜索筛选属性;null 清空属性。

请求示例

curl -X POST "https://api.deepraxis.ai/openai/v1/vector_stores/${VECTOR_STORE_ID}/files/${FILE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"attributes\":{\"category\":\"refund\"}}"

响应

HTTP 200

字段类型说明
idstring必有; 与源文件相同的 ID。; 最短字符数: 1
object"vector_store.file"必有; 对象标记;vector_store.file 表示知识库中的附件。
vector_store_idstring必有; 资源 ID。; 最短字符数: 1
status"in_progress" / "completed" / "cancelled" / "failed"必有; in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。
last_errorobject / null必有; 入库失败详情;未失败、成功完成或重新入库时为 null。
last_error (1).code"server_error" / "unsupported_file" / "invalid_file"必有; unsupported_file 表示不支持的文件类型;invalid_file 表示加密、空文件或超过解析 token 上限;server_error 表示其它入库失败或超过截止时间。
last_error (1).messagestring必有; 与 code 对应的入库失败说明。
usage_bytesinteger必有; 完成后计入源文件字节数;处理中、失败或已取消时为零。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。
chunking_strategyobject / object必有; 此附件已保存的分段策略;auto 输入返回为具体 static 设置。
chunking_strategy (1).type"static"必有; static 表示使用显式分段大小与重叠设置。
chunking_strategy (1).staticobject必有; 以估算 token 数表示的分段大小与重叠限制。
chunking_strategy (1).static.max_chunk_size_tokensinteger必有; 每段的估算 token 数。; 最小: 100; 最大: 4096
chunking_strategy (1).static.chunk_overlap_tokensinteger必有; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
chunking_strategy (2).type"other"必有
attributesobject / null必有; 用于搜索筛选的文件属性;null 表示未设置。

错误码与错误对象

移除文件

DELETE /openai/v1/vector_stores/{vector_store_id}/files/{file_id}

返回后立即不再搜索到该文件;不会删除源文件。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
file_idpath: string必填;添加附件或附件列表返回的源 File ID。 最短字符数: 1

请求示例

curl -X DELETE "https://api.deepraxis.ai/openai/v1/vector_stores/${VECTOR_STORE_ID}/files/${FILE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store.file.deleted"必有; 对象标记;vector_store.file.deleted 表示此操作回执。
deletedtrue必有; 确认已从此知识库移出;源 File 未删除。

错误码与错误对象

读取抽取内容

GET /openai/v1/vector_stores/{vector_store_id}/files/{file_id}/content

抽取文本按分段返回,可能重叠。图片内容可能是生成的描述,并非逐字 OCR。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
file_idpath: string必填;添加附件或附件列表返回的源 File ID。 最短字符数: 1

请求示例

curl -X GET "https://api.deepraxis.ai/openai/v1/vector_stores/${VECTOR_STORE_ID}/files/${FILE_ID}/content" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
object"vector_store.file_content.page"必有; 对象标记;vector_store.file_content.page 表示提取的文件内容。
dataobject[]必有; 按分段序号排列的全部现存文本分段;相邻分段可能重叠。
data[].type"text"必有; text 表示提取出的文本分段。
data[].textstring必有; 此分段的提取文本;可能与相邻分段重叠。
has_morefalse必有; 恒为 false;此响应返回全部现存分段。
next_pagenull必有; 恒为 null;提取内容不分页。

错误码与错误对象

创建文件批次

POST /openai/v1/vector_stores/{vector_store_id}/file_batches

批量添加已有 File 并异步入库。file_ids 与 files 必须且只能提供一个;files 支持逐文件设置。已有附件直接复用。使用返回的批次 id 查询进度。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1

请求体

file_ids 与 files 必须且只能提供一个。已有文件直接复用,不修改属性或分段策略。

字段类型说明
(1).file_idsstring[]必填; 使用共同属性和分段设置的已有 File ID 列表。file_ids 与 files 二选一。; 最少条数: 1; 最多条数: 500
(1).attributesobject / null可选; 用于每个新附件的搜索筛选属性;省略或 null 表示不设置。
(1).chunking_strategyobject / object可选; auto 等同于每段 800 token、重叠 400 token。; 默认: {"type":"auto"}
(1).chunking_strategy (1).type"auto"必填; auto 使用默认静态分段:800 个估算 token,重叠 400 个。
(1).chunking_strategy (2).type"static"必填; static 表示使用显式分段大小与重叠设置。
(1).chunking_strategy (2).staticobject必填; 以估算 token 数表示的分段大小与重叠限制。
(1).chunking_strategy (2).static.max_chunk_size_tokensinteger必填; 每段的估算 token 数。; 最小: 100; 最大: 4096
(1).chunking_strategy (2).static.chunk_overlap_tokensinteger必填; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
(2).filesobject[]必填; 分别指定属性和分段设置的附件列表;忽略顶层 attributes 与 chunking_strategy。; 最少条数: 1; 最多条数: 500
(2).files[].file_idstring必填; 上传文件返回的已有源 File ID;文件必须对调用方可见。; 最短字符数: 1
(2).files[].attributesobject可选; 用于搜索筛选的文件属性。最多 16 个键,键最多 64 字符,字符串值最多 512 字符。; 最多键数: 16; 键最多 64 字符; 值: string / number / boolean
(2).files[].chunking_strategyobject / object可选; auto 等同于每段 800 token、重叠 400 token。; 默认: {"type":"auto"}
(2).files[].chunking_strategy (1).type"auto"必填; auto 使用默认静态分段:800 个估算 token,重叠 400 个。
(2).files[].chunking_strategy (2).type"static"必填; static 表示使用显式分段大小与重叠设置。
(2).files[].chunking_strategy (2).staticobject必填; 以估算 token 数表示的分段大小与重叠限制。
(2).files[].chunking_strategy (2).static.max_chunk_size_tokensinteger必填; 每段的估算 token 数。; 最小: 100; 最大: 4096
(2).files[].chunking_strategy (2).static.chunk_overlap_tokensinteger必填; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
(2).attributesJSON可选; 不生效: 使用 files 时不生效。
(2).chunking_strategyJSON可选; 不生效: 使用 files 时不生效。

请求示例

curl -X POST "https://api.deepraxis.ai/openai/v1/vector_stores/${VECTOR_STORE_ID}/file_batches" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"file_ids\":[\"${FILE_ID}\"]}"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store.files_batch"必有; 对象标记;vector_store.files_batch 表示批量附件。
vector_store_idstring必有; 资源 ID。; 最短字符数: 1
status"in_progress" / "completed" / "cancelled" / "failed"必有; cancelled 表示批次已取消;否则 in_progress 表示仍有成员入库中,failed 表示入库结束且有失败成员,completed 表示无入库中或失败成员。取消终态批次不会改变它。
file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。

错误码与错误对象

读取文件批次

GET /openai/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}

读取此知识库中创建的批次,包括当前状态和文件计数。使用创建批次返回的 id 监测入库结果。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
batch_idpath: string必填;此知识库创建批次时返回的文件批次 ID。 最短字符数: 1

请求示例

curl -X GET "https://api.deepraxis.ai/openai/v1/vector_stores/${VECTOR_STORE_ID}/file_batches/${BATCH_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store.files_batch"必有; 对象标记;vector_store.files_batch 表示批量附件。
vector_store_idstring必有; 资源 ID。; 最短字符数: 1
status"in_progress" / "completed" / "cancelled" / "failed"必有; cancelled 表示批次已取消;否则 in_progress 表示仍有成员入库中,failed 表示入库结束且有失败成员,completed 表示无入库中或失败成员。取消终态批次不会改变它。
file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。

错误码与错误对象

取消文件批次

POST /openai/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel

只取消处理中的批次和文件。已完成、失败或已取消的批次原样返回(200,幂等),计数不变。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
batch_idpath: string必填;此知识库创建批次时返回的文件批次 ID。 最短字符数: 1

请求示例

curl -X POST "https://api.deepraxis.ai/openai/v1/vector_stores/${VECTOR_STORE_ID}/file_batches/${BATCH_ID}/cancel" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store.files_batch"必有; 对象标记;vector_store.files_batch 表示批量附件。
vector_store_idstring必有; 资源 ID。; 最短字符数: 1
status"in_progress" / "completed" / "cancelled" / "failed"必有; cancelled 表示批次已取消;否则 in_progress 表示仍有成员入库中,failed 表示入库结束且有失败成员,completed 表示无入库中或失败成员。取消终态批次不会改变它。
file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。

错误码与错误对象

列出批次文件

GET /openai/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/files

列出指定批次仍在库中的附件,默认最新附件在前。使用批次创建返回的 id;?filter=failed 查看失败文件,last_id 可作为下一页 after。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
batch_idpath: string必填;此知识库创建批次时返回的文件批次 ID。 最短字符数: 1
afterquery: string上一页的 ID 游标。 最短字符数: 1
beforequery: string返回此 ID 之前的条目。 最短字符数: 1
limitquery: integer每页条数。 最小: 1; 最大: 100; 默认: 20
orderquery: "asc" / "desc"知识库和文件默认按创建时间降序;分段默认按序号升序。 默认: "desc"
filterquery: "in_progress" / "completed" / "failed" / "cancelled"in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。省略时包含全部状态。

请求示例

curl -X GET "https://api.deepraxis.ai/openai/v1/vector_stores/${VECTOR_STORE_ID}/file_batches/${BATCH_ID}/files" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
object"list"必有; 对象标记;list 表示游标分页集合。
dataobject[]必有; 按请求顺序返回的当前页条目。
data[].idstring必有; 与源文件相同的 ID。; 最短字符数: 1
data[].object"vector_store.file"必有; 对象标记;vector_store.file 表示知识库中的附件。
data[].vector_store_idstring必有; 资源 ID。; 最短字符数: 1
data[].status"in_progress" / "completed" / "cancelled" / "failed"必有; in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。
data[].last_errorobject / null必有; 入库失败详情;未失败、成功完成或重新入库时为 null。
data[].last_error (1).code"server_error" / "unsupported_file" / "invalid_file"必有; unsupported_file 表示不支持的文件类型;invalid_file 表示加密、空文件或超过解析 token 上限;server_error 表示其它入库失败或超过截止时间。
data[].last_error (1).messagestring必有; 与 code 对应的入库失败说明。
data[].usage_bytesinteger必有; 完成后计入源文件字节数;处理中、失败或已取消时为零。; 最小: 0
data[].created_atinteger必有; Unix 时间戳,单位秒。
data[].chunking_strategyobject / object必有; 此附件已保存的分段策略;auto 输入返回为具体 static 设置。
data[].chunking_strategy (1).type"static"必有; static 表示使用显式分段大小与重叠设置。
data[].chunking_strategy (1).staticobject必有; 以估算 token 数表示的分段大小与重叠限制。
data[].chunking_strategy (1).static.max_chunk_size_tokensinteger必有; 每段的估算 token 数。; 最小: 100; 最大: 4096
data[].chunking_strategy (1).static.chunk_overlap_tokensinteger必有; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
data[].chunking_strategy (2).type"other"必有
data[].attributesobject / null必有; 用于搜索筛选的文件属性;null 表示未设置。
first_idstring / null必有; 本页首项的 ID;空页为 null。
last_idstring / null必有; 本页末项的 ID,可作为 after 继续查询;空页为 null。
has_moreboolean必有; 当前游标范围内,本页之后是否还有条目。

错误码与错误对象

Anthropic 兼容接口

基础地址

加载中…

接入

加载中…

端点

方法路径说明支持
POST/v1/messages发送消息● 支持
POST/v1/messages/count_tokens统计 token◐ 部分支持
GET/v1/models列出模型● 支持
POST/v1/files上传文件● 支持
GET/v1/files列出文件● 支持
GET/v1/files/{file_id}读取文件信息● 支持
DELETE/v1/files/{file_id}删除文件● 支持
GET/v1/files/{file_id}/content下载文件内容● 支持

与官方的差异

  • 发送消息:支持顶层 cache_control、top_k、metadata.user_id、output_config.format、thinking.display 与 anthropic-user-profile-id。仅原生 Anthropic 能表达的选项会限制路由;没有可保真供应时返回参数错误。anthropic-workspace-id 尚未支持,非空值返回 400。container、inference_geo 与 service_tier 接受并忽略;其他扩展见字段支持标注。 未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。
  • 统计 token:按模型族校准的估算值(包括中文和工具定义),响应头为 x-praxis-token-count: estimated;不能用作精确用量或计费依据。
  • 列出模型:始终返回 capabilities、max_input_tokens、max_tokens;目录无法确定的值为 null,不将总上下文窗口冒充独立输入上限。非空 anthropic-workspace-id 返回 400;尚不按 anthropic-beta 选择目录版本。
  • 上传文件:SDK 0.128.0 上传参数为表单 file 和可选的表单 expires_in_seconds(3600–7776000 秒)。其他表单字段(包括 purpose)返回 400 invalid_request_error,消息形如 "purpose: Extra inputs are not permitted";查询参数只接受 SDK 自带的 beta,其他查询参数返回 400,查询参数 expires_in_seconds 会提示改放表单。平台将上传文件记为 user_data;不支持 anthropic-workspace-id,请求携带该头时返回 400。
  • 列出文件:按创建时间从新到旧排列。用 after_id / before_id 与 limit 分页(两者同时给返回 400),也可以用 page 游标(next_page);三者只能选一个。响应包含 data、has_more、first_id、last_id 与 next_page。ids(最多 100 个去重 ID)与 page、after_id、before_id、limit 互斥。scope_id 需要 anthropic-beta: managed-agents-2026-04-01 请求头;缺少该头返回 400,不存在的会话范围返回 404。anthropic-workspace-id 返回 400。
  • 下载文件内容:只有代码执行工具生成的文件可以下载;你自己上传的文件(用途为 user_data)下载会返回 400 invalid_request_error,这与 Anthropic 官方的行为一致。

参数与字段的权威定义以 Anthropic 官方文档为准。

错误按 Anthropic 格式返回,参见错误;额度与响应头参见限流。

发送消息

POST /anthropic/v1/messages● 支持

Anthropic 官方文档 ↗

请求体

  • modelstring必填◐ 部分支持

    Body param: The model that will complete your prompt. See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    deepseek-v4-pro、glm-5.3-flash、qwen3.8-flash、claude-opus-5 可调用;deepseek-v4-flash 在此协议面返回 400。

  • max_tokensnumber必填

    Body param: The maximum number of tokens to generate before stopping. Note that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate. Set to `0` to populate the [prompt cache](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#pre-warming-the-cache) without generating a response. Different models have different maximum values for this parameter. See [models](https://platform.claude.com/docs/en/about-claude/models/overview) for details.

    限制输出 token,思考也占用预算。

  • messagesarray必填◐ 部分支持

    Body param: Input messages. Our models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn. Each input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages. If the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response. Example with a single `user` message: ```json [{ "role": "user", "content": "Hello, Claude" }] ``` Example with multiple conversational turns: ```json [ { "role": "user", "content": "Hello there." }, { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" }, { "role": "user", "content": "Can you explain LLMs in plain English?" } ] ``` Example with a partially-filled response from Claude: ```json [ { "role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun" }, { "role": "assistant", "content": "The best answer is (" } ] ``` Each input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `"text"`. The following input messages are equivalent: ```json { "role": "user", "content": "Hello, Claude" } ``` ```json { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] } ``` See [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages). Note that if you want to include a [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role), you can use the top-level `system` parameter — there is no `"system"` role for input messages in the Messages API. There is a limit of 100,000 messages in a single request.

    文本和工具往返生效;document 的托管 file_id 返回 400,qwen3.8-flash 可读取内联 PDF;图片有模型尺寸限制。

    ▸ 展开子字段(2)
    • contentstring | array必填

      Message content: a plain string (shorthand for one text block) or an array of content blocks such as text, image, document, tool_use and tool_result.

    • rolestring必填

      Who produced the message. Use user for your turns and assistant to replay earlier model turns; system-role messages are accepted by the shape but system instructions normally go in the top-level system field.

  • streamboolean可选◐ 部分支持

    Body param: Whether to incrementally stream the response using server-sent events. See [streaming](https://platform.claude.com/docs/en/build-with-claude/streaming) for details.

    流式正文和工具事件可用;可能在正文前出现额外 message_delta,message_start 的用量为 0。

  • systemstring | array可选

    Body param: System prompt. A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role).

    已验证生效。

  • temperaturenumber可选
  • top_pnumber可选
  • top_knumber可选
  • stop_sequencesarray可选◐ 部分支持

    Body param: Custom text sequences that will cause the model to stop generating. Our models will normally stop when they have naturally completed their turn, which will result in a response `stop_reason` of `"end_turn"`. If you want the model to stop generating when it encounters custom strings of text, you can use the `stop_sequences` parameter. If the model encounters one of the custom sequences, the response `stop_reason` value will be `"stop_sequence"` and the response `stop_sequence` value will contain the matched stop sequence.

    deepseek-v4-pro、qwen3.8-flash 生效;glm-5.3-flash 文本截断但 stop_reason 和 stop_sequence 未准确反映。

  • toolsarray可选

    Body param: Definitions of tools that the model may use. If you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks. There are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool)). Each tool definition includes: - `name`: Name of the tool. - `description`: Optional, but strongly-recommended description of the tool. - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks. For example, if you defined `tools` as: ```json [ { "name": "get_stock_price", "description": "Get the current stock price for a given ticker symbol.", "input_schema": { "type": "object", "properties": { "ticker": { "type": "string", "description": "The stock ticker symbol, e.g. AAPL for Apple Inc." } }, "required": ["ticker"] } } ] ``` And then asked the model "What's the S&P 500 at today?", the model might produce `tool_use` content blocks in the response like this: ```json [ { "type": "tool_use", "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "name": "get_stock_price", "input": { "ticker": "^GSPC" } } ] ``` You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an input, and return the following back to the model in a subsequent `user` message: ```json [ { "type": "tool_result", "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "content": "259.75 USD" } ] ``` Tools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output. See our [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) for more details.

    已验证生效。

  • ▸ 更多参数(16)
    • tool_choiceobject可选◐ 部分支持

      Body param: How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.

      qwen3.8-flash 四种模式生效;deepseek-v4-pro 忽略 any/tool/none;glm-5.3-flash 忽略 none。

      ▸ 展开子字段(3)
      • typestring必填
        取值 none
      • disable_parallel_tool_useboolean可选○ 当前不生效

        Whether to disable parallel tool use. Defaults to `false`. If set to `true`, the model will output exactly one tool use.

        接受但当前不生效。true 仍可能返回多个工具调用。

      • namestring必填

        The name of the tool to use.

    • metadataobject可选◐ 部分支持

      Body param: An object describing metadata about the request.

      接受 metadata;metadata.user_id 由同协议线路传递,不承诺上游回显。

      ▸ 展开子字段(1)
      • user_idstring可选

        An external identifier for the user who is associated with the request. This should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number.

    • cache_controlobject可选◐ 部分支持

      Body param: Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.

      deepseek-v4-pro、qwen3.8-flash、glm-5.3-flash 有隐式缓存命中,但不能据此确认标记生效;claude-opus-5 未命中缓存,ttl=1h 未见效果。

      ▸ 展开子字段(2)
      • typestring必填

        Always `ephemeral`. Discriminator that marks this object as a CacheControlEphemeral in a `type`-tagged union.

        取值 ephemeral
      • ttlstring可选

        The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.

    • containerstring | object可选○ 当前不生效

      接受并忽略 container;平台尚未实现此能力。

      ▸ 展开子字段(2)
      • idstring可选

        Container id

      • skillsarray可选

        List of skills to load in the container

    • inference_geostring可选○ 当前不生效

      接受并忽略 inference_geo;平台尚未实现此能力。

    • output_configobject可选

      Body param: Configuration options for the model's output, such as the output format.

      ▸ 展开子字段(2)
      • effortstring可选◐ 部分支持

        All possible effort levels.

        deepseek-v4-pro 仅 high/xhigh 可用,其余返回 400;qwen3.8-flash 全档返回 400;glm-5.3-flash 接受各档但消耗不随档位单调变化。

      • formatobject可选◐ 部分支持

        A schema to specify Claude's output format in responses. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)

        json_schema 在 deepseek-v4-pro、qwen3.8-flash 生效;glm-5.3-flash 与 thinking 同传返回 400。

    • service_tierstring可选○ 当前不生效

      接受并忽略 service_tier;平台尚未实现此能力。

    • thinkingobject可选◐ 部分支持

      Body param: Configuration for enabling Claude's extended thinking. When enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit. See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.

      disabled 在 deepseek-v4-pro、qwen3.8-flash 生效;glm-5.3-flash 携带任何 thinking 都返回 400。adaptive 在已测的 deepseek-v4-pro、qwen3.8-flash 也返回 400。

      ▸ 展开子字段(3)
      • budget_tokensnumber必填◐ 部分支持

        Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality. Must be ≥1024 and less than `max_tokens`. See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.

        deepseek-v4-pro、qwen3.8-flash 接受,但预算不构成可靠上限;glm-5.3-flash 返回 400。

      • typestring必填
        取值 adaptive
      • displaystring可选○ 当前不生效

        Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.

        接受但当前不生效。omitted 仍返回完整思考内容。

    • context_managementobject可选○ 当前不生效

      接受并忽略 context_management;平台尚未实现此能力。

    • diagnosticsobject可选○ 当前不生效

      接受并忽略 diagnostics;平台尚未实现此能力。

    • mcp_serversarray可选○ 当前不生效

      接受并忽略 mcp_servers;平台尚未实现此能力。

    • speedstring可选○ 当前不生效

      接受并忽略 speed;平台尚未实现此能力。

    • output_formatobject可选○ 当前不生效

      接受并忽略此旧字段;结构化输出使用 output_config.format。

    • compactionobject可选○ 未支持

      已识别 compaction;尚未实现,传入返回 400 并明确说明不支持。

    • fallback_credit_tokenstring可选○ 未支持

      已识别 fallback_credit_token;尚未实现,传入返回 400 并明确说明不支持。

    • fallbacksstring可选○ 未支持

      已识别 fallbacks;尚未实现,传入返回 400 并明确说明不支持。

返回

200

stream=true 时以 SSE 增量返回(text/event-stream)。

支持顶层 cache_control、top_k、metadata.user_id、output_config.format、thinking.display 与 anthropic-user-profile-id。仅原生 Anthropic 能表达的选项会限制路由;没有可保真供应时返回参数错误。anthropic-workspace-id 尚未支持,非空值返回 400。container、inference_geo 与 service_tier 接受并忽略;其他扩展见字段支持标注。 未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。

错误按 Anthropic 格式返回,参见 错误码

响应

HTTP 200

Message created

application/json

名称类型说明
idstringUnique object identifier. The format and length of IDs may change over time.
containernull | objectInformation about the container used in the request (for the code execution tool)
container.idstringIdentifier for the container used in this request
container.expires_atstringThe time at which the container will expire.
container.skillsnull | array<object>Skills loaded in the container
contentarray<object>Content generated by the model. This is an array of content blocks, each of which has a `type` that determines its shape. Example: ```json [{ "type": "text", "text": "Hi, I'm Claude." }] ``` If the request input `messages` ended with an `assistant` turn, then the response `content` will continue directly from that last turn. You can use this to constrain the model's output. For example, if the input `messages` were: ```json [ { "role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun" }, { "role": "assistant", "content": "The best answer is (" } ] ``` Then the response `content` might be: ```json [{ "type": "text", "text": "B)" }] ```
content[].citationsnull | array<object>Citations supporting the text block. The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.
content[].textstringThe text generated by the model.
content[].typestringAlways `text`. Discriminator that marks this object as a TextBlock in a `type`-tagged union. / Always `thinking`. Discriminator that marks this object as a ThinkingBlock in a `type`-tagged union. / Always `redacted_thinking`. Discriminator that marks this object as a RedactedThinkingBlock in a `type`-tagged union. / Always `tool_use`. Discriminator that marks this object as a ToolUseBlock in a `type`-tagged union. / Always `server_tool_use`. Discriminator that marks this object as a ServerToolUseBlock in a `type`-tagged union. / Always `web_search_tool_result`. Discriminator that marks this object as a WebSearchToolResultBlock in a `type`-tagged union. / Always `web_fetch_tool_result`. Discriminator that marks this object as a WebFetchToolResultBlock in a `type`-tagged union. / Always `code_execution_tool_result`. Discriminator that marks this object as a CodeExecutionToolResultBlock in a `type`-tagged union. / Always `bash_code_execution_tool_result`. Discriminator that marks this object as a BashCodeExecutionToolResultBlock in a `type`-tagged union. / Always `text_editor_code_execution_tool_result`. Discriminator that marks this object as a TextEditorCodeExecutionToolResultBlock in a `type`-tagged union. / Always `tool_search_tool_result`. Discriminator that marks this object as a ToolSearchToolResultBlock in a `type`-tagged union. / Always `container_upload`. Discriminator that marks this object as a ContainerUploadBlock in a `type`-tagged union.
content[].signaturestringA value used to verify that this thinking block was generated by Claude when it is passed back to the API. This is an opaque field and should not be interpreted or parsed. When passing thinking blocks back to the API (required when using tools with extended thinking), pass them back exactly as received, with this field intact. See extended thinking for details.
content[].thinkingstringThe text of Claude's thinking process for this block.
content[].datastringThe contents of this redacted thinking block, returned when portions of the model's thinking were safety-redacted. This field is opaque and encrypted, with no readable content. Pass `redacted_thinking` blocks back to the API unchanged when continuing a multi-turn conversation. See extended thinking for details.
content[].idstringId of the tool call; send it back as tool_use_id in the tool_result block that answers it. / Id of the server tool call; the matching result block repeats it as tool_use_id.
content[].callerobjectWhich party invoked the tool: the model directly or a code execution tool. / Which party invoked the server tool: the model directly or a code execution tool. / Which party invoked the search: the model directly or a code execution tool. / Which party invoked the fetch: the model directly or a code execution tool.
content[].inputanyArguments the model chose, as a JSON object that follows the tool's input_schema. / Arguments the model passed to the server tool, as a JSON object.
content[].namestringName of the tool the model wants to call. / Name of the server tool the model called, such as web_search, web_fetch or code_execution.
content[].toolset_namenull | stringFor a toolset member tool_use, the toolset family.
content[].contentobject | array<object> | object | object | object | object | objectSearch results (array of web_search_result blocks) or an error object. / The fetched document or an error object. / Result of the code execution: a result block, an encrypted result block, or an error object. / Result of the bash command: a result block or an error object. / Result of the text editor command: a view, create or str_replace result block, or an error object. / Result of the tool search: a search result block that lists tool references, or an error object.
content[].tool_use_idstringId of the web_search server tool call this result belongs to. / Id of the web_fetch server tool call this result belongs to. / Id of the code_execution server tool call this result belongs to. / Id of the bash_code_execution server tool call this result belongs to. / Id of the text_editor_code_execution server tool call this result belongs to. / Id of the tool search server tool call this result belongs to.
content[].file_idstringId of the file that was uploaded into the code execution container.
modelstringThe model that will complete your prompt. See models for additional details and options.
rolestringConversational role of the generated message. This will always be `"assistant"`.
stop_detailsnull | objectStructured information about a refusal.
stop_details.categorynull | stringThe policy category that triggered a refusal. - `cyber` - The request could enable cyber harm, such as malware or exploit development. Benign cybersecurity work can also trigger this category. - `bio` - The request could enable biological harm, such as dangerous lab methods. Beneficial life sciences work can also trigger this category. - `frontier_llm` - The request could assist the development of competing AI models, which is restricted under Anthropic's commercial terms. Benign machine learning work can also trigger this category. - `reasoning_extraction` - The request asks the model to reproduce its internal reasoning in the response text. To get reasoning in a structured form instead, use adaptive thinking. - `general_harms` - The request could be related to an area that was determined as harmful. Benign work might sometimes trigger this category.
stop_details.explanationnull | stringHuman-readable explanation of the refusal. This text is not guaranteed to be stable. `null` when no explanation is available for the category.
stop_details.typestringAlways `refusal`. Discriminator that marks this object as a RefusalStopDetails in a `type`-tagged union.
stop_reasonnull | stringThe reason that we stopped. This may be one the following values: - `"end_turn"`: the model reached a natural stopping point - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated - `"tool_use"`: the model invoked one or more tools - `"pause_turn"`: we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue. - `"refusal"`: when streaming classifiers intervene to handle potential policy violations - `"model_context_window_exceeded"`: we exceeded the model's context window In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.
stop_sequencenull | stringWhich custom stop sequence was generated, if any. This value will be a non-null string if one of your custom stop sequences was generated.
typestringObject type. For Messages, this is always `"message"`.
usageobjectBilling and rate-limit usage. Anthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems. Under the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response. For example, `output_tokens` will be non-zero, even for an empty string response from Claude. Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.
usage.cache_creationnull | objectBreakdown of cached tokens by TTL
usage.cache_creation_input_tokensnull | numberThe number of input tokens used to create the cache entry.
usage.cache_read_input_tokensnull | numberThe number of input tokens read from the cache.
usage.inference_geonull | stringThe geographic region where inference was performed for this request.
usage.input_tokensnumberThe number of input tokens which were used.
usage.output_tokensnumberThe number of output tokens which were used.
usage.output_tokens_detailsnull | objectBreakdown of output tokens by category. `output_tokens` remains the inclusive, authoritative total used for billing. This object provides a read-only decomposition for observability — for example, how many of the billed output tokens were spent on internal reasoning that may have been summarized before being returned to you.
usage.server_tool_usenull | objectThe number of server tool requests.
usage.service_tiernull | stringIf the request used the priority, standard, or batch tier.

text/event-stream — chunk / 事件对象

名称类型说明
deltaobjectFinal fields of the message sent with message_delta: why generation stopped and the container. / The incremental change to the content block at index.
delta.containernull | objectInformation about the container used in the request (for the code execution tool)
delta.stop_detailsnull | objectStructured information about a refusal.
delta.stop_reasonnull | stringWhy the model stopped; null while the message is still generating.
delta.stop_sequencenull | stringThe custom stop sequence that was matched; null unless stop_reason is stop_sequence.
delta.textstringText fragment to append to the text block.
delta.typestringAlways `text_delta`. Discriminator that marks this object as a TextDelta in a `type`-tagged union. / Always `input_json_delta`. Discriminator that marks this object as a InputJSONDelta in a `type`-tagged union. / Always `citations_delta`. Discriminator that marks this object as a CitationsDelta in a `type`-tagged union. / Always `thinking_delta`. Discriminator that marks this object as a ThinkingDelta in a `type`-tagged union. / Always `signature_delta`. Discriminator that marks this object as a SignatureDelta in a `type`-tagged union.
delta.partial_jsonstringFragment of the tool input JSON string; concatenate all fragments of a block and parse the result when the block stops.
delta.citationobjectThe citation to attach to the text block being streamed.
delta.thinkingstringThe incremental `thinking` text for this content block. Concatenate the `thinking` values of successive `thinking_delta` events to assemble the block's full `thinking` value.
delta.signaturestringThe `signature` for this thinking block: an opaque value used to verify that the block was generated by Claude when it is passed back to the API. Delivered in a `signature_delta` event just before the block's `content_block_stop` event.
typestringAlways `message_delta`. Discriminator that marks this object as a RawMessageDeltaEvent in a `type`-tagged union. / Always `content_block_delta`. Discriminator that marks this object as a RawContentBlockDeltaEvent in a `type`-tagged union. / Always `message_start`. Discriminator that marks this object as a RawMessageStartEvent in a `type`-tagged union. / Always `message_stop`. Discriminator that marks this object as a RawMessageStopEvent in a `type`-tagged union. / Always `content_block_start`. Discriminator that marks this object as a RawContentBlockStartEvent in a `type`-tagged union. / Always `content_block_stop`. Discriminator that marks this object as a RawContentBlockStopEvent in a `type`-tagged union.
usageobjectBilling and rate-limit usage. Anthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems. Under the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response. For example, `output_tokens` will be non-zero, even for an empty string response from Claude. Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.
usage.cache_creation_input_tokensnull | numberThe cumulative number of input tokens used to create the cache entry.
usage.cache_read_input_tokensnull | numberThe cumulative number of input tokens read from the cache.
usage.input_tokensnull | numberThe cumulative number of input tokens which were used.
usage.output_tokensnumberThe cumulative number of output tokens which were used.
usage.output_tokens_detailsnull | objectBreakdown of output tokens by category. `output_tokens` remains the inclusive, authoritative total used for billing. This object provides a read-only decomposition for observability — for example, how many of the billed output tokens were spent on internal reasoning that may have been summarized before being returned to you.
usage.server_tool_usenull | objectThe number of server tool requests.
indexnumberZero-based index of the content block this delta applies to. / Zero-based index of the content block that starts. / Zero-based index of the content block that ends.
messageobjectThe complete Message object being started; its content is empty at message_start and filled by the following content_block events.
message.idstringUnique object identifier. The format and length of IDs may change over time.
message.containernull | objectInformation about the container used in the request (for the code execution tool)
message.contentarray<object>Content generated by the model. This is an array of content blocks, each of which has a `type` that determines its shape. Example: ```json [{ "type": "text", "text": "Hi, I'm Claude." }] ``` If the request input `messages` ended with an `assistant` turn, then the response `content` will continue directly from that last turn. You can use this to constrain the model's output. For example, if the input `messages` were: ```json [ { "role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun" }, { "role": "assistant", "content": "The best answer is (" } ] ``` Then the response `content` might be: ```json [{ "type": "text", "text": "B)" }] ```
message.modelstringThe model that will complete your prompt. See models for additional details and options.
message.rolestringConversational role of the generated message. This will always be `"assistant"`.
message.stop_detailsnull | objectStructured information about a refusal.
message.stop_reasonnull | stringThe reason that we stopped. This may be one the following values: - `"end_turn"`: the model reached a natural stopping point - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated - `"tool_use"`: the model invoked one or more tools - `"pause_turn"`: we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue. - `"refusal"`: when streaming classifiers intervene to handle potential policy violations - `"model_context_window_exceeded"`: we exceeded the model's context window In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.
message.stop_sequencenull | stringWhich custom stop sequence was generated, if any. This value will be a non-null string if one of your custom stop sequences was generated.
message.typestringObject type. For Messages, this is always `"message"`.
message.usageobjectBilling and rate-limit usage. Anthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems. Under the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response. For example, `output_tokens` will be non-zero, even for an empty string response from Claude. Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.
content_blockobjectThe content block as it starts, with empty text or input to be filled by deltas.
content_block.citationsnull | array<object>Citations supporting the text block. The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.
content_block.textstringThe text generated by the model.
content_block.typestringAlways `text`. Discriminator that marks this object as a TextBlock in a `type`-tagged union. / Always `thinking`. Discriminator that marks this object as a ThinkingBlock in a `type`-tagged union. / Always `redacted_thinking`. Discriminator that marks this object as a RedactedThinkingBlock in a `type`-tagged union. / Always `tool_use`. Discriminator that marks this object as a ToolUseBlock in a `type`-tagged union. / Always `server_tool_use`. Discriminator that marks this object as a ServerToolUseBlock in a `type`-tagged union. / Always `web_search_tool_result`. Discriminator that marks this object as a WebSearchToolResultBlock in a `type`-tagged union. / Always `web_fetch_tool_result`. Discriminator that marks this object as a WebFetchToolResultBlock in a `type`-tagged union. / Always `code_execution_tool_result`. Discriminator that marks this object as a CodeExecutionToolResultBlock in a `type`-tagged union. / Always `bash_code_execution_tool_result`. Discriminator that marks this object as a BashCodeExecutionToolResultBlock in a `type`-tagged union. / Always `text_editor_code_execution_tool_result`. Discriminator that marks this object as a TextEditorCodeExecutionToolResultBlock in a `type`-tagged union. / Always `tool_search_tool_result`. Discriminator that marks this object as a ToolSearchToolResultBlock in a `type`-tagged union. / Always `container_upload`. Discriminator that marks this object as a ContainerUploadBlock in a `type`-tagged union.
content_block.signaturestringA value used to verify that this thinking block was generated by Claude when it is passed back to the API. This is an opaque field and should not be interpreted or parsed. When passing thinking blocks back to the API (required when using tools with extended thinking), pass them back exactly as received, with this field intact. See extended thinking for details.
content_block.thinkingstringThe text of Claude's thinking process for this block.
content_block.datastringThe contents of this redacted thinking block, returned when portions of the model's thinking were safety-redacted. This field is opaque and encrypted, with no readable content. Pass `redacted_thinking` blocks back to the API unchanged when continuing a multi-turn conversation. See extended thinking for details.
content_block.idstringId of the tool call; send it back as tool_use_id in the tool_result block that answers it. / Id of the server tool call; the matching result block repeats it as tool_use_id.
content_block.callerobjectWhich party invoked the tool: the model directly or a code execution tool. / Which party invoked the server tool: the model directly or a code execution tool. / Which party invoked the search: the model directly or a code execution tool. / Which party invoked the fetch: the model directly or a code execution tool.
content_block.inputanyArguments the model chose, as a JSON object that follows the tool's input_schema. / Arguments the model passed to the server tool, as a JSON object.
content_block.namestringName of the tool the model wants to call. / Name of the server tool the model called, such as web_search, web_fetch or code_execution.
content_block.toolset_namenull | stringFor a toolset member tool_use, the toolset family.
content_block.contentobject | array<object> | object | object | object | object | objectSearch results (array of web_search_result blocks) or an error object. / The fetched document or an error object. / Result of the code execution: a result block, an encrypted result block, or an error object. / Result of the bash command: a result block or an error object. / Result of the text editor command: a view, create or str_replace result block, or an error object. / Result of the tool search: a search result block that lists tool references, or an error object.
content_block.tool_use_idstringId of the web_search server tool call this result belongs to. / Id of the web_fetch server tool call this result belongs to. / Id of the code_execution server tool call this result belongs to. / Id of the bash_code_execution server tool call this result belongs to. / Id of the text_editor_code_execution server tool call this result belongs to. / Id of the tool search server tool call this result belongs to.
content_block.file_idstringId of the file that was uploaded into the code execution container.

POST /anthropic/v1/messages/count_tokens◐ 部分支持

Anthropic 官方文档 ↗

请求体

  • modelstring必填

    Body param: The model that will complete your prompt. See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    必填并校验存在性,用于选择原生线路和本地分词器。

  • messagesarray必填◐ 部分支持

    Body param: Input messages. Our models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn. Each input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages. If the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response. Example with a single `user` message: ```json [{ "role": "user", "content": "Hello, Claude" }] ``` Example with multiple conversational turns: ```json [ { "role": "user", "content": "Hello there." }, { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" }, { "role": "user", "content": "Can you explain LLMs in plain English?" } ] ``` Example with a partially-filled response from Claude: ```json [ { "role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun" }, { "role": "assistant", "content": "The best answer is (" } ] ``` Each input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `"text"`. The following input messages are equivalent: ```json { "role": "user", "content": "Hello, Claude" } ``` ```json { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] } ``` See [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages). Note that if you want to include a [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role), you can use the top-level `system` parameter — there is no `"system"` role for input messages in the Messages API. There is a limit of 100,000 messages in a single request.

    原生路径保留消息;本地使用 o200k 或按模型族校准的估算,图片按已知模型规则估算,未知尺寸使用近似额度;不下载图片 URL。

    ▸ 展开子字段(2)
    • contentstring | array必填

      Message content: a plain string (shorthand for one text block) or an array of content blocks such as text, image, document, tool_use and tool_result.

    • rolestring必填

      Who produced the message. Use user for your turns and assistant to replay earlier model turns; system-role messages are accepted by the shape but system instructions normally go in the top-level system field.

  • systemstring | array可选◐ 部分支持

    Body param: System prompt. A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role).

    原生透传;本地计入估算。

  • toolsarray可选◐ 部分支持

    Body param: Definitions of tools that the model may use. If you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks. There are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool)). Each tool definition includes: - `name`: Name of the tool. - `description`: Optional, but strongly-recommended description of the tool. - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks. For example, if you defined `tools` as: ```json [ { "name": "get_stock_price", "description": "Get the current stock price for a given ticker symbol.", "input_schema": { "type": "object", "properties": { "ticker": { "type": "string", "description": "The stock ticker symbol, e.g. AAPL for Apple Inc." } }, "required": ["ticker"] } } ] ``` And then asked the model "What's the S&P 500 at today?", the model might produce `tool_use` content blocks in the response like this: ```json [ { "type": "tool_use", "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "name": "get_stock_price", "input": { "ticker": "^GSPC" } } ] ``` You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an input, and return the following back to the model in a subsequent `user` message: ```json [ { "type": "tool_result", "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "content": "259.75 USD" } ] ``` Tools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output. See our [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) for more details.

    原生透传;本地计入定义与包装的估算。

  • tool_choiceobject可选◐ 部分支持

    Body param: How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.

    原生透传;本地计入估算。

    ▸ 展开子字段(3)
    • typestring必填

      Disable tool calls for this request.

      取值 none
    • disable_parallel_tool_useboolean可选

      Whether to disable parallel tool use. Defaults to `false`. If set to `true`, the model will output exactly one tool use.

    • namestring必填

      The name of the tool to use.

  • cache_controlobject可选◐ 部分支持

    Body param: Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.

    原生路径保留消息内标记;计数不能预测缓存命中或计费。

    ▸ 展开子字段(2)
    • typestring必填

      Always `ephemeral`. Discriminator that marks this object as a CacheControlEphemeral in a `type`-tagged union.

      取值 ephemeral
    • ttlstring可选

      The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.

  • output_configobject可选◐ 部分支持

    Body param: Configuration options for the model's output, such as the output format.

    原生路径透传;本地不承诺其附加模板的精确计数。

    ▸ 展开子字段(2)
    • effortstring可选

      All possible effort levels.

    • formatobject可选

      A schema to specify Claude's output format in responses. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)

  • thinkingobject可选◐ 部分支持

    Body param: Configuration for enabling Claude's extended thinking. When enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit. See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.

    原生路径透传;本地不承诺思考模板精确计数。

    ▸ 展开子字段(3)
    • budget_tokensnumber必填

      Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality. Must be ≥1024 and less than `max_tokens`. See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.

    • typestring必填

      Let the model choose its reasoning budget, subject to output_config.effort when supplied.

      取值 adaptive
    • displaystring可选

      Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.

返回

200

按模型族校准的估算值(包括中文和工具定义),响应头为 x-praxis-token-count: estimated;不能用作精确用量或计费依据。

错误按 Anthropic 格式返回,参见 错误码

响应

HTTP 200

Token count

application/json

名称类型说明
input_tokensnumberThe total number of tokens across the provided list of messages, system prompt, and tools.

列出模型

GET /anthropic/v1/models● 支持

Anthropic 官方文档 ↗

请求参数

  • limitnumber可选

    query: Number of items per page.

    已验证生效。

  • before_idstring可选

    query:

    已验证生效。

  • after_idstring可选

    query:

    已验证生效。

返回

200

始终返回 capabilities、max_input_tokens、max_tokens;目录无法确定的值为 null,不将总上下文窗口冒充独立输入上限。非空 anthropic-workspace-id 返回 400;尚不按 anthropic-beta 选择目录版本。

错误按 Anthropic 格式返回,参见 错误码

响应

HTTP 200

Models listed

application/json

名称类型说明
dataarray<object>
data[].idstringUnique model identifier.
data[].capabilitiesnull | objectModel capability information.
data[].created_atstringRFC 3339 datetime string representing the time at which the model was released. May be set to an epoch value if the release date is unknown.
data[].display_namestringA human-readable name for the model.
data[].max_input_tokensnull | numberMaximum input context window size in tokens for this model.
data[].max_tokensnull | numberMaximum value for the `max_tokens` parameter when using this model.
data[].typestringObject type. For Models, this is always `"model"`.
has_moreboolean
first_idnull | string
last_idnull | string

上传文件

POST /anthropic/v1/files● 支持

Anthropic 官方文档 ↗

请求体

  • filestring必填◐ 部分支持

    Body param: The file to upload. Only the final path component of the part's `filename` is kept; an absent or empty `filename` is replaced with `unnamed` plus the extension for the file's stored `mime_type`, when known.

    支持文本、PDF 和 PNG;按文件内容识别类型,不支持任意二进制。

  • expires_in_secondsnumber可选◐ 部分支持

    Body param: Seconds from upload until the file expires and its bytes become permanently unavailable. Must be between 3600 (one hour) and 7776000 (ninety days).

    表单字段支持 3600–7776000 秒;作为查询参数传入返回 400,提示改放表单。

返回

200

SDK 0.128.0 上传参数为表单 file 和可选的表单 expires_in_seconds(3600–7776000 秒)。其他表单字段(包括 purpose)返回 400 invalid_request_error,消息形如 "purpose: Extra inputs are not permitted";查询参数只接受 SDK 自带的 beta,其他查询参数返回 400,查询参数 expires_in_seconds 会提示改放表单。平台将上传文件记为 user_data;不支持 anthropic-workspace-id,请求携带该头时返回 400。

错误按 Anthropic 格式返回,参见 错误码

响应

HTTP 200

File uploaded

application/json

名称类型说明
idstringUnique object identifier. The format and length of IDs may change over time.
created_atstringRFC 3339 datetime string representing when the file was created.
filenamestringOriginal filename of the uploaded file.
mime_typestringMIME type of the file.
size_bytesnumberSize of the file in bytes.
typestringObject type. For files, this is always `"file"`.
downloadablebooleanWhether the file can be downloaded.
expires_atnull | stringRFC 3339 datetime string representing when the file will expire and become unavailable for download. Null if the file does not expire. For files uploaded with `expires_in_seconds`, this is the upload time plus that value.
scopenull | objectThe scope of this file, indicating the context in which it was created (e.g., a session).
scope.idstringThe ID of the scoping resource (e.g., the session ID).
scope.typestringThe type of scope (e.g., `"session"`).

列出文件

GET /anthropic/v1/files● 支持

Anthropic 官方文档 ↗

请求参数

  • idsarray可选

    query: Query param: Restrict the result set to Files whose `id` is in this list. At most 100 entries (after de-duplication). Mutually exclusive with `page` and `limit`. When supplied, the response is always a single page (`next_page` is null). IDs that do not resolve to a visible File — including deleted Files — are silently omitted.

    已验证生效。

  • scope_idstring可选◐ 部分支持

    query: Query param: Filter by scope ID. Only returns files associated with the specified scope (e.g., a session ID).

    需要 anthropic-beta: managed-agents-2026-04-01。非法 scope_id 返回 400,不存在的会话范围返回 404。

  • limitnumber可选

    query: Number of items per page.

    已验证生效。

  • pagestring可选

    query:

    已验证生效。

  • after_idstring可选

    query: Return the page of files immediately after this file id (older files).

    返回该文件之后(更早创建)的一页;不能与 before_id 或 page 同时使用。

  • before_idstring可选

    query: Return the page of files immediately before this file id (newer files).

    返回该文件之前(更新创建)的一页;不能与 after_id 或 page 同时使用。

返回

200

按创建时间从新到旧排列。用 after_id / before_id 与 limit 分页(两者同时给返回 400),也可以用 page 游标(next_page);三者只能选一个。响应包含 data、has_more、first_id、last_id 与 next_page。ids(最多 100 个去重 ID)与 page、after_id、before_id、limit 互斥。scope_id 需要 anthropic-beta: managed-agents-2026-04-01 请求头;缺少该头返回 400,不存在的会话范围返回 404。anthropic-workspace-id 返回 400。

错误按 Anthropic 格式返回,参见 错误码

响应

HTTP 200

Files listed

application/json

名称类型说明
dataarray<object>
data[].idstringUnique object identifier. The format and length of IDs may change over time.
data[].created_atstringRFC 3339 datetime string representing when the file was created.
data[].filenamestringOriginal filename of the uploaded file.
data[].mime_typestringMIME type of the file.
data[].size_bytesnumberSize of the file in bytes.
data[].typestringObject type. For files, this is always `"file"`.
data[].downloadablebooleanWhether the file can be downloaded.
data[].expires_atnull | stringRFC 3339 datetime string representing when the file will expire and become unavailable for download. Null if the file does not expire. For files uploaded with `expires_in_seconds`, this is the upload time plus that value.
data[].scopenull | objectThe scope of this file, indicating the context in which it was created (e.g., a session).
next_pagenull | string

读取文件信息

先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。

GET /anthropic/v1/files/{file_id}● 支持

Anthropic 官方文档 ↗

请求参数

  • file_idstring必填

    path:

返回

200

错误按 Anthropic 格式返回,参见 错误码

响应

HTTP 200

Metadata

application/json

名称类型说明
idstringUnique object identifier. The format and length of IDs may change over time.
created_atstringRFC 3339 datetime string representing when the file was created.
filenamestringOriginal filename of the uploaded file.
mime_typestringMIME type of the file.
size_bytesnumberSize of the file in bytes.
typestringObject type. For files, this is always `"file"`.
downloadablebooleanWhether the file can be downloaded.
expires_atnull | stringRFC 3339 datetime string representing when the file will expire and become unavailable for download. Null if the file does not expire. For files uploaded with `expires_in_seconds`, this is the upload time plus that value.
scopenull | objectThe scope of this file, indicating the context in which it was created (e.g., a session).
scope.idstringThe ID of the scoping resource (e.g., the session ID).
scope.typestringThe type of scope (e.g., `"session"`).

删除文件

先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。

DELETE /anthropic/v1/files/{file_id}● 支持

Anthropic 官方文档 ↗

请求参数

  • file_idstring必填

    path:

返回

200

错误按 Anthropic 格式返回,参见 错误码

响应

HTTP 200

Deleted

application/json

名称类型说明
idstringID of the deleted file.
typestringDeleted object type. For file deletion, this is always `"file_deleted"`.

下载文件内容

先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。

GET /anthropic/v1/files/{file_id}/content● 支持

Anthropic 官方文档 ↗

请求参数

  • file_idstring必填

    path:

返回

400

只有代码执行工具生成的文件可以下载;你自己上传的文件(用途为 user_data)下载会返回 400 invalid_request_error,这与 Anthropic 官方的行为一致。

错误按 Anthropic 格式返回,参见 错误码

响应

HTTP 200

Binary content

未声明响应体。

Claude 托管智能体 API

基础地址

加载中…

接入

加载中…

运行一次会话

  1. 创建智能体,保存返回的 agent_… ID。
  2. 创建会话,将 agent 替换为该 ID,保存 sesn_… ID。
  3. 先订阅事件流,再发送消息。将两个请求的会话 ID 替换为同一个真实 ID。
  4. 收到 agent.message 后等待 session.status_idle;也可查询历史事件。

SDK 基础地址就是上面的基础地址。每个请求均需 API Key、anthropic-version: 2023-06-01 和 anthropic-beta: managed-agents-2026-04-01。在线试调会自动带上这些协议头,资源 ID 需自行替换。

官方 95 个操作已全部声明:其中 41 个已支持或部分支持(见端点清单徽标);其余 54 个平台尚未实现,调用如实返回 501(not_implemented_error,响应带 x-should-retry: false),不产生任何副作用、不计费。各项能力与凭据库的具体限制见端点说明。

端点

智能体(6 个端点,6 个可用)

方法路径说明支持
POST/v1/agents创建智能体◐ 部分支持
GET/v1/agents列出智能体● 支持
GET/v1/agents/{agent_id}读取智能体● 支持
POST/v1/agents/{agent_id}更新智能体◐ 部分支持
GET/v1/agents/{agent_id}/versions列出版本● 支持
POST/v1/agents/{agent_id}/archive归档智能体● 支持

会话与事件(9 个端点,8 个可用)

方法路径说明支持
POST/v1/sessions创建会话◐ 部分支持
GET/v1/sessions列出会话◐ 部分支持
GET/v1/sessions/{session_id}读取会话● 支持
POST/v1/sessions/{session_id}/events发送事件◐ 部分支持
GET/v1/sessions/{session_id}/events列出事件● 支持
GET/v1/sessions/{session_id}/events/stream订阅事件◐ 部分支持
POST/v1/sessions/{session_id}更新会话◐ 部分支持
DELETE/v1/sessions/{session_id}删除会话○ 未支持
POST/v1/sessions/{session_id}/archive归档会话● 支持

定时部署(10 个端点,0 个可用)

方法路径说明支持
GET/v1/deployment_runs列出部署运行○ 未支持
GET/v1/deployment_runs/{deployment_run_id}读取部署运行○ 未支持
GET/v1/deployments列出部署○ 未支持
POST/v1/deployments创建部署○ 未支持
GET/v1/deployments/{deployment_id}读取部署○ 未支持
POST/v1/deployments/{deployment_id}更新部署○ 未支持
POST/v1/deployments/{deployment_id}/archive归档部署○ 未支持
POST/v1/deployments/{deployment_id}/pause暂停部署○ 未支持
POST/v1/deployments/{deployment_id}/run运行部署○ 未支持
POST/v1/deployments/{deployment_id}/unpause恢复部署○ 未支持

环境(6 个端点,5 个可用)

方法路径说明支持
GET/v1/environments列出环境◐ 部分支持
POST/v1/environments创建环境◐ 部分支持
DELETE/v1/environments/{environment_id}删除环境○ 未支持
GET/v1/environments/{environment_id}读取环境◐ 部分支持
POST/v1/environments/{environment_id}更新环境◐ 部分支持
POST/v1/environments/{environment_id}/archive归档环境◐ 部分支持

环境任务(8 个端点,0 个可用)

方法路径说明支持
GET/v1/environments/{environment_id}/work列出工作项○ 未支持
GET/v1/environments/{environment_id}/work/{work_id}读取工作项○ 未支持
POST/v1/environments/{environment_id}/work/{work_id}更新工作项○ 未支持
POST/v1/environments/{environment_id}/work/{work_id}/ack确认工作项○ 未支持
POST/v1/environments/{environment_id}/work/{work_id}/heartbeat工作项心跳○ 未支持
POST/v1/environments/{environment_id}/work/{work_id}/stop停止工作项○ 未支持
GET/v1/environments/{environment_id}/work/poll轮询工作项○ 未支持
GET/v1/environments/{environment_id}/work/stats工作项统计○ 未支持

记忆库(14 个端点,0 个可用)

方法路径说明支持
GET/v1/memory_stores列出记忆库○ 未支持
POST/v1/memory_stores创建记忆库○ 未支持
DELETE/v1/memory_stores/{memory_store_id}删除记忆库○ 未支持
GET/v1/memory_stores/{memory_store_id}读取记忆库○ 未支持
POST/v1/memory_stores/{memory_store_id}更新记忆库○ 未支持
POST/v1/memory_stores/{memory_store_id}/archive归档记忆库○ 未支持
GET/v1/memory_stores/{memory_store_id}/memories列出记忆○ 未支持
POST/v1/memory_stores/{memory_store_id}/memories创建记忆○ 未支持
DELETE/v1/memory_stores/{memory_store_id}/memories/{memory_id}删除记忆○ 未支持
GET/v1/memory_stores/{memory_store_id}/memories/{memory_id}读取记忆○ 未支持
POST/v1/memory_stores/{memory_store_id}/memories/{memory_id}更新记忆○ 未支持
GET/v1/memory_stores/{memory_store_id}/memory_versions列出记忆版本○ 未支持
GET/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}读取记忆版本○ 未支持
POST/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}/redact抹除记忆版本○ 未支持

会话资源(5 个端点,4 个可用)

方法路径说明支持
GET/v1/sessions/{session_id}/resources列出会话资源◐ 部分支持
POST/v1/sessions/{session_id}/resources添加会话资源◐ 部分支持
DELETE/v1/sessions/{session_id}/resources/{resource_id}删除会话资源◐ 部分支持
GET/v1/sessions/{session_id}/resources/{resource_id}读取会话资源◐ 部分支持
POST/v1/sessions/{session_id}/resources/{resource_id}更新会话资源○ 未支持

会话线程(5 个端点,5 个可用)

方法路径说明支持
GET/v1/sessions/{session_id}/threads列出线程◐ 部分支持
GET/v1/sessions/{session_id}/threads/{thread_id}读取线程◐ 部分支持
POST/v1/sessions/{session_id}/threads/{thread_id}/archive归档线程◐ 部分支持
GET/v1/sessions/{session_id}/threads/{thread_id}/events列出线程事件◐ 部分支持
GET/v1/sessions/{session_id}/threads/{thread_id}/stream订阅线程事件◐ 部分支持

技能(9 个端点,0 个可用)

方法路径说明支持
GET/v1/skills列出技能○ 未支持
POST/v1/skills创建技能○ 未支持
DELETE/v1/skills/{skill_id}删除技能○ 未支持
GET/v1/skills/{skill_id}读取技能○ 未支持
GET/v1/skills/{skill_id}/versions列出技能版本○ 未支持
POST/v1/skills/{skill_id}/versions创建技能版本○ 未支持
DELETE/v1/skills/{skill_id}/versions/{version}删除技能版本○ 未支持
GET/v1/skills/{skill_id}/versions/{version}读取技能版本○ 未支持
GET/v1/skills/{skill_id}/versions/{version}/content下载技能版本内容○ 未支持

隧道(10 个端点,0 个可用)

方法路径说明支持
GET/v1/tunnels列出隧道○ 未支持
POST/v1/tunnels创建隧道○ 未支持
GET/v1/tunnels/{tunnel_id}读取隧道○ 未支持
POST/v1/tunnels/{tunnel_id}/archive归档隧道○ 未支持
GET/v1/tunnels/{tunnel_id}/certificates列出隧道证书○ 未支持
POST/v1/tunnels/{tunnel_id}/certificates创建隧道证书○ 未支持
GET/v1/tunnels/{tunnel_id}/certificates/{certificate_id}读取隧道证书○ 未支持
POST/v1/tunnels/{tunnel_id}/certificates/{certificate_id}/archive归档隧道证书○ 未支持
POST/v1/tunnels/{tunnel_id}/reveal_token显示隧道令牌○ 未支持
POST/v1/tunnels/{tunnel_id}/rotate_token轮换隧道令牌○ 未支持

凭据保险库(13 个端点,13 个可用)

方法路径说明支持
GET/v1/vaults列出凭据库● 支持
POST/v1/vaults创建凭据库● 支持
DELETE/v1/vaults/{vault_id}删除凭据库● 支持
GET/v1/vaults/{vault_id}读取凭据库● 支持
POST/v1/vaults/{vault_id}更新凭据库● 支持
POST/v1/vaults/{vault_id}/archive归档凭据库● 支持
GET/v1/vaults/{vault_id}/credentials列出凭据◐ 部分支持
POST/v1/vaults/{vault_id}/credentials创建凭据◐ 部分支持
DELETE/v1/vaults/{vault_id}/credentials/{credential_id}删除凭据◐ 部分支持
GET/v1/vaults/{vault_id}/credentials/{credential_id}读取凭据◐ 部分支持
POST/v1/vaults/{vault_id}/credentials/{credential_id}更新凭据◐ 部分支持
POST/v1/vaults/{vault_id}/credentials/{credential_id}/archive归档凭据◐ 部分支持
POST/v1/vaults/{vault_id}/credentials/{credential_id}/mcp_oauth_validate校验凭据 MCP OAuth◐ 部分支持

与官方的差异

  • 创建智能体:支持文本提示词、模型、元数据与内置工具。MCP、Skills 及额外模型控制尚不支持,传入会返回 400。 multiagent 接受 null 或 coordinator 名册,1–20 项:智能体 ID、{type:"agent",id,version?} 或最多一个 {type:"self"}。创建/更新时固定版本;成员去重且须存在、未归档、不能自身带 multiagent。兼容 API 只提供 bash、edit、glob、grep、read、write、web_search、web_fetch 这 8 个官方工具;configs 不接受其他工具名,经此入口创建的会话不提供后台任务、Monitor 或子智能体。完整原生工具请使用 /agent/v1。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。
  • 读取智能体:将示例中的资源 ID 替换成你创建的资源 ID。
  • 更新智能体:version 可用于乐观并发控制,版本冲突返回 409;无变化的更新不增加版本。MCP、Skills 尚不支持。 multiagent 接受 null 或 coordinator 名册,1–20 项:智能体 ID、{type:"agent",id,version?} 或最多一个 {type:"self"}。创建/更新时固定版本;成员去重且须存在、未归档、不能自身带 multiagent。兼容 API 只提供 bash、edit、glob、grep、read、write、web_search、web_fetch 这 8 个官方工具;configs 不接受其他工具名,经此入口创建的会话不提供后台任务、Monitor 或子智能体。完整原生工具请使用 /agent/v1。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。
  • 列出版本:将示例中的资源 ID 替换成你创建的资源 ID。
  • 归档智能体:归档后保留查询与历史版本,不能继续更新。请只归档自己的测试智能体。
  • 创建会话:先创建智能体,将示例 agent_123 换成返回的 id。Anthropic 兼容 API 的 environment_id 必填,可用 node22 或租户自建 cloud 环境;/agent/v1 可省略 environment_id 得到轻量机器。不支持内联智能体覆盖、预算与凭据库。 支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 列出会话:支持 limit、page 与 agent_id;agent_version、时间范围、deployment_id、memory_store_id、include_archived、order、statuses 尚不支持,传入返回 400。
  • 读取会话:将示例中的资源 ID 替换成你创建的资源 ID。
  • 发送事件:将 sesn_123 换成创建会话返回的 id。每条 user.message 只接受一个非空文本块。支持文本 user.message、user.interrupt 和工具确认;其它事件变体尚不支持。返回的是已接纳事件;模型回复从事件历史或订阅读取。会话等待工具授权时发送的 user.message 会排队:返回的事件 processed_at 为 null,授权处理完成后按发送顺序执行。
  • 列出事件:先发送消息再读取历史;处理完成前可能只看到已接纳的输入。支持分页、事件类型和时间过滤。会话等待工具授权时停在 session.status_idle,stop_reason 为 requires_action,event_ids 列出待确认的 agent.tool_use;运行失败时先出现 session.error,再出现 session.status_terminated。agent.thinking 与官方一致,是不带内容的进度信号。
  • 订阅事件:保持 SSE 连接以接收事件;请求不会像普通 JSON 接口一样立刻结束。先创建会话并替换 sesn_123,再从另一请求发送消息;停止按钮只断开订阅,不会停止智能体。SDK 0.124.0 会过滤 session.usage,完整用量请读历史。传 event_deltas[]=agent.message 可在最终事件到达前收到逐段文本预览;agent.thinking 与官方一致,只有 event_start。
  • 列出环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 创建环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 读取环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 更新环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 归档环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 更新会话:支持 title 与 metadata(官方补丁语义:字符串值写入、null 删除该键、整包 null 清空,未提及的键保留)。官方的 agent 覆盖(tools/mcp_servers)、budget 与 vault_ids 不支持,传入返回 400 并点名字段。归档后的会话更新返回 409。
  • 归档会话:归档后的会话拒绝新消息(400 invalid_request_error,写明会话已归档),读取与事件历史仍可用;重复归档幂等,archived_at 保持首次归档时间。
  • 列出会话资源:支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 添加会话资源:支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 删除会话资源:支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 读取会话资源:支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 列出线程:按 created_at 升序返回主线程及全部子线程。线程 id 为 sthr_ 加所属会话 id 的后缀;子线程的 parent_thread_id 指向主线程,session_id 始终为父会话。agent 是实际运行的定义,内置类型的 name 为类型名,未注册的 id/version 为 null。归档子线程的 status 为 terminated,archived_at 为归档时间;stats/usage 无线程级追踪时如实为 null。
  • 读取线程:返回本会话的主线程或子线程,与列表项逐字段一致。其他会话的线程、未知线程或非 sthr_ id 一律返回 404,不泄露其存在性。
  • 归档线程:主线程沿用会话归档动作;子线程仅归档对应子会话,不归档父会话或其他子线程。子线程归档后 status 为 terminated,带 archived_at;历史事件仍可读。
  • 列出线程事件:读取所选线程自己的事件记录:主线程读主会话,子线程读对应子会话。沿用会话事件接口的查询参数、公开事件类型和 data + next_page 信封。使用网页工具时,两个接口均返回 search_result 块;回答 citations 为 /agent/v1 扩展,/anthropic 将引用显示为正文 [n]。
  • 订阅线程事件:订阅所选线程自己的实时事件流。复用会话 SSE 实现;/agent 接口支持同址只读 WebSocket。主会话流同时包含子线程创建、状态和消息事件,子线程审批带 session_thread_id 上浮;确认或中断携带该字段时路由到所属子线程。
  • 列出凭据库:支持创建、列出、读取、更新、归档与删除。列表支持 limit、page 和 include_archived。归档会同时归档库内全部凭据并清除凭据的值;删除会一并删除全部凭据,不可恢复。以 anthropic. 开头的 metadata 键由平台保留,不能写入。同一个库也可以通过原生接口 /vault/v1 管理。
  • 创建凭据库:支持创建、列出、读取、更新、归档与删除。列表支持 limit、page 和 include_archived。归档会同时归档库内全部凭据并清除凭据的值;删除会一并删除全部凭据,不可恢复。以 anthropic. 开头的 metadata 键由平台保留,不能写入。同一个库也可以通过原生接口 /vault/v1 管理。
  • 删除凭据库:支持创建、列出、读取、更新、归档与删除。列表支持 limit、page 和 include_archived。归档会同时归档库内全部凭据并清除凭据的值;删除会一并删除全部凭据,不可恢复。以 anthropic. 开头的 metadata 键由平台保留,不能写入。同一个库也可以通过原生接口 /vault/v1 管理。
  • 读取凭据库:支持创建、列出、读取、更新、归档与删除。列表支持 limit、page 和 include_archived。归档会同时归档库内全部凭据并清除凭据的值;删除会一并删除全部凭据,不可恢复。以 anthropic. 开头的 metadata 键由平台保留,不能写入。同一个库也可以通过原生接口 /vault/v1 管理。
  • 更新凭据库:支持创建、列出、读取、更新、归档与删除。列表支持 limit、page 和 include_archived。归档会同时归档库内全部凭据并清除凭据的值;删除会一并删除全部凭据,不可恢复。以 anthropic. 开头的 metadata 键由平台保留,不能写入。同一个库也可以通过原生接口 /vault/v1 管理。
  • 归档凭据库:支持创建、列出、读取、更新、归档与删除。列表支持 limit、page 和 include_archived。归档会同时归档库内全部凭据并清除凭据的值;删除会一并删除全部凭据,不可恢复。以 anthropic. 开头的 metadata 键由平台保留,不能写入。同一个库也可以通过原生接口 /vault/v1 管理。
  • 列出凭据:支持 environment_variable 与 static_bearer。environment_variable 的 networking 只支持 limited,传 unrestricted 返回 400;secret_name 只能使用大写字母、数字和下划线,且不能以数字开头;injection_location 的默认值与官方一致。static_bearer 的令牌只在 mcp_server_url 所在主机上可用。创建或更新 mcp_oauth 返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试;需要 OAuth 令牌时请使用 /vault/v1/authorizations 一键授权。每个库最多 20 个有效凭据。以 anthropic. 开头的 metadata 键由平台保留,不能写入。
  • 创建凭据:支持 environment_variable 与 static_bearer。environment_variable 的 networking 只支持 limited,传 unrestricted 返回 400;secret_name 只能使用大写字母、数字和下划线,且不能以数字开头;injection_location 的默认值与官方一致。static_bearer 的令牌只在 mcp_server_url 所在主机上可用。创建或更新 mcp_oauth 返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试;需要 OAuth 令牌时请使用 /vault/v1/authorizations 一键授权。每个库最多 20 个有效凭据。以 anthropic. 开头的 metadata 键由平台保留,不能写入。
  • 删除凭据:支持 environment_variable 与 static_bearer。environment_variable 的 networking 只支持 limited,传 unrestricted 返回 400;secret_name 只能使用大写字母、数字和下划线,且不能以数字开头;injection_location 的默认值与官方一致。static_bearer 的令牌只在 mcp_server_url 所在主机上可用。创建或更新 mcp_oauth 返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试;需要 OAuth 令牌时请使用 /vault/v1/authorizations 一键授权。每个库最多 20 个有效凭据。以 anthropic. 开头的 metadata 键由平台保留,不能写入。
  • 读取凭据:支持 environment_variable 与 static_bearer。environment_variable 的 networking 只支持 limited,传 unrestricted 返回 400;secret_name 只能使用大写字母、数字和下划线,且不能以数字开头;injection_location 的默认值与官方一致。static_bearer 的令牌只在 mcp_server_url 所在主机上可用。创建或更新 mcp_oauth 返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试;需要 OAuth 令牌时请使用 /vault/v1/authorizations 一键授权。每个库最多 20 个有效凭据。以 anthropic. 开头的 metadata 键由平台保留,不能写入。
  • 更新凭据:支持 environment_variable 与 static_bearer。environment_variable 的 networking 只支持 limited,传 unrestricted 返回 400;secret_name 只能使用大写字母、数字和下划线,且不能以数字开头;injection_location 的默认值与官方一致。static_bearer 的令牌只在 mcp_server_url 所在主机上可用。创建或更新 mcp_oauth 返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试;需要 OAuth 令牌时请使用 /vault/v1/authorizations 一键授权。每个库最多 20 个有效凭据。以 anthropic. 开头的 metadata 键由平台保留,不能写入。
  • 归档凭据:支持 environment_variable 与 static_bearer。environment_variable 的 networking 只支持 limited,传 unrestricted 返回 400;secret_name 只能使用大写字母、数字和下划线,且不能以数字开头;injection_location 的默认值与官方一致。static_bearer 的令牌只在 mcp_server_url 所在主机上可用。创建或更新 mcp_oauth 返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试;需要 OAuth 令牌时请使用 /vault/v1/authorizations 一键授权。每个库最多 20 个有效凭据。以 anthropic. 开头的 metadata 键由平台保留,不能写入。
  • 校验凭据 MCP OAuth:只适用于 OAuth 凭据,对其他类型返回 400。结果总是 HTTP 200,status 为 valid、invalid 或 unknown;mcp_probe 只在未通过时给出失败的一步,refresh 只在尝试了续期时给出。

参数与字段的权威定义以 Claude Managed Agents 官方文档为准。

错误按 Claude Managed Agents 格式返回,参见错误;额度与响应头参见限流。

POST /anthropic/v1/agents◐ 部分支持

Claude 官方文档 ↗

请求体

  • namestring必填

    智能体名称,1–255 个字符,工作区内可读。

  • modelstring | object必填

    智能体使用的模型:直接写模型名字符串(如 claude-opus-5),或传对象做附加配置(见子字段)。

    ▸ 展开子字段(4)
    • idstring必填

      模型名字符串,如 claude-opus-5。

    • effortstring | object可选

      每次推理的思考力度:可传级别字符串(如 high)或 {type: high} 对象。创建时省略取该模型的默认值;更新时省略保持不变。

    • inference_geostring可选

      模型推理的地理区域;不传沿用工作区默认。model 是整体替换字段,更新时省略子字段即清除该项。

    • speedstring可选

      推理速度模式:fast 出字显著更快但按溢价计费;并非所有模型都支持,不支持的组合在创建时被拒。

  • systemstring可选

    智能体的系统提示词。

  • descriptionstring可选

    智能体的用途说明。

  • mcp_serversarray可选○ 未支持

    智能体连接的 MCP 服务器列表,最多 20 个,名称必须唯一;每个服务器都要被 tools 里的 mcp_toolset 引用,否则整笔请求被拒。

    ▸ 展开子字段(3)
    • namestring必填

      MCP 服务器在本列表内的唯一名称,1–255 个字符,供 mcp_toolset 配置引用。

    • typestring必填

      服务器类型,目前只支持 url。

      取值 url
    • urlstring必填

      MCP 服务器的端点地址。

  • metadataobject可选

    自定义元数据键值对,最多 16 个键、每个值最长 512 字符。

  • multiagentobject可选

    多智能体协作拓扑:会话主线程作为协调者,从 agents 名单派生会话线程执行工作。

    ▸ 展开子字段(2)
    • agentsarray必填

      协调者可以派生为会话线程的智能体名单,1–20 项;支持 ID 字符串、{type: agent, id, version?} 和最多一个 {type: self}。创建/更新时固定版本。成员须唯一、存在且未归档,不能自身带 multiagent。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。

    • typestring必填

      拓扑类型,目前只有 coordinator。

      取值 coordinator
  • skillsarray可选○ 未支持

    智能体可用的 Skill 列表。

  • toolsarray可选

    智能体可用的工具配置,所有工具合计最多 128 个。

返回

200

支持文本提示词、模型、元数据与内置工具。MCP、Skills 及额外模型控制尚不支持,传入会返回 400。 multiagent 接受 null 或 coordinator 名册,1–20 项:智能体 ID、{type:"agent",id,version?} 或最多一个 {type:"self"}。创建/更新时固定版本;成员去重且须存在、未归档、不能自身带 multiagent。兼容 API 只提供 bash、edit、glob、grep、read、write、web_search、web_fetch 这 8 个官方工具;configs 不接受其他工具名,经此入口创建的会话不提供后台任务、Monitor 或子智能体。完整原生工具请使用 /agent/v1。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstring
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | string
mcp_serversarray<object>
mcp_servers[].namestring
mcp_servers[].typestring
mcp_servers[].urlstring
metadataobject
modelobjectModel identifier and configuration.
model.idstringThe model that will power your agent. See models for additional details and options.
model.effortobjectHow hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes.
model.inference_geostringGeographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo.
model.speedstringInference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.
multiagentnull | objectResolved coordinator topology with a concrete agent roster.
multiagent.agentsarray<object>Agents the coordinator may spawn as session threads, each resolved to a specific version.
multiagent.typestring
namestring
skillsarray<object>
skills[].skill_idstring
skills[].typestring
skills[].versionstring
systemnull | string
toolsarray<object>
tools[].configsarray<object>
tools[].default_configobjectResolved default configuration for agent tools. / Resolved default configuration for all tools from an MCP server.
tools[].typestring
tools[].mcp_server_namestring
tools[].descriptionstring
tools[].input_schemaobjectJSON Schema for custom tool input parameters.
tools[].namestring
typestring
updated_atstringA timestamp in RFC 3339 format
versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.

列出智能体

GET /anthropic/v1/agents● 支持

Claude 官方文档 ↗

请求参数

  • created_at[gte]string可选

    query: 只返回不早于该时间创建的记录。

  • created_at[lte]string可选

    query: 只返回不晚于该时间创建的记录。

  • include_archivedboolean可选

    query: 是否包含已归档的记录。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

200

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstring
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].created_atstringA timestamp in RFC 3339 format
data[].descriptionnull | string
data[].mcp_serversarray<object>
data[].metadataobject
data[].modelobjectModel identifier and configuration.
data[].multiagentnull | objectResolved coordinator topology with a concrete agent roster.
data[].namestring
data[].skillsarray<object>
data[].systemnull | string
data[].toolsarray<object>
data[].typestring
data[].updated_atstringA timestamp in RFC 3339 format
data[].versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.
next_pagestring | null

读取智能体

先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。

GET /anthropic/v1/agents/{agent_id}● 支持

Claude 官方文档 ↗

请求参数

  • agent_idstring必填

    path: 按智能体 ID 过滤结果。

  • versionnumber可选

    query: 路径参数:版本号。

返回

200

将示例中的资源 ID 替换成你创建的资源 ID。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstring
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | string
mcp_serversarray<object>
mcp_servers[].namestring
mcp_servers[].typestring
mcp_servers[].urlstring
metadataobject
modelobjectModel identifier and configuration.
model.idstringThe model that will power your agent. See models for additional details and options.
model.effortobjectHow hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes.
model.inference_geostringGeographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo.
model.speedstringInference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.
multiagentnull | objectResolved coordinator topology with a concrete agent roster.
multiagent.agentsarray<object>Agents the coordinator may spawn as session threads, each resolved to a specific version.
multiagent.typestring
namestring
skillsarray<object>
skills[].skill_idstring
skills[].typestring
skills[].versionstring
systemnull | string
toolsarray<object>
tools[].configsarray<object>
tools[].default_configobjectResolved default configuration for agent tools. / Resolved default configuration for all tools from an MCP server.
tools[].typestring
tools[].mcp_server_namestring
tools[].descriptionstring
tools[].input_schemaobjectJSON Schema for custom tool input parameters.
tools[].namestring
typestring
updated_atstringA timestamp in RFC 3339 format
versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.

先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。

POST /anthropic/v1/agents/{agent_id}◐ 部分支持

Claude 官方文档 ↗

请求参数

  • agent_idstring必填

    path: 按智能体 ID 过滤结果。

  • namestring可选

    智能体名称;省略保持不变,不能传空串清除。

  • modelstring | object可选

    智能体使用的模型:直接写模型名字符串(如 claude-opus-5),或传对象做附加配置(见子字段)。

    ▸ 展开子字段(4)
    • idstring必填

      模型名字符串,如 claude-opus-5。

    • effortstring | object可选

      每次推理的思考力度:可传级别字符串(如 high)或 {type: high} 对象。创建时省略取该模型的默认值;更新时省略保持不变。

    • inference_geostring可选

      模型推理的地理区域;不传沿用工作区默认。model 是整体替换字段,更新时省略子字段即清除该项。

    • speedstring可选

      推理速度模式:fast 出字显著更快但按溢价计费;并非所有模型都支持,不支持的组合在创建时被拒。

  • systemstring可选

    系统提示词;省略保持不变,传空串或 null 清除。

  • descriptionstring可选

    用途说明;省略保持不变,传空串或 null 清除。

  • mcp_serversarray可选○ 未支持

    整体替换的 MCP 服务器列表;省略保持不变,传空数组或 null 清除。

  • metadataobject可选

    元数据补丁:键设为字符串即写入,设为 null 即删除;省略该字段保持不变。存储上限 16 个键、每个值 512 字符。

  • multiagentobject可选

    多智能体协作拓扑:会话主线程作为协调者,从 agents 名单派生会话线程执行工作。

    ▸ 展开子字段(2)
    • agentsarray必填

      协调者可以派生为会话线程的智能体名单,1–20 项;支持 ID 字符串、{type: agent, id, version?} 和最多一个 {type: self}。创建/更新时固定版本。成员须唯一、存在且未归档,不能自身带 multiagent。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。

    • typestring必填

      拓扑类型,目前只有 coordinator。

      取值 coordinator
  • skillsarray可选○ 未支持

    整体替换的 Skill 列表;省略保持不变,传空数组或 null 清除。

  • toolsarray可选

    整体替换的工具配置;省略保持不变,传空数组或 null 清除。

  • ▸ 更多参数(1)
    • versionnumber可选

      智能体当前版本号,用于并发保护:必须与最近一次创建/读取返回的版本一致,否则返回冲突。

返回

200

version 可用于乐观并发控制,版本冲突返回 409;无变化的更新不增加版本。MCP、Skills 尚不支持。 multiagent 接受 null 或 coordinator 名册,1–20 项:智能体 ID、{type:"agent",id,version?} 或最多一个 {type:"self"}。创建/更新时固定版本;成员去重且须存在、未归档、不能自身带 multiagent。兼容 API 只提供 bash、edit、glob、grep、read、write、web_search、web_fetch 这 8 个官方工具;configs 不接受其他工具名,经此入口创建的会话不提供后台任务、Monitor 或子智能体。完整原生工具请使用 /agent/v1。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstring
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | string
mcp_serversarray<object>
mcp_servers[].namestring
mcp_servers[].typestring
mcp_servers[].urlstring
metadataobject
modelobjectModel identifier and configuration.
model.idstringThe model that will power your agent. See models for additional details and options.
model.effortobjectHow hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes.
model.inference_geostringGeographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo.
model.speedstringInference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.
multiagentnull | objectResolved coordinator topology with a concrete agent roster.
multiagent.agentsarray<object>Agents the coordinator may spawn as session threads, each resolved to a specific version.
multiagent.typestring
namestring
skillsarray<object>
skills[].skill_idstring
skills[].typestring
skills[].versionstring
systemnull | string
toolsarray<object>
tools[].configsarray<object>
tools[].default_configobjectResolved default configuration for agent tools. / Resolved default configuration for all tools from an MCP server.
tools[].typestring
tools[].mcp_server_namestring
tools[].descriptionstring
tools[].input_schemaobjectJSON Schema for custom tool input parameters.
tools[].namestring
typestring
updated_atstringA timestamp in RFC 3339 format
versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.

列出版本

先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。

GET /anthropic/v1/agents/{agent_id}/versions● 支持

Claude 官方文档 ↗

请求参数

  • agent_idstring必填

    path: 按智能体 ID 过滤结果。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

200

将示例中的资源 ID 替换成你创建的资源 ID。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstring
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].created_atstringA timestamp in RFC 3339 format
data[].descriptionnull | string
data[].mcp_serversarray<object>
data[].metadataobject
data[].modelobjectModel identifier and configuration.
data[].multiagentnull | objectResolved coordinator topology with a concrete agent roster.
data[].namestring
data[].skillsarray<object>
data[].systemnull | string
data[].toolsarray<object>
data[].typestring
data[].updated_atstringA timestamp in RFC 3339 format
data[].versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.
next_pagestring | null

归档智能体

先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。

POST /anthropic/v1/agents/{agent_id}/archive● 支持

Claude 官方文档 ↗

请求参数

  • agent_idstring必填

    path: 按智能体 ID 过滤结果。

返回

200

归档后保留查询与历史版本,不能继续更新。请只归档自己的测试智能体。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstring
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | string
mcp_serversarray<object>
mcp_servers[].namestring
mcp_servers[].typestring
mcp_servers[].urlstring
metadataobject
modelobjectModel identifier and configuration.
model.idstringThe model that will power your agent. See models for additional details and options.
model.effortobjectHow hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes.
model.inference_geostringGeographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo.
model.speedstringInference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.
multiagentnull | objectResolved coordinator topology with a concrete agent roster.
multiagent.agentsarray<object>Agents the coordinator may spawn as session threads, each resolved to a specific version.
multiagent.typestring
namestring
skillsarray<object>
skills[].skill_idstring
skills[].typestring
skills[].versionstring
systemnull | string
toolsarray<object>
tools[].configsarray<object>
tools[].default_configobjectResolved default configuration for agent tools. / Resolved default configuration for all tools from an MCP server.
tools[].typestring
tools[].mcp_server_namestring
tools[].descriptionstring
tools[].input_schemaobjectJSON Schema for custom tool input parameters.
tools[].namestring
typestring
updated_atstringA timestamp in RFC 3339 format
versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.

先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。

POST /anthropic/v1/sessions◐ 部分支持

Claude 官方文档 ↗

请求体

  • agentstring | object必填

    会话要运行的智能体:直接写智能体 ID 字符串(固定用最新版本),或传对象指定 id 与 version(见子字段)。

    ▸ 展开子字段(8)
    • idstring必填

      会话要运行的智能体 ID。

    • typestring必填

      引用类型,目前只有 agent。

      取值 agent_with_overrides
    • versionnumber可选

      固定使用的智能体版本;省略用最新版本。

    • mcp_serversarray可选

      替换本会话的 MCP 服务器列表:传入的数组整体生效;传空数组清除,省略沿用智能体的配置。

    • modelstring | object可选

      替换本会话的模型:模型名字符串(如 claude-opus-5)或配置对象;省略沿用智能体自身的模型。

    • skillsarray可选

      替换本会话的 Skill 列表;传空数组清除,省略沿用智能体的配置。

    • systemstring可选

      替换本会话的系统提示词,最长 100,000 字符;传 null 清除,省略沿用智能体的。

    • toolsarray可选

      替换本会话的工具配置;传空数组清除,省略沿用智能体的配置。

  • environment_idstring必填

    会话运行所在的环境 ID,决定容器的基础环境。

  • budgetobject可选○ 未支持

    会话的预算上限设置。

    ▸ 展开子字段(2)
    • max_list_costobject必填

      预算内列表类调用的花费上限。

    • typestring必填

      预算类型,目前只有 max_list_cost。

      取值 limit
  • initial_eventsarray可选

    创建时按顺序发给会话的初始事件,支持 user.message 与 user.define_outcome,一次最多 50 条。

  • metadataobject可选

    会话的自定义元数据键值对。

  • resourcesarray可选◐ 部分支持

    要挂载进会话容器的资源(如代码仓库、文件)。

  • titlestring可选

    会话标题,便于在控制台辨认。

  • vault_idsarray可选○ 未支持

    保险库 ID 列表:会话里智能体可以使用这些已存凭据。

返回

200

先创建智能体,将示例 agent_123 换成返回的 id。Anthropic 兼容 API 的 environment_id 必填,可用 node22 或租户自建 cloud 环境;/agent/v1 可省略 environment_id 得到轻量机器。不支持内联智能体覆盖、预算与凭据库。 支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstring
agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
agent.idstring
agent.descriptionnull | string
agent.mcp_serversarray<object>
agent.modelobjectModel identifier and configuration.
agent.multiagentnull | objectResolved coordinator topology with full agent definitions for each roster member.
agent.namestring
agent.skillsarray<object>
agent.systemnull | string
agent.toolsarray<object>
agent.typestring
agent.versionnumber
archived_atnull | stringA timestamp in RFC 3339 format
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestring
created_atstringA timestamp in RFC 3339 format
environment_idstring
metadataobject
outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
outcome_evaluations[].completed_atnull | stringA timestamp in RFC 3339 format
outcome_evaluations[].descriptionstringWhat the agent should produce.
outcome_evaluations[].explanationnull | stringGrader's verdict text from the most recent evaluation. For `satisfied`, explains why criteria are met; for `needs_revision` (intermediate), what's missing; for `failed`, why unrecoverable.
outcome_evaluations[].iterationnumber0-indexed revision cycle the outcome is currently on.
outcome_evaluations[].outcome_idstringServer-generated outc_ ID for this outcome.
outcome_evaluations[].resultstringCurrent evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.
outcome_evaluations[].typestring
resourcesarray<object>
resources[].idstring
resources[].created_atstringA timestamp in RFC 3339 format
resources[].mount_pathstring | null | stringFilesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.
resources[].typestring
resources[].updated_atstringA timestamp in RFC 3339 format
resources[].urlstring
resources[].checkoutnull | object
resources[].file_idstring
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
resources[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
statsobjectTiming statistics for a session.
stats.active_secondsnumberCumulative time in seconds the session spent in `running` status. Excludes idle time.
stats.duration_secondsnumberElapsed time since session creation in seconds. For terminated sessions, frozen at the final update.
statusstringSessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion.
titlenull | string
typestring
updated_atstringA timestamp in RFC 3339 format
usageobjectCumulative token usage for a session across all turns.
usage.active_secondsnumberCumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime cost is priced on.
usage.cache_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.
vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.

GET /anthropic/v1/sessions◐ 部分支持

Claude 官方文档 ↗

请求参数

  • agent_idstring可选

    query: 按智能体 ID 过滤结果。

  • agent_versionnumber可选

    query: 按智能体版本过滤;仅在同时设置 agent_id 时生效。

  • created_at[gt]string可选

    query: 只返回严格晚于该时间创建的记录。

  • created_at[gte]string可选

    query: 只返回不早于该时间创建的记录。

  • created_at[lt]string可选

    query: 只返回严格早于该时间创建的记录。

  • created_at[lte]string可选

    query: 只返回不晚于该时间创建的记录。

  • deployment_idstring可选

    query: 部署 ID(路径或查询参数)。

  • include_archivedboolean可选

    query: 是否包含已归档的记录。

  • memory_store_idstring可选

    query: 记忆库 ID(路径或查询参数)。

  • orderstring可选

    query: 按创建时间排序:asc 从旧到新,desc 从新到旧(默认)。

  • ▸ 更多参数(3)
    • statusesarray可选

      query: 按会话状态过滤,可重复该参数匹配多种状态。

    • limitnumber可选

      query: 每页返回的条数上限。

    • pagestring可选

      query: 分页游标,取自上一页响应的 next_page。

返回

200

支持 limit、page 与 agent_id;agent_version、时间范围、deployment_id、memory_store_id、include_archived、order、statuses 尚不支持,传入返回 400。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstring
data[].agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
data[].created_atstringA timestamp in RFC 3339 format
data[].environment_idstring
data[].metadataobject
data[].outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
data[].resourcesarray<object>
data[].statsobjectTiming statistics for a session.
data[].statusstringSessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion.
data[].titlenull | string
data[].typestring
data[].updated_atstringA timestamp in RFC 3339 format
data[].usageobjectCumulative token usage for a session across all turns.
data[].vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
data[].deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.
next_pagestring | null

读取会话

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /anthropic/v1/sessions/{session_id}● 支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

返回

200

将示例中的资源 ID 替换成你创建的资源 ID。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstring
agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
agent.idstring
agent.descriptionnull | string
agent.mcp_serversarray<object>
agent.modelobjectModel identifier and configuration.
agent.multiagentnull | objectResolved coordinator topology with full agent definitions for each roster member.
agent.namestring
agent.skillsarray<object>
agent.systemnull | string
agent.toolsarray<object>
agent.typestring
agent.versionnumber
archived_atnull | stringA timestamp in RFC 3339 format
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestring
created_atstringA timestamp in RFC 3339 format
environment_idstring
metadataobject
outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
outcome_evaluations[].completed_atnull | stringA timestamp in RFC 3339 format
outcome_evaluations[].descriptionstringWhat the agent should produce.
outcome_evaluations[].explanationnull | stringGrader's verdict text from the most recent evaluation. For `satisfied`, explains why criteria are met; for `needs_revision` (intermediate), what's missing; for `failed`, why unrecoverable.
outcome_evaluations[].iterationnumber0-indexed revision cycle the outcome is currently on.
outcome_evaluations[].outcome_idstringServer-generated outc_ ID for this outcome.
outcome_evaluations[].resultstringCurrent evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.
outcome_evaluations[].typestring
resourcesarray<object>
resources[].idstring
resources[].created_atstringA timestamp in RFC 3339 format
resources[].mount_pathstring | null | stringFilesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.
resources[].typestring
resources[].updated_atstringA timestamp in RFC 3339 format
resources[].urlstring
resources[].checkoutnull | object
resources[].file_idstring
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
resources[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
statsobjectTiming statistics for a session.
stats.active_secondsnumberCumulative time in seconds the session spent in `running` status. Excludes idle time.
stats.duration_secondsnumberElapsed time since session creation in seconds. For terminated sessions, frozen at the final update.
statusstringSessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion.
titlenull | string
typestring
updated_atstringA timestamp in RFC 3339 format
usageobjectCumulative token usage for a session across all turns.
usage.active_secondsnumberCumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime cost is priced on.
usage.cache_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.
vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /anthropic/v1/sessions/{session_id}/events◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • eventsarray必填

    要发送给会话的事件列表。

返回

200

将 sesn_123 换成创建会话返回的 id。每条 user.message 只接受一个非空文本块。支持文本 user.message、user.interrupt 和工具确认;其它事件变体尚不支持。返回的是已接纳事件;模型回复从事件历史或订阅读取。会话等待工具授权时发送的 user.message 会排队:返回的事件 processed_at 为 null,授权处理完成后按发送顺序执行。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Sent events
data[].idstringUnique identifier for this event.
data[].contentarray<object>Array of content blocks comprising the user message. / The result content returned by the tool. / The result content returned by the tool. / System content blocks. Text-only.
data[].typestring
data[].processed_atnull | string | string | null | string | null | stringA timestamp in RFC 3339 format
data[].session_thread_idnull | stringIf absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Set by the server to the subagent thread this confirmation was routed to. Omitted when it was routed to the primary thread. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread.
data[].resultstringUserToolConfirmationResult enum
data[].tool_use_idstringThe id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. / The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field.
data[].deny_messagenull | stringOptional message providing context for a 'deny' decision. Only allowed when result is 'deny'.
data[].custom_tool_use_idstringThe id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field.
data[].is_errornull | booleanWhether the tool execution resulted in an error.
data[].descriptionstringWhat the agent should produce. Copied from the input event.
data[].max_iterationsnull | numberEvaluate-then-revise cycles before giving up. Default 3, max 20.
data[].outcome_idstringServer-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.
data[].rubricobjectRubric for grading the quality of an outcome.

列出事件

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /anthropic/v1/sessions/{session_id}/events● 支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • created_at[gt]string可选

    query: 只返回严格晚于该时间创建的记录。

  • created_at[gte]string可选

    query: 只返回不早于该时间创建的记录。

  • created_at[lt]string可选

    query: 只返回严格早于该时间创建的记录。

  • created_at[lte]string可选

    query: 只返回不晚于该时间创建的记录。

  • orderstring可选

    query: 按事件处理时间排序:asc 从早到晚(默认),desc 相反。

  • typesarray可选

    query: 按事件类型过滤,取值与返回事件的 type 字段一致(如 user.message、agent.tool_use);不传返回全部类型。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

200

先发送消息再读取历史;处理完成前可能只看到已接纳的输入。支持分页、事件类型和时间过滤。会话等待工具授权时停在 session.status_idle,stop_reason 为 requires_action,event_ids 列出待确认的 agent.tool_use;运行失败时先出现 session.error,再出现 session.status_terminated。agent.thinking 与官方一致,是不带内容的进度信号。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringUnique identifier for this event.
data[].contentarray<object>Array of content blocks comprising the user message. / The result content returned by the tool. / Array of text blocks comprising the agent response. / The result content returned by the tool. / The result content returned by the tool. / Message content blocks. / Message content blocks. / The result content returned by the tool. / System content blocks. Text-only.
data[].typestring
data[].processed_atnull | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | null | string | string | string | null | string | stringA timestamp in RFC 3339 format
data[].session_thread_idnull | string | string | string | string | string | null | string | stringIf absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Set by the server to the subagent thread this confirmation was routed to. Omitted when it was routed to the primary thread. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.custom_tool_result` by `custom_tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` by `tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` or `user.tool_result` by `tool_use_id`, so clients do not send it back. / Public `sthr_` ID of the newly created thread. / Public sthr_ ID of the thread that started running. / Public sthr_ ID of the thread that went idle. / Public sthr_ ID of the thread that terminated. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / Public sthr_ ID of the thread that is retrying.
data[].resultstringUserToolConfirmationResult enum / Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress.
data[].tool_use_idstringThe id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. / The id of the `agent.tool_use` event this result corresponds to. / The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field.
data[].deny_messagenull | stringOptional message providing context for a 'deny' decision. Only allowed when result is 'deny'.
data[].custom_tool_use_idstringThe id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field.
data[].is_errornull | booleanWhether the tool execution resulted in an error. / Whether the model request resulted in an error. / Whether the tool execution resulted in an error.
data[].inputobjectInput parameters for the tool call.
data[].namestringName of the custom tool being called. / Name of the MCP tool being used. / Name of the agent tool being used.
data[].mcp_server_namestringName of the MCP server providing the tool.
data[].evaluated_permissionstringAgentEvaluatedPermission enum
data[].evaluationobjectNames the resolved permission_policy that produced evaluated_permission, and under auto carries the judgement. Open union: clients must tolerate unknown variants.
data[].mcp_tool_use_idstringThe id of the `agent.mcp_tool_use` event this result corresponds to.
data[].from_session_thread_idstringPublic `sthr_` ID of the thread that sent the message.
data[].from_agent_namenull | stringName of the callable agent this message came from. Absent when received from the primary agent.
data[].to_session_thread_idstringPublic `sthr_` ID of the thread the message was sent to.
data[].to_agent_namenull | stringName of the callable agent this message was sent to. Absent when sent to the primary agent.
data[].errorobject
data[].stop_reasonobject
data[].agent_namestringName of the callable agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs.
data[].iterationnumber0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc. / 0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`. / 0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.
data[].outcome_idstringThe `outc_` ID of the outcome being evaluated. / Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.
data[].explanationstringHuman-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why.
data[].outcome_evaluation_start_idstringThe id of the corresponding `span.outcome_evaluation_start` event.
data[].usageobjectToken usage for a single model request. / Point-in-time snapshot of a session's cumulative usage.
data[].model_request_start_idstringThe id of the corresponding `span.model_request_start` event.
data[].model_usageobjectToken usage for a single model request.
data[].descriptionstringWhat the agent should produce. Copied from the input event.
data[].max_iterationsnull | numberEvaluate-then-revise cycles before giving up. Default 3, max 20.
data[].rubricobjectRubric for grading the quality of an outcome.
data[].agentnull | objectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
data[].budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
data[].metadataobjectThe session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty.
data[].titlenull | stringThe session's new title. Present only when the update changed it.
next_pagestring | null

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /anthropic/v1/sessions/{session_id}/events/stream◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • event_deltasarray可选

    query: 设置后连接同时接收流式增量事件。

返回

200

保持 SSE 连接以接收事件;请求不会像普通 JSON 接口一样立刻结束。先创建会话并替换 sesn_123,再从另一请求发送消息;停止按钮只断开订阅,不会停止智能体。SDK 0.124.0 会过滤 session.usage,完整用量请读历史。传 event_deltas[]=agent.message 可在最终事件到达前收到逐段文本预览;agent.thinking 与官方一致,只有 event_start。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Server-sent events

text/event-stream — chunk / 事件对象

未声明字段结构。

GET /anthropic/v1/deployment_runs○ 未支持

请求参数

  • created_at[gt]string可选

    query: 只返回严格晚于该时间创建的记录。

  • created_at[gte]string可选

    query: 只返回不早于该时间创建的记录。

  • created_at[lt]string可选

    query: 只返回严格早于该时间创建的记录。

  • created_at[lte]string可选

    query: 只返回不晚于该时间创建的记录。

  • deployment_idstring可选

    query: 部署 ID(路径或查询参数)。

  • has_errorboolean可选

    query: 按是否出错过滤部署运行。

  • trigger_typestring可选

    query: 按触发类型过滤部署运行。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不能按计划或触发条件自动运行智能体。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringUnique identifier for this run (`drun_...`).
data[].agentobjectA resolved agent reference with a concrete version.
data[].created_atstringA timestamp in RFC 3339 format
data[].deployment_idstringID of the deployment that produced this run.
data[].errornull | objectWhy the run failed to create a session. The type identifies the failure; message is human-readable detail.
data[].session_idnull | stringPopulated on success. Null on creation failure. Exactly one of `session_id` or `error` is non-null.
data[].trigger_contextobjectDescribes what triggered a deployment run, with trigger-specific metadata.
data[].typestring
next_pagestring | null

GET /anthropic/v1/deployment_runs/{deployment_run_id}○ 未支持

请求参数

  • deployment_run_idstring必填

    path: 路径参数:部署运行 ID。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不能按计划或触发条件自动运行智能体。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this run (`drun_...`).
agentobjectA resolved agent reference with a concrete version.
agent.idstring
agent.typestring
agent.versionnumber
created_atstringA timestamp in RFC 3339 format
deployment_idstringID of the deployment that produced this run.
errornull | objectWhy the run failed to create a session. The type identifies the failure; message is human-readable detail.
error.messagestringHuman-readable error description.
error.typestring
session_idnull | stringPopulated on success. Null on creation failure. Exactly one of `session_id` or `error` is non-null.
trigger_contextobjectDescribes what triggered a deployment run, with trigger-specific metadata.
trigger_context.scheduled_atstringA timestamp in RFC 3339 format
trigger_context.typestring
typestring

GET /anthropic/v1/deployments○ 未支持

请求参数

  • agent_idstring可选

    query: 按智能体 ID 过滤结果。

  • created_at[gte]string可选

    query: 只返回不早于该时间创建的记录。

  • created_at[lte]string可选

    query: 只返回不晚于该时间创建的记录。

  • include_archivedboolean可选

    query: 是否包含已归档的记录。

  • statusstring可选

    query: 按状态过滤:active 或 paused。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不能按计划或触发条件自动运行智能体。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringUnique identifier for this deployment.
data[].agentobjectA resolved agent reference with a concrete version.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].created_atstringA timestamp in RFC 3339 format
data[].descriptionnull | stringDescription of what the deployment does.
data[].environment_idstringID of the `environment` where sessions run.
data[].initial_eventsarray<object>Events sent to each session immediately after creation.
data[].metadataobjectArbitrary key-value metadata. Maximum 16 pairs.
data[].namestringHuman-readable name.
data[].paused_reasonnull | objectWhy a deployment is paused. Non-null exactly when `status` is `paused`.
data[].resourcesarray<object>Resources attached to sessions created from this deployment. Echoes the input minus write-only credentials.
data[].schedulenull | object5-field POSIX cron schedule with computed runtime timestamps.
data[].statusstringLifecycle status of a deployment.
data[].typestring
data[].updated_atstringA timestamp in RFC 3339 format
data[].vault_idsarray<string>Vault IDs supplying stored credentials for sessions created from this deployment.
data[].budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
next_pagestring | null

POST /anthropic/v1/deployments○ 未支持

请求体

  • namestring必填

    Human-readable name for the deployment.

  • agentstring | object必填

    Agent to deploy. Accepts the `agent` ID string, which pins the latest version, or an `agent` object with both id and version specified. The agent must exist and not be archived.

    ▸ 展开子字段(3)
    • idstring必填

      The `agent` ID.

    • typestring必填
      取值 agent
    • versionnumber可选

      The specific `agent` version to use. Omit to use the latest version. Must be at least 1 if specified.

  • environment_idstring必填

    ID of the `environment` defining the container configuration for sessions created from this deployment.

  • initial_eventsarray必填

    Events to send to each session immediately after creation. At least 1, maximum 50.

  • budgetobject可选

    A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.

    ▸ 展开子字段(2)
    • max_list_costobject必填

      A monetary amount in a specific currency.

    • typestring必填
      取值 limit
  • descriptionstring可选

    Description of what the deployment does.

  • metadataobject可选

    Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars.

  • resourcesarray可选

    Resources (e.g. repositories, files) to mount into each session's container. Maximum 500.

  • scheduleobject可选

    5-field POSIX cron schedule. Literal wall-clock matching in the configured timezone.

    ▸ 展开子字段(3)
    • expressionstring必填

      5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 \* \* 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended cron syntax - seconds or year fields, and the special characters L, W, #, and ? - is not supported, nor are predefined shortcuts (@daily).

    • timezonestring必填

      Required. IANA timezone identifier (e.g., "America/Los_Angeles", "UTC"). Validated against the IANA timezone database.

    • typestring必填
      取值 cron
  • vault_idsarray可选

    Vault IDs for stored credentials the agent can use during sessions created from this deployment. Maximum 50.

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不能按计划或触发条件自动运行智能体。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this deployment.
agentobjectA resolved agent reference with a concrete version.
agent.idstring
agent.typestring
agent.versionnumber
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | stringDescription of what the deployment does.
environment_idstringID of the `environment` where sessions run.
initial_eventsarray<object>Events sent to each session immediately after creation.
initial_events[].contentarray<object>Array of content blocks for the user message. / System content blocks to append. Text-only.
initial_events[].typestring
initial_events[].descriptionstringWhat the agent should produce. This is the task specification.
initial_events[].rubricobjectRubric for grading the quality of an outcome.
initial_events[].max_iterationsnull | numberEval→revision cycles before giving up. Default 3, max 20.
metadataobjectArbitrary key-value metadata. Maximum 16 pairs.
namestringHuman-readable name.
paused_reasonnull | objectWhy a deployment is paused. Non-null exactly when `status` is `paused`.
paused_reason.typestring
paused_reason.errorobjectThe error that triggered an auto-pause. Matches the failed run's `error.type`.
resourcesarray<object>Resources attached to sessions created from this deployment. Echoes the input minus write-only credentials.
resources[].typestring
resources[].urlstringGithub URL of the repository
resources[].checkoutnull | objectBranch or commit to check out. Defaults to the repository's default branch.
resources[].mount_pathnull | stringMount path in the container. Defaults to `/workspace/<repo-name>`. / Mount path in the container. Defaults to `/mnt/session/uploads/<file_id>`.
resources[].file_idstringID of a previously uploaded file.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
schedulenull | object5-field POSIX cron schedule with computed runtime timestamps.
schedule.expressionstring5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 * * 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended cron syntax - seconds or year fields, and the special characters L, W, #, and ? - is not supported, nor are predefined shortcuts (@daily).
schedule.timezonestringIANA timezone identifier (e.g., "America/Los_Angeles", "UTC").
schedule.typestring
schedule.last_run_atnull | stringA timestamp in RFC 3339 format
schedule.upcoming_runs_atarray<string>Up to 5 timestamps of upcoming cron occurrences. Non-empty for active and paused deployments (reflects what the schedule would do if unpaused); empty once the deployment is archived (`archived_at` set). Each fire is offset by a small per-schedule jitter, so a run will actually start at or shortly after its listed time.
statusstringLifecycle status of a deployment.
typestring
updated_atstringA timestamp in RFC 3339 format
vault_idsarray<string>Vault IDs supplying stored credentials for sessions created from this deployment.
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestring

GET /anthropic/v1/deployments/{deployment_id}○ 未支持

请求参数

  • deployment_idstring必填

    path: 部署 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不能按计划或触发条件自动运行智能体。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this deployment.
agentobjectA resolved agent reference with a concrete version.
agent.idstring
agent.typestring
agent.versionnumber
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | stringDescription of what the deployment does.
environment_idstringID of the `environment` where sessions run.
initial_eventsarray<object>Events sent to each session immediately after creation.
initial_events[].contentarray<object>Array of content blocks for the user message. / System content blocks to append. Text-only.
initial_events[].typestring
initial_events[].descriptionstringWhat the agent should produce. This is the task specification.
initial_events[].rubricobjectRubric for grading the quality of an outcome.
initial_events[].max_iterationsnull | numberEval→revision cycles before giving up. Default 3, max 20.
metadataobjectArbitrary key-value metadata. Maximum 16 pairs.
namestringHuman-readable name.
paused_reasonnull | objectWhy a deployment is paused. Non-null exactly when `status` is `paused`.
paused_reason.typestring
paused_reason.errorobjectThe error that triggered an auto-pause. Matches the failed run's `error.type`.
resourcesarray<object>Resources attached to sessions created from this deployment. Echoes the input minus write-only credentials.
resources[].typestring
resources[].urlstringGithub URL of the repository
resources[].checkoutnull | objectBranch or commit to check out. Defaults to the repository's default branch.
resources[].mount_pathnull | stringMount path in the container. Defaults to `/workspace/<repo-name>`. / Mount path in the container. Defaults to `/mnt/session/uploads/<file_id>`.
resources[].file_idstringID of a previously uploaded file.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
schedulenull | object5-field POSIX cron schedule with computed runtime timestamps.
schedule.expressionstring5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 * * 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended cron syntax - seconds or year fields, and the special characters L, W, #, and ? - is not supported, nor are predefined shortcuts (@daily).
schedule.timezonestringIANA timezone identifier (e.g., "America/Los_Angeles", "UTC").
schedule.typestring
schedule.last_run_atnull | stringA timestamp in RFC 3339 format
schedule.upcoming_runs_atarray<string>Up to 5 timestamps of upcoming cron occurrences. Non-empty for active and paused deployments (reflects what the schedule would do if unpaused); empty once the deployment is archived (`archived_at` set). Each fire is offset by a small per-schedule jitter, so a run will actually start at or shortly after its listed time.
statusstringLifecycle status of a deployment.
typestring
updated_atstringA timestamp in RFC 3339 format
vault_idsarray<string>Vault IDs supplying stored credentials for sessions created from this deployment.
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestring

POST /anthropic/v1/deployments/{deployment_id}○ 未支持

请求参数

  • deployment_idstring必填

    path: 部署 ID(路径或查询参数)。

  • namestring可选

    Human-readable name. Must be non-empty. Omit to preserve. Cannot be cleared.

  • agentstring | object可选

    Agent to deploy. Accepts the `agent` ID string, which re-pins to the latest version, or an `agent` object with both id and version specified. Omit to preserve. Cannot be cleared.

    ▸ 展开子字段(3)
    • idstring必填

      The `agent` ID.

    • typestring必填
      取值 agent
    • versionnumber可选

      The specific `agent` version to use. Omit to use the latest version. Must be at least 1 if specified.

  • environment_idstring可选

    ID of the `environment` where sessions run. Omit to preserve. Cannot be cleared.

  • budgetobject可选

    A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.

    ▸ 展开子字段(2)
    • max_list_costobject必填

      A monetary amount in a specific currency.

    • typestring必填
      取值 limit
  • descriptionstring可选

    Description. Omit to preserve; send empty string or null to clear.

  • initial_eventsarray可选

    Initial events. Full replacement. Omit to preserve. Cannot be cleared. At least 1, maximum 50.

  • metadataobject可选

    Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve. The stored bag is limited to 16 keys (up to 64 chars each) with values up to 512 chars.

  • resourcesarray可选

    Session resources. Full replacement. Omit to preserve; send empty array or null to clear. Maximum 500.

  • scheduleobject可选

    5-field POSIX cron schedule. Literal wall-clock matching in the configured timezone.

    ▸ 展开子字段(3)
    • expressionstring必填

      5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 \* \* 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended cron syntax - seconds or year fields, and the special characters L, W, #, and ? - is not supported, nor are predefined shortcuts (@daily).

    • timezonestring必填

      Required. IANA timezone identifier (e.g., "America/Los_Angeles", "UTC"). Validated against the IANA timezone database.

    • typestring必填
      取值 cron
  • ▸ 更多参数(1)
    • vault_idsarray可选

      Vault IDs. Full replacement. Omit to preserve; send empty array or null to clear. Maximum 50.

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不能按计划或触发条件自动运行智能体。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this deployment.
agentobjectA resolved agent reference with a concrete version.
agent.idstring
agent.typestring
agent.versionnumber
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | stringDescription of what the deployment does.
environment_idstringID of the `environment` where sessions run.
initial_eventsarray<object>Events sent to each session immediately after creation.
initial_events[].contentarray<object>Array of content blocks for the user message. / System content blocks to append. Text-only.
initial_events[].typestring
initial_events[].descriptionstringWhat the agent should produce. This is the task specification.
initial_events[].rubricobjectRubric for grading the quality of an outcome.
initial_events[].max_iterationsnull | numberEval→revision cycles before giving up. Default 3, max 20.
metadataobjectArbitrary key-value metadata. Maximum 16 pairs.
namestringHuman-readable name.
paused_reasonnull | objectWhy a deployment is paused. Non-null exactly when `status` is `paused`.
paused_reason.typestring
paused_reason.errorobjectThe error that triggered an auto-pause. Matches the failed run's `error.type`.
resourcesarray<object>Resources attached to sessions created from this deployment. Echoes the input minus write-only credentials.
resources[].typestring
resources[].urlstringGithub URL of the repository
resources[].checkoutnull | objectBranch or commit to check out. Defaults to the repository's default branch.
resources[].mount_pathnull | stringMount path in the container. Defaults to `/workspace/<repo-name>`. / Mount path in the container. Defaults to `/mnt/session/uploads/<file_id>`.
resources[].file_idstringID of a previously uploaded file.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
schedulenull | object5-field POSIX cron schedule with computed runtime timestamps.
schedule.expressionstring5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 * * 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended cron syntax - seconds or year fields, and the special characters L, W, #, and ? - is not supported, nor are predefined shortcuts (@daily).
schedule.timezonestringIANA timezone identifier (e.g., "America/Los_Angeles", "UTC").
schedule.typestring
schedule.last_run_atnull | stringA timestamp in RFC 3339 format
schedule.upcoming_runs_atarray<string>Up to 5 timestamps of upcoming cron occurrences. Non-empty for active and paused deployments (reflects what the schedule would do if unpaused); empty once the deployment is archived (`archived_at` set). Each fire is offset by a small per-schedule jitter, so a run will actually start at or shortly after its listed time.
statusstringLifecycle status of a deployment.
typestring
updated_atstringA timestamp in RFC 3339 format
vault_idsarray<string>Vault IDs supplying stored credentials for sessions created from this deployment.
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestring

POST /anthropic/v1/deployments/{deployment_id}/archive○ 未支持

请求参数

  • deployment_idstring必填

    path: 部署 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不能按计划或触发条件自动运行智能体。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this deployment.
agentobjectA resolved agent reference with a concrete version.
agent.idstring
agent.typestring
agent.versionnumber
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | stringDescription of what the deployment does.
environment_idstringID of the `environment` where sessions run.
initial_eventsarray<object>Events sent to each session immediately after creation.
initial_events[].contentarray<object>Array of content blocks for the user message. / System content blocks to append. Text-only.
initial_events[].typestring
initial_events[].descriptionstringWhat the agent should produce. This is the task specification.
initial_events[].rubricobjectRubric for grading the quality of an outcome.
initial_events[].max_iterationsnull | numberEval→revision cycles before giving up. Default 3, max 20.
metadataobjectArbitrary key-value metadata. Maximum 16 pairs.
namestringHuman-readable name.
paused_reasonnull | objectWhy a deployment is paused. Non-null exactly when `status` is `paused`.
paused_reason.typestring
paused_reason.errorobjectThe error that triggered an auto-pause. Matches the failed run's `error.type`.
resourcesarray<object>Resources attached to sessions created from this deployment. Echoes the input minus write-only credentials.
resources[].typestring
resources[].urlstringGithub URL of the repository
resources[].checkoutnull | objectBranch or commit to check out. Defaults to the repository's default branch.
resources[].mount_pathnull | stringMount path in the container. Defaults to `/workspace/<repo-name>`. / Mount path in the container. Defaults to `/mnt/session/uploads/<file_id>`.
resources[].file_idstringID of a previously uploaded file.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
schedulenull | object5-field POSIX cron schedule with computed runtime timestamps.
schedule.expressionstring5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 * * 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended cron syntax - seconds or year fields, and the special characters L, W, #, and ? - is not supported, nor are predefined shortcuts (@daily).
schedule.timezonestringIANA timezone identifier (e.g., "America/Los_Angeles", "UTC").
schedule.typestring
schedule.last_run_atnull | stringA timestamp in RFC 3339 format
schedule.upcoming_runs_atarray<string>Up to 5 timestamps of upcoming cron occurrences. Non-empty for active and paused deployments (reflects what the schedule would do if unpaused); empty once the deployment is archived (`archived_at` set). Each fire is offset by a small per-schedule jitter, so a run will actually start at or shortly after its listed time.
statusstringLifecycle status of a deployment.
typestring
updated_atstringA timestamp in RFC 3339 format
vault_idsarray<string>Vault IDs supplying stored credentials for sessions created from this deployment.
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestring

POST /anthropic/v1/deployments/{deployment_id}/pause○ 未支持

请求参数

  • deployment_idstring必填

    path: 部署 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不能按计划或触发条件自动运行智能体。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this deployment.
agentobjectA resolved agent reference with a concrete version.
agent.idstring
agent.typestring
agent.versionnumber
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | stringDescription of what the deployment does.
environment_idstringID of the `environment` where sessions run.
initial_eventsarray<object>Events sent to each session immediately after creation.
initial_events[].contentarray<object>Array of content blocks for the user message. / System content blocks to append. Text-only.
initial_events[].typestring
initial_events[].descriptionstringWhat the agent should produce. This is the task specification.
initial_events[].rubricobjectRubric for grading the quality of an outcome.
initial_events[].max_iterationsnull | numberEval→revision cycles before giving up. Default 3, max 20.
metadataobjectArbitrary key-value metadata. Maximum 16 pairs.
namestringHuman-readable name.
paused_reasonnull | objectWhy a deployment is paused. Non-null exactly when `status` is `paused`.
paused_reason.typestring
paused_reason.errorobjectThe error that triggered an auto-pause. Matches the failed run's `error.type`.
resourcesarray<object>Resources attached to sessions created from this deployment. Echoes the input minus write-only credentials.
resources[].typestring
resources[].urlstringGithub URL of the repository
resources[].checkoutnull | objectBranch or commit to check out. Defaults to the repository's default branch.
resources[].mount_pathnull | stringMount path in the container. Defaults to `/workspace/<repo-name>`. / Mount path in the container. Defaults to `/mnt/session/uploads/<file_id>`.
resources[].file_idstringID of a previously uploaded file.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
schedulenull | object5-field POSIX cron schedule with computed runtime timestamps.
schedule.expressionstring5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 * * 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended cron syntax - seconds or year fields, and the special characters L, W, #, and ? - is not supported, nor are predefined shortcuts (@daily).
schedule.timezonestringIANA timezone identifier (e.g., "America/Los_Angeles", "UTC").
schedule.typestring
schedule.last_run_atnull | stringA timestamp in RFC 3339 format
schedule.upcoming_runs_atarray<string>Up to 5 timestamps of upcoming cron occurrences. Non-empty for active and paused deployments (reflects what the schedule would do if unpaused); empty once the deployment is archived (`archived_at` set). Each fire is offset by a small per-schedule jitter, so a run will actually start at or shortly after its listed time.
statusstringLifecycle status of a deployment.
typestring
updated_atstringA timestamp in RFC 3339 format
vault_idsarray<string>Vault IDs supplying stored credentials for sessions created from this deployment.
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestring

POST /anthropic/v1/deployments/{deployment_id}/run○ 未支持

请求参数

  • deployment_idstring必填

    path: 部署 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不能按计划或触发条件自动运行智能体。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this run (`drun_...`).
agentobjectA resolved agent reference with a concrete version.
agent.idstring
agent.typestring
agent.versionnumber
created_atstringA timestamp in RFC 3339 format
deployment_idstringID of the deployment that produced this run.
errornull | objectWhy the run failed to create a session. The type identifies the failure; message is human-readable detail.
error.messagestringHuman-readable error description.
error.typestring
session_idnull | stringPopulated on success. Null on creation failure. Exactly one of `session_id` or `error` is non-null.
trigger_contextobjectDescribes what triggered a deployment run, with trigger-specific metadata.
trigger_context.scheduled_atstringA timestamp in RFC 3339 format
trigger_context.typestring
typestring

POST /anthropic/v1/deployments/{deployment_id}/unpause○ 未支持

请求参数

  • deployment_idstring必填

    path: 部署 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不能按计划或触发条件自动运行智能体。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this deployment.
agentobjectA resolved agent reference with a concrete version.
agent.idstring
agent.typestring
agent.versionnumber
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | stringDescription of what the deployment does.
environment_idstringID of the `environment` where sessions run.
initial_eventsarray<object>Events sent to each session immediately after creation.
initial_events[].contentarray<object>Array of content blocks for the user message. / System content blocks to append. Text-only.
initial_events[].typestring
initial_events[].descriptionstringWhat the agent should produce. This is the task specification.
initial_events[].rubricobjectRubric for grading the quality of an outcome.
initial_events[].max_iterationsnull | numberEval→revision cycles before giving up. Default 3, max 20.
metadataobjectArbitrary key-value metadata. Maximum 16 pairs.
namestringHuman-readable name.
paused_reasonnull | objectWhy a deployment is paused. Non-null exactly when `status` is `paused`.
paused_reason.typestring
paused_reason.errorobjectThe error that triggered an auto-pause. Matches the failed run's `error.type`.
resourcesarray<object>Resources attached to sessions created from this deployment. Echoes the input minus write-only credentials.
resources[].typestring
resources[].urlstringGithub URL of the repository
resources[].checkoutnull | objectBranch or commit to check out. Defaults to the repository's default branch.
resources[].mount_pathnull | stringMount path in the container. Defaults to `/workspace/<repo-name>`. / Mount path in the container. Defaults to `/mnt/session/uploads/<file_id>`.
resources[].file_idstringID of a previously uploaded file.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
schedulenull | object5-field POSIX cron schedule with computed runtime timestamps.
schedule.expressionstring5-field POSIX cron expression: minute hour day-of-month month day-of-week (e.g., "0 9 * * 1-5" for weekdays at 9am). Day-of-week is 0-7 where 0 and 7 both mean Sunday. Extended cron syntax - seconds or year fields, and the special characters L, W, #, and ? - is not supported, nor are predefined shortcuts (@daily).
schedule.timezonestringIANA timezone identifier (e.g., "America/Los_Angeles", "UTC").
schedule.typestring
schedule.last_run_atnull | stringA timestamp in RFC 3339 format
schedule.upcoming_runs_atarray<string>Up to 5 timestamps of upcoming cron occurrences. Non-empty for active and paused deployments (reflects what the schedule would do if unpaused); empty once the deployment is archived (`archived_at` set). Each fire is offset by a small per-schedule jitter, so a run will actually start at or shortly after its listed time.
statusstringLifecycle status of a deployment.
typestring
updated_atstringA timestamp in RFC 3339 format
vault_idsarray<string>Vault IDs supplying stored credentials for sessions created from this deployment.
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestring

GET /anthropic/v1/environments◐ 部分支持

Claude 官方文档 ↗

请求参数

  • include_archivedboolean可选

    query: 是否包含已归档的记录。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

200

支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringEnvironment identifier (e.g., 'env_...')
data[].archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
data[].configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
data[].created_atstringRFC 3339 timestamp when environment was created
data[].descriptionnull | stringUser-provided description for the environment; null when unset
data[].metadataobjectUser-provided metadata key-value pairs
data[].namestringHuman-readable name for the environment
data[].typestringThe type of object (always 'environment')
data[].updated_atstringRFC 3339 timestamp when environment was last updated
data[].scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.
next_pagestring | null

POST /anthropic/v1/environments◐ 部分支持

请求体

  • namestring必填

    Human-readable name for the environment

  • configobject可选

    Environment configuration

    ▸ 展开子字段(3)
    • typestring必填

      Environment type

      取值 self_hosted
    • networkingobject可选

      Network configuration policy. Omit on update to preserve the existing value.

    • packagesobject可选

      Specify packages (and optionally their versions) available in this environment. When versioning, use the version semantics relevant for the package manager, e.g. for `pip` use `package==1.0.0`. You are responsible for validating the package and version exist. Unversioned installs the latest. Under `limited` networking, requires `networking.allow_package_managers` to be `true`.

  • descriptionstring可选

    Optional description of the environment

  • metadataobject可选

    User-provided metadata key-value pairs

  • scopestring可选

    The visibility scope for this environment. 'organization' makes the environment visible to all accounts. 'account' restricts visibility to the owning account only. API organizations support only 'organization'; 'account' is rejected. If not specified, defaults based on organization type.

返回

501

支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringEnvironment identifier (e.g., 'env_...')
archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
config.networkingobjectNetwork configuration policy.
config.packagesobjectPackage manager configuration.
config.typestringEnvironment type
created_atstringRFC 3339 timestamp when environment was created
descriptionnull | stringUser-provided description for the environment; null when unset
metadataobjectUser-provided metadata key-value pairs
namestringHuman-readable name for the environment
typestringThe type of object (always 'environment')
updated_atstringRFC 3339 timestamp when environment was last updated
scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

DELETE /anthropic/v1/environments/{environment_id}○ 未支持

请求参数

  • environment_idstring必填

    path: 环境 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

会话目前统一使用平台内置环境,还不能自定义创建或管理环境。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringEnvironment identifier
typestringThe type of response

GET /anthropic/v1/environments/{environment_id}◐ 部分支持

Claude 官方文档 ↗

请求参数

  • environment_idstring必填

    path: 环境 ID(路径或查询参数)。

返回

200

支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringEnvironment identifier (e.g., 'env_...')
archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
config.networkingobjectNetwork configuration policy.
config.packagesobjectPackage manager configuration.
config.typestringEnvironment type
created_atstringRFC 3339 timestamp when environment was created
descriptionnull | stringUser-provided description for the environment; null when unset
metadataobjectUser-provided metadata key-value pairs
namestringHuman-readable name for the environment
typestringThe type of object (always 'environment')
updated_atstringRFC 3339 timestamp when environment was last updated
scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

POST /anthropic/v1/environments/{environment_id}◐ 部分支持

请求参数

  • environment_idstring必填

    path: 环境 ID(路径或查询参数)。

  • namestring可选

    Updated name for the environment

  • configobject可选

    Updated environment configuration

    ▸ 展开子字段(3)
    • typestring必填

      Environment type

      取值 self_hosted
    • networkingobject可选

      Network configuration policy. Omit on update to preserve the existing value.

    • packagesobject可选

      Specify packages (and optionally their versions) available in this environment. When versioning, use the version semantics relevant for the package manager, e.g. for `pip` use `package==1.0.0`. You are responsible for validating the package and version exist. Unversioned installs the latest. Under `limited` networking, requires `networking.allow_package_managers` to be `true`.

  • descriptionstring可选

    Updated description of the environment. Omit to preserve; null clears to null; an empty string is stored as an empty string.

  • metadataobject可选

    User-provided metadata key-value pairs. Set a value to null or empty string to delete the key.

  • scopestring可选

    The visibility scope for this environment. 'organization' makes the environment visible to all accounts. 'account' restricts visibility to the owning account only.

返回

501

支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringEnvironment identifier (e.g., 'env_...')
archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
config.networkingobjectNetwork configuration policy.
config.packagesobjectPackage manager configuration.
config.typestringEnvironment type
created_atstringRFC 3339 timestamp when environment was created
descriptionnull | stringUser-provided description for the environment; null when unset
metadataobjectUser-provided metadata key-value pairs
namestringHuman-readable name for the environment
typestringThe type of object (always 'environment')
updated_atstringRFC 3339 timestamp when environment was last updated
scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

POST /anthropic/v1/environments/{environment_id}/archive◐ 部分支持

请求参数

  • environment_idstring必填

    path: 环境 ID(路径或查询参数)。

返回

501

支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringEnvironment identifier (e.g., 'env_...')
archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
config.networkingobjectNetwork configuration policy.
config.packagesobjectPackage manager configuration.
config.typestringEnvironment type
created_atstringRFC 3339 timestamp when environment was created
descriptionnull | stringUser-provided description for the environment; null when unset
metadataobjectUser-provided metadata key-value pairs
namestringHuman-readable name for the environment
typestringThe type of object (always 'environment')
updated_atstringRFC 3339 timestamp when environment was last updated
scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

GET /anthropic/v1/environments/{environment_id}/work○ 未支持

请求参数

  • environment_idstring必填

    path: 环境 ID(路径或查询参数)。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

这是自托管执行器领取任务的协议;平台的智能体都在平台上执行,不支持自托管执行器。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringWork identifier (e.g., 'work_...')
data[].acknowledged_atnull | stringRFC 3339 timestamp when work was acknowledged by Environment Manager
data[].created_atstringRFC 3339 timestamp when work was created
data[].dataobjectThe actual work to be performed (session or health check)
data[].environment_idstringEnvironment identifier this work belongs to (e.g., `env_...`)
data[].latest_heartbeat_atnull | stringRFC 3339 timestamp of the most recent heartbeat
data[].metadataobjectUser-provided metadata key-value pairs associated with this work item
data[].secretnull | stringCredential payload used by the environment worker to execute this work item. May be populated when polling for work; null on all other retrieval paths.
data[].started_atnull | stringRFC 3339 timestamp when work execution started
data[].statestringCurrent state of the work item
data[].stop_requested_atnull | stringRFC 3339 timestamp when stop was requested
data[].stopped_atnull | stringRFC 3339 timestamp when work execution stopped
data[].typestringThe type of object (always 'work')
next_pagestring | null

GET /anthropic/v1/environments/{environment_id}/work/{work_id}○ 未支持

请求参数

  • environment_idstring必填

    path: 环境 ID(路径或查询参数)。

  • work_idstring必填

    path: 路径参数:任务 ID。

  • environment_idstring必填

    query: 环境 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

这是自托管执行器领取任务的协议;平台的智能体都在平台上执行,不支持自托管执行器。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringWork identifier (e.g., 'work_...')
acknowledged_atnull | stringRFC 3339 timestamp when work was acknowledged by Environment Manager
created_atstringRFC 3339 timestamp when work was created
dataobjectThe actual work to be performed (session or health check)
data.idstringSession identifier (e.g., 'session_...') / Health check identifier
data.typestringType of work data
environment_idstringEnvironment identifier this work belongs to (e.g., `env_...`)
latest_heartbeat_atnull | stringRFC 3339 timestamp of the most recent heartbeat
metadataobjectUser-provided metadata key-value pairs associated with this work item
secretnull | stringCredential payload used by the environment worker to execute this work item. May be populated when polling for work; null on all other retrieval paths.
started_atnull | stringRFC 3339 timestamp when work execution started
statestringCurrent state of the work item
stop_requested_atnull | stringRFC 3339 timestamp when stop was requested
stopped_atnull | stringRFC 3339 timestamp when work execution stopped
typestringThe type of object (always 'work')

POST /anthropic/v1/environments/{environment_id}/work/{work_id}○ 未支持

请求参数

  • environment_idstring必填

    path: 环境 ID(路径或查询参数)。

  • work_idstring必填

    path: 路径参数:任务 ID。

  • environment_idstring必填

    query: 环境 ID(路径或查询参数)。

  • metadataobject必填

    Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve existing metadata.

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

这是自托管执行器领取任务的协议;平台的智能体都在平台上执行,不支持自托管执行器。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringWork identifier (e.g., 'work_...')
acknowledged_atnull | stringRFC 3339 timestamp when work was acknowledged by Environment Manager
created_atstringRFC 3339 timestamp when work was created
dataobjectThe actual work to be performed (session or health check)
data.idstringSession identifier (e.g., 'session_...') / Health check identifier
data.typestringType of work data
environment_idstringEnvironment identifier this work belongs to (e.g., `env_...`)
latest_heartbeat_atnull | stringRFC 3339 timestamp of the most recent heartbeat
metadataobjectUser-provided metadata key-value pairs associated with this work item
secretnull | stringCredential payload used by the environment worker to execute this work item. May be populated when polling for work; null on all other retrieval paths.
started_atnull | stringRFC 3339 timestamp when work execution started
statestringCurrent state of the work item
stop_requested_atnull | stringRFC 3339 timestamp when stop was requested
stopped_atnull | stringRFC 3339 timestamp when work execution stopped
typestringThe type of object (always 'work')

POST /anthropic/v1/environments/{environment_id}/work/{work_id}/ack○ 未支持

请求参数

  • environment_idstring必填

    path: 环境 ID(路径或查询参数)。

  • work_idstring必填

    path: 路径参数:任务 ID。

  • environment_idstring必填

    query: 环境 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

这是自托管执行器领取任务的协议;平台的智能体都在平台上执行,不支持自托管执行器。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringWork identifier (e.g., 'work_...')
acknowledged_atnull | stringRFC 3339 timestamp when work was acknowledged by Environment Manager
created_atstringRFC 3339 timestamp when work was created
dataobjectThe actual work to be performed (session or health check)
data.idstringSession identifier (e.g., 'session_...') / Health check identifier
data.typestringType of work data
environment_idstringEnvironment identifier this work belongs to (e.g., `env_...`)
latest_heartbeat_atnull | stringRFC 3339 timestamp of the most recent heartbeat
metadataobjectUser-provided metadata key-value pairs associated with this work item
secretnull | stringCredential payload used by the environment worker to execute this work item. May be populated when polling for work; null on all other retrieval paths.
started_atnull | stringRFC 3339 timestamp when work execution started
statestringCurrent state of the work item
stop_requested_atnull | stringRFC 3339 timestamp when stop was requested
stopped_atnull | stringRFC 3339 timestamp when work execution stopped
typestringThe type of object (always 'work')

POST /anthropic/v1/environments/{environment_id}/work/{work_id}/heartbeat○ 未支持

请求参数

  • environment_idstring必填

    path: 环境 ID(路径或查询参数)。

  • work_idstring必填

    path: 路径参数:任务 ID。

  • environment_idstring必填

    query: 环境 ID(路径或查询参数)。

  • desired_ttl_secondsnumber可选

    query: 期望的任务租约有效期(秒)。

  • expected_last_heartbeatstring可选

    query: 期望的最后心跳时间,用于并发保护。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

这是自托管执行器领取任务的协议;平台的智能体都在平台上执行,不支持自托管执行器。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
last_heartbeatstringRFC 3339 timestamp of the actual heartbeat from DB
lease_extendedbooleanWhether the heartbeat succeeded in extending the lease
statestringCurrent state of the work item (active/stopping/stopped)
ttl_secondsnumberEffective TTL applied to the lease
typestringThe type of response

POST /anthropic/v1/environments/{environment_id}/work/{work_id}/stop○ 未支持

请求参数

  • environment_idstring必填

    path: 环境 ID(路径或查询参数)。

  • work_idstring必填

    path: 路径参数:任务 ID。

  • environment_idstring必填

    query: 环境 ID(路径或查询参数)。

  • forceboolean可选

    If true, immediately stop work without graceful shutdown

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

这是自托管执行器领取任务的协议;平台的智能体都在平台上执行,不支持自托管执行器。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringWork identifier (e.g., 'work_...')
acknowledged_atnull | stringRFC 3339 timestamp when work was acknowledged by Environment Manager
created_atstringRFC 3339 timestamp when work was created
dataobjectThe actual work to be performed (session or health check)
data.idstringSession identifier (e.g., 'session_...') / Health check identifier
data.typestringType of work data
environment_idstringEnvironment identifier this work belongs to (e.g., `env_...`)
latest_heartbeat_atnull | stringRFC 3339 timestamp of the most recent heartbeat
metadataobjectUser-provided metadata key-value pairs associated with this work item
secretnull | stringCredential payload used by the environment worker to execute this work item. May be populated when polling for work; null on all other retrieval paths.
started_atnull | stringRFC 3339 timestamp when work execution started
statestringCurrent state of the work item
stop_requested_atnull | stringRFC 3339 timestamp when stop was requested
stopped_atnull | stringRFC 3339 timestamp when work execution stopped
typestringThe type of object (always 'work')

GET /anthropic/v1/environments/{environment_id}/work/poll○ 未支持

请求参数

  • environment_idstring必填

    path: 环境 ID(路径或查询参数)。

  • block_msnumber可选

    query: 没有可领任务时最多等待的毫秒数(1–999)。

  • reclaim_older_than_msnumber可选

    query: 回收租约早于该毫秒数的任务。

  • Anthropic-Worker-IDstring可选

    query: 发起轮询的自托管执行器实例 ID,用于在控制台聚合环境级任务指标。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

这是自托管执行器领取任务的协议;平台的智能体都在平台上执行,不支持自托管执行器。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringWork identifier (e.g., 'work_...')
acknowledged_atnull | stringRFC 3339 timestamp when work was acknowledged by Environment Manager
created_atstringRFC 3339 timestamp when work was created
dataobjectThe actual work to be performed (session or health check)
data.idstringSession identifier (e.g., 'session_...') / Health check identifier
data.typestringType of work data
environment_idstringEnvironment identifier this work belongs to (e.g., `env_...`)
latest_heartbeat_atnull | stringRFC 3339 timestamp of the most recent heartbeat
metadataobjectUser-provided metadata key-value pairs associated with this work item
secretnull | stringCredential payload used by the environment worker to execute this work item. May be populated when polling for work; null on all other retrieval paths.
started_atnull | stringRFC 3339 timestamp when work execution started
statestringCurrent state of the work item
stop_requested_atnull | stringRFC 3339 timestamp when stop was requested
stopped_atnull | stringRFC 3339 timestamp when work execution stopped
typestringThe type of object (always 'work')

GET /anthropic/v1/environments/{environment_id}/work/stats○ 未支持

请求参数

  • environment_idstring必填

    path: 环境 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

这是自托管执行器领取任务的协议;平台的智能体都在平台上执行,不支持自托管执行器。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
depthnumberNumber of work items waiting to be picked up (lag from consumer group)
oldest_queued_atnull | stringRFC 3339 timestamp of oldest item in the work stream (includes both queued and pending items), null if stream empty
pendingnumberNumber of work items being processed (polled but not acknowledged)
typestringThe type of object
workers_pollingnull | numberNumber of workers that have polled for work in the last 30 seconds. Requires worker_id to be sent with poll requests.

GET /anthropic/v1/memory_stores○ 未支持

请求参数

  • created_at[gte]string可选

    query: 只返回不早于该时间创建的记录。

  • created_at[lte]string可选

    query: 只返回不晚于该时间创建的记录。

  • include_archivedboolean可选

    query: 是否包含已归档的记录。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供智能体可读写的持久记忆库。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringUnique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls.
data[].created_atstringA timestamp in RFC 3339 format
data[].namestringHuman-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name.
data[].typestring
data[].updated_atstringA timestamp in RFC 3339 format
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].descriptionstringFree-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset.
data[].metadataobjectArbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable.
next_pagestring | null

POST /anthropic/v1/memory_stores○ 未支持

请求体

  • namestring必填

    Human-readable name for the store. Required; 1–255 characters; no control characters. The mount-path slug under `/mnt/memory/` is derived from this name (lowercased, non-alphanumeric runs collapsed to a hyphen). Names need not be unique within a workspace.

  • descriptionstring可选

    Free-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent.

  • metadataobject可选

    Arbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Not visible to the agent.

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供智能体可读写的持久记忆库。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls.
created_atstringA timestamp in RFC 3339 format
namestringHuman-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name.
typestring
updated_atstringA timestamp in RFC 3339 format
archived_atnull | stringA timestamp in RFC 3339 format
descriptionstringFree-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset.
metadataobjectArbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable.

DELETE /anthropic/v1/memory_stores/{memory_store_id}○ 未支持

请求参数

  • memory_store_idstring必填

    path: 记忆库 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供智能体可读写的持久记忆库。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringID of the deleted memory store (a `memstore_...` identifier). The store and all its memories and versions are no longer retrievable.
typestring

GET /anthropic/v1/memory_stores/{memory_store_id}○ 未支持

请求参数

  • memory_store_idstring必填

    path: 记忆库 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供智能体可读写的持久记忆库。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls.
created_atstringA timestamp in RFC 3339 format
namestringHuman-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name.
typestring
updated_atstringA timestamp in RFC 3339 format
archived_atnull | stringA timestamp in RFC 3339 format
descriptionstringFree-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset.
metadataobjectArbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable.

POST /anthropic/v1/memory_stores/{memory_store_id}○ 未支持

请求参数

  • memory_store_idstring必填

    path: 记忆库 ID(路径或查询参数)。

  • namestring可选

    New human-readable name for the store. 1–255 characters; no control characters. Renaming changes the slug used for the store's `mount_path` in sessions created after the update.

  • descriptionstring可选

    New description for the store, up to 1024 characters. Pass an empty string to clear it.

  • metadataobject可选

    Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve. The stored bag is limited to 16 keys (up to 64 chars each) with values up to 512 chars.

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供智能体可读写的持久记忆库。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls.
created_atstringA timestamp in RFC 3339 format
namestringHuman-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name.
typestring
updated_atstringA timestamp in RFC 3339 format
archived_atnull | stringA timestamp in RFC 3339 format
descriptionstringFree-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset.
metadataobjectArbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable.

POST /anthropic/v1/memory_stores/{memory_store_id}/archive○ 未支持

请求参数

  • memory_store_idstring必填

    path: 记忆库 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供智能体可读写的持久记忆库。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls.
created_atstringA timestamp in RFC 3339 format
namestringHuman-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name.
typestring
updated_atstringA timestamp in RFC 3339 format
archived_atnull | stringA timestamp in RFC 3339 format
descriptionstringFree-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset.
metadataobjectArbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable.

GET /anthropic/v1/memory_stores/{memory_store_id}/memories○ 未支持

请求参数

  • memory_store_idstring必填

    path: 记忆库 ID(路径或查询参数)。

  • depthnumber可选

    query: 子节点回溯深度:0(默认)递归返回全部后代,1 只返回直接子节点。

  • path_prefixstring可选

    query: 按路径前缀过滤(需以 / 结尾并对齐分段)。

  • viewstring可选

    query: 返回投影:basic 省略内容,full 附带完整内容。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供智能体可读写的持久记忆库。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringUnique identifier for this memory (a `mem_...` value). Stable across renames; use this ID, not the path, to read, update, or delete the memory.
data[].content_sha256stringLowercase hex SHA-256 digest of the UTF-8 `content` bytes (64 characters). The server applies no normalization, so clients can compute the same hash locally for staleness checks and as the value for a `content_sha256` precondition on update. Always populated, regardless of `view`.
data[].content_size_bytesnumberSize of `content` in bytes (the UTF-8 plaintext length). Always populated, regardless of `view`.
data[].created_atstringA timestamp in RFC 3339 format
data[].memory_store_idstringID of the memory store this memory belongs to (a `memstore_...` value).
data[].memory_version_idstringID of the `memory_version` representing this memory's current content (a `memver_...` value). This is the authoritative head pointer; `memory_version` objects do not carry an `is_latest` flag, so compare against this field instead. Enumerate the history via List memory versions.
data[].pathstringHierarchical path of the memory within the store, e.g. `/projects/foo/notes.md`. Always starts with `/`. Paths are case-sensitive and unique within a store. Maximum 1,024 bytes. / The rolled-up path prefix, including a trailing `/` (e.g. `/projects/foo/`). Pass this value as `path_prefix` on a subsequent list call to drill into the directory.
data[].typestring
data[].updated_atstringA timestamp in RFC 3339 format
data[].contentnull | stringThe memory's UTF-8 text content. Populated when `view=full`; `null` when `view=basic`. Maximum 100 kB (102,400 bytes).
next_pagestring | null

POST /anthropic/v1/memory_stores/{memory_store_id}/memories○ 未支持

请求参数

  • memory_store_idstring必填

    path: 记忆库 ID(路径或查询参数)。

  • viewstring可选

    query: 返回投影:basic 省略内容,full 附带完整内容。

  • contentstring必填

    UTF-8 text content for the new memory. Maximum 100 kB (102,400 bytes). Required; pass `""` explicitly to create an empty memory.

  • pathstring必填

    Hierarchical path for the new memory, e.g. `/projects/foo/notes.md`. Must start with `/`, contain at least one non-empty segment, and be at most 1,024 bytes. Must not contain empty segments, `.` or `..` segments, control or format characters, or the Unicode line and paragraph separators (U+2028, U+2029), and must be NFC-normalized. Paths are case-sensitive.

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供智能体可读写的持久记忆库。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this memory (a `mem_...` value). Stable across renames; use this ID, not the path, to read, update, or delete the memory.
content_sha256stringLowercase hex SHA-256 digest of the UTF-8 `content` bytes (64 characters). The server applies no normalization, so clients can compute the same hash locally for staleness checks and as the value for a `content_sha256` precondition on update. Always populated, regardless of `view`.
content_size_bytesnumberSize of `content` in bytes (the UTF-8 plaintext length). Always populated, regardless of `view`.
created_atstringA timestamp in RFC 3339 format
memory_store_idstringID of the memory store this memory belongs to (a `memstore_...` value).
memory_version_idstringID of the `memory_version` representing this memory's current content (a `memver_...` value). This is the authoritative head pointer; `memory_version` objects do not carry an `is_latest` flag, so compare against this field instead. Enumerate the history via List memory versions.
pathstringHierarchical path of the memory within the store, e.g. `/projects/foo/notes.md`. Always starts with `/`. Paths are case-sensitive and unique within a store. Maximum 1,024 bytes.
typestring
updated_atstringA timestamp in RFC 3339 format
contentnull | stringThe memory's UTF-8 text content. Populated when `view=full`; `null` when `view=basic`. Maximum 100 kB (102,400 bytes).

DELETE /anthropic/v1/memory_stores/{memory_store_id}/memories/{memory_id}○ 未支持

请求参数

  • memory_store_idstring必填

    path: 记忆库 ID(路径或查询参数)。

  • memory_idstring必填

    path: 记忆 ID(路径或查询参数)。

  • memory_store_idstring必填

    query: 记忆库 ID(路径或查询参数)。

  • expected_content_sha256string可选

    query: 期望的内容 SHA-256,用于并发修改保护。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供智能体可读写的持久记忆库。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringID of the deleted memory (a `mem_...` value).
typestring

GET /anthropic/v1/memory_stores/{memory_store_id}/memories/{memory_id}○ 未支持

请求参数

  • memory_store_idstring必填

    path: 记忆库 ID(路径或查询参数)。

  • memory_idstring必填

    path: 记忆 ID(路径或查询参数)。

  • memory_store_idstring必填

    query: 记忆库 ID(路径或查询参数)。

  • viewstring可选

    query: 返回投影:basic 省略内容,full 附带完整内容。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供智能体可读写的持久记忆库。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this memory (a `mem_...` value). Stable across renames; use this ID, not the path, to read, update, or delete the memory.
content_sha256stringLowercase hex SHA-256 digest of the UTF-8 `content` bytes (64 characters). The server applies no normalization, so clients can compute the same hash locally for staleness checks and as the value for a `content_sha256` precondition on update. Always populated, regardless of `view`.
content_size_bytesnumberSize of `content` in bytes (the UTF-8 plaintext length). Always populated, regardless of `view`.
created_atstringA timestamp in RFC 3339 format
memory_store_idstringID of the memory store this memory belongs to (a `memstore_...` value).
memory_version_idstringID of the `memory_version` representing this memory's current content (a `memver_...` value). This is the authoritative head pointer; `memory_version` objects do not carry an `is_latest` flag, so compare against this field instead. Enumerate the history via List memory versions.
pathstringHierarchical path of the memory within the store, e.g. `/projects/foo/notes.md`. Always starts with `/`. Paths are case-sensitive and unique within a store. Maximum 1,024 bytes.
typestring
updated_atstringA timestamp in RFC 3339 format
contentnull | stringThe memory's UTF-8 text content. Populated when `view=full`; `null` when `view=basic`. Maximum 100 kB (102,400 bytes).

POST /anthropic/v1/memory_stores/{memory_store_id}/memories/{memory_id}○ 未支持

请求参数

  • memory_store_idstring必填

    path: 记忆库 ID(路径或查询参数)。

  • memory_idstring必填

    path: 记忆 ID(路径或查询参数)。

  • memory_store_idstring必填

    query: 记忆库 ID(路径或查询参数)。

  • viewstring可选

    query: 返回投影:basic 省略内容,full 附带完整内容。

  • contentstring可选

    New UTF-8 text content for the memory. Maximum 100 kB (102,400 bytes). Omit to leave the content unchanged (e.g., for a rename-only update).

  • pathstring可选

    New path for the memory (a rename). Must start with `/`, contain at least one non-empty segment, and be at most 1,024 bytes. Must not contain empty segments, `.` or `..` segments, control or format characters, or the Unicode line and paragraph separators (U+2028, U+2029), and must be NFC-normalized. Paths are case-sensitive. The memory's `id` is preserved across renames. Omit to leave the path unchanged.

  • preconditionobject可选

    Optimistic-concurrency precondition: the update applies only if the memory's stored `content_sha256` equals the supplied value. On mismatch, the request returns `memory_precondition_failed_error` (HTTP 409); re-read the memory and retry against the fresh state. If the precondition fails but the stored state already exactly matches the requested `content` and `path`, the server returns 200 instead of 409.

    ▸ 展开子字段(2)
    • typestring必填
      取值 content_sha256
    • content_sha256string可选

      Expected `content_sha256` of the stored memory (64 lowercase hexadecimal characters). Typically the `content_sha256` returned by a prior read or list call. Because the server applies no content normalization, clients can also compute this locally as the SHA-256 of the UTF-8 content bytes.

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供智能体可读写的持久记忆库。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this memory (a `mem_...` value). Stable across renames; use this ID, not the path, to read, update, or delete the memory.
content_sha256stringLowercase hex SHA-256 digest of the UTF-8 `content` bytes (64 characters). The server applies no normalization, so clients can compute the same hash locally for staleness checks and as the value for a `content_sha256` precondition on update. Always populated, regardless of `view`.
content_size_bytesnumberSize of `content` in bytes (the UTF-8 plaintext length). Always populated, regardless of `view`.
created_atstringA timestamp in RFC 3339 format
memory_store_idstringID of the memory store this memory belongs to (a `memstore_...` value).
memory_version_idstringID of the `memory_version` representing this memory's current content (a `memver_...` value). This is the authoritative head pointer; `memory_version` objects do not carry an `is_latest` flag, so compare against this field instead. Enumerate the history via List memory versions.
pathstringHierarchical path of the memory within the store, e.g. `/projects/foo/notes.md`. Always starts with `/`. Paths are case-sensitive and unique within a store. Maximum 1,024 bytes.
typestring
updated_atstringA timestamp in RFC 3339 format
contentnull | stringThe memory's UTF-8 text content. Populated when `view=full`; `null` when `view=basic`. Maximum 100 kB (102,400 bytes).

GET /anthropic/v1/memory_stores/{memory_store_id}/memory_versions○ 未支持

请求参数

  • memory_store_idstring必填

    path: 记忆库 ID(路径或查询参数)。

  • api_key_idstring可选

    query: 只返回用该 API Key 写入的版本。

  • created_at[gte]string可选

    query: 只返回不早于该时间创建的记录。

  • created_at[lte]string可选

    query: 只返回不晚于该时间创建的记录。

  • memory_idstring可选

    query: 记忆 ID(路径或查询参数)。

  • operationstring可选

    query: 只返回记录该类变更的版本。

  • service_account_idstring可选

    query: 只返回该服务账号写入的版本。

  • session_idstring可选

    query: 会话 ID(路径或查询参数)。

  • viewstring可选

    query: 返回投影:basic 省略内容,full 附带完整内容。

  • limitnumber可选

    query: 每页返回的条数上限。

  • ▸ 更多参数(1)
    • pagestring可选

      query: 分页游标,取自上一页响应的 next_page。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供智能体可读写的持久记忆库。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringUnique identifier for this version (a `memver_...` value).
data[].created_atstringA timestamp in RFC 3339 format
data[].memory_idstringID of the memory this version snapshots (a `mem_...` value). Remains valid after the memory is deleted; pass it as `memory_id` to List memory versions to retrieve the memory's retained versions, including the `deleted` row while the lineage is retained.
data[].memory_store_idstringID of the memory store this version belongs to (a `memstore_...` value).
data[].operationstringThe kind of mutation a `memory_version` records. Every non-no-op mutation to a memory appends exactly one version row with one of these values.
data[].typestring
data[].contentnull | stringThe memory's UTF-8 text content as of this version. `null` when `view=basic`, when `operation` is `deleted`, or when `redacted_at` is set.
data[].content_sha256null | stringLowercase hex SHA-256 digest of `content` as of this version (64 characters). `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.
data[].content_size_bytesnull | numberSize of `content` in bytes as of this version. `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.
data[].created_byobjectIdentifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the Sessions API.
data[].pathnull | stringThe memory's path at the time of this write. `null` if and only if `redacted_at` is set.
data[].redacted_atnull | stringA timestamp in RFC 3339 format
data[].redacted_byobjectIdentifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the Sessions API.
next_pagestring | null

GET /anthropic/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}○ 未支持

请求参数

  • memory_store_idstring必填

    path: 记忆库 ID(路径或查询参数)。

  • memory_version_idstring必填

    path: 路径参数:记忆版本 ID。

  • memory_store_idstring必填

    query: 记忆库 ID(路径或查询参数)。

  • viewstring可选

    query: 返回投影:basic 省略内容,full 附带完整内容。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供智能体可读写的持久记忆库。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this version (a `memver_...` value).
created_atstringA timestamp in RFC 3339 format
memory_idstringID of the memory this version snapshots (a `mem_...` value). Remains valid after the memory is deleted; pass it as `memory_id` to List memory versions to retrieve the memory's retained versions, including the `deleted` row while the lineage is retained.
memory_store_idstringID of the memory store this version belongs to (a `memstore_...` value).
operationstringThe kind of mutation a `memory_version` records. Every non-no-op mutation to a memory appends exactly one version row with one of these values.
typestring
contentnull | stringThe memory's UTF-8 text content as of this version. `null` when `view=basic`, when `operation` is `deleted`, or when `redacted_at` is set.
content_sha256null | stringLowercase hex SHA-256 digest of `content` as of this version (64 characters). `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.
content_size_bytesnull | numberSize of `content` in bytes as of this version. `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.
created_byobjectIdentifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the Sessions API.
created_by.session_idstringID of the session that performed the write (a `sesn_...` value). Look up the session via Retrieve a session for further provenance.
created_by.typestring
created_by.api_key_idstringID of the API key that performed the write. This identifies the key, not the secret.
created_by.user_idstringID of the user who performed the write (a `user_...` value).
created_by.service_account_idstringID of the service account that performed the write (a `svac_...` value).
pathnull | stringThe memory's path at the time of this write. `null` if and only if `redacted_at` is set.
redacted_atnull | stringA timestamp in RFC 3339 format
redacted_byobjectIdentifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the Sessions API.
redacted_by.session_idstringID of the session that performed the write (a `sesn_...` value). Look up the session via Retrieve a session for further provenance.
redacted_by.typestring
redacted_by.api_key_idstringID of the API key that performed the write. This identifies the key, not the secret.
redacted_by.user_idstringID of the user who performed the write (a `user_...` value).
redacted_by.service_account_idstringID of the service account that performed the write (a `svac_...` value).

POST /anthropic/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}/redact○ 未支持

请求参数

  • memory_store_idstring必填

    path: 记忆库 ID(路径或查询参数)。

  • memory_version_idstring必填

    path: 路径参数:记忆版本 ID。

  • memory_store_idstring必填

    query: 记忆库 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供智能体可读写的持久记忆库。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this version (a `memver_...` value).
created_atstringA timestamp in RFC 3339 format
memory_idstringID of the memory this version snapshots (a `mem_...` value). Remains valid after the memory is deleted; pass it as `memory_id` to List memory versions to retrieve the memory's retained versions, including the `deleted` row while the lineage is retained.
memory_store_idstringID of the memory store this version belongs to (a `memstore_...` value).
operationstringThe kind of mutation a `memory_version` records. Every non-no-op mutation to a memory appends exactly one version row with one of these values.
typestring
contentnull | stringThe memory's UTF-8 text content as of this version. `null` when `view=basic`, when `operation` is `deleted`, or when `redacted_at` is set.
content_sha256null | stringLowercase hex SHA-256 digest of `content` as of this version (64 characters). `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.
content_size_bytesnull | numberSize of `content` in bytes as of this version. `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.
created_byobjectIdentifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the Sessions API.
created_by.session_idstringID of the session that performed the write (a `sesn_...` value). Look up the session via Retrieve a session for further provenance.
created_by.typestring
created_by.api_key_idstringID of the API key that performed the write. This identifies the key, not the secret.
created_by.user_idstringID of the user who performed the write (a `user_...` value).
created_by.service_account_idstringID of the service account that performed the write (a `svac_...` value).
pathnull | stringThe memory's path at the time of this write. `null` if and only if `redacted_at` is set.
redacted_atnull | stringA timestamp in RFC 3339 format
redacted_byobjectIdentifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the Sessions API.
redacted_by.session_idstringID of the session that performed the write (a `sesn_...` value). Look up the session via Retrieve a session for further provenance.
redacted_by.typestring
redacted_by.api_key_idstringID of the API key that performed the write. This identifies the key, not the secret.
redacted_by.user_idstringID of the user who performed the write (a `user_...` value).
redacted_by.service_account_idstringID of the service account that performed the write (a `svac_...` value).

DELETE /anthropic/v1/sessions/{session_id}○ 未支持

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

会话目前支持创建、读取、列出、更新与归档;删除还没有实现。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstring
typestring

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /anthropic/v1/sessions/{session_id}◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • agentobject可选

    会话要运行的智能体:直接写智能体 ID 字符串(固定用最新版本),或传对象指定 id 与 version(见子字段)。

    ▸ 展开子字段(2)
    • mcp_serversarray可选

      替换本会话的 MCP 服务器列表:传入的数组整体生效;传空数组清除,省略沿用智能体的配置。

    • toolsarray可选

      替换本会话的工具配置;传空数组清除,省略沿用智能体的配置。

  • budgetobject可选

    A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.

    ▸ 展开子字段(2)
    • max_list_costobject必填

      预算内列表类调用的花费上限。

    • typestring必填

      预算类型,目前只有 max_list_cost。

      取值 limit
  • metadataobject可选

    Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve.

  • titlestring可选

    Human-readable session title.

  • vault_idsarray可选

    Vault IDs (`vlt_*`) to attach to the session. Not yet supported; requests setting this field are rejected. Reserved for future use.

返回

200

支持 title 与 metadata(官方补丁语义:字符串值写入、null 删除该键、整包 null 清空,未提及的键保留)。官方的 agent 覆盖(tools/mcp_servers)、budget 与 vault_ids 不支持,传入返回 400 并点名字段。归档后的会话更新返回 409。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstring
agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
agent.idstring
agent.descriptionnull | string
agent.mcp_serversarray<object>
agent.modelobjectModel identifier and configuration.
agent.multiagentnull | objectResolved coordinator topology with full agent definitions for each roster member.
agent.namestring
agent.skillsarray<object>
agent.systemnull | string
agent.toolsarray<object>
agent.typestring
agent.versionnumber
archived_atnull | stringA timestamp in RFC 3339 format
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestring
created_atstringA timestamp in RFC 3339 format
environment_idstring
metadataobject
outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
outcome_evaluations[].completed_atnull | stringA timestamp in RFC 3339 format
outcome_evaluations[].descriptionstringWhat the agent should produce.
outcome_evaluations[].explanationnull | stringGrader's verdict text from the most recent evaluation. For `satisfied`, explains why criteria are met; for `needs_revision` (intermediate), what's missing; for `failed`, why unrecoverable.
outcome_evaluations[].iterationnumber0-indexed revision cycle the outcome is currently on.
outcome_evaluations[].outcome_idstringServer-generated outc_ ID for this outcome.
outcome_evaluations[].resultstringCurrent evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.
outcome_evaluations[].typestring
resourcesarray<object>
resources[].idstring
resources[].created_atstringA timestamp in RFC 3339 format
resources[].mount_pathstring | null | stringFilesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.
resources[].typestring
resources[].updated_atstringA timestamp in RFC 3339 format
resources[].urlstring
resources[].checkoutnull | object
resources[].file_idstring
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
resources[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
statsobjectTiming statistics for a session.
stats.active_secondsnumberCumulative time in seconds the session spent in `running` status. Excludes idle time.
stats.duration_secondsnumberElapsed time since session creation in seconds. For terminated sessions, frozen at the final update.
statusstringSessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion.
titlenull | string
typestring
updated_atstringA timestamp in RFC 3339 format
usageobjectCumulative token usage for a session across all turns.
usage.active_secondsnumberCumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime cost is priced on.
usage.cache_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.
vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.

归档会话

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /anthropic/v1/sessions/{session_id}/archive● 支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

返回

200

归档后的会话拒绝新消息(400 invalid_request_error,写明会话已归档),读取与事件历史仍可用;重复归档幂等,archived_at 保持首次归档时间。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstring
agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
agent.idstring
agent.descriptionnull | string
agent.mcp_serversarray<object>
agent.modelobjectModel identifier and configuration.
agent.multiagentnull | objectResolved coordinator topology with full agent definitions for each roster member.
agent.namestring
agent.skillsarray<object>
agent.systemnull | string
agent.toolsarray<object>
agent.typestring
agent.versionnumber
archived_atnull | stringA timestamp in RFC 3339 format
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestring
created_atstringA timestamp in RFC 3339 format
environment_idstring
metadataobject
outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
outcome_evaluations[].completed_atnull | stringA timestamp in RFC 3339 format
outcome_evaluations[].descriptionstringWhat the agent should produce.
outcome_evaluations[].explanationnull | stringGrader's verdict text from the most recent evaluation. For `satisfied`, explains why criteria are met; for `needs_revision` (intermediate), what's missing; for `failed`, why unrecoverable.
outcome_evaluations[].iterationnumber0-indexed revision cycle the outcome is currently on.
outcome_evaluations[].outcome_idstringServer-generated outc_ ID for this outcome.
outcome_evaluations[].resultstringCurrent evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.
outcome_evaluations[].typestring
resourcesarray<object>
resources[].idstring
resources[].created_atstringA timestamp in RFC 3339 format
resources[].mount_pathstring | null | stringFilesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.
resources[].typestring
resources[].updated_atstringA timestamp in RFC 3339 format
resources[].urlstring
resources[].checkoutnull | object
resources[].file_idstring
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
resources[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
statsobjectTiming statistics for a session.
stats.active_secondsnumberCumulative time in seconds the session spent in `running` status. Excludes idle time.
stats.duration_secondsnumberElapsed time since session creation in seconds. For terminated sessions, frozen at the final update.
statusstringSessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion.
titlenull | string
typestring
updated_atstringA timestamp in RFC 3339 format
usageobjectCumulative token usage for a session across all turns.
usage.active_secondsnumberCumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime cost is priced on.
usage.cache_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.
vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.

GET /anthropic/v1/sessions/{session_id}/resources◐ 部分支持

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

501

支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstring
data[].created_atstringA timestamp in RFC 3339 format
data[].mount_pathstring | null | stringFilesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.
data[].typestring
data[].updated_atstringA timestamp in RFC 3339 format
data[].urlstring
data[].checkoutnull | object
data[].file_idstring
data[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
data[].accessnull | stringAccess mode for an attached memory store.
data[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
data[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
data[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
next_pagestring | null

POST /anthropic/v1/sessions/{session_id}/resources◐ 部分支持

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • typestring必填

    query: 要新增的资源在请求体里对应的字段名。

    取值 file
  • file_idstring必填

    ID of a previously uploaded file.

  • mount_pathstring可选

    Mount path in the container. Defaults to `/mnt/session/uploads/<file_id>`.

返回

501

支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstring
created_atstringA timestamp in RFC 3339 format
file_idstring
mount_pathstring
typestring
updated_atstringA timestamp in RFC 3339 format

DELETE /anthropic/v1/sessions/{session_id}/resources/{resource_id}◐ 部分支持

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • resource_idstring必填

    path: 路径参数:会话资源 ID。

  • session_idstring必填

    query: 会话 ID(路径或查询参数)。

返回

501

支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstring
typestring

GET /anthropic/v1/sessions/{session_id}/resources/{resource_id}◐ 部分支持

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • resource_idstring必填

    path: 路径参数:会话资源 ID。

  • session_idstring必填

    query: 会话 ID(路径或查询参数)。

返回

501

支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstring
created_atstringA timestamp in RFC 3339 format
mount_pathstring | null | stringFilesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.
typestring
updated_atstringA timestamp in RFC 3339 format
urlstring
checkoutnull | object
checkout.namestringBranch name to check out.
checkout.typestring
checkout.shastringFull commit SHA to check out.
file_idstring
memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
accessnull | stringAccess mode for an attached memory store.
descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

POST /anthropic/v1/sessions/{session_id}/resources/{resource_id}○ 未支持

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • resource_idstring必填

    path: 路径参数:会话资源 ID。

  • session_idstring必填

    query: 会话 ID(路径或查询参数)。

  • authorization_tokenstring必填

    New authorization token for the resource. Currently only `github_repository` resources support token rotation.

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不能给会话挂载额外资源(文件、代码仓库等)。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstring
created_atstringA timestamp in RFC 3339 format
mount_pathstring | null | stringFilesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.
typestring
updated_atstringA timestamp in RFC 3339 format
urlstring
checkoutnull | object
checkout.namestringBranch name to check out.
checkout.typestring
checkout.shastringFull commit SHA to check out.
file_idstring
memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
accessnull | stringAccess mode for an attached memory store.
descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /anthropic/v1/sessions/{session_id}/threads◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

200

按 created_at 升序返回主线程及全部子线程。线程 id 为 sthr_ 加所属会话 id 的后缀;子线程的 parent_thread_id 指向主线程,session_id 始终为父会话。agent 是实际运行的定义,内置类型的 name 为类型名,未注册的 id/version 为 null。归档子线程的 status 为 terminated,archived_at 为归档时间;stats/usage 无线程级追踪时如实为 null。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringUnique identifier for this thread.
data[].agentobjectThe resolved agent a `session_thread` runs.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].created_atstringA timestamp in RFC 3339 format
data[].parent_thread_idnull | stringParent thread that spawned this thread. Null for the primary thread.
data[].session_idstringThe session this thread belongs to.
data[].statsnull | objectTiming statistics for a session thread.
data[].statusstringSessionThreadStatus enum
data[].typestring
data[].updated_atstringA timestamp in RFC 3339 format
data[].usagenull | objectCumulative token usage for a session thread across all turns.
next_pagestring | null

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /anthropic/v1/sessions/{session_id}/threads/{thread_id}◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • thread_idstring必填

    path: 路径参数:线程 ID。

  • session_idstring必填

    query: 会话 ID(路径或查询参数)。

返回

200

返回本会话的主线程或子线程,与列表项逐字段一致。其他会话的线程、未知线程或非 sthr_ id 一律返回 404,不泄露其存在性。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this thread.
agentobjectThe resolved agent a `session_thread` runs.
agent.modelstring | objectThe advisor model id. / Model identifier and configuration.
agent.typestring
agent.idstring
agent.descriptionnull | string
agent.mcp_serversarray<object>
agent.namestring
agent.skillsarray<object>
agent.systemnull | string
agent.toolsarray<object>
agent.versionnumber
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
parent_thread_idnull | stringParent thread that spawned this thread. Null for the primary thread.
session_idstringThe session this thread belongs to.
statsnull | objectTiming statistics for a session thread.
stats.active_secondsnumberCumulative time in seconds the thread spent actively running. Excludes idle time.
stats.duration_secondsnumberElapsed time since thread creation in seconds. For archived threads, frozen at the final update.
stats.startup_secondsnumberTime in seconds for the thread to begin running. Zero for child threads, which start immediately.
statusstringSessionThreadStatus enum
typestring
updated_atstringA timestamp in RFC 3339 format
usagenull | objectCumulative token usage for a session thread across all turns.
usage.active_secondsnumberCumulative time in seconds this thread spent in running status. Equal to `stats.active_seconds`; surfaced here so a thread's usage carries every quantity its cost is priced on.
usage.cache_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /anthropic/v1/sessions/{session_id}/threads/{thread_id}/archive◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • thread_idstring必填

    path: 路径参数:线程 ID。

  • session_idstring必填

    query: 会话 ID(路径或查询参数)。

返回

200

主线程沿用会话归档动作;子线程仅归档对应子会话,不归档父会话或其他子线程。子线程归档后 status 为 terminated,带 archived_at;历史事件仍可读。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this thread.
agentobjectThe resolved agent a `session_thread` runs.
agent.modelstring | objectThe advisor model id. / Model identifier and configuration.
agent.typestring
agent.idstring
agent.descriptionnull | string
agent.mcp_serversarray<object>
agent.namestring
agent.skillsarray<object>
agent.systemnull | string
agent.toolsarray<object>
agent.versionnumber
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
parent_thread_idnull | stringParent thread that spawned this thread. Null for the primary thread.
session_idstringThe session this thread belongs to.
statsnull | objectTiming statistics for a session thread.
stats.active_secondsnumberCumulative time in seconds the thread spent actively running. Excludes idle time.
stats.duration_secondsnumberElapsed time since thread creation in seconds. For archived threads, frozen at the final update.
stats.startup_secondsnumberTime in seconds for the thread to begin running. Zero for child threads, which start immediately.
statusstringSessionThreadStatus enum
typestring
updated_atstringA timestamp in RFC 3339 format
usagenull | objectCumulative token usage for a session thread across all turns.
usage.active_secondsnumberCumulative time in seconds this thread spent in running status. Equal to `stats.active_seconds`; surfaced here so a thread's usage carries every quantity its cost is priced on.
usage.cache_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /anthropic/v1/sessions/{session_id}/threads/{thread_id}/events◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • thread_idstring必填

    path: 路径参数:线程 ID。

  • session_idstring必填

    query: 会话 ID(路径或查询参数)。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

200

读取所选线程自己的事件记录:主线程读主会话,子线程读对应子会话。沿用会话事件接口的查询参数、公开事件类型和 data + next_page 信封。使用网页工具时,两个接口均返回 search_result 块;回答 citations 为 /agent/v1 扩展,/anthropic 将引用显示为正文 [n]。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringUnique identifier for this event.
data[].contentarray<object>Array of content blocks comprising the user message. / The result content returned by the tool. / Array of text blocks comprising the agent response. / The result content returned by the tool. / The result content returned by the tool. / Message content blocks. / Message content blocks. / The result content returned by the tool. / System content blocks. Text-only.
data[].typestring
data[].processed_atnull | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | null | string | string | string | null | string | stringA timestamp in RFC 3339 format
data[].session_thread_idnull | string | string | string | string | string | null | string | stringIf absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Set by the server to the subagent thread this confirmation was routed to. Omitted when it was routed to the primary thread. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.custom_tool_result` by `custom_tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` by `tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` or `user.tool_result` by `tool_use_id`, so clients do not send it back. / Public `sthr_` ID of the newly created thread. / Public sthr_ ID of the thread that started running. / Public sthr_ ID of the thread that went idle. / Public sthr_ ID of the thread that terminated. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / Public sthr_ ID of the thread that is retrying.
data[].resultstringUserToolConfirmationResult enum / Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress.
data[].tool_use_idstringThe id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. / The id of the `agent.tool_use` event this result corresponds to. / The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field.
data[].deny_messagenull | stringOptional message providing context for a 'deny' decision. Only allowed when result is 'deny'.
data[].custom_tool_use_idstringThe id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field.
data[].is_errornull | booleanWhether the tool execution resulted in an error. / Whether the model request resulted in an error. / Whether the tool execution resulted in an error.
data[].inputobjectInput parameters for the tool call.
data[].namestringName of the custom tool being called. / Name of the MCP tool being used. / Name of the agent tool being used.
data[].mcp_server_namestringName of the MCP server providing the tool.
data[].evaluated_permissionstringAgentEvaluatedPermission enum
data[].evaluationobjectNames the resolved permission_policy that produced evaluated_permission, and under auto carries the judgement. Open union: clients must tolerate unknown variants.
data[].mcp_tool_use_idstringThe id of the `agent.mcp_tool_use` event this result corresponds to.
data[].from_session_thread_idstringPublic `sthr_` ID of the thread that sent the message.
data[].from_agent_namenull | stringName of the callable agent this message came from. Absent when received from the primary agent.
data[].to_session_thread_idstringPublic `sthr_` ID of the thread the message was sent to.
data[].to_agent_namenull | stringName of the callable agent this message was sent to. Absent when sent to the primary agent.
data[].errorobject
data[].stop_reasonobject
data[].agent_namestringName of the callable agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs.
data[].iterationnumber0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc. / 0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`. / 0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.
data[].outcome_idstringThe `outc_` ID of the outcome being evaluated. / Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.
data[].explanationstringHuman-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why.
data[].outcome_evaluation_start_idstringThe id of the corresponding `span.outcome_evaluation_start` event.
data[].usageobjectToken usage for a single model request. / Point-in-time snapshot of a session's cumulative usage.
data[].model_request_start_idstringThe id of the corresponding `span.model_request_start` event.
data[].model_usageobjectToken usage for a single model request.
data[].descriptionstringWhat the agent should produce. Copied from the input event.
data[].max_iterationsnull | numberEvaluate-then-revise cycles before giving up. Default 3, max 20.
data[].rubricobjectRubric for grading the quality of an outcome.
data[].agentnull | objectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
data[].budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
data[].metadataobjectThe session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty.
data[].titlenull | stringThe session's new title. Present only when the update changed it.
next_pagestring | null

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /anthropic/v1/sessions/{session_id}/threads/{thread_id}/stream◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • thread_idstring必填

    path: 路径参数:线程 ID。

  • session_idstring必填

    query: 会话 ID(路径或查询参数)。

  • event_deltasarray可选

    query: 设置后连接同时接收流式增量事件。

返回

200

订阅所选线程自己的实时事件流。复用会话 SSE 实现;/agent 接口支持同址只读 WebSocket。主会话流同时包含子线程创建、状态和消息事件,子线程审批带 session_thread_id 上浮;确认或中断携带该字段时路由到所属子线程。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Server-sent events

text/event-stream — chunk / 事件对象

未声明字段结构。

GET /anthropic/v1/skills○ 未支持

请求参数

  • sourcestring可选

    query: 按来源过滤 Skill:custom 或官方来源。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不支持上传和管理 Skills;创建智能体时传入 skills 会返回 400。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringUnique identifier for the skill. The format and length of IDs may change over time.
data[].created_atstringISO 8601 timestamp of when the skill was created.
data[].display_namestringHuman-readable, single-line label for the Skill. Maximum 255 characters. Always set: derived from the SKILL.md frontmatter `name` when omitted at creation. Not unique.
data[].latest_version_idstringID of the newest Skill Version — what `latest` references resolve to. Always set: a Skill holds at least one version.
data[].sourceobjectWhere the Skill comes from. Possible values: - `"custom"`: authored by the platform user; private to their workspace - `"anthropic"`: published by Anthropic; shared and read-only - `"anthropic_example"`: Anthropic-published sample Skill - `"plugin"`: resolved from an installed plugin
data[].typestringObject type. For Skills, this is always `"skill"`.
data[].updated_atstringISO 8601 timestamp of when the skill was last updated.
next_pagestring | null

POST /anthropic/v1/skills○ 未支持

请求体

  • filesarray必填

    Files to upload for the skill. All files must be in the same top-level directory and must include a SKILL.md file at the root of that directory.

  • display_namestring可选

    Human-readable, single-line label for the Skill. Maximum 255 characters. Always set: derived from the SKILL.md frontmatter `name` when omitted at creation. Not unique.

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不支持上传和管理 Skills;创建智能体时传入 skills 会返回 400。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

multipart/form-data

名称类型说明
idstringUnique identifier for the skill. The format and length of IDs may change over time.
created_atstringISO 8601 timestamp of when the skill was created.
display_namestringHuman-readable, single-line label for the Skill. Maximum 255 characters. Always set: derived from the SKILL.md frontmatter `name` when omitted at creation. Not unique.
latest_version_idstringID of the newest Skill Version — what `latest` references resolve to. Always set: a Skill holds at least one version.
sourceobjectWhere the Skill comes from. Possible values: - `"custom"`: authored by the platform user; private to their workspace - `"anthropic"`: published by Anthropic; shared and read-only - `"anthropic_example"`: Anthropic-published sample Skill - `"plugin"`: resolved from an installed plugin
source.typestringWhere the Skill comes from. Possible values: - `"custom"`: authored by the platform user; private to their workspace - `"anthropic"`: published by Anthropic; shared and read-only - `"anthropic_example"`: Anthropic-published sample Skill - `"plugin"`: resolved from an installed plugin
typestringObject type. For Skills, this is always `"skill"`.
updated_atstringISO 8601 timestamp of when the skill was last updated.

DELETE /anthropic/v1/skills/{skill_id}○ 未支持

请求参数

  • skill_idstring必填

    path: Skill ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不支持上传和管理 Skills;创建智能体时传入 skills 会返回 400。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the skill. The format and length of IDs may change over time.
typestringDeleted object type. For Skills, this is always `"skill_deleted"`.

GET /anthropic/v1/skills/{skill_id}○ 未支持

请求参数

  • skill_idstring必填

    path: Skill ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不支持上传和管理 Skills;创建智能体时传入 skills 会返回 400。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the skill. The format and length of IDs may change over time.
created_atstringISO 8601 timestamp of when the skill was created.
display_namestringHuman-readable, single-line label for the Skill. Maximum 255 characters. Always set: derived from the SKILL.md frontmatter `name` when omitted at creation. Not unique.
latest_version_idstringID of the newest Skill Version — what `latest` references resolve to. Always set: a Skill holds at least one version.
sourceobjectWhere the Skill comes from. Possible values: - `"custom"`: authored by the platform user; private to their workspace - `"anthropic"`: published by Anthropic; shared and read-only - `"anthropic_example"`: Anthropic-published sample Skill - `"plugin"`: resolved from an installed plugin
source.typestringWhere the Skill comes from. Possible values: - `"custom"`: authored by the platform user; private to their workspace - `"anthropic"`: published by Anthropic; shared and read-only - `"anthropic_example"`: Anthropic-published sample Skill - `"plugin"`: resolved from an installed plugin
typestringObject type. For Skills, this is always `"skill"`.
updated_atstringISO 8601 timestamp of when the skill was last updated.

GET /anthropic/v1/skills/{skill_id}/versions○ 未支持

请求参数

  • skill_idstring必填

    path: Skill ID(路径或查询参数)。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不支持上传和管理 Skills;创建智能体时传入 skills 会返回 400。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringUnique identifier for this Skill Version. The id addresses the version in paths and pins it in references.
data[].created_atstringISO 8601 timestamp of when the skill was created.
data[].descriptionstringDescription of the skill version. This is extracted from the SKILL.md file in the skill upload.
data[].namestringThe Skill's immutable kebab-case slug, set at creation from the first upload's SKILL.md frontmatter `name` (or its enclosing directory). Every later upload must resolve to the same value. Also the top-level directory of the Skill's mounted files and the base name of a downloaded archive.
data[].skill_idstringUnique identifier for the skill. The format and length of IDs may change over time.
data[].typestringObject type. For Skill Versions, this is always `"skill_version"`.
next_pagestring | null

POST /anthropic/v1/skills/{skill_id}/versions○ 未支持

请求参数

  • skill_idstring必填

    path: Skill ID(路径或查询参数)。

  • filesarray必填

    Files to upload for the skill. All files must be in the same top-level directory and must include a SKILL.md file at the root of that directory.

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不支持上传和管理 Skills;创建智能体时传入 skills 会返回 400。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

multipart/form-data

名称类型说明
idstringUnique identifier for this Skill Version. The id addresses the version in paths and pins it in references.
created_atstringISO 8601 timestamp of when the skill was created.
descriptionstringDescription of the skill version. This is extracted from the SKILL.md file in the skill upload.
namestringThe Skill's immutable kebab-case slug, set at creation from the first upload's SKILL.md frontmatter `name` (or its enclosing directory). Every later upload must resolve to the same value. Also the top-level directory of the Skill's mounted files and the base name of a downloaded archive.
skill_idstringUnique identifier for the skill. The format and length of IDs may change over time.
typestringObject type. For Skill Versions, this is always `"skill_version"`.

DELETE /anthropic/v1/skills/{skill_id}/versions/{version}○ 未支持

请求参数

  • skill_idstring必填

    path: Skill ID(路径或查询参数)。

  • versionstring必填

    path: 路径参数:版本号。

  • skill_idstring必填

    query: Skill ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不支持上传和管理 Skills;创建智能体时传入 skills 会返回 400。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this Skill Version. The id addresses the version in paths and pins it in references.
typestringDeleted object type. For Skill Versions, this is always `"skill_version_deleted"`.

GET /anthropic/v1/skills/{skill_id}/versions/{version}○ 未支持

请求参数

  • skill_idstring必填

    path: Skill ID(路径或查询参数)。

  • versionstring必填

    path: 路径参数:版本号。

  • skill_idstring必填

    query: Skill ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不支持上传和管理 Skills;创建智能体时传入 skills 会返回 400。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this Skill Version. The id addresses the version in paths and pins it in references.
created_atstringISO 8601 timestamp of when the skill was created.
descriptionstringDescription of the skill version. This is extracted from the SKILL.md file in the skill upload.
namestringThe Skill's immutable kebab-case slug, set at creation from the first upload's SKILL.md frontmatter `name` (or its enclosing directory). Every later upload must resolve to the same value. Also the top-level directory of the Skill's mounted files and the base name of a downloaded archive.
skill_idstringUnique identifier for the skill. The format and length of IDs may change over time.
typestringObject type. For Skill Versions, this is always `"skill_version"`.

GET /anthropic/v1/skills/{skill_id}/versions/{version}/content○ 未支持

请求参数

  • skill_idstring必填

    path: Skill ID(路径或查询参数)。

  • versionstring必填

    path: 路径参数:版本号。

  • skill_idstring必填

    query: Skill ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还不支持上传和管理 Skills;创建智能体时传入 skills 会返回 400。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Binary response body

application/octet-stream

名称类型说明
$string (binary)

GET /anthropic/v1/tunnels○ 未支持

请求参数

  • include_archivedboolean可选

    query: 是否包含已归档的记录。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供把智能体接入你自有网络的隧道。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringUnique identifier for the tunnel, prefixed with `tnl_`.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].created_atstringA timestamp in RFC 3339 format
data[].display_namenull | stringHuman-readable name for the tunnel (1-255 characters). Null if unset.
data[].domainstringAnthropic-assigned hostname for the tunnel. MCP server URLs whose host is a subdomain of this value are routed through the tunnel. Globally unique and never reused, even after the tunnel is archived.
data[].typestring
next_pagestring | null

POST /anthropic/v1/tunnels○ 未支持

请求体

  • display_namestring可选

    Optional human-readable name for the tunnel (1-255 characters).

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供把智能体接入你自有网络的隧道。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the tunnel, prefixed with `tnl_`.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
display_namenull | stringHuman-readable name for the tunnel (1-255 characters). Null if unset.
domainstringAnthropic-assigned hostname for the tunnel. MCP server URLs whose host is a subdomain of this value are routed through the tunnel. Globally unique and never reused, even after the tunnel is archived.
typestring

GET /anthropic/v1/tunnels/{tunnel_id}○ 未支持

请求参数

  • tunnel_idstring必填

    path: 隧道 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供把智能体接入你自有网络的隧道。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the tunnel, prefixed with `tnl_`.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
display_namenull | stringHuman-readable name for the tunnel (1-255 characters). Null if unset.
domainstringAnthropic-assigned hostname for the tunnel. MCP server URLs whose host is a subdomain of this value are routed through the tunnel. Globally unique and never reused, even after the tunnel is archived.
typestring

POST /anthropic/v1/tunnels/{tunnel_id}/archive○ 未支持

请求参数

  • tunnel_idstring必填

    path: 隧道 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供把智能体接入你自有网络的隧道。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the tunnel, prefixed with `tnl_`.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
display_namenull | stringHuman-readable name for the tunnel (1-255 characters). Null if unset.
domainstringAnthropic-assigned hostname for the tunnel. MCP server URLs whose host is a subdomain of this value are routed through the tunnel. Globally unique and never reused, even after the tunnel is archived.
typestring

GET /anthropic/v1/tunnels/{tunnel_id}/certificates○ 未支持

请求参数

  • tunnel_idstring必填

    path: 隧道 ID(路径或查询参数)。

  • include_archivedboolean可选

    query: 是否包含已归档的记录。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供把智能体接入你自有网络的隧道。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringUnique identifier for the certificate, prefixed with `tcrt_`.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].created_atstringA timestamp in RFC 3339 format
data[].expires_atnull | stringA timestamp in RFC 3339 format
data[].fingerprintstringLowercase hex SHA-256 fingerprint of the certificate's DER encoding.
data[].tunnel_idstringID of the tunnel the certificate is registered against.
data[].typestring
next_pagestring | null

POST /anthropic/v1/tunnels/{tunnel_id}/certificates○ 未支持

请求参数

  • tunnel_idstring必填

    path: 隧道 ID(路径或查询参数)。

  • ca_certificate_pemstring必填

    PEM-encoded X.509 CA certificate. Must contain exactly one certificate and no private-key material. Maximum 8KB.

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供把智能体接入你自有网络的隧道。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the certificate, prefixed with `tcrt_`.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
expires_atnull | stringA timestamp in RFC 3339 format
fingerprintstringLowercase hex SHA-256 fingerprint of the certificate's DER encoding.
tunnel_idstringID of the tunnel the certificate is registered against.
typestring

GET /anthropic/v1/tunnels/{tunnel_id}/certificates/{certificate_id}○ 未支持

请求参数

  • tunnel_idstring必填

    path: 隧道 ID(路径或查询参数)。

  • certificate_idstring必填

    path: 路径参数:客户端证书 ID。

  • tunnel_idstring必填

    query: 隧道 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供把智能体接入你自有网络的隧道。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the certificate, prefixed with `tcrt_`.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
expires_atnull | stringA timestamp in RFC 3339 format
fingerprintstringLowercase hex SHA-256 fingerprint of the certificate's DER encoding.
tunnel_idstringID of the tunnel the certificate is registered against.
typestring

POST /anthropic/v1/tunnels/{tunnel_id}/certificates/{certificate_id}/archive○ 未支持

请求参数

  • tunnel_idstring必填

    path: 隧道 ID(路径或查询参数)。

  • certificate_idstring必填

    path: 路径参数:客户端证书 ID。

  • tunnel_idstring必填

    query: 隧道 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供把智能体接入你自有网络的隧道。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the certificate, prefixed with `tcrt_`.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
expires_atnull | stringA timestamp in RFC 3339 format
fingerprintstringLowercase hex SHA-256 fingerprint of the certificate's DER encoding.
tunnel_idstringID of the tunnel the certificate is registered against.
typestring

POST /anthropic/v1/tunnels/{tunnel_id}/reveal_token○ 未支持

请求参数

  • tunnel_idstring必填

    path: 隧道 ID(路径或查询参数)。

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供把智能体接入你自有网络的隧道。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringStable identifier for the current token value. Changes when the token is rotated.
tunnel_tokenstringThe connector token used to run the tunnel. Treat as a credential.
typestring

POST /anthropic/v1/tunnels/{tunnel_id}/rotate_token○ 未支持

请求参数

  • tunnel_idstring必填

    path: 隧道 ID(路径或查询参数)。

  • reasonstring可选

    Optional free-text reason for the rotation, recorded for audit.

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

平台还没有提供把智能体接入你自有网络的隧道。调用会返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringStable identifier for the current token value. Changes when the token is rotated.
tunnel_tokenstringThe connector token used to run the tunnel. Treat as a credential.
typestring

列出凭据库

GET /anthropic/v1/vaults● 支持

请求参数

  • include_archivedboolean可选

    query: 是否包含已归档的记录。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

200

支持创建、列出、读取、更新、归档与删除。列表支持 limit、page 和 include_archived。归档会同时归档库内全部凭据并清除凭据的值;删除会一并删除全部凭据,不可恢复。以 anthropic. 开头的 metadata 键由平台保留,不能写入。同一个库也可以通过原生接口 /vault/v1 管理。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringUnique identifier for the vault.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].created_atstringA timestamp in RFC 3339 format
data[].display_namestringHuman-readable name for the vault.
data[].metadataobjectArbitrary key-value metadata attached to the vault.
data[].typestring
data[].updated_atstringA timestamp in RFC 3339 format
next_pagestring | null

创建凭据库

POST /anthropic/v1/vaults● 支持

请求体

  • display_namestring必填

    Human-readable name for the vault. 1-255 characters.

  • metadataobject可选

    Arbitrary key-value metadata to attach to the vault. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars.

返回

200

支持创建、列出、读取、更新、归档与删除。列表支持 limit、page 和 include_archived。归档会同时归档库内全部凭据并清除凭据的值;删除会一并删除全部凭据,不可恢复。以 anthropic. 开头的 metadata 键由平台保留,不能写入。同一个库也可以通过原生接口 /vault/v1 管理。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the vault.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
display_namestringHuman-readable name for the vault.
metadataobjectArbitrary key-value metadata attached to the vault.
typestring
updated_atstringA timestamp in RFC 3339 format

删除凭据库

DELETE /anthropic/v1/vaults/{vault_id}● 支持

请求参数

  • vault_idstring必填

    path: 保险库 ID(路径或查询参数)。

返回

200

支持创建、列出、读取、更新、归档与删除。列表支持 limit、page 和 include_archived。归档会同时归档库内全部凭据并清除凭据的值;删除会一并删除全部凭据,不可恢复。以 anthropic. 开头的 metadata 键由平台保留,不能写入。同一个库也可以通过原生接口 /vault/v1 管理。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier of the deleted vault.
typestring

读取凭据库

GET /anthropic/v1/vaults/{vault_id}● 支持

请求参数

  • vault_idstring必填

    path: 保险库 ID(路径或查询参数)。

返回

200

支持创建、列出、读取、更新、归档与删除。列表支持 limit、page 和 include_archived。归档会同时归档库内全部凭据并清除凭据的值;删除会一并删除全部凭据,不可恢复。以 anthropic. 开头的 metadata 键由平台保留,不能写入。同一个库也可以通过原生接口 /vault/v1 管理。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the vault.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
display_namestringHuman-readable name for the vault.
metadataobjectArbitrary key-value metadata attached to the vault.
typestring
updated_atstringA timestamp in RFC 3339 format

更新凭据库

POST /anthropic/v1/vaults/{vault_id}● 支持

请求参数

  • vault_idstring必填

    path: 保险库 ID(路径或查询参数)。

  • display_namestring可选

    Updated human-readable name for the vault. 1-255 characters.

  • metadataobject可选

    Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omitted keys are preserved.

返回

200

支持创建、列出、读取、更新、归档与删除。列表支持 limit、page 和 include_archived。归档会同时归档库内全部凭据并清除凭据的值;删除会一并删除全部凭据,不可恢复。以 anthropic. 开头的 metadata 键由平台保留,不能写入。同一个库也可以通过原生接口 /vault/v1 管理。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the vault.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
display_namestringHuman-readable name for the vault.
metadataobjectArbitrary key-value metadata attached to the vault.
typestring
updated_atstringA timestamp in RFC 3339 format

归档凭据库

POST /anthropic/v1/vaults/{vault_id}/archive● 支持

请求参数

  • vault_idstring必填

    path: 保险库 ID(路径或查询参数)。

返回

200

支持创建、列出、读取、更新、归档与删除。列表支持 limit、page 和 include_archived。归档会同时归档库内全部凭据并清除凭据的值;删除会一并删除全部凭据,不可恢复。以 anthropic. 开头的 metadata 键由平台保留,不能写入。同一个库也可以通过原生接口 /vault/v1 管理。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the vault.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
display_namestringHuman-readable name for the vault.
metadataobjectArbitrary key-value metadata attached to the vault.
typestring
updated_atstringA timestamp in RFC 3339 format

GET /anthropic/v1/vaults/{vault_id}/credentials◐ 部分支持

请求参数

  • vault_idstring必填

    path: 保险库 ID(路径或查询参数)。

  • include_archivedboolean可选

    query: 是否包含已归档的记录。

  • limitnumber可选

    query: 每页返回的条数上限。

  • pagestring可选

    query: 分页游标,取自上一页响应的 next_page。

返回

200

支持 environment_variable 与 static_bearer。environment_variable 的 networking 只支持 limited,传 unrestricted 返回 400;secret_name 只能使用大写字母、数字和下划线,且不能以数字开头;injection_location 的默认值与官方一致。static_bearer 的令牌只在 mcp_server_url 所在主机上可用。创建或更新 mcp_oauth 返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试;需要 OAuth 令牌时请使用 /vault/v1/authorizations 一键授权。每个库最多 20 个有效凭据。以 anthropic. 开头的 metadata 键由平台保留,不能写入。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>
data[].idstringUnique identifier for the credential.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].authobjectAuthentication details for a credential.
data[].created_atstringA timestamp in RFC 3339 format
data[].metadataobjectArbitrary key-value metadata attached to the credential.
data[].typestring
data[].updated_atstringA timestamp in RFC 3339 format
data[].vault_idstringIdentifier of the vault this credential belongs to.
data[].display_namenull | stringHuman-readable name for the credential.
next_pagestring | null

POST /anthropic/v1/vaults/{vault_id}/credentials◐ 部分支持

请求参数

  • vault_idstring必填

    path: 保险库 ID(路径或查询参数)。

  • authobject必填

    Authentication details for creating a credential.

    ▸ 展开子字段(10)
    • access_tokenstring必填

      OAuth access token.

    • mcp_server_urlstring必填

      URL of the MCP server this credential authenticates against.

    • typestring必填
      取值 environment_variable
    • expires_atstring可选

      A timestamp in RFC 3339 format

    • refreshobject可选

      OAuth refresh token parameters for creating a credential with refresh support.

    • tokenstring必填

      Static bearer token value.

    • networkingobject必填

      Outbound hosts the secret value is substituted on.

    • secret_namestring必填

      Name of the environment variable. Immutable after create.

    • secret_valuestring必填

      Secret value. Write-only; never returned in responses.

    • injection_locationobject可选

      Where in the outbound request the secret value may be substituted.

  • display_namestring可选

    Human-readable name for the credential. Up to 255 characters.

  • metadataobject可选

    Arbitrary key-value metadata to attach to the credential. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars.

返回

200

支持 environment_variable 与 static_bearer。environment_variable 的 networking 只支持 limited,传 unrestricted 返回 400;secret_name 只能使用大写字母、数字和下划线,且不能以数字开头;injection_location 的默认值与官方一致。static_bearer 的令牌只在 mcp_server_url 所在主机上可用。创建或更新 mcp_oauth 返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试;需要 OAuth 令牌时请使用 /vault/v1/authorizations 一键授权。每个库最多 20 个有效凭据。以 anthropic. 开头的 metadata 键由平台保留,不能写入。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the credential.
archived_atnull | stringA timestamp in RFC 3339 format
authobjectAuthentication details for a credential.
auth.mcp_server_urlstringURL of the MCP server this credential authenticates against.
auth.typestring
auth.expires_atnull | stringA timestamp in RFC 3339 format
auth.refreshnull | objectOAuth refresh token configuration returned in credential responses.
auth.injection_locationobjectWhere in the outbound request the secret value is substituted.
auth.networkingobjectOutbound hosts the secret value is substituted on.
auth.secret_namestringName of the environment variable.
created_atstringA timestamp in RFC 3339 format
metadataobjectArbitrary key-value metadata attached to the credential.
typestring
updated_atstringA timestamp in RFC 3339 format
vault_idstringIdentifier of the vault this credential belongs to.
display_namenull | stringHuman-readable name for the credential.

MCP OAuth 创建限制

上面的示例创建 environment_variable 凭据。创建 mcp_oauth 仍返回 501,不会创建凭据;更新已有 mcp_oauth 凭据也不支持。以下为创建请求的实测错误响应。

{
  "type": "error",
  "error": {
    "type": "not_implemented_error",
    "message": "Not implemented: creating mcp_oauth credentials is not available on this platform yet; use static_bearer or environment_variable."
  },
  "request_id": "4c1dcdba-97bb-46ce-aad0-0a7d8753357c"
}

DELETE /anthropic/v1/vaults/{vault_id}/credentials/{credential_id}◐ 部分支持

请求参数

  • vault_idstring必填

    path: 保险库 ID(路径或查询参数)。

  • credential_idstring必填

    path: 路径参数:凭据 ID。

  • vault_idstring必填

    query: 保险库 ID(路径或查询参数)。

返回

200

支持 environment_variable 与 static_bearer。environment_variable 的 networking 只支持 limited,传 unrestricted 返回 400;secret_name 只能使用大写字母、数字和下划线,且不能以数字开头;injection_location 的默认值与官方一致。static_bearer 的令牌只在 mcp_server_url 所在主机上可用。创建或更新 mcp_oauth 返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试;需要 OAuth 令牌时请使用 /vault/v1/authorizations 一键授权。每个库最多 20 个有效凭据。以 anthropic. 开头的 metadata 键由平台保留,不能写入。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier of the deleted credential.
typestring

GET /anthropic/v1/vaults/{vault_id}/credentials/{credential_id}◐ 部分支持

请求参数

  • vault_idstring必填

    path: 保险库 ID(路径或查询参数)。

  • credential_idstring必填

    path: 路径参数:凭据 ID。

  • vault_idstring必填

    query: 保险库 ID(路径或查询参数)。

返回

200

支持 environment_variable 与 static_bearer。environment_variable 的 networking 只支持 limited,传 unrestricted 返回 400;secret_name 只能使用大写字母、数字和下划线,且不能以数字开头;injection_location 的默认值与官方一致。static_bearer 的令牌只在 mcp_server_url 所在主机上可用。创建或更新 mcp_oauth 返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试;需要 OAuth 令牌时请使用 /vault/v1/authorizations 一键授权。每个库最多 20 个有效凭据。以 anthropic. 开头的 metadata 键由平台保留,不能写入。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the credential.
archived_atnull | stringA timestamp in RFC 3339 format
authobjectAuthentication details for a credential.
auth.mcp_server_urlstringURL of the MCP server this credential authenticates against.
auth.typestring
auth.expires_atnull | stringA timestamp in RFC 3339 format
auth.refreshnull | objectOAuth refresh token configuration returned in credential responses.
auth.injection_locationobjectWhere in the outbound request the secret value is substituted.
auth.networkingobjectOutbound hosts the secret value is substituted on.
auth.secret_namestringName of the environment variable.
created_atstringA timestamp in RFC 3339 format
metadataobjectArbitrary key-value metadata attached to the credential.
typestring
updated_atstringA timestamp in RFC 3339 format
vault_idstringIdentifier of the vault this credential belongs to.
display_namenull | stringHuman-readable name for the credential.

POST /anthropic/v1/vaults/{vault_id}/credentials/{credential_id}◐ 部分支持

请求参数

  • vault_idstring必填

    path: 保险库 ID(路径或查询参数)。

  • credential_idstring必填

    path: 路径参数:凭据 ID。

  • vault_idstring必填

    query: 保险库 ID(路径或查询参数)。

  • authobject可选

    Updated authentication details for a credential.

    ▸ 展开子字段(8)
    • typestring必填
      取值 environment_variable
    • access_tokenstring可选

      Updated OAuth access token.

    • expires_atstring可选

      A timestamp in RFC 3339 format

    • refreshobject可选

      Parameters for updating OAuth refresh token configuration.

    • tokenstring可选

      Updated static bearer token value.

    • injection_locationobject可选

      Updated injection location.

    • networkingobject可选

      Updated networking scope. Full replacement.

    • secret_valuestring可选

      Updated secret value.

  • display_namestring可选

    Updated human-readable name for the credential. 1-255 characters.

  • metadataobject可选

    Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omitted keys are preserved.

返回

200

支持 environment_variable 与 static_bearer。environment_variable 的 networking 只支持 limited,传 unrestricted 返回 400;secret_name 只能使用大写字母、数字和下划线,且不能以数字开头;injection_location 的默认值与官方一致。static_bearer 的令牌只在 mcp_server_url 所在主机上可用。创建或更新 mcp_oauth 返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试;需要 OAuth 令牌时请使用 /vault/v1/authorizations 一键授权。每个库最多 20 个有效凭据。以 anthropic. 开头的 metadata 键由平台保留,不能写入。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the credential.
archived_atnull | stringA timestamp in RFC 3339 format
authobjectAuthentication details for a credential.
auth.mcp_server_urlstringURL of the MCP server this credential authenticates against.
auth.typestring
auth.expires_atnull | stringA timestamp in RFC 3339 format
auth.refreshnull | objectOAuth refresh token configuration returned in credential responses.
auth.injection_locationobjectWhere in the outbound request the secret value is substituted.
auth.networkingobjectOutbound hosts the secret value is substituted on.
auth.secret_namestringName of the environment variable.
created_atstringA timestamp in RFC 3339 format
metadataobjectArbitrary key-value metadata attached to the credential.
typestring
updated_atstringA timestamp in RFC 3339 format
vault_idstringIdentifier of the vault this credential belongs to.
display_namenull | stringHuman-readable name for the credential.

POST /anthropic/v1/vaults/{vault_id}/credentials/{credential_id}/archive◐ 部分支持

请求参数

  • vault_idstring必填

    path: 保险库 ID(路径或查询参数)。

  • credential_idstring必填

    path: 路径参数:凭据 ID。

  • vault_idstring必填

    query: 保险库 ID(路径或查询参数)。

返回

200

支持 environment_variable 与 static_bearer。environment_variable 的 networking 只支持 limited,传 unrestricted 返回 400;secret_name 只能使用大写字母、数字和下划线,且不能以数字开头;injection_location 的默认值与官方一致。static_bearer 的令牌只在 mcp_server_url 所在主机上可用。创建或更新 mcp_oauth 返回 501(not_implemented_error),不产生副作用,官方 SDK 不会重试;需要 OAuth 令牌时请使用 /vault/v1/authorizations 一键授权。每个库最多 20 个有效凭据。以 anthropic. 开头的 metadata 键由平台保留,不能写入。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for the credential.
archived_atnull | stringA timestamp in RFC 3339 format
authobjectAuthentication details for a credential.
auth.mcp_server_urlstringURL of the MCP server this credential authenticates against.
auth.typestring
auth.expires_atnull | stringA timestamp in RFC 3339 format
auth.refreshnull | objectOAuth refresh token configuration returned in credential responses.
auth.injection_locationobjectWhere in the outbound request the secret value is substituted.
auth.networkingobjectOutbound hosts the secret value is substituted on.
auth.secret_namestringName of the environment variable.
created_atstringA timestamp in RFC 3339 format
metadataobjectArbitrary key-value metadata attached to the credential.
typestring
updated_atstringA timestamp in RFC 3339 format
vault_idstringIdentifier of the vault this credential belongs to.
display_namenull | stringHuman-readable name for the credential.

POST /anthropic/v1/vaults/{vault_id}/credentials/{credential_id}/mcp_oauth_validate◐ 部分支持

请求参数

  • vault_idstring必填

    path: 保险库 ID(路径或查询参数)。

  • credential_idstring必填

    path: 路径参数:凭据 ID。

  • vault_idstring必填

    query: 保险库 ID(路径或查询参数)。

返回

400

只适用于 OAuth 凭据,对其他类型返回 400。结果总是 HTTP 200,status 为 valid、invalid 或 unknown;mcp_probe 只在未通过时给出失败的一步,refresh 只在尝试了续期时给出。

错误按 Claude Managed Agents 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
credential_idstringUnique identifier of the credential that was validated.
has_refresh_tokenbooleanWhether the credential has a refresh token configured.
mcp_probenull | objectThe failing step of an MCP validation probe.
mcp_probe.http_responsenull | objectAn HTTP response captured during a credential validation probe.
mcp_probe.methodstringThe MCP method that failed (for example `initialize` or `tools/list`).
refreshnull | objectOutcome of a refresh-token exchange attempted during credential validation.
refresh.http_responsenull | objectAn HTTP response captured during a credential validation probe.
refresh.statusstringOutcome of a refresh-token exchange attempted during credential validation. - `succeeded` - The token endpoint returned a new access token. - `failed` - The token endpoint returned an error response. See `http_response` for detail. - `connect_error` - The token endpoint could not be reached (DNS, TLS, or connection error). - `no_refresh_token` - No refresh token is stored for the credential, so no exchange was attempted.
statusstringOverall verdict of a credential validation probe.
typestring
validated_atstringA timestamp in RFC 3339 format
vault_idstringIdentifier of the vault containing the credential.

示例前提

此示例针对前面创建的 static 凭据,因此实测返回 400 invalid_request_error。要获得校验结果,请先通过一键授权完成用户授权,再将 credential_id 换成产生的 OAuth Secret ID。校验 OAuth 凭据返回 HTTP 200,状态为 valid、invalid 或 unknown。

Google Gemini 兼容接口

基础地址

加载中…

接入

加载中…

可用模型

  • 路径里的模型名就是平台模型名(如 gemini-2.5-flash),可用模型见列出模型。只有声明了 Google 协议的模型可以在这里调用,其他模型返回 404。
  • 需要图片输出时,在 generationConfig.responseModalities 里带上 IMAGE,请求会交给平台的图像模型处理。
  • 在思考模型上强制调用工具(toolConfig 的 ANY 模式)与 Gemini 原生 API 一致,会原样转发给模型:模型接受即执行,不接受时返回 Google 格式的 400 错误。

端点

方法路径说明支持
POST/v1beta/models/{modelsId}:generateContent生成内容● 支持
POST/v1beta/models/{modelsId}:streamGenerateContent流式生成内容● 支持
POST/v1beta/models/{modelsId}:countTokens统计 token◐ 部分支持
POST/v1beta/models/{modelsId}:embedContent生成向量嵌入● 支持
POST/v1beta/models/{modelsId}:batchEmbedContents批量生成向量嵌入● 支持
GET/v1beta/models列出模型● 支持
GET/v1beta/models/{modelsId}读取模型● 支持

与官方的差异

  • 生成内容:toolConfig 的强制工具(functionCallingConfig mode ANY,含 allowedFunctionNames) 在思考模型上同样忠实转发给上游——与 Gemini 原生 API 一致,是否接受由上游模型 决定:如果上游返回 400,错误保持 Google 格式并携带上游的代码与状态。
  • 统计 token:按模型族校准的估算值(包括中文和工具定义),响应头为 x-praxis-token-count: estimated;不能用作精确用量或计费依据。
  • 生成向量嵌入:只接受文本部件;图像等多模态部件会被拒绝。taskType、title 以及 autoTruncate / documentOcr / audioTrackExtraction 等检索配置在平台上没有等价语义, 请求携带时会收到 400(INVALID_ARGUMENT),不会静默忽略——因为不同 taskType 生成的向量行为不同,静默丢弃会悄悄改变检索质量。outputDimensionality 映射为 返回向量的维度。
  • 批量生成向量嵌入:requests 中每一项的约束与 embedContent 相同(文本部件、同上拒绝规则);批量内 所有条目的 outputDimensionality 必须一致。当前官方 JS 与 Python SDK 的 embedContent 调用实际走的就是这个批量端点。
  • 列出模型:向量嵌入模型会以 embedContent 作为其唯一受支持的方法列出。当模型目录 暂时不可用时,generateContent 的行为保持不变:显式要求图像输出 (responseModalities 含 IMAGE)的请求仍走图像通道;未显式声明的旧式图像请求 在该窗口内会按文本对话处理——降级期间每个响应都带 X-Praxis-Route-Degraded: model-catalog-unavailable 头以示区别。

参数与字段的权威定义以 Gemini API 官方文档为准。

错误按 Gemini API 格式返回,参见错误;额度与响应头参见限流。

生成内容

POST /google/v1beta/models/{modelsId}:generateContent● 支持

Gemini API 官方文档 ↗

请求参数

  • modelstring必填

    path: Required. The name of the `Model` to use for generating the completion. Format: `models/{model}`.

  • contentsarray必填◐ 部分支持

    Required. The content of the current conversation with the model. For single-turn queries, this is a single instance. For multi-turn queries like [chat](https://ai.google.dev/gemini-api/docs/text-generation#chat), this is a repeated field that contains the conversation history and the latest request.

    多轮、文本、图片和工具往返生效,图片支持 URL-safe base64;audio/wav、text/plain 内联媒体及 fileData URL 返回 400。

    ▸ 展开子字段(2)
    • partsarray可选

      Ordered `Parts` that constitute a single message. Parts may have different MIME types.

      ▸ 展开子字段(16)
      • audioTranscriptionobject可选

        Optional. Audio (input or output) transcription. This is only set when this Part contains audio data.

      • codeExecutionResultobject可选

        Result of executing the `ExecutableCode`.

      • executableCodeobject可选

        Code generated by the model that is meant to be executed.

      • fileDataobject可选○ 未支持

        URI based data.

        已测 HTTPS、gs、Files API 和 YouTube URL 均返回 400。

      • functionCallobject可选

        A predicted `FunctionCall` returned from the model that contains a string representing the `FunctionDeclaration.name` with the arguments and their values.

      • functionResponseobject可选

        The result output of a `FunctionCall` that contains a string representing the `FunctionDeclaration.name` and a structured JSON object containing any output from the function is used as context to the model.

      • inlineDataobject可选◐ 部分支持

        Inline media bytes.

        image/png 生效(含 URL-safe base64);audio/wav、text/plain 返回 400;PDF 效果不可观测。

      • mediaProcessingstring可选

        Optional. How the model processes this part's media for understanding. Only meaningful for video parts (`inline_data` or `file_data` with video mime). Non-video parts ignore this field.

        取值 AGENTICMEDIA_PROCESSING_UNSPECIFIEDSTATIC
      • mediaResolutionobject可选

        Optional. Media resolution for the input media.

      • partMetadataobject可选

        Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams.

      • textstring可选

        Inline text.

      • thoughtboolean可选

        Optional. Indicates if the part is thought from the model.

      • thoughtSignaturestring可选

        Optional. An opaque signature for the thought so it can be reused in subsequent requests.

      • toolCallobject可选

        Server-side tool call. This field is populated when the model predicts a tool invocation that should be executed on the server. The client is expected to echo this message back to the API.

      • toolResponseobject可选

        The output from a server-side `ToolCall` execution. This field is populated by the client with the results of executing the corresponding `ToolCall`.

      • videoMetadataobject可选

        Optional. Video metadata. The metadata should only be specified while the video data is presented in inline_data or file_data.

    • rolestring可选

      Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset.

  • systemInstructionobject可选

    Optional. Developer set [system instruction(s)](https://ai.google.dev/gemini-api/docs/system-instructions). Currently, text only.

    已验证生效。

    ▸ 展开子字段(2)
    • partsarray可选

      Ordered `Parts` that constitute a single message. Parts may have different MIME types.

    • rolestring可选

      Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset.

  • generationConfigobject可选

    Optional. Configuration options for model generation and outputs.

    ▸ 展开子字段(25)
    • _responseJsonSchemaany可选○ 当前不生效

      Optional. Output schema of the generated response. This is an alternative to `response_schema` that accepts [JSON Schema](https://json-schema.org/). If set, `response_schema` must be omitted, but `response_mime_type` is required. While the full JSON Schema may be sent, not all features are supported. Specifically, only the following properties are supported: - `$id` - `$defs` - `$ref` - `$anchor` - `type` - `format` - `title` - `description` - `enum` (for strings and numbers) - `items` - `prefixItems` - `minItems` - `maxItems` - `minimum` - `maximum` - `anyOf` - `oneOf` (interpreted the same as `anyOf`) - `properties` - `additionalProperties` - `required` The non-standard `propertyOrdering` property may also be set. Cyclic references are unrolled to a limited degree and, as such, may only be used within non-required properties. (Nullable properties are not sufficient.) If `$ref` is set on a sub-schema, no other properties, except for than those starting as a `$`, may be set. Deprecated. Use `response_format` instead.

      接受但当前不生效。请使用 responseJsonSchema。

    • audioTranscriptionConfigobject可选○ 当前不生效

      Optional. Config for audio transcription (speech recognition).

      接受但当前不生效。已测文本模型不应用此选项。

    • candidateCountinteger可选◐ 部分支持

      Optional. Number of generated responses to return. If unset, this will default to 1. Please note that this doesn't work for previous generation models (Gemini 1.0 family)

      非流式支持多个候选;流式设置 2 返回 400。

    • enableAffectiveDialogboolean可选○ 当前不生效

      Optional. If enabled, the model will detect emotions and adapt its responses accordingly.

      接受但当前不生效。已测文本模型不应用此选项。

    • enableEnhancedCivicAnswersboolean可选○ 未支持

      Optional. Enables enhanced civic answers. It may not be available for all models.

      已测文本模型传入返回 400。

    • frequencyPenaltynumber可选◐ 部分支持

      Optional. Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the respponse so far. A positive penalty will discourage the use of tokens that have already been used, proportional to the number of times the token has been used: The more a token is used, the more difficult it is for the model to use that token again increasing the vocabulary of responses. Caution: A _negative_ penalty will encourage the model to reuse tokens proportional to the number of times the token has been used. Small negative values will reduce the vocabulary of a response. Larger negative values will cause the model to start repeating a common token until it hits the max_output_tokens limit.

      gemini-2.5-flash 偶发观察到效果;gemini-2.5-flash-lite 接受但当前不生效;2.0 可能返回 400。

    • imageConfigobject可选○ 未支持

      Optional. Config for image generation. An error will be returned if this field is set for models that don't support these config options.

      已测文本模型传入返回 400。

    • logprobsinteger可选

      Optional. Only valid if response_logprobs=True. This sets the number of top logprobs, including the chosen candidate, to return at each decoding step in the Candidate.logprobs_result. The number must be in the range of [0, 20].

      已验证生效。

    • maxOutputTokensinteger可选◐ 部分支持

      Optional. The maximum number of tokens to include in a response candidate. Note: The default value varies by model, see the `Model.output_token_limit` attribute of the `Model` returned from the `getModel` function.

      限制输出预算;思考占用预算,极小预算可能只返回思考或报错,gemini-3.5-flash 可能提前截断。

    • mediaResolutionstring可选

      Optional. If specified, the media resolution specified will be used.

      gemini-2.5-flash 的 LOW/MEDIUM/HIGH 改变图片 token 消耗。

      取值 MEDIA_RESOLUTION_HIGHMEDIA_RESOLUTION_LOWMEDIA_RESOLUTION_MEDIUMMEDIA_RESOLUTION_UNSPECIFIED
    • presencePenaltynumber可选○ 当前不生效

      Optional. Presence penalty applied to the next token's logprobs if the token has already been seen in the response. This penalty is binary on/off and not dependant on the number of times the token is used (after the first). Use frequency_penalty for a penalty that increases with each use. A positive penalty will discourage the use of tokens that have already been used in the response, increasing the vocabulary. A negative penalty will encourage the use of tokens that have already been used in the response, decreasing the vocabulary.

      接受但当前不生效。gemini-2.5-flash 和 gemini-2.5-flash-lite 输出未变化。

    • responseFormatobject可选○ 当前不生效

      Optional. Configuration for the response output format. Allows specifying output configuration per modality (text, audio, image) in a flat structure.

      接受但当前不生效。已测文本模型不应用此选项。

    • responseJsonSchemaany可选◐ 部分支持

      Optional. An internal detail. Use `responseJsonSchema` rather than this field.

      2.5 系列生效;3.5 预算不足可能截断。不可与 responseSchema 同传。

    • responseLogprobsboolean可选

      Optional. If true, export the logprobs results in response.

      已验证生效。

    • responseMimeTypestring可选◐ 部分支持

      Optional. MIME type of the generated candidate text. Supported MIME types are: `text/plain`: (default) Text output. `application/json`: JSON response in the response candidates. `text/x.enum`: ENUM as a string response in the response candidates. Refer to the [docs](https://ai.google.dev/gemini-api/docs/prompting_with_media#plain_text_formats) for a list of all supported text MIME types.

      application/json 在 2.5 系列生效,3.5 可能返回非 JSON;text/x.enum 在 flash-lite 生效。

    • responseModalitiesarray可选◐ 部分支持

      Optional. The requested modalities of the response. Represents the set of modalities that the model can return, and should be expected in the response. This is an exact match to the modalities of the response. A model may have multiple combinations of supported modalities. If the requested modalities do not match any of the supported combinations, an error will be returned. An empty list is equivalent to requesting only text.

      已测文本模型支持 TEXT;AUDIO 返回 400,IMAGE 返回错误。

    • responseSchemaobject可选◐ 部分支持

      Optional. Output schema of the generated candidate text. Schemas must be a subset of the [OpenAPI schema](https://spec.openapis.org/oas/v3.0.3#schema) and can be objects, primitives or arrays. If set, a compatible `response_mime_type` must also be set. Compatible MIME types: `application/json`: Schema for JSON response. Refer to the [JSON text generation guide](https://ai.google.dev/gemini-api/docs/json-mode) for more details. Deprecated. Use `response_format` instead.

      2.5 系列的 JSON 约束生效;3.5 预算不足可能截断;需正确指定 responseMimeType。

    • seedinteger可选◐ 部分支持

      Optional. Seed used in decoding. If not set, the request uses a randomly generated seed.

      gemini-2.5-flash-lite 可复现;gemini-2.5-flash 接受但当前不生效。

    • speechConfigobject可选○ 当前不生效

      Optional. The speech generation config.

      接受但当前不生效。已测文本模型不应用此选项。

    • stopSequencesarray可选

      Optional. The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a `stop_sequence`. The stop sequence will not be included as part of the response.

      gemini-2.5-flash、gemini-2.5-flash-lite 生效;最多 5 项。

    • temperaturenumber可选◐ 部分支持

      Optional. Controls the randomness of the output. Note: The default value varies by model, see the `Model.temperature` attribute of the `Model` returned from the `getModel` function. Values can range from [0.0, 2.0].

      gemini-2.5-flash-lite 观察到效果;gemini-2.5-flash 的采样差异不可观测。

    • thinkingConfigobject可选

      Optional. Config for thinking features. An error will be returned if this field is set for models that don't support thinking.

      ▸ 展开子字段(3)
      • includeThoughtsboolean可选◐ 部分支持

        Indicates whether to include thoughts in the response. If true, thoughts are returned only when available.

        思考开启时 true/false 控制是否返回思考;flash-lite 默认未开启思考时单传此字段返回 400。

      • thinkingBudgetinteger可选

        The number of thoughts tokens that the model should generate.

        0 关闭思考;正数控制思考预算,-1 为自动。越界值返回 400。

      • thinkingLevelstring可选◐ 部分支持

        Optional. Controls the maximum depth of the model's internal reasoning process before it produces a response. The default value is model-dependent. Refer to the [Thinking levels guide](https://ai.google.dev/gemini-api/docs/thinking#thinking-levels) for more details. Recommended for Gemini 3 or later models. Use with earlier models results in an error.

        gemini-3.5-flash 支持 MINIMAL/LOW/MEDIUM/HIGH;用于 2.5 系列返回 400。

        取值 HIGHLOWMEDIUMMINIMALTHINKING_LEVEL_UNSPECIFIED
    • topKinteger可选○ 当前不生效

      接受该参数但不生效:采样不使用 topK。

      接受但当前不生效。gemini-2.5-flash-lite 在 topK=1 时仍返回不同输出;gemini-2.5-flash 不可观测。

    • topPnumber可选

      Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and Top-p (nucleus) sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits the number of tokens based on the cumulative probability. Note: The default value varies by `Model` and is specified by the`Model.top_p` attribute returned from the `getModel` function. An empty `top_k` attribute indicates that the model doesn't apply top-k sampling and doesn't allow setting `top_k` on requests.

      gemini-2.5-flash 和 gemini-2.5-flash-lite 已验证生效。

    • translationConfigobject可选○ 当前不生效

      Optional. Config for translation.

      接受但当前不生效。已测文本模型不应用此选项。

  • toolsarray可选

    Optional. A list of `Tools` the `Model` may use to generate the next response. A `Tool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the `Model`. Supported `Tool`s are `Function` and `code_execution`. Refer to the [Function calling](https://ai.google.dev/gemini-api/docs/function-calling) and the [Code execution](https://ai.google.dev/gemini-api/docs/code-execution) guides to learn more.

    ▸ 展开子字段(9)
    • codeExecutionobject可选○ 未支持

      Optional. Enables the model to execute code as part of generation.

      已测请求返回 502,当前不可用。

    • computerUseobject可选○ 未支持

      Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.

      已测 gemini-2.5-flash 返回 400。

    • fileSearchobject可选○ 未支持

      Optional. FileSearch tool type. Tool to retrieve knowledge from Semantic Retrieval corpora.

      已测 gemini-2.5-flash 返回 400。

    • functionDeclarationsarray可选

      Optional. A list of `FunctionDeclarations` available to the model that can be used for function calling. The model or system does not execute the function. Instead the defined function may be returned as a FunctionCall with arguments to the client side for execution. The model may decide to call a subset of these functions by populating FunctionCall in the response. The next conversation turn may contain a FunctionResponse with the Content.role "function" generation context for the next model turn.

      ▸ 展开子字段(7)
      • behaviorstring可选○ 当前不生效

        Optional. Specifies the function Behavior. Currently only supported by the BidiGenerateContent method.

        接受但当前不生效。

        取值 BLOCKINGNON_BLOCKINGUNSPECIFIED
      • descriptionstring可选

        Required. A brief description of the function.

      • namestring可选

        Required. The name of the function. Must be a-z, A-Z, 0-9, or contain underscores, colons, dots, and dashes, with a maximum length of 128.

      • parametersobject可选

        Optional. Describes the parameters to this function. Reflects the Open API 3.03 Parameter Object string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter.

        已验证生效。

      • parametersJsonSchemaany可选

        Optional. Describes the parameters to the function in JSON Schema format. The schema must describe an object where the properties are the parameters to the function. For example: ``` { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "additionalProperties": false, "required": ["name", "age"], "propertyOrdering": ["name", "age"] } ``` This field is mutually exclusive with `parameters`.

        已验证生效。

      • responseobject可选○ 当前不生效

        Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function.

        接受但当前不生效。

      • responseJsonSchemaany可选

        Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function. This field is mutually exclusive with `response`.

    • googleMapsobject可选

      Optional. Tool that allows grounding the model's response with geospatial context related to the user's query.

    • googleSearchobject可选

      Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.

      gemini-2.5-flash 返回 groundingMetadata。

    • googleSearchRetrievalobject可选○ 未支持

      Optional. Retrieval tool that is powered by Google search.

      已测 gemini-2.5-flash 返回 400。

    • mcpServersarray可选○ 未支持

      Optional. MCP Servers to connect to.

      已测 gemini-2.5-flash 返回 400。

    • urlContextobject可选

      Optional. Tool to support URL context retrieval.

  • toolConfigobject可选

    Optional. Tool configuration for any `Tool` specified in the request. Refer to the [Function calling guide](https://ai.google.dev/gemini-api/docs/function-calling#function_calling_mode) for a usage example.

    ▸ 展开子字段(3)
    • functionCallingConfigobject可选

      Optional. Function calling config.

      ▸ 展开子字段(2)
      • allowedFunctionNamesarray可选

        Optional. A set of function names that, when provided, limits the functions the model will call. This should only be set when the Mode is ANY or VALIDATED. Function names should match [FunctionDeclaration.name]. When set, model will predict a function call from only allowed function names.

        已验证生效。

      • modestring可选◐ 部分支持

        Optional. Specifies the mode in which function calling should execute. If unspecified, the default value will be set to AUTO.

        ANY/AUTO/VALIDATED 生效;NONE 在 flash-lite 偶发仍调用工具,复测生效。

        取值 ANYAUTOMODE_UNSPECIFIEDNONEVALIDATED
    • includeServerSideToolInvocationsboolean可选

      Optional. If true, the API response will include the server-side tool calls and responses within the `Content` message. This allows clients to observe the server's tool interactions.

    • retrievalConfigobject可选

      Optional. Retrieval config.

  • safetySettingsarray可选

    接受该参数但不生效:安全设置不会拦截或改变任何回复。

    ▸ 展开子字段(2)
    • categorystring可选

      Required. The category for this setting.

      取值 HARM_CATEGORY_CIVIC_INTEGRITYHARM_CATEGORY_DANGEROUSHARM_CATEGORY_DANGEROUS_CONTENTHARM_CATEGORY_DEROGATORYHARM_CATEGORY_HARASSMENTHARM_CATEGORY_HATE_SPEECHHARM_CATEGORY_JAILBREAKHARM_CATEGORY_MEDICALHARM_CATEGORY_SEXUALHARM_CATEGORY_SEXUALLY_EXPLICITHARM_CATEGORY_TOXICITYHARM_CATEGORY_UNSPECIFIEDHARM_CATEGORY_VIOLENCE
    • thresholdstring可选

      Required. Controls the probability threshold at which harm is blocked.

      取值 BLOCK_LOW_AND_ABOVEBLOCK_MEDIUM_AND_ABOVEBLOCK_NONEBLOCK_ONLY_HIGHHARM_BLOCK_THRESHOLD_UNSPECIFIEDOFF
  • cachedContentstring可选○ 未支持

    平台不支持上下文缓存:传入会返回 400(Google 错误格式)。

    传入返回 400;当前不支持引用上下文缓存。

  • labelsobject可选

    接受该参数但不生效:标签不会被存储,也不参与请求处理。

  • modelstring可选○ 当前不生效

    Required. The name of the `Model` to use for generating the completion. Format: `models/{model}`.

    接受但当前不生效。以 URL 路径里的模型名为准。

  • ▸ 更多参数(2)
    • serviceTierstring可选

      接受该参数但不生效:所有请求都按平台当前的服务档位处理。

      取值 flexprioritystandardunspecified
    • storeboolean可选

      Optional. Configures the logging behavior for a given request. If set, it takes precedence over the project-level logging config.

返回

200

toolConfig 的强制工具(functionCallingConfig mode ANY,含 allowedFunctionNames) 在思考模型上同样忠实转发给上游——与 Gemini 原生 API 一致,是否接受由上游模型 决定:如果上游返回 400,错误保持 Google 格式并携带上游的代码与状态。

错误按 Gemini API 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
candidatesarray<object>Candidate responses from the model.
candidates[].avgLogprobsnumberOutput only. Average log probability score of the candidate.
candidates[].citationMetadataobjectOutput only. Citation information for model-generated candidate. This field may be populated with recitation information for any text included in the `content`. These are passages that are "recited" from copyrighted material in the foundational LLM's training data.
candidates[].contentobjectOutput only. Generated content returned from the model.
candidates[].finishMessagestringOptional. Output only. Details the reason why the model stopped generating tokens. This is populated only when `finish_reason` is set.
candidates[].finishReasonstringOptional. Output only. The reason why the model stopped generating tokens. If empty, the model has not stopped generating tokens.
candidates[].groundingAttributionsarray<object>Output only. Attribution information for sources that contributed to a grounded answer. This field is populated for `GenerateAnswer` calls.
candidates[].groundingMetadataobjectOutput only. Grounding metadata for the candidate. This field is populated for `GenerateContent` calls.
candidates[].indexintegerOutput only. Index of the candidate in the list of response candidates.
candidates[].logprobsResultobjectOutput only. Log-likelihood scores for the response tokens and top tokens
candidates[].safetyRatingsarray<object>List of ratings for the safety of a response candidate. There is at most one rating per category.
candidates[].tokenCountintegerOutput only. Token count for this candidate.
candidates[].urlContextMetadataobjectOutput only. Metadata related to url context retrieval tool.
modelStatusobjectOutput only. The current model status of this model.
modelStatus.messagestringA message explaining the model status.
modelStatus.modelStagestringThe stage of the underlying model.
modelStatus.retirementTimestringThe time at which the model will be retired.
modelVersionstringOutput only. The model version used to generate the response.
promptFeedbackobjectReturns the prompt's feedback related to the content filters.
promptFeedback.blockReasonstringOptional. If set, the prompt was blocked and no candidates are returned. Rephrase the prompt.
promptFeedback.safetyRatingsarray<object>Ratings for safety of the prompt. There is at most one rating per category.
responseIdstringOutput only. response_id is used to identify each response.
usageMetadataobjectOutput only. Metadata on the generation requests' token usage.
usageMetadata.cacheTokensDetailsarray<object>Output only. List of modalities of the cached content in the request input.
usageMetadata.cachedContentTokenCountintegerNumber of tokens in the cached part of the prompt (the cached content)
usageMetadata.candidatesTokenCountintegerTotal number of tokens across all the generated response candidates.
usageMetadata.candidatesTokensDetailsarray<object>Output only. List of modalities that were returned in the response.
usageMetadata.promptTokenCountintegerNumber of tokens in the prompt. When `cached_content` is set, this is still the total effective prompt size meaning this includes the number of tokens in the cached content.
usageMetadata.promptTokensDetailsarray<object>Output only. List of modalities that were processed in the request input.
usageMetadata.serviceTierstringOutput only. Service tier of the request.
usageMetadata.thoughtsTokenCountintegerOutput only. Number of tokens of thoughts for thinking models.
usageMetadata.toolUsePromptTokenCountintegerOutput only. Number of tokens present in tool-use prompt(s).
usageMetadata.toolUsePromptTokensDetailsarray<object>Output only. List of modalities that were processed for tool-use request inputs.
usageMetadata.totalTokenCountintegerTotal token count for the generation request (prompt + thoughts + response candidates).

流式生成内容

POST /google/v1beta/models/{modelsId}:streamGenerateContent● 支持

Gemini API 官方文档 ↗

请求参数

  • modelstring必填

    path: Required. The name of the `Model` to use for generating the completion. Format: `models/{model}`.

  • contentsarray必填◐ 部分支持

    Required. The content of the current conversation with the model. For single-turn queries, this is a single instance. For multi-turn queries like [chat](https://ai.google.dev/gemini-api/docs/text-generation#chat), this is a repeated field that contains the conversation history and the latest request.

    多轮、文本、图片和工具往返生效,图片支持 URL-safe base64;audio/wav、text/plain 内联媒体及 fileData URL 返回 400。

    ▸ 展开子字段(2)
    • partsarray可选

      Ordered `Parts` that constitute a single message. Parts may have different MIME types.

      ▸ 展开子字段(16)
      • audioTranscriptionobject可选

        Optional. Audio (input or output) transcription. This is only set when this Part contains audio data.

      • codeExecutionResultobject可选

        Result of executing the `ExecutableCode`.

      • executableCodeobject可选

        Code generated by the model that is meant to be executed.

      • fileDataobject可选○ 未支持

        URI based data.

        已测 HTTPS、gs、Files API 和 YouTube URL 均返回 400。

      • functionCallobject可选

        A predicted `FunctionCall` returned from the model that contains a string representing the `FunctionDeclaration.name` with the arguments and their values.

      • functionResponseobject可选

        The result output of a `FunctionCall` that contains a string representing the `FunctionDeclaration.name` and a structured JSON object containing any output from the function is used as context to the model.

      • inlineDataobject可选◐ 部分支持

        Inline media bytes.

        image/png 生效(含 URL-safe base64);audio/wav、text/plain 返回 400;PDF 效果不可观测。

      • mediaProcessingstring可选

        Optional. How the model processes this part's media for understanding. Only meaningful for video parts (`inline_data` or `file_data` with video mime). Non-video parts ignore this field.

        取值 AGENTICMEDIA_PROCESSING_UNSPECIFIEDSTATIC
      • mediaResolutionobject可选

        Optional. Media resolution for the input media.

      • partMetadataobject可选

        Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams.

      • textstring可选

        Inline text.

      • thoughtboolean可选

        Optional. Indicates if the part is thought from the model.

      • thoughtSignaturestring可选

        Optional. An opaque signature for the thought so it can be reused in subsequent requests.

      • toolCallobject可选

        Server-side tool call. This field is populated when the model predicts a tool invocation that should be executed on the server. The client is expected to echo this message back to the API.

      • toolResponseobject可选

        The output from a server-side `ToolCall` execution. This field is populated by the client with the results of executing the corresponding `ToolCall`.

      • videoMetadataobject可选

        Optional. Video metadata. The metadata should only be specified while the video data is presented in inline_data or file_data.

    • rolestring可选

      Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset.

  • systemInstructionobject可选

    Optional. Developer set [system instruction(s)](https://ai.google.dev/gemini-api/docs/system-instructions). Currently, text only.

    已验证生效。

    ▸ 展开子字段(2)
    • partsarray可选

      Ordered `Parts` that constitute a single message. Parts may have different MIME types.

    • rolestring可选

      Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset.

  • generationConfigobject可选

    Optional. Configuration options for model generation and outputs.

    ▸ 展开子字段(25)
    • _responseJsonSchemaany可选○ 当前不生效

      Optional. Output schema of the generated response. This is an alternative to `response_schema` that accepts [JSON Schema](https://json-schema.org/). If set, `response_schema` must be omitted, but `response_mime_type` is required. While the full JSON Schema may be sent, not all features are supported. Specifically, only the following properties are supported: - `$id` - `$defs` - `$ref` - `$anchor` - `type` - `format` - `title` - `description` - `enum` (for strings and numbers) - `items` - `prefixItems` - `minItems` - `maxItems` - `minimum` - `maximum` - `anyOf` - `oneOf` (interpreted the same as `anyOf`) - `properties` - `additionalProperties` - `required` The non-standard `propertyOrdering` property may also be set. Cyclic references are unrolled to a limited degree and, as such, may only be used within non-required properties. (Nullable properties are not sufficient.) If `$ref` is set on a sub-schema, no other properties, except for than those starting as a `$`, may be set. Deprecated. Use `response_format` instead.

      接受但当前不生效。请使用 responseJsonSchema。

    • audioTranscriptionConfigobject可选○ 当前不生效

      Optional. Config for audio transcription (speech recognition).

      接受但当前不生效。已测文本模型不应用此选项。

    • candidateCountinteger可选◐ 部分支持

      Optional. Number of generated responses to return. If unset, this will default to 1. Please note that this doesn't work for previous generation models (Gemini 1.0 family)

      非流式支持多个候选;流式设置 2 返回 400。

    • enableAffectiveDialogboolean可选○ 当前不生效

      Optional. If enabled, the model will detect emotions and adapt its responses accordingly.

      接受但当前不生效。已测文本模型不应用此选项。

    • enableEnhancedCivicAnswersboolean可选○ 未支持

      Optional. Enables enhanced civic answers. It may not be available for all models.

      已测文本模型传入返回 400。

    • frequencyPenaltynumber可选◐ 部分支持

      Optional. Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the respponse so far. A positive penalty will discourage the use of tokens that have already been used, proportional to the number of times the token has been used: The more a token is used, the more difficult it is for the model to use that token again increasing the vocabulary of responses. Caution: A _negative_ penalty will encourage the model to reuse tokens proportional to the number of times the token has been used. Small negative values will reduce the vocabulary of a response. Larger negative values will cause the model to start repeating a common token until it hits the max_output_tokens limit.

      gemini-2.5-flash 偶发观察到效果;gemini-2.5-flash-lite 接受但当前不生效;2.0 可能返回 400。

    • imageConfigobject可选○ 未支持

      Optional. Config for image generation. An error will be returned if this field is set for models that don't support these config options.

      已测文本模型传入返回 400。

    • logprobsinteger可选

      Optional. Only valid if response_logprobs=True. This sets the number of top logprobs, including the chosen candidate, to return at each decoding step in the Candidate.logprobs_result. The number must be in the range of [0, 20].

      已验证生效。

    • maxOutputTokensinteger可选◐ 部分支持

      Optional. The maximum number of tokens to include in a response candidate. Note: The default value varies by model, see the `Model.output_token_limit` attribute of the `Model` returned from the `getModel` function.

      限制输出预算;思考占用预算,极小预算可能只返回思考或报错,gemini-3.5-flash 可能提前截断。

    • mediaResolutionstring可选

      Optional. If specified, the media resolution specified will be used.

      gemini-2.5-flash 的 LOW/MEDIUM/HIGH 改变图片 token 消耗。

      取值 MEDIA_RESOLUTION_HIGHMEDIA_RESOLUTION_LOWMEDIA_RESOLUTION_MEDIUMMEDIA_RESOLUTION_UNSPECIFIED
    • presencePenaltynumber可选○ 当前不生效

      Optional. Presence penalty applied to the next token's logprobs if the token has already been seen in the response. This penalty is binary on/off and not dependant on the number of times the token is used (after the first). Use frequency_penalty for a penalty that increases with each use. A positive penalty will discourage the use of tokens that have already been used in the response, increasing the vocabulary. A negative penalty will encourage the use of tokens that have already been used in the response, decreasing the vocabulary.

      接受但当前不生效。gemini-2.5-flash 和 gemini-2.5-flash-lite 输出未变化。

    • responseFormatobject可选○ 当前不生效

      Optional. Configuration for the response output format. Allows specifying output configuration per modality (text, audio, image) in a flat structure.

      接受但当前不生效。已测文本模型不应用此选项。

    • responseJsonSchemaany可选◐ 部分支持

      Optional. An internal detail. Use `responseJsonSchema` rather than this field.

      2.5 系列生效;3.5 预算不足可能截断。不可与 responseSchema 同传。

    • responseLogprobsboolean可选

      Optional. If true, export the logprobs results in response.

      已验证生效。

    • responseMimeTypestring可选◐ 部分支持

      Optional. MIME type of the generated candidate text. Supported MIME types are: `text/plain`: (default) Text output. `application/json`: JSON response in the response candidates. `text/x.enum`: ENUM as a string response in the response candidates. Refer to the [docs](https://ai.google.dev/gemini-api/docs/prompting_with_media#plain_text_formats) for a list of all supported text MIME types.

      application/json 在 2.5 系列生效,3.5 可能返回非 JSON;text/x.enum 在 flash-lite 生效。

    • responseModalitiesarray可选◐ 部分支持

      Optional. The requested modalities of the response. Represents the set of modalities that the model can return, and should be expected in the response. This is an exact match to the modalities of the response. A model may have multiple combinations of supported modalities. If the requested modalities do not match any of the supported combinations, an error will be returned. An empty list is equivalent to requesting only text.

      已测文本模型支持 TEXT;AUDIO 返回 400,IMAGE 返回错误。

    • responseSchemaobject可选◐ 部分支持

      Optional. Output schema of the generated candidate text. Schemas must be a subset of the [OpenAPI schema](https://spec.openapis.org/oas/v3.0.3#schema) and can be objects, primitives or arrays. If set, a compatible `response_mime_type` must also be set. Compatible MIME types: `application/json`: Schema for JSON response. Refer to the [JSON text generation guide](https://ai.google.dev/gemini-api/docs/json-mode) for more details. Deprecated. Use `response_format` instead.

      2.5 系列的 JSON 约束生效;3.5 预算不足可能截断;需正确指定 responseMimeType。

    • seedinteger可选◐ 部分支持

      Optional. Seed used in decoding. If not set, the request uses a randomly generated seed.

      gemini-2.5-flash-lite 可复现;gemini-2.5-flash 接受但当前不生效。

    • speechConfigobject可选○ 当前不生效

      Optional. The speech generation config.

      接受但当前不生效。已测文本模型不应用此选项。

    • stopSequencesarray可选

      Optional. The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a `stop_sequence`. The stop sequence will not be included as part of the response.

      gemini-2.5-flash、gemini-2.5-flash-lite 生效;最多 5 项。

    • temperaturenumber可选◐ 部分支持

      Optional. Controls the randomness of the output. Note: The default value varies by model, see the `Model.temperature` attribute of the `Model` returned from the `getModel` function. Values can range from [0.0, 2.0].

      gemini-2.5-flash-lite 观察到效果;gemini-2.5-flash 的采样差异不可观测。

    • thinkingConfigobject可选

      Optional. Config for thinking features. An error will be returned if this field is set for models that don't support thinking.

      ▸ 展开子字段(3)
      • includeThoughtsboolean可选◐ 部分支持

        Indicates whether to include thoughts in the response. If true, thoughts are returned only when available.

        思考开启时 true/false 控制是否返回思考;flash-lite 默认未开启思考时单传此字段返回 400。

      • thinkingBudgetinteger可选

        The number of thoughts tokens that the model should generate.

        0 关闭思考;正数控制思考预算,-1 为自动。越界值返回 400。

      • thinkingLevelstring可选◐ 部分支持

        Optional. Controls the maximum depth of the model's internal reasoning process before it produces a response. The default value is model-dependent. Refer to the [Thinking levels guide](https://ai.google.dev/gemini-api/docs/thinking#thinking-levels) for more details. Recommended for Gemini 3 or later models. Use with earlier models results in an error.

        gemini-3.5-flash 支持 MINIMAL/LOW/MEDIUM/HIGH;用于 2.5 系列返回 400。

        取值 HIGHLOWMEDIUMMINIMALTHINKING_LEVEL_UNSPECIFIED
    • topKinteger可选○ 当前不生效

      接受该参数但不生效:采样不使用 topK。

      接受但当前不生效。gemini-2.5-flash-lite 在 topK=1 时仍返回不同输出;gemini-2.5-flash 不可观测。

    • topPnumber可选

      Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and Top-p (nucleus) sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits the number of tokens based on the cumulative probability. Note: The default value varies by `Model` and is specified by the`Model.top_p` attribute returned from the `getModel` function. An empty `top_k` attribute indicates that the model doesn't apply top-k sampling and doesn't allow setting `top_k` on requests.

      gemini-2.5-flash 和 gemini-2.5-flash-lite 已验证生效。

    • translationConfigobject可选○ 当前不生效

      Optional. Config for translation.

      接受但当前不生效。已测文本模型不应用此选项。

  • toolsarray可选

    Optional. A list of `Tools` the `Model` may use to generate the next response. A `Tool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the `Model`. Supported `Tool`s are `Function` and `code_execution`. Refer to the [Function calling](https://ai.google.dev/gemini-api/docs/function-calling) and the [Code execution](https://ai.google.dev/gemini-api/docs/code-execution) guides to learn more.

    ▸ 展开子字段(9)
    • codeExecutionobject可选○ 未支持

      Optional. Enables the model to execute code as part of generation.

      已测请求返回 502,当前不可用。

    • computerUseobject可选○ 未支持

      Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.

      已测 gemini-2.5-flash 返回 400。

    • fileSearchobject可选○ 未支持

      Optional. FileSearch tool type. Tool to retrieve knowledge from Semantic Retrieval corpora.

      已测 gemini-2.5-flash 返回 400。

    • functionDeclarationsarray可选

      Optional. A list of `FunctionDeclarations` available to the model that can be used for function calling. The model or system does not execute the function. Instead the defined function may be returned as a FunctionCall with arguments to the client side for execution. The model may decide to call a subset of these functions by populating FunctionCall in the response. The next conversation turn may contain a FunctionResponse with the Content.role "function" generation context for the next model turn.

      ▸ 展开子字段(7)
      • behaviorstring可选○ 当前不生效

        Optional. Specifies the function Behavior. Currently only supported by the BidiGenerateContent method.

        接受但当前不生效。

        取值 BLOCKINGNON_BLOCKINGUNSPECIFIED
      • descriptionstring可选

        Required. A brief description of the function.

      • namestring可选

        Required. The name of the function. Must be a-z, A-Z, 0-9, or contain underscores, colons, dots, and dashes, with a maximum length of 128.

      • parametersobject可选

        Optional. Describes the parameters to this function. Reflects the Open API 3.03 Parameter Object string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter.

        已验证生效。

      • parametersJsonSchemaany可选

        Optional. Describes the parameters to the function in JSON Schema format. The schema must describe an object where the properties are the parameters to the function. For example: ``` { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "additionalProperties": false, "required": ["name", "age"], "propertyOrdering": ["name", "age"] } ``` This field is mutually exclusive with `parameters`.

        已验证生效。

      • responseobject可选○ 当前不生效

        Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function.

        接受但当前不生效。

      • responseJsonSchemaany可选

        Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function. This field is mutually exclusive with `response`.

    • googleMapsobject可选

      Optional. Tool that allows grounding the model's response with geospatial context related to the user's query.

    • googleSearchobject可选

      Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.

      gemini-2.5-flash 返回 groundingMetadata。

    • googleSearchRetrievalobject可选○ 未支持

      Optional. Retrieval tool that is powered by Google search.

      已测 gemini-2.5-flash 返回 400。

    • mcpServersarray可选○ 未支持

      Optional. MCP Servers to connect to.

      已测 gemini-2.5-flash 返回 400。

    • urlContextobject可选

      Optional. Tool to support URL context retrieval.

  • toolConfigobject可选

    Optional. Tool configuration for any `Tool` specified in the request. Refer to the [Function calling guide](https://ai.google.dev/gemini-api/docs/function-calling#function_calling_mode) for a usage example.

    ▸ 展开子字段(3)
    • functionCallingConfigobject可选

      Optional. Function calling config.

      ▸ 展开子字段(2)
      • allowedFunctionNamesarray可选

        Optional. A set of function names that, when provided, limits the functions the model will call. This should only be set when the Mode is ANY or VALIDATED. Function names should match [FunctionDeclaration.name]. When set, model will predict a function call from only allowed function names.

        已验证生效。

      • modestring可选◐ 部分支持

        Optional. Specifies the mode in which function calling should execute. If unspecified, the default value will be set to AUTO.

        ANY/AUTO/VALIDATED 生效;NONE 在 flash-lite 偶发仍调用工具,复测生效。

        取值 ANYAUTOMODE_UNSPECIFIEDNONEVALIDATED
    • includeServerSideToolInvocationsboolean可选

      Optional. If true, the API response will include the server-side tool calls and responses within the `Content` message. This allows clients to observe the server's tool interactions.

    • retrievalConfigobject可选

      Optional. Retrieval config.

  • safetySettingsarray可选

    接受该参数但不生效:安全设置不会拦截或改变任何回复。

    ▸ 展开子字段(2)
    • categorystring可选

      Required. The category for this setting.

      取值 HARM_CATEGORY_CIVIC_INTEGRITYHARM_CATEGORY_DANGEROUSHARM_CATEGORY_DANGEROUS_CONTENTHARM_CATEGORY_DEROGATORYHARM_CATEGORY_HARASSMENTHARM_CATEGORY_HATE_SPEECHHARM_CATEGORY_JAILBREAKHARM_CATEGORY_MEDICALHARM_CATEGORY_SEXUALHARM_CATEGORY_SEXUALLY_EXPLICITHARM_CATEGORY_TOXICITYHARM_CATEGORY_UNSPECIFIEDHARM_CATEGORY_VIOLENCE
    • thresholdstring可选

      Required. Controls the probability threshold at which harm is blocked.

      取值 BLOCK_LOW_AND_ABOVEBLOCK_MEDIUM_AND_ABOVEBLOCK_NONEBLOCK_ONLY_HIGHHARM_BLOCK_THRESHOLD_UNSPECIFIEDOFF
  • cachedContentstring可选○ 未支持

    平台不支持上下文缓存:传入会返回 400(Google 错误格式)。

    传入返回 400;当前不支持引用上下文缓存。

  • labelsobject可选

    接受该参数但不生效:标签不会被存储,也不参与请求处理。

  • modelstring可选○ 当前不生效

    Required. The name of the `Model` to use for generating the completion. Format: `models/{model}`.

    接受但当前不生效。以 URL 路径里的模型名为准。

  • ▸ 更多参数(2)
    • serviceTierstring可选

      接受该参数但不生效:所有请求都按平台当前的服务档位处理。

      取值 flexprioritystandardunspecified
    • storeboolean可选

      Optional. Configures the logging behavior for a given request. If set, it takes precedence over the project-level logging config.

返回

200

错误按 Gemini API 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
candidatesarray<object>Candidate responses from the model.
candidates[].avgLogprobsnumberOutput only. Average log probability score of the candidate.
candidates[].citationMetadataobjectOutput only. Citation information for model-generated candidate. This field may be populated with recitation information for any text included in the `content`. These are passages that are "recited" from copyrighted material in the foundational LLM's training data.
candidates[].contentobjectOutput only. Generated content returned from the model.
candidates[].finishMessagestringOptional. Output only. Details the reason why the model stopped generating tokens. This is populated only when `finish_reason` is set.
candidates[].finishReasonstringOptional. Output only. The reason why the model stopped generating tokens. If empty, the model has not stopped generating tokens.
candidates[].groundingAttributionsarray<object>Output only. Attribution information for sources that contributed to a grounded answer. This field is populated for `GenerateAnswer` calls.
candidates[].groundingMetadataobjectOutput only. Grounding metadata for the candidate. This field is populated for `GenerateContent` calls.
candidates[].indexintegerOutput only. Index of the candidate in the list of response candidates.
candidates[].logprobsResultobjectOutput only. Log-likelihood scores for the response tokens and top tokens
candidates[].safetyRatingsarray<object>List of ratings for the safety of a response candidate. There is at most one rating per category.
candidates[].tokenCountintegerOutput only. Token count for this candidate.
candidates[].urlContextMetadataobjectOutput only. Metadata related to url context retrieval tool.
modelStatusobjectOutput only. The current model status of this model.
modelStatus.messagestringA message explaining the model status.
modelStatus.modelStagestringThe stage of the underlying model.
modelStatus.retirementTimestringThe time at which the model will be retired.
modelVersionstringOutput only. The model version used to generate the response.
promptFeedbackobjectReturns the prompt's feedback related to the content filters.
promptFeedback.blockReasonstringOptional. If set, the prompt was blocked and no candidates are returned. Rephrase the prompt.
promptFeedback.safetyRatingsarray<object>Ratings for safety of the prompt. There is at most one rating per category.
responseIdstringOutput only. response_id is used to identify each response.
usageMetadataobjectOutput only. Metadata on the generation requests' token usage.
usageMetadata.cacheTokensDetailsarray<object>Output only. List of modalities of the cached content in the request input.
usageMetadata.cachedContentTokenCountintegerNumber of tokens in the cached part of the prompt (the cached content)
usageMetadata.candidatesTokenCountintegerTotal number of tokens across all the generated response candidates.
usageMetadata.candidatesTokensDetailsarray<object>Output only. List of modalities that were returned in the response.
usageMetadata.promptTokenCountintegerNumber of tokens in the prompt. When `cached_content` is set, this is still the total effective prompt size meaning this includes the number of tokens in the cached content.
usageMetadata.promptTokensDetailsarray<object>Output only. List of modalities that were processed in the request input.
usageMetadata.serviceTierstringOutput only. Service tier of the request.
usageMetadata.thoughtsTokenCountintegerOutput only. Number of tokens of thoughts for thinking models.
usageMetadata.toolUsePromptTokenCountintegerOutput only. Number of tokens present in tool-use prompt(s).
usageMetadata.toolUsePromptTokensDetailsarray<object>Output only. List of modalities that were processed for tool-use request inputs.
usageMetadata.totalTokenCountintegerTotal token count for the generation request (prompt + thoughts + response candidates).

POST /google/v1beta/models/{modelsId}:countTokens◐ 部分支持

Gemini API 官方文档 ↗

请求参数

  • modelstring必填

    path: Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`

  • contentsarray可选◐ 部分支持

    Optional. The input given to the model as a prompt. This field is ignored when `generate_content_request` is set.

    原生透传;本地估算。与 generateContentRequest 同传返回 400。

    ▸ 展开子字段(2)
    • partsarray可选

      Ordered `Parts` that constitute a single message. Parts may have different MIME types.

      ▸ 展开子字段(16)
      • audioTranscriptionobject可选

        Optional. Audio (input or output) transcription. This is only set when this Part contains audio data.

      • codeExecutionResultobject可选

        Result of executing the `ExecutableCode`.

      • executableCodeobject可选

        Code generated by the model that is meant to be executed.

      • fileDataobject可选

        URI based data.

      • functionCallobject可选

        A predicted `FunctionCall` returned from the model that contains a string representing the `FunctionDeclaration.name` with the arguments and their values.

      • functionResponseobject可选

        The result output of a `FunctionCall` that contains a string representing the `FunctionDeclaration.name` and a structured JSON object containing any output from the function is used as context to the model.

      • inlineDataobject可选◐ 部分支持

        Inline media bytes.

        原生透传;本地读取 PNG/JPEG/GIF 头估算图片 token,不把 base64 当文本;其他媒体使用近似额度。

      • mediaProcessingstring可选

        Optional. How the model processes this part's media for understanding. Only meaningful for video parts (`inline_data` or `file_data` with video mime). Non-video parts ignore this field.

        取值 AGENTICMEDIA_PROCESSING_UNSPECIFIEDSTATIC
      • mediaResolutionobject可选

        Optional. Media resolution for the input media.

      • partMetadataobject可选

        Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams.

      • textstring可选

        Inline text.

      • thoughtboolean可选

        Optional. Indicates if the part is thought from the model.

      • thoughtSignaturestring可选

        Optional. An opaque signature for the thought so it can be reused in subsequent requests.

      • toolCallobject可选

        Server-side tool call. This field is populated when the model predicts a tool invocation that should be executed on the server. The client is expected to echo this message back to the API.

      • toolResponseobject可选

        The output from a server-side `ToolCall` execution. This field is populated by the client with the results of executing the corresponding `ToolCall`.

      • videoMetadataobject可选

        Optional. Video metadata. The metadata should only be specified while the video data is presented in inline_data or file_data.

    • rolestring可选

      Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset.

  • generateContentRequestobject可选◐ 部分支持

    Optional. The overall input given to the `Model`. This includes the prompt as well as other model steering information like [system instructions](https://ai.google.dev/gemini-api/docs/system-instructions), and/or function declarations for [function calling](https://ai.google.dev/gemini-api/docs/function-calling). `Model`s/`Content`s and `generate_content_request`s are mutually exclusive. You can either send `Model` + `Content`s or a `generate_content_request`, but never both.

    原生路径保留 systemInstruction 和 tools 并映射模型;本地计入估算。

    ▸ 展开子字段(11)
    • cachedContentstring可选○ 未支持

      Optional. The name of the content [cached](https://ai.google.dev/gemini-api/docs/caching) to use as context to serve the prediction. Format: `cachedContents/{cachedContent}`

    • contentsarray可选

      Required. The content of the current conversation with the model. For single-turn queries, this is a single instance. For multi-turn queries like [chat](https://ai.google.dev/gemini-api/docs/text-generation#chat), this is a repeated field that contains the conversation history and the latest request.

    • generationConfigobject可选

      Optional. Configuration options for model generation and outputs.

    • labelsobject可选

      Optional. Labels with user-defined metadata for the request. Optional. Labels must follow standard unified Cloud label requirements: - Label keys must start with a letter. - Label keys and values can be no longer than 63 characters (Unicode codepoints) and can only contain lowercase letters, numeric characters, underscores, and dashes. - International characters are allowed. Usage: - Safety identifiers from aggregators: Use the key `safety_identifier` (e.g. `{"safety_identifier": "user_session_123"}`)

    • modelstring可选

      Required. The name of the `Model` to use for generating the completion. Format: `models/{model}`.

    • safetySettingsarray可选

      Optional. A list of unique `SafetySetting` instances for blocking unsafe content. This will be enforced on the `GenerateContentRequest.contents` and `GenerateContentResponse.candidates`. There should not be more than one setting for each `SafetyCategory` type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT, HARM_CATEGORY_CIVIC_INTEGRITY, HARM_CATEGORY_JAILBREAK are supported. Refer to the [guide](https://ai.google.dev/gemini-api/docs/safety-settings) for detailed information on available safety settings. Also refer to the [Safety guidance](https://ai.google.dev/gemini-api/docs/safety-guidance) to learn how to incorporate safety considerations in your AI applications.

    • serviceTierstring可选

      Optional. The service tier of the request.

      取值 flexprioritystandardunspecified
    • storeboolean可选

      Optional. Configures the logging behavior for a given request. If set, it takes precedence over the project-level logging config.

    • systemInstructionobject可选

      Optional. Developer set [system instruction(s)](https://ai.google.dev/gemini-api/docs/system-instructions). Currently, text only.

    • toolConfigobject可选

      Optional. Tool configuration for any `Tool` specified in the request. Refer to the [Function calling guide](https://ai.google.dev/gemini-api/docs/function-calling#function_calling_mode) for a usage example.

    • toolsarray可选

      Optional. A list of `Tools` the `Model` may use to generate the next response. A `Tool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the `Model`. Supported `Tool`s are `Function` and `code_execution`. Refer to the [Function calling](https://ai.google.dev/gemini-api/docs/function-calling) and the [Code execution](https://ai.google.dev/gemini-api/docs/code-execution) guides to learn more.

返回

200

按模型族校准的估算值(包括中文和工具定义),响应头为 x-praxis-token-count: estimated;不能用作精确用量或计费依据。

错误按 Gemini API 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
cacheTokensDetailsarray<object>Output only. List of modalities that were processed in the cached content.
cacheTokensDetails[].modalitystringThe modality associated with this token count.
cacheTokensDetails[].tokenCountintegerNumber of tokens.
cachedContentTokenCountintegerNumber of tokens in the cached part of the prompt (the cached content).
promptTokensDetailsarray<object>Output only. List of modalities that were processed in the request input.
promptTokensDetails[].modalitystringThe modality associated with this token count.
promptTokensDetails[].tokenCountintegerNumber of tokens.
totalTokensintegerThe number of tokens that the `Model` tokenizes the `prompt` into. Always non-negative.

生成向量嵌入

POST /google/v1beta/models/{modelsId}:embedContent● 支持

Gemini API 官方文档 ↗

请求参数

  • modelstring必填

    path: Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`

  • contentobject必填◐ 部分支持

    Required. The content to embed. Only the `parts.text` fields will be counted.

    仅文本部件生效;图片(含多模态嵌入模型)返回 400。

    ▸ 展开子字段(2)
    • partsarray可选

      Ordered `Parts` that constitute a single message. Parts may have different MIME types.

    • rolestring可选

      Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset.

  • embedContentConfigobject可选◐ 部分支持

    Optional. Configuration for the EmbedContent request.

    仅 outputDimensionality 可用(受模型限制);autoTruncate、documentOcr、audioTrackExtraction 等其余配置返回 400。

    ▸ 展开子字段(6)
    • audioTrackExtractionboolean可选○ 未支持

      Optional. Whether to extract audio from video content.

      传入返回 400;此嵌入配置当前不支持。

    • autoTruncateboolean可选○ 未支持

      Optional. Whether to silently truncate the input content if it's longer than the maximum sequence length.

      传入返回 400;此嵌入配置当前不支持。

    • documentOcrboolean可选○ 未支持

      Optional. Whether to enable OCR for document content.

      传入返回 400;此嵌入配置当前不支持。

    • outputDimensionalityinteger可选◐ 部分支持

      Optional. Reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end.

      text-embedding-3-small、qwen3-vl-embedding 支持已测维度;doubao-embedding-vision 需至少 1024;bge-m3、qwen3-embedding-0.6b 报错。

    • taskTypestring可选○ 未支持

      Optional. The task type of the embedding.

      传入返回 400;此嵌入配置当前不支持。

      取值 CLASSIFICATIONCLUSTERINGCODE_RETRIEVAL_QUERYFACT_VERIFICATIONQUESTION_ANSWERINGRETRIEVAL_DOCUMENTRETRIEVAL_QUERYSEMANTIC_SIMILARITYTASK_TYPE_UNSPECIFIED
    • titlestring可选○ 未支持

      Optional. The title for the text.

      传入返回 400;此嵌入配置当前不支持。

  • modelstring可选

    Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`

    必须与 URL 路径中的模型一致,否则返回 400。

  • outputDimensionalityinteger可选◐ 部分支持

    Optional. Deprecated: Please use EmbedContentConfig.output_dimensionality instead. Optional reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end. Supported by newer models since 2024 only. You cannot set this value if using the earlier model (`models/embedding-001`).

    text-embedding-3-small、qwen3-vl-embedding 支持已测维度;doubao-embedding-vision 需至少 1024;bge-m3、qwen3-embedding-0.6b 报错。

  • taskTypestring可选○ 未支持

    Optional. Deprecated: Please use EmbedContentConfig.task_type instead. Optional task type for which the embeddings will be used. Not supported on earlier models (`models/embedding-001`).

    传入返回 400。

    取值 CLASSIFICATIONCLUSTERINGCODE_RETRIEVAL_QUERYFACT_VERIFICATIONQUESTION_ANSWERINGRETRIEVAL_DOCUMENTRETRIEVAL_QUERYSEMANTIC_SIMILARITYTASK_TYPE_UNSPECIFIED
  • titlestring可选○ 未支持

    Optional. Deprecated: Please use EmbedContentConfig.title instead. An optional title for the text. Only applicable when TaskType is `RETRIEVAL_DOCUMENT`. Note: Specifying a `title` for `RETRIEVAL_DOCUMENT` provides better quality embeddings for retrieval.

    传入返回 400。

返回

200

只接受文本部件;图像等多模态部件会被拒绝。taskType、title 以及 autoTruncate / documentOcr / audioTrackExtraction 等检索配置在平台上没有等价语义, 请求携带时会收到 400(INVALID_ARGUMENT),不会静默忽略——因为不同 taskType 生成的向量行为不同,静默丢弃会悄悄改变检索质量。outputDimensionality 映射为 返回向量的维度。

错误按 Gemini API 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
embeddingobjectOutput only. The embedding generated from the input content.
embedding.shapearray<integer>This field stores the soft tokens tensor frame shape (e.g. [1, 1, 256, 2048]).
embedding.valuesarray<number>The embedding values. This is for 3P users only and will not be populated for 1P calls.
usageMetadataobjectOutput only. The usage metadata for the request.
usageMetadata.promptTokenCountintegerOutput only. Number of tokens in the prompt.
usageMetadata.promptTokenDetailsarray<object>Output only. List of modalities that were processed in the request input.

批量生成向量嵌入

POST /google/v1beta/models/{modelsId}:batchEmbedContents● 支持

Gemini API 官方文档 ↗

请求参数

  • modelstring必填

    path: Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`

  • requestsarray必填

    Required. Embed requests for the batch. The model in each of these requests must match the model specified `BatchEmbedContentsRequest.model`.

    支持 1–100 项,返回顺序与输入一致;维度必须一致。

    ▸ 展开子字段(6)
    • contentobject可选◐ 部分支持

      Required. The content to embed. Only the `parts.text` fields will be counted.

      仅文本部件生效;图片(含多模态嵌入模型)返回 400。

    • embedContentConfigobject可选◐ 部分支持

      Optional. Configuration for the EmbedContent request.

      仅 outputDimensionality 可用(受模型限制);autoTruncate、documentOcr、audioTrackExtraction 等其余配置返回 400。

      ▸ 展开子字段(6)
      • audioTrackExtractionboolean可选○ 未支持

        Optional. Whether to extract audio from video content.

        传入返回 400;此嵌入配置当前不支持。

      • autoTruncateboolean可选○ 未支持

        Optional. Whether to silently truncate the input content if it's longer than the maximum sequence length.

        传入返回 400;此嵌入配置当前不支持。

      • documentOcrboolean可选○ 未支持

        Optional. Whether to enable OCR for document content.

        传入返回 400;此嵌入配置当前不支持。

      • outputDimensionalityinteger可选◐ 部分支持

        Optional. Reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end.

        text-embedding-3-small、qwen3-vl-embedding 支持已测维度;doubao-embedding-vision 需至少 1024;bge-m3、qwen3-embedding-0.6b 报错。

      • taskTypestring可选○ 未支持

        Optional. The task type of the embedding.

        传入返回 400;此嵌入配置当前不支持。

        取值 CLASSIFICATIONCLUSTERINGCODE_RETRIEVAL_QUERYFACT_VERIFICATIONQUESTION_ANSWERINGRETRIEVAL_DOCUMENTRETRIEVAL_QUERYSEMANTIC_SIMILARITYTASK_TYPE_UNSPECIFIED
      • titlestring可选○ 未支持

        Optional. The title for the text.

        传入返回 400;此嵌入配置当前不支持。

    • modelstring可选

      Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`

      必须与 URL 路径中的模型一致,否则返回 400。

    • outputDimensionalityinteger可选◐ 部分支持

      Optional. Deprecated: Please use EmbedContentConfig.output_dimensionality instead. Optional reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end. Supported by newer models since 2024 only. You cannot set this value if using the earlier model (`models/embedding-001`).

      text-embedding-3-small、qwen3-vl-embedding 支持已测维度;doubao-embedding-vision 需至少 1024;bge-m3、qwen3-embedding-0.6b 报错。

    • taskTypestring可选○ 未支持

      Optional. Deprecated: Please use EmbedContentConfig.task_type instead. Optional task type for which the embeddings will be used. Not supported on earlier models (`models/embedding-001`).

      传入返回 400。

      取值 CLASSIFICATIONCLUSTERINGCODE_RETRIEVAL_QUERYFACT_VERIFICATIONQUESTION_ANSWERINGRETRIEVAL_DOCUMENTRETRIEVAL_QUERYSEMANTIC_SIMILARITYTASK_TYPE_UNSPECIFIED
    • titlestring可选○ 未支持

      Optional. Deprecated: Please use EmbedContentConfig.title instead. An optional title for the text. Only applicable when TaskType is `RETRIEVAL_DOCUMENT`. Note: Specifying a `title` for `RETRIEVAL_DOCUMENT` provides better quality embeddings for retrieval.

      传入返回 400。

返回

200

requests 中每一项的约束与 embedContent 相同(文本部件、同上拒绝规则);批量内 所有条目的 outputDimensionality 必须一致。当前官方 JS 与 Python SDK 的 embedContent 调用实际走的就是这个批量端点。

错误按 Gemini API 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
embeddingsarray<object>Output only. The embeddings for each request, in the same order as provided in the batch request.
embeddings[].shapearray<integer>This field stores the soft tokens tensor frame shape (e.g. [1, 1, 256, 2048]).
embeddings[].valuesarray<number>The embedding values. This is for 3P users only and will not be populated for 1P calls.
usageMetadataobjectOutput only. The usage metadata for the request.
usageMetadata.promptTokenCountintegerOutput only. Number of tokens in the prompt.
usageMetadata.promptTokenDetailsarray<object>Output only. List of modalities that were processed in the request input.

列出模型

GET /google/v1beta/models● 支持

Gemini API 官方文档 ↗

请求参数

  • pageSizeinteger可选

    query: The maximum number of `Models` to return (per page). If unspecified, 50 models will be returned per page. This method returns at most 1000 models per page, even if you pass a larger page_size.

    支持分页;0、负数和非数字返回 400,超过上限会截断。

  • pageTokenstring可选

    query: A page token, received from a previous `ListModels` call. Provide the `page_token` returned by one request as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListModels` must match the call that provided the page token.

    已验证生效。

返回

200

向量嵌入模型会以 embedContent 作为其唯一受支持的方法列出。当模型目录 暂时不可用时,generateContent 的行为保持不变:显式要求图像输出 (responseModalities 含 IMAGE)的请求仍走图像通道;未显式声明的旧式图像请求 在该窗口内会按文本对话处理——降级期间每个响应都带 X-Praxis-Route-Degraded: model-catalog-unavailable 头以示区别。

错误按 Gemini API 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
modelsarray<object>The returned Models.
models[].baseModelIdstringRequired. The name of the base model, pass this to the generation request. Examples: * `gemini-1.5-flash`
models[].descriptionstringA short description of the model.
models[].displayNamestringThe human-readable name of the model. E.g. "Gemini 1.5 Flash". The name can be up to 128 characters long and can consist of any UTF-8 characters.
models[].inputTokenLimitintegerMaximum number of input tokens allowed for this model.
models[].maxTemperaturenumberThe maximum temperature this model can use.
models[].namestringRequired. The resource name of the `Model`. Refer to Model variants for all allowed values. Format: `models/{model}` with a `{model}` naming convention of: * "{base_model_id}-{version}" Examples: * `models/gemini-1.5-flash-001`
models[].outputTokenLimitintegerMaximum number of output tokens available for this model.
models[].supportedGenerationMethodsarray<string>The model's supported generation methods. The corresponding API method names are defined as Pascal case strings, such as `generateMessage` and `generateContent`.
models[].temperaturenumberControls the randomness of the output. Values can range over `[0.0,max_temperature]`, inclusive. A higher value will produce responses that are more varied, while a value closer to `0.0` will typically result in less surprising responses from the model. This value specifies default to be used by the backend while making the call to the model.
models[].thinkingbooleanWhether the model supports thinking.
models[].topKintegerFor Top-k sampling. Top-k sampling considers the set of `top_k` most probable tokens. This value specifies default to be used by the backend while making the call to the model. If empty, indicates the model doesn't use top-k sampling, and `top_k` isn't allowed as a generation parameter.
models[].topPnumberFor Nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`. This value specifies default to be used by the backend while making the call to the model.
models[].versionstringRequired. The version number of the model. This represents the major version (`1.0` or `1.5`)
nextPageTokenstringA token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages.

读取模型

GET /google/v1beta/models/{modelsId}● 支持

Gemini API 官方文档 ↗

请求参数

  • namestring必填

    path: Required. The resource name of the model. This name should match a model name returned by the `ListModels` method. Format: `models/{model}`

返回

200

错误按 Gemini API 格式返回,参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
baseModelIdstringRequired. The name of the base model, pass this to the generation request. Examples: * `gemini-1.5-flash`
descriptionstringA short description of the model.
displayNamestringThe human-readable name of the model. E.g. "Gemini 1.5 Flash". The name can be up to 128 characters long and can consist of any UTF-8 characters.
inputTokenLimitintegerMaximum number of input tokens allowed for this model.
maxTemperaturenumberThe maximum temperature this model can use.
namestringRequired. The resource name of the `Model`. Refer to Model variants for all allowed values. Format: `models/{model}` with a `{model}` naming convention of: * "{base_model_id}-{version}" Examples: * `models/gemini-1.5-flash-001`
outputTokenLimitintegerMaximum number of output tokens available for this model.
supportedGenerationMethodsarray<string>The model's supported generation methods. The corresponding API method names are defined as Pascal case strings, such as `generateMessage` and `generateContent`.
temperaturenumberControls the randomness of the output. Values can range over `[0.0,max_temperature]`, inclusive. A higher value will produce responses that are more varied, while a value closer to `0.0` will typically result in less surprising responses from the model. This value specifies default to be used by the backend while making the call to the model.
thinkingbooleanWhether the model supports thinking.
topKintegerFor Top-k sampling. Top-k sampling considers the set of `top_k` most probable tokens. This value specifies default to be used by the backend while making the call to the model. If empty, indicates the model doesn't use top-k sampling, and `top_k` isn't allowed as a generation parameter.
topPnumberFor Nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`. This value specifies default to be used by the backend while making the call to the model.
versionstringRequired. The version number of the model. This represents the major version (`1.0` or `1.5`)

E2B 兼容接口

基础地址

加载中…

接入

加载中…

控制面与数据面

  • 控制面:创建、列出、暂停、连接、终止沙箱等本页列出的端点,地址是上面的基础地址,用你的 API Key 认证(X-API-Key 头,官方 SDK 自动带上)。
  • 数据面:在沙箱里运行命令、读写文件,由 SDK 直连 <端口>-<沙箱 ID>.praxisusercontent.com,用创建沙箱时返回的访问凭证认证。所以 SDK 除了 api_url 还要把 domain 设为 praxisusercontent.com。

也可以不改代码,只设环境变量:

加载中…

端点

方法路径说明支持
POST/sandboxes创建沙箱● 支持
GET/sandboxes列出沙箱● 支持
GET/sandboxes/{sandboxID}读取沙箱● 支持
GET/sandboxes/{sandboxID}/metrics沙箱指标● 支持
POST/sandboxes/{sandboxID}/timeout设置超时● 支持
POST/sandboxes/{sandboxID}/pause暂停沙箱● 支持
POST/sandboxes/{sandboxID}/connect连接沙箱● 支持
DELETE/sandboxes/{sandboxID}终止沙箱● 支持
POST/v2/sandboxes创建沙箱(v2)● 支持
GET/v2/sandboxes列出沙箱(v2)● 支持
POST/v2/sandboxes/{sandboxID}/connect连接沙箱(v2)● 支持
GET/templates列出模板● 支持
GET/v2/templates列出模板(v2)● 支持
POST/volumes创建卷● 支持
GET/volumes列出卷● 支持
GET/volumes/{volumeID}读取卷● 支持
DELETE/volumes/{volumeID}删除卷● 支持
POST/sandboxes/{sandboxID}/fork复制沙箱● 支持
POST/sandboxes/{sandboxID}/snapshots创建快照● 支持
GET/snapshots列出快照● 支持
DELETE/templates/{templateID}删除快照● 支持
PUT/sandboxes/{sandboxID}/network更新网络策略● 支持
GET/v2/sandboxes/{sandboxID}/logs读取沙箱日志● 支持

与官方的差异

  • 创建沙箱:已弃用:最新官方 SDK 走 v2。平台暂未提供 E2B 默认的 base 模板:不带模板参数的 Sandbox.create() 会返回 404,请显式指定模板(可用模板见「列出模板」)。
  • 列出沙箱:已弃用:最新官方 SDK 走 v2。
  • 连接沙箱:已弃用:最新官方 SDK 走 v2。
  • 列出模板:已弃用:最新官方 SDK 走 v2。

参数与字段的权威定义以 E2B 官方文档为准。

错误按 E2B 格式返回,参见错误;额度与响应头参见限流。

创建沙箱

POST /e2b/sandboxes● 支持

E2B 官方文档 ↗

请求体

  • templateIDstring必填

    Identifier of the required template

  • timeoutinteger可选
    默认 15

    Time to live for the sandbox in seconds.

  • autoPauseboolean可选
    默认 false

    Automatically pauses the sandbox after the timeout

  • metadataany可选
  • envVarsany可选
  • secureboolean可选

    Secure all system communication with sandbox

  • allow_internet_accessboolean可选

    Allow sandbox to access the internet. When set to false, it behaves the same as specifying denyOut to 0.0.0.0/0 in the network config.

  • autoPauseMemoryboolean可选
    默认 true

    Controls the snapshot kind taken when the sandbox auto-pauses on timeout (only relevant when autoPause is true). When false, the auto-pause drops the in-memory state and persists only the filesystem (a filesystem-only snapshot); resuming it cold-boots (reboots) the sandbox from disk. Such a snapshot cannot be auto-resumed by traffic and must be resumed explicitly, so it cannot be combined with autoResume. Defaults to true (full memory snapshot).

  • autoResumeobject可选

    Auto-resume configuration for paused sandboxes.

    ▸ 展开子字段(1)
    • enabledboolean必填
      默认 false

      Auto-resume enabled flag for paused sandboxes. Default false.

  • networkobject可选
    ▸ 展开子字段(7)
    • allowPublicTrafficboolean可选
      默认 true

      Specify if the sandbox URLs should be accessible only with authentication.

    • allowOutarray可选

      List of allowed destinations for egress traffic. Each entry can be a CIDR block (e.g. "8.8.8.8/32"), a bare IP address (e.g. "8.8.8.8"), or a domain name (e.g. "example.com", "*.example.com"). Allowed entries always take precedence over denied entries.

    • denyOutarray可选

      List of denied CIDR blocks or IP addresses for egress traffic. Domain names are not supported for deny rules.

    • egressProxyobject可选

      SOCKS5 proxy for sandbox egress. Outbound TCP is tunneled through the proxy after allow/deny filtering; the sandbox is unaware. Domain-matched flows use remote DNS (ATYP=domain).

    • maskRequestHoststring可选

      Specify host mask which will be used for all sandbox requests

    • httpsPortsarray可选

      Sandbox ports that serve HTTPS rather than plaintext HTTP. Affects how the proxy reaches the service inside the sandbox; the public URL is HTTPS either way. Certificates are not verified, so self-signed ones work. The envd port (49983) cannot be listed.

    • rulesobject可选

      Per-domain transform rules applied to matching outbound HTTPS requests. Keys may be exact DNS names (for example, "api.example.com") or a leading wildcard (for example, "*.example.com"), and are normalized to lowercase on write. Wildcards match subdomains at any depth but not the apex domain; a bare "*" is invalid. Exact rules take precedence, followed by the longest matching wildcard suffix, and matching rule sets are not merged. Broad wildcards such as "*.com" are allowed and may expose transformed credentials to every matching destination the sandbox contacts. Rules do not grant network access; configure allowOut separately to permit the destination.

  • ▸ 更多参数(3)
    • mcpobject可选

      MCP configuration for the sandbox

    • iamobject可选

      Sandbox workload identity configuration. A non-empty, valid tokens map enables workload identity for the sandbox.

      ▸ 展开子字段(1)
      • tokensobject可选

        Named workload-token definitions, keyed by a caller-chosen token name.

    • volumeMountsarray可选
      ▸ 展开子字段(2)
      • namestring必填

        Name of the volume

      • pathstring必填

        Path of the volume

返回

201

已弃用:最新官方 SDK 走 v2。平台暂未提供 E2B 默认的 base 模板:不带模板参数的 Sandbox.create() 会返回 404,请显式指定模板(可用模板见「列出模板」)。

错误按 E2B 格式返回,参见 错误码

响应

HTTP 201

The sandbox was created successfully

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringBase domain where the sandbox traffic is accessible

列出沙箱

GET /e2b/sandboxes● 支持

E2B 官方文档 ↗

请求参数

  • metadatastring可选

    query: Metadata query used to filter the sandboxes (e.g. "user=abc&app=prod"). Each key and values must be URL encoded.

返回

200

已弃用:最新官方 SDK 走 v2。

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned all running sandboxes

application/json

名称类型说明
[].templateIDstringIdentifier of the template from which is the sandbox created
[].aliasstringAlias of the template
[].sandboxIDstringIdentifier of the sandbox
[].clientIDstringIdentifier of the client
[].startedAtstringTime when the sandbox was started
[].endAtstringTime when the sandbox will expire
[].cpuCountintegerCPU cores for the sandbox
[].memoryMBintegerMemory for the sandbox in MiB
[].diskSizeMBintegerDisk size for the sandbox in MiB
[].metadataany
[].statestringState of the sandbox
[].envdVersionstringVersion of the envd running in the sandbox
[].volumeMountsarray<object>
[].volumeMounts[].namestringName of the volume
[].volumeMounts[].pathstringPath of the volume

读取沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

GET /e2b/sandboxes/{sandboxID}● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned the sandbox

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
aliasstringAlias of the template
sandboxIDstringIdentifier of the sandbox
clientIDstringIdentifier of the client
startedAtstringTime when the sandbox was started
endAtstringTime when the sandbox will expire
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
allowInternetAccessbooleanWhether internet access was explicitly enabled or disabled for the sandbox. Null means it was not explicitly set.
domainstringBase domain where the sandbox traffic is accessible
cpuCountintegerCPU cores for the sandbox
memoryMBintegerMemory for the sandbox in MiB
diskSizeMBintegerDisk size for the sandbox in MiB
metadataany
statestringState of the sandbox
networkobject
network.allowPublicTrafficbooleanSpecify if the sandbox URLs should be accessible only with authentication.
network.allowOutarray<string>List of allowed destinations for egress traffic. Each entry can be a CIDR block (e.g. "8.8.8.8/32"), a bare IP address (e.g. "8.8.8.8"), or a domain name (e.g. "example.com", "*.example.com"). Allowed entries always take precedence over denied entries.
network.denyOutarray<string>List of denied CIDR blocks or IP addresses for egress traffic. Domain names are not supported for deny rules.
network.egressProxyobjectSOCKS5 proxy for sandbox egress. Outbound TCP is tunneled through the proxy after allow/deny filtering; the sandbox is unaware. Domain-matched flows use remote DNS (ATYP=domain).
network.maskRequestHoststringSpecify host mask which will be used for all sandbox requests
network.httpsPortsarray<integer>Sandbox ports that serve HTTPS rather than plaintext HTTP. Affects how the proxy reaches the service inside the sandbox; the public URL is HTTPS either way. Certificates are not verified, so self-signed ones work. The envd port (49983) cannot be listed.
network.rulesobjectPer-domain transform rules applied to matching outbound HTTPS requests. Keys may be exact DNS names (for example, "api.example.com") or a leading wildcard (for example, ".example.com"), and are normalized to lowercase on write. Wildcards match subdomains at any depth but not the apex domain; a bare "" is invalid. Exact rules take precedence, followed by the longest matching wildcard suffix, and matching rule sets are not merged. Broad wildcards such as "*.com" are allowed and may expose transformed credentials to every matching destination the sandbox contacts. Rules do not grant network access; configure allowOut separately to permit the destination.
lifecycleobjectSandbox lifecycle policy returned by sandbox info.
lifecycle.autoResumebooleanWhether the sandbox can auto-resume.
lifecycle.onTimeoutstringAction taken when the sandbox times out.
volumeMountsarray<object>
volumeMounts[].namestringName of the volume
volumeMounts[].pathstringPath of the volume

沙箱指标

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

GET /e2b/sandboxes/{sandboxID}/metrics● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • startinteger可选

    query: Unix timestamp for the start of the interval, in seconds, for which the metrics

  • endinteger可选

    query: Unix timestamp for the end of the interval, in seconds, for which the metrics

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned the sandbox metrics

application/json

名称类型说明
[].timestampstringTimestamp of the metric entry
[].timestampUnixintegerTimestamp of the metric entry in Unix time (seconds since epoch)
[].cpuCountintegerNumber of CPU cores
[].cpuUsedPctnumberCPU usage percentage
[].memUsedintegerMemory used in bytes
[].memTotalintegerTotal memory in bytes
[].memCacheintegerCached memory (page cache) in bytes
[].diskUsedintegerDisk used in bytes
[].diskTotalintegerTotal disk space in bytes

设置超时

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /e2b/sandboxes/{sandboxID}/timeout● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • timeoutinteger必填

    Timeout in seconds from the current time after which the sandbox should expire

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

Successfully set the sandbox timeout

未声明响应体。

暂停沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /e2b/sandboxes/{sandboxID}/pause● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • memoryboolean可选
    默认 true

    Whether to capture a full memory snapshot. When false, only the filesystem is persisted and resuming the sandbox cold-boots (reboots) it from disk, losing in-memory state, running processes, and open connections. Resume it with an explicit request (connect or resume); auto-resume, which can be triggered by arbitrary traffic, refuses such a sandbox. Defaults to true.

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

The sandbox was paused successfully and can be resumed

未声明响应体。

连接沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /e2b/sandboxes/{sandboxID}/connect● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • timeoutinteger必填

    Timeout in seconds from the current time after which the sandbox should expire

  • memoryboolean可选

    Defaults to true. When false and the sandbox is paused, resume from disk state only: the sandbox cold-boots fresh and any memory in the snapshot is ignored, never modified or deleted. Disk state has crash-recovery semantics — writes not flushed before the pause may be lost. A no-op for snapshots that contain no memory. Rejected with an error in environments where this capability is not enabled, never silently downgraded to a memory restore.

返回

201

已弃用:最新官方 SDK 走 v2。

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

The sandbox was already running

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringBase domain where the sandbox traffic is accessible

HTTP 201

The sandbox was resumed successfully

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringBase domain where the sandbox traffic is accessible

终止沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

DELETE /e2b/sandboxes/{sandboxID}● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

The sandbox was killed successfully

未声明响应体。

创建沙箱(v2)

POST /e2b/v2/sandboxes● 支持

E2B 官方文档 ↗

请求体

  • templateIDstring必填

    Identifier of the required template

  • timeoutinteger可选
    默认 300

    Time to live for the sandbox in seconds.

  • autoPauseboolean可选
    默认 false

    Automatically pauses the sandbox after the timeout

  • metadataany可选
  • envVarsany可选
  • allow_internet_accessboolean可选

    Allow sandbox to access the internet. When set to false, it behaves the same as specifying denyOut to 0.0.0.0/0 in the network config.

  • autoPauseMemoryboolean可选
    默认 true

    Controls the snapshot kind taken when the sandbox auto-pauses on timeout (only relevant when autoPause is true). When false, the auto-pause drops the in-memory state and persists only the filesystem (a filesystem-only snapshot); resuming it cold-boots (reboots) the sandbox from disk. Such a snapshot cannot be auto-resumed by traffic and must be resumed explicitly, so it cannot be combined with autoResume. Defaults to true (full memory snapshot).

  • autoResumeobject可选

    Auto-resume configuration for paused sandboxes.

    ▸ 展开子字段(1)
    • enabledboolean必填
      默认 false

      Auto-resume enabled flag for paused sandboxes. Default false.

  • networkobject可选
    ▸ 展开子字段(7)
    • allowPublicTrafficboolean可选
      默认 true

      Specify if the sandbox URLs should be accessible only with authentication.

    • allowOutarray可选

      List of allowed destinations for egress traffic. Each entry can be a CIDR block (e.g. "8.8.8.8/32"), a bare IP address (e.g. "8.8.8.8"), or a domain name (e.g. "example.com", "*.example.com"). Allowed entries always take precedence over denied entries.

    • denyOutarray可选

      List of denied CIDR blocks or IP addresses for egress traffic. Domain names are not supported for deny rules.

    • egressProxyobject可选

      SOCKS5 proxy for sandbox egress. Outbound TCP is tunneled through the proxy after allow/deny filtering; the sandbox is unaware. Domain-matched flows use remote DNS (ATYP=domain).

    • maskRequestHoststring可选

      Specify host mask which will be used for all sandbox requests

    • httpsPortsarray可选

      Sandbox ports that serve HTTPS rather than plaintext HTTP. Affects how the proxy reaches the service inside the sandbox; the public URL is HTTPS either way. Certificates are not verified, so self-signed ones work. The envd port (49983) cannot be listed.

    • rulesobject可选

      Per-domain transform rules applied to matching outbound HTTPS requests. Keys may be exact DNS names (for example, "api.example.com") or a leading wildcard (for example, "*.example.com"), and are normalized to lowercase on write. Wildcards match subdomains at any depth but not the apex domain; a bare "*" is invalid. Exact rules take precedence, followed by the longest matching wildcard suffix, and matching rule sets are not merged. Broad wildcards such as "*.com" are allowed and may expose transformed credentials to every matching destination the sandbox contacts. Rules do not grant network access; configure allowOut separately to permit the destination.

  • mcpobject可选

    MCP configuration for the sandbox

  • ▸ 更多参数(2)
    • iamobject可选

      Sandbox workload identity configuration. A non-empty, valid tokens map enables workload identity for the sandbox.

      ▸ 展开子字段(1)
      • tokensobject可选

        Named workload-token definitions, keyed by a caller-chosen token name.

    • volumeMountsarray可选
      ▸ 展开子字段(2)
      • namestring必填

        Name of the volume

      • pathstring必填

        Path of the volume

返回

201

错误按 E2B 格式返回,参见 错误码

响应

HTTP 201

The sandbox was created successfully

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringBase domain where the sandbox traffic is accessible

列出沙箱(v2)

GET /e2b/v2/sandboxes● 支持

E2B 官方文档 ↗

请求参数

  • metadatastring可选

    query: Metadata query used to filter the sandboxes (e.g. "user=abc&app=prod"). Each key and values must be URL encoded.

  • statearray可选

    query: Filter sandboxes by one or more states

  • orderstring可选
    默认 "desc"

    query: Sort direction by sandbox start time. Defaults to desc (newest first).

    取值 ascdesc
  • startedAfterstring可选

    query: Return sandboxes started at or after this timestamp.

  • templatestring可选

    query: Filter sandboxes by a template ID or alias.

  • nextTokenstring可选

    query: Cursor to start the list from

  • limitinteger可选
    默认 100

    query: Maximum number of items to return per page

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned all running sandboxes

application/json

名称类型说明
[].templateIDstringIdentifier of the template from which is the sandbox created
[].aliasstringAlias of the template
[].sandboxIDstringIdentifier of the sandbox
[].clientIDstringIdentifier of the client
[].startedAtstringTime when the sandbox was started
[].endAtstringTime when the sandbox will expire
[].cpuCountintegerCPU cores for the sandbox
[].memoryMBintegerMemory for the sandbox in MiB
[].diskSizeMBintegerDisk size for the sandbox in MiB
[].metadataany
[].statestringState of the sandbox
[].envdVersionstringVersion of the envd running in the sandbox
[].volumeMountsarray<object>
[].volumeMounts[].namestringName of the volume
[].volumeMounts[].pathstringPath of the volume

连接沙箱(v2)

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /e2b/v2/sandboxes/{sandboxID}/connect● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • timeoutinteger可选
    默认 300

    Timeout in seconds from the current time after which the sandbox should expire

  • memoryboolean可选

    Defaults to true. When false and the sandbox is paused, resume from disk state only: the sandbox cold-boots fresh and any memory in the snapshot is ignored, never modified or deleted. Disk state has crash-recovery semantics — writes not flushed before the pause may be lost. A no-op for snapshots that contain no memory. Rejected with an error in environments where this capability is not enabled, never silently downgraded to a memory restore.

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

The sandbox was already running

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringBase domain where the sandbox traffic is accessible

HTTP 201

The sandbox was resumed successfully

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringBase domain where the sandbox traffic is accessible

列出模板

GET /e2b/templates● 支持

E2B 官方文档 ↗

请求参数

  • teamIDstring可选

    query: Identifier of the team

返回

200

已弃用:最新官方 SDK 走 v2。

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned all templates

application/json

名称类型说明
[].templateIDstringIdentifier of the template
[].buildIDstringIdentifier of the last successful build for given template
[].cpuCountintegerCPU cores for the sandbox
[].memoryMBintegerMemory for the sandbox in MiB
[].diskSizeMBintegerDisk size for the sandbox in MiB
[].publicbooleanWhether the template is public or only accessible by the team
[].aliasesarray<string>Aliases of the template
[].namesarray<string>Names of the template (namespace/alias format when namespaced)
[].createdAtstringTime when the template was created
[].updatedAtstringTime when the template was last updated
[].createdByobject
[].createdBy.idstringIdentifier of the user
[].createdBy.emailstringEmail of the user
[].lastSpawnedAtstringTime when the template was last used
[].spawnCountintegerNumber of times the template was used
[].buildCountintegerNumber of times the template was built
[].envdVersionstringVersion of the envd running in the sandbox
[].buildStatusstringStatus of the template build

列出模板(v2)

GET /e2b/v2/templates● 支持

E2B 官方文档 ↗

请求参数

  • teamIDstring可选

    query: Identifier of the team

  • nextTokenstring可选

    query: Cursor to start the list from

  • limitinteger可选
    默认 100

    query: Maximum number of items to return per page

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned all templates

application/json

名称类型说明
[].templateIDstringIdentifier of the template
[].buildIDstringIdentifier of the last successful build for given template
[].cpuCountintegerCPU cores for the sandbox
[].memoryMBintegerMemory for the sandbox in MiB
[].diskSizeMBintegerDisk size for the sandbox in MiB
[].publicbooleanWhether the template is public or only accessible by the team
[].aliasesarray<string>Aliases of the template
[].namesarray<string>Names of the template (namespace/alias format when namespaced)
[].createdAtstringTime when the template was created
[].updatedAtstringTime when the template was last updated
[].createdByobject
[].createdBy.idstringIdentifier of the user
[].createdBy.emailstringEmail of the user
[].lastSpawnedAtstringTime when the template was last used
[].spawnCountintegerNumber of times the template was used
[].buildCountintegerNumber of times the template was built
[].envdVersionstringVersion of the envd running in the sandbox
[].buildStatusstringStatus of the template build

创建卷

POST /e2b/volumes● 支持

E2B 官方文档 ↗

请求体

  • namestring必填

    Name of the volume

返回

201

错误按 E2B 格式返回,参见 错误码

响应

HTTP 201

Successfully created a new team volume

application/json

名称类型说明
volumeIDstringID of the volume
namestringName of the volume
tokenstringAuth token to use for interacting with volume content
domainstringDomain to use as the destination for volume content requests, replacing the default `api.<E2B_DOMAIN>`. Only returned when the team is connected to a custom (BYOC) cluster; absent otherwise, in which case the default domain is used.

列出卷

GET /e2b/volumes● 支持

E2B 官方文档 ↗

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully listed all team volumes

application/json

名称类型说明
[].volumeIDstringID of the volume
[].namestringName of the volume

读取卷

GET /e2b/volumes/{volumeID}● 支持

E2B 官方文档 ↗

请求参数

  • volumeIDstring必填

    path:

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully retrieved a team volume

application/json

名称类型说明
volumeIDstringID of the volume
namestringName of the volume
tokenstringAuth token to use for interacting with volume content
domainstringDomain to use as the destination for volume content requests, replacing the default `api.<E2B_DOMAIN>`. Only returned when the team is connected to a custom (BYOC) cluster; absent otherwise, in which case the default domain is used.

删除卷

DELETE /e2b/volumes/{volumeID}● 支持

E2B 官方文档 ↗

请求参数

  • volumeIDstring必填

    path:

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

Successfully deleted a team volume

未声明响应体。

复制沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /e2b/sandboxes/{sandboxID}/fork● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • timeoutinteger可选
    默认 15

    新副本的存活时间,单位为秒。

  • countinteger可选
    默认 1

    要创建的独立副本数。所有副本来自同一次快照,每个副本分别返回成功结果或错误。

返回

201

错误按 E2B 格式返回,参见 错误码

响应

HTTP 201

The sandbox was snapshotted and the forks were attempted; each entry reports one fork's outcome

application/json

名称类型说明
[].sandboxobject
[].sandbox.templateIDstringIdentifier of the template from which is the sandbox created
[].sandbox.sandboxIDstringIdentifier of the sandbox
[].sandbox.aliasstringAlias of the template
[].sandbox.clientIDstringIdentifier of the client
[].sandbox.envdVersionstringVersion of the envd running in the sandbox
[].sandbox.envdAccessTokenstringAccess token used for envd communication
[].sandbox.trafficAccessTokenstringToken required for accessing sandbox via proxy.
[].sandbox.domainstringBase domain where the sandbox traffic is accessible
[].errorobject
[].error.codeintegerError code
[].error.error_codestringMachine-readable semantic error code. Not a closed set; initial values: sandbox_capacity_unavailable, sandbox_placement_timeout, sandbox_no_compatible_node, sandbox_create_failed, internal_server_error.
[].error.messagestringError

创建快照

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /e2b/sandboxes/{sandboxID}/snapshots● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • namestring可选

    可选别名。同一主体重复使用该别名会更新既有快照,保留本平台快照 ID。

返回

201

错误按 E2B 格式返回,参见 错误码

响应

HTTP 201

Snapshot created successfully

application/json

名称类型说明
snapshotIDstringIdentifier of the snapshot template including the tag. Uses namespace/alias when a name was provided (e.g. team-slug/my-snapshot:default), otherwise falls back to the raw template ID (e.g. abc123:default).
namesarray<string>Full names of the snapshot template including team namespace and tag (e.g. team-slug/my-snapshot:v2)

列出快照

GET /e2b/snapshots● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring可选

    query: 按来源沙箱 ID 筛选。

  • namestring可选

    query: 按原始别名或本平台 snap_ 快照 ID 筛选。

  • limitinteger可选
    默认 100

    query: 每页返回的快照数量上限。

  • nextTokenstring可选

    query: 上一页响应头 X-Next-Token 返回的游标。

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned snapshots

application/json

名称类型说明
[].snapshotIDstringIdentifier of the snapshot template including the tag. Uses namespace/alias when a name was provided (e.g. team-slug/my-snapshot:default), otherwise falls back to the raw template ID (e.g. abc123:default).
[].namesarray<string>Full names of the snapshot template including team namespace and tag (e.g. team-slug/my-snapshot:v2)

删除快照

DELETE /e2b/templates/{templateID}● 支持

E2B 官方文档 ↗

请求参数

  • templateIDstring必填

    path: 本平台返回的 snap_ 快照 ID,不接受供应商句柄。

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

The template was deleted successfully

未声明响应体。

更新网络策略

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

PUT /e2b/sandboxes/{sandboxID}/network● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • allow_internet_accessboolean可选

    是否允许访问外网。false 等效于 denyOut 包含 0.0.0.0/0。

  • allowOutarray可选

    出站目标白名单,可用 CIDR、IP 或域名;白名单优先于拒绝规则。

  • denyOutarray可选

    出站目标黑名单,支持 CIDR 或 IP,不支持域名。

  • egressProxyobject可选

    上游代理配置字段,当前平台尚未应用。

    ▸ 展开子字段(3)
    • addressstring必填

      SOCKS5 proxy address in host:port format (e.g. "proxy.example.com:1080").

    • usernamestring可选

      Optional SOCKS5 username (RFC 1929), max 255 bytes.

    • passwordstring可选

      Optional SOCKS5 password (RFC 1929), max 255 bytes.

  • rulesobject可选

    上游按域名转换规则字段,当前平台尚未应用。

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

Successfully updated the sandbox network configuration

未声明响应体。

读取沙箱日志

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

GET /e2b/v2/sandboxes/{sandboxID}/logs● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • cursorinteger可选

    query: 起始时间戳,单位为 Unix 毫秒。

  • limitinteger可选
    默认 1000

    query: 最多返回的日志条数。

  • directionstring可选

    query: forward 按时间向后读取;backward 按时间向前读取。

    取值 forwardbackward
  • levelstring可选

    query: 最低日志级别,低于该级别的日志会被过滤。

    取值 debuginfowarnerror
  • searchstring可选

    query: 按日志正文的子串筛选,区分大小写。

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned the sandbox logs

application/json

名称类型说明
logsarray<object>Sandbox logs structured
logs[].timestampstringTimestamp of the log entry
logs[].messagestringLog message content
logs[].levelstringState of the sandbox
logs[].fieldsobject

Tavily 兼容接口

基础地址

加载中…

接入

加载中…

端点

方法路径说明支持
POST/search搜索● 支持
POST/extract提取网页内容● 支持
POST/crawl站内爬取● 支持
POST/map站点地图● 支持
POST/feedback提交反馈● 支持

与官方的差异

  • 站内爬取:调用前要求账户余额大于 0;按 Tavily 返回的 usage.credits 计费,每 credit $0.01;Tavily 未返回用量时,按本次请求可能消耗的上限计费。
  • 站点地图:调用前要求账户余额大于 0;按 Tavily 返回的 usage.credits 计费,每 credit $0.01;Tavily 未返回用量时,按本次请求可能消耗的上限计费。
  • 提交反馈:原样转发给 Tavily,不计费(Tavily 官方定价未对反馈单独计费)。

参数与字段的权威定义以 Tavily 官方文档为准。

错误按 Tavily 格式返回,参见错误;额度与响应头参见限流。

搜索

POST /tavily/search● 支持

Tavily 官方文档 ↗

请求体

  • querystring必填

    The search query to execute with Tavily.

  • search_depthstring可选
    默认 "basic"

    Controls the latency vs. relevance tradeoff and how `results[].content` is generated: - `advanced`: Highest relevance with increased latency. Best for detailed, high-precision queries. Returns multiple semantically relevant snippets per URL (configurable via `chunks_per_source`). - `basic`: A balanced option for relevance and latency. Ideal for general-purpose searches. Returns multiple semantically relevant snippets per URL (configurable via `chunks_per_source`). - `fast`: Prioritizes lower latency while maintaining good relevance. Returns multiple semantically relevant snippets per URL (configurable via `chunks_per_source`). - `ultra-fast`: Minimizes latency above all else. Best for time-critical use cases. Returns one NLP summary per URL. **Cost**: - `basic`, `fast`, `ultra-fast`: 1 API Credit - `advanced`: 2 API Credits See [Search Best Practices](/documentation/best-practices/best-practices-search#search-depth) for guidance on choosing the right search depth.

    取值 advancedbasicfastultra-fast
  • chunks_per_sourceinteger可选
    默认 3

    Chunks are short content snippets (maximum 500 characters each) pulled directly from the source. Use `chunks_per_source` to define the maximum number of relevant chunks returned per source and to control the `content` length. Chunks will appear in the `content` field as: `<chunk 1> [...] <chunk 2> [...] <chunk 3>`. Available when `search_depth` is `advanced`, `basic` or `fast`.

  • max_resultsinteger可选
    默认 10

    The maximum number of search results to return.

  • topicstring可选
    默认 "general"

    The category of the search.`news` is useful for retrieving real-time updates, particularly about politics, sports, and major current events covered by mainstream media sources. `general` is for broader, more general-purpose searches that may include a wide range of sources.

    取值 generalnewsfinance
  • time_rangestring可选
    默认 null

    The time range back from the current date to filter results based on publish date or last updated date. Useful when looking for sources that have published or updated data. By default, results with no detectable published date are not removed; set `filter_by_published_date` to `true` to remove them.

    取值 dayweekmonthyeardwmy
  • start_datestring可选
    默认 null

    Will return all results after the specified start date based on publish date or last updated date. Required to be written in the format YYYY-MM-DD. By default, results with no detectable published date are not removed; set `filter_by_published_date` to `true` to remove them.

  • end_datestring可选
    默认 null

    Will return all results before the specified end date based on publish date or last updated date. Required to be written in the format YYYY-MM-DD. By default, results with no detectable published date are not removed; set `filter_by_published_date` to `true` to remove them.

  • include_published_dateboolean可选
    默认 false

    Include a `published_date` field in each result. The date is Tavily's best estimate of when the source was published or last updated, so it can be later than the original publish date. Results with no detectable date return `null`. Automatically enabled when `topic` is `news`. **Note**: this feature is currently in beta.

  • filter_by_published_dateboolean可选
    默认 false

    Remove results whose published date falls outside the `time_range`, `start_date`, or `end_date` window. Results with no detectable published date are also removed. Setting this to `true` also enables `include_published_date`. If you want date-window filtering but don't want to lose sources without a detectable date, leave this `false` and set `include_published_date: true` together with a date range instead.

  • ▸ 更多参数(15)
    • include_answerboolean | string可选
      默认 false

      Include an LLM-generated answer to the provided query. `basic` or `true` returns a quick answer. `advanced` returns a more detailed answer.

    • include_raw_contentboolean | string可选
      默认 false

      Include the cleaned and parsed HTML content of each search result. `markdown` or `true` returns search result content in markdown format. `text` returns the plain text from the results and may increase latency.

    • include_imagesboolean可选
      默认 false

      Include images in the response. Returns both a top-level `images` list of query-related images and an `images` array inside each result object with images extracted from that specific source.

    • include_image_descriptionsboolean可选
      默认 false

      When `include_images` is `true`, also add a descriptive text for each image.

    • include_faviconboolean可选
      默认 false

      Whether to include the favicon URL for each result.

    • include_domainsarray可选
      默认 []

      A list of domains to specifically include in the search results. Maximum 300 domains.

    • exclude_domainsarray可选
      默认 []

      A list of domains to specifically exclude from the search results. Maximum 150 domains.

    • include_domains_modestring可选
      默认 null

      Controls how `include_domains` is applied. `restrict` limits results to only the listed domains. `prefer` also searches the rest of the web, so results outside `include_domains` can still surface, rather than excluding them. Requires `include_domains` to be set; returns a 400 error otherwise.

      取值 restrictprefer
    • countrystring可选
      默认 null

      Boost search results from a specific country. This will prioritize content from the selected country in the search results. Available only if topic is `general`.

      取值 afghanistanalbaniaalgeriaandorraangolaargentinaarmeniaaustraliaaustriaazerbaijanbahamasbahrainbangladeshbarbadosbelarusbelgiumbelizebeninbhutanboliviabosnia and herzegovinabotswanabrazilbruneibulgariaburkina fasoburundicambodiacamerooncanadacape verdecentral african republicchadchilechinacolombiacomoroscongocosta ricacroatiacubacyprusczech republicdenmarkdjiboutidominican republicecuadoregyptel salvadorequatorial guineaeritreaestoniaethiopiafijifinlandfrancegabongambiageorgiagermanyghanagreeceguatemalaguineahaitihondurashungaryicelandindiaindonesiairaniraqirelandisraelitalyjamaicajapanjordankazakhstankenyakuwaitkyrgyzstanlatvialebanonlesotholiberialibyaliechtensteinlithuanialuxembourgmadagascarmalawimalaysiamaldivesmalimaltamauritaniamauritiusmexicomoldovamonacomongoliamontenegromoroccomozambiquemyanmarnamibianepalnetherlandsnew zealandnicaraguanigernigerianorth koreanorth macedonianorwayomanpakistanpanamapapua new guineaparaguayperuphilippinespolandportugalqatarromaniarussiarwandasaudi arabiasenegalserbiasingaporeslovakiasloveniasomaliasouth africasouth koreasouth sudanspainsri lankasudanswedenswitzerlandsyriataiwantajikistantanzaniathailandtogotrinidad and tobagotunisiaturkeyturkmenistanugandaukraineunited arab emiratesunited kingdomunited statesuruguayuzbekistanvenezuelavietnamyemenzambiazimbabwe
    • languagestring可选
      默认 null

      Boost search results in a specific language. Accepts an ISO 639-1 code (e.g. `en`, `fr`, `zh-cn`) or an English language name (e.g. `english`, `french`). By default this only boosts matching-language results in ranking; pass `filter_by_language: true` to strictly filter out non-matching results instead. For best results, write your `query` in the same language you set here.

    • filter_by_languageboolean可选
      默认 false

      Strictly filter out search results that don't match the `language` parameter, instead of only boosting them in ranking. Requires `language` to be set; returns a 400 error otherwise.

    • auto_parametersboolean可选
      默认 false

      When `auto_parameters` is enabled, Tavily automatically configures search parameters based on your query's content and intent. You can still set other parameters manually, and your explicit values will override the automatic ones. The parameters `include_answer`, `include_raw_content`, and `max_results` must always be set manually, as they directly affect response size. Note: `search_depth` may be automatically set to advanced when it's likely to improve results. This uses 2 API credits per request. To avoid the extra cost, you can explicitly set `search_depth` to `basic`.

    • exact_matchboolean可选
      默认 false

      Ensure that only search results containing the exact quoted phrase(s) in the query are returned, bypassing synonyms or semantic variations. Wrap target phrases in quotes within your query (e.g. `"John Smith" CEO Acme Corp`). Punctuation is typically ignored inside quotes.

    • include_usageboolean可选
      默认 false

      Whether to include credit usage information in the response.

    • safe_searchboolean可选
      默认 false

      Whether to filter out adult or unsafe content from results. Not supported for `fast` or `ultra-fast` search depths.

返回

200

错误按 Tavily 格式返回,参见 错误码

响应

HTTP 200

Search results returned successfully

application/json

名称类型说明
querystringThe search query that was executed.
answerstringA short answer to the user's query, generated by an LLM. Included in the response only if `include_answer` is requested (i.e., set to `true`, `basic`, or `advanced`)
imagesarray<object>A list of query-related images from image search. If `include_image_descriptions` is true, each item will have `url` and `description`. Note: per-result images are also returned inside each result object's `images` field.
images[].urlstring
images[].descriptionstring
resultsarray<object>A list of sorted search results, ranked by relevancy.
results[].titlestringThe title of the search result.
results[].urlstringThe URL of the search result.
results[].contentstringA short description of the search result.
results[].scorenumberThe relevance score of the search result.
results[].raw_contentstringThe cleaned and parsed HTML content of the search result. Only if `include_raw_content` is true.
results[].published_datestringTavily's best estimate of when the source was published or last updated. Can be later than the original publish date. `null` if no date could be detected. Only returned when `include_published_date` is `true` (automatically enabled when `topic` is `news`).
results[].faviconstringThe favicon URL for the result.
results[].imagesarray<object>A list of images extracted from this search result. Only included when `include_images` is `true`. If `include_image_descriptions` is `true`, each item will have `url` and `description`.
results[].idstringUnique identifier for this result
auto_parametersobjectA dictionary of the selected auto_parameters, only shown when `auto_parameters` is true.
response_timenumberTime in seconds it took to complete the request.
usageobjectCredit usage details for the request.
request_idstringA unique request identifier you can share with customer support to help resolve issues with specific requests.

提取网页内容

POST /tavily/extract● 支持

Tavily 官方文档 ↗

请求体

  • querystring可选

    User intent for reranking extracted content chunks. When provided, chunks are reranked based on relevance to this query.

  • urlsstring | array必填
  • chunks_per_sourceinteger可选
    默认 3

    Chunks are short content snippets (maximum 500 characters each) pulled directly from the source. Use `chunks_per_source` to define the maximum number of relevant chunks returned per source and to control the `raw_content` length. Chunks will appear in the `raw_content` field as: `<chunk 1> [...] <chunk 2> [...] <chunk 3>`. Available only when `query` is provided. Must be between 1 and 5.

  • extract_depthstring可选
    默认 "basic"

    The depth of the extraction process. `advanced` extraction retrieves more data, including tables and embedded content, with higher success but may increase latency.`basic` extraction costs 1 credit per 5 successful URL extractions, while `advanced` extraction costs 2 credits per 5 successful URL extractions.

    取值 basicadvanced
  • include_imagesboolean可选
    默认 false

    Include a list of images extracted from the URLs in the response. Default is false.

  • include_faviconboolean可选
    默认 false

    Whether to include the favicon URL for each result.

  • formatstring可选
    默认 "markdown"

    The format of the extracted web page content. `markdown` returns content in markdown format. `text` returns plain text and may increase latency.

    取值 markdowntext
  • timeoutnumber可选
    默认 "None"

    Maximum time in seconds to wait for the URL extraction before timing out. Must be between 1.0 and 60.0 seconds. If not specified, default timeouts are applied based on extract_depth: 10 seconds for basic extraction and 30 seconds for advanced extraction.

  • include_usageboolean可选
    默认 false

    Whether to include credit usage information in the response. `NOTE:`The value may be 0 if the total successful URL extractions has not yet reached 5 calls. See our [Credits & Pricing documentation](https://docs.tavily.com/documentation/api-credits) for details.

返回

200

错误按 Tavily 格式返回,参见 错误码

响应

HTTP 200

Extraction completed. Check results and failed_results for each URL. HTTP 200 can have an empty results array when all valid URLs fail during extraction; output order is not guaranteed.

application/json

名称类型说明
resultsarray<object>A list of extracted content from the provided URLs.
results[].urlstringThe URL from which the content was extracted.
results[].raw_contentstringThe full content extracted from the page. When `query` is provided, contains the top-ranked chunks joined by `[...]` separator.
results[].imagesarray<string>This is only available if `include_images` is set to `true`. A list of image URLs extracted from the page.
results[].faviconstringThe favicon URL for the result.
failed_resultsarray<object>A list of URLs that could not be processed.
failed_results[].urlstringThe URL that failed to be processed.
failed_results[].errorstringAn error message describing why the URL couldn't be processed.
response_timenumberTime in seconds it took to complete the request.
usageobjectCredit usage details for the request.
request_idstringA unique request identifier you can share with customer support to help resolve issues with specific requests.

站内爬取

POST /tavily/crawl● 支持

Tavily 官方文档 ↗

请求体

  • urlstring必填

    The root URL to begin the crawl.

  • limitinteger可选
    默认 50

    Total number of links the crawler will process before stopping.

  • instructionsstring可选

    Natural language instructions for the crawler. When specified, the mapping cost increases to 2 API credits per 10 successful pages instead of 1 API credit per 10 pages.

  • chunks_per_sourceinteger可选
    默认 3

    Chunks are short content snippets (maximum 500 characters each) pulled directly from the source. Use `chunks_per_source` to define the maximum number of relevant chunks returned per source and to control the `raw_content` length. Chunks will appear in the `raw_content` field as: `<chunk 1> [...] <chunk 2> [...] <chunk 3>`. Available only when `instructions` are provided. Must be between 1 and 5.

  • max_depthinteger可选
    默认 1

    Max depth of the crawl. Defines how far from the base URL the crawler can explore.

  • max_breadthinteger可选
    默认 20

    Max number of links to follow per level of the tree (i.e., per page).

  • select_pathsarray可选
    默认 null

    Regex patterns to select only URLs with specific path patterns (e.g., `/docs/.*`, `/api/v1.*`).

  • select_domainsarray可选
    默认 null

    Regex patterns to select crawling to specific domains or subdomains (e.g., `^docs\.example\.com$`).

  • exclude_pathsarray可选
    默认 null

    Regex patterns to exclude URLs with specific path patterns (e.g., `/private/.*`, `/admin/.*`).

  • exclude_domainsarray可选
    默认 null

    Regex patterns to exclude specific domains or subdomains from crawling (e.g., `^private\.example\.com$`).

  • ▸ 更多参数(7)
    • allow_externalboolean可选
      默认 true

      Whether to include external domain links in the final results list.

    • include_imagesboolean可选
      默认 false

      Whether to include images in the crawl results.

    • extract_depthstring可选
      默认 "basic"

      Advanced extraction retrieves more data, including tables and embedded content, with higher success but may increase latency. `basic` extraction costs 1 credit per 5 successful extractions, while `advanced` extraction costs 2 credits per 5 successful extractions.

      取值 basicadvanced
    • formatstring可选
      默认 "markdown"

      The format of the extracted web page content. `markdown` returns content in markdown format. `text` returns plain text and may increase latency.

      取值 markdowntext
    • include_faviconboolean可选
      默认 false

      Whether to include the favicon URL for each result.

    • timeoutnumber可选
      默认 150

      Maximum time in seconds to wait for the crawl operation before timing out. Must be between 10 and 150 seconds.

    • include_usageboolean可选
      默认 false

      Whether to include credit usage information in the response. `NOTE:`The value may be 0 if the total use of /extract and /map have not yet reached minimum requirements. See our [Credits & Pricing documentation](https://docs.tavily.com/documentation/api-credits) for details.

返回

200

调用前要求账户余额大于 0;按 Tavily 返回的 usage.credits 计费,每 credit $0.01;Tavily 未返回用量时,按本次请求可能消耗的上限计费。

错误按 Tavily 格式返回,参见 错误码

响应

HTTP 200

Crawl results returned successfully

application/json

名称类型说明
base_urlstringThe base URL that was crawled.
resultsarray<object>A list of extracted content from the crawled URLs.
results[].urlstringThe URL that was crawled.
results[].raw_contentstringThe full content extracted from the page. When `query` is provided, contains the top-ranked chunks joined by `[...]` separator.
results[].faviconstringThe favicon URL for the result.
response_timenumberTime in seconds it took to complete the request.
usageobjectCredit usage details for the request.
request_idstringA unique request identifier you can share with customer support to help resolve issues with specific requests.

站点地图

POST /tavily/map● 支持

Tavily 官方文档 ↗

请求体

  • urlstring必填

    The root URL to begin the mapping.

  • limitinteger可选
    默认 50

    Total number of links the crawler will process before stopping.

  • instructionsstring可选
    默认 null

    Natural language instructions for the crawler. When specified, the cost increases to 2 API credits per 10 successful pages instead of 1 API credit per 10 pages.

  • max_depthinteger可选
    默认 1

    Max depth of the mapping. Defines how far from the base URL the crawler can explore.

  • max_breadthinteger可选
    默认 20

    Max number of links to follow per level of the tree (i.e., per page).

  • select_pathsarray可选
    默认 null

    Regex patterns to select only URLs with specific path patterns (e.g., `/docs/.*`, `/api/v1.*`).

  • select_domainsarray可选
    默认 null

    Regex patterns to select crawling to specific domains or subdomains (e.g., `^docs\.example\.com$`).

  • exclude_pathsarray可选
    默认 null

    Regex patterns to exclude URLs with specific path patterns (e.g., `/private/.*`, `/admin/.*`).

  • exclude_domainsarray可选
    默认 null

    Regex patterns to exclude specific domains or subdomains from crawling (e.g., `^private\.example\.com$`).

  • allow_externalboolean可选
    默认 true

    Whether to include external domain links in the final results list.

  • ▸ 更多参数(2)
    • timeoutnumber可选
      默认 150

      Maximum time in seconds to wait for the map operation before timing out. Must be between 10 and 150 seconds.

    • include_usageboolean可选
      默认 false

      Whether to include credit usage information in the response.`NOTE:`The value may be 0 if the total successful pages mapped has not yet reached 10 calls. See our [Credits & Pricing documentation](https://docs.tavily.com/documentation/api-credits) for details.

返回

200

调用前要求账户余额大于 0;按 Tavily 返回的 usage.credits 计费,每 credit $0.01;Tavily 未返回用量时,按本次请求可能消耗的上限计费。

错误按 Tavily 格式返回,参见 错误码

响应

HTTP 200

Map results returned successfully

application/json

名称类型说明
base_urlstringThe base URL that was mapped.
resultsarray<string>A list of URLs that were discovered during the mapping.
response_timenumberTime in seconds it took to complete the request.
usageobjectCredit usage details for the request.
request_idstringA unique request identifier you can share with customer support to help resolve issues with specific requests.

提交反馈

POST /tavily/feedback● 支持

Tavily 官方文档 ↗

请求体

  • request_idstring可选

    The search request to give feedback on, as returned in the `request_id` field of the search response. When provided, the feedback applies to this request.

  • session_idstring可选

    The session to give feedback on — the value you sent in the `X-Session-Id` header. When `request_id` is omitted, the feedback applies to the whole session. Optional if `request_id` is provided.

  • agent_scorenumber | string可选

    Overall score for how relevant and useful the results were for your task.

  • human_scorenumber | string可选

    Feedback from your end user, if you collect it.

  • extra_scoresarray可选

    Additional labeled scores for the dimensions you care about.

    ▸ 展开子字段(2)
    • labelstring必填

      Name of the dimension being scored.

    • valuenumber | string必填

      A numeric score, or a short string label (max 64 characters).

  • commentstring可选

    Free-text explanation of the feedback.

  • response_deliveredstring可选

    The final answer you produced using the results.

  • used_idsarray可选

    IDs of the results you actually used in your answer. Alternative to `used_urls`.

  • used_urlsarray可选

    URLs of the results you actually used in your answer. Alternative to `used_ids`.

  • used_citationsarray可选

    The specific content snippets you quoted from the results.

  • ▸ 更多参数(1)
    • urls_scoresarray可选

      Per-result feedback. Identify each result by `id` or `url`.

      ▸ 展开子字段(5)
      • idstring可选

        The `id` of the result, as returned in the search response.

      • urlstring可选

        The URL of the result. Use instead of `id` when you don't have the result ID.

      • agent_scorenumber | string可选

        Score for this specific result.

      • scoresarray可选

        Additional labeled scores for this result.

      • commentstring可选

        Free-text explanation of the feedback on this result.

返回

200

原样转发给 Tavily,不计费(Tavily 官方定价未对反馈单独计费)。

错误按 Tavily 格式返回,参见 错误码

响应

HTTP 200

Feedback accepted

application/json

名称类型说明
successbooleanWhether the feedback was accepted.
feedback_idstringUnique identifier of this feedback submission.
response_timenumberResponse time of this feedback request in seconds.

Supabase 兼容接口

使用官方 supabase-js 读写一个库中的表。

指南 →

基础地址

https://api.deepraxis.ai/supabase/{database_id}/

部分含义
{database_id}建库返回的 ID;每个库使用自己的地址。
/保留末尾斜杠,supabase-js 才会保留库 ID 并追加 rest/v1。

API Key 用作 Authorization: Bearer 凭据;supabase-js 的第二个参数传同一 Key。以下示例在服务端运行。

import { createClient } from "@supabase/supabase-js";

const supabase = createClient(
  `https://api.deepraxis.ai/supabase/${process.env.DATABASE_ID}/`,
  process.env.PRAXIS_API_KEY,
  { auth: { persistSession: false, autoRefreshToken: false } },
);

表端点

GET / HEAD / POST / PATCH / DELETE

/supabase/{database_id}/rest/v1/{table}

仅提供下列 PostgREST 子集。不支持的语法返回 HTTP 400,code 为 PGRST127;无效或未知参数可能返回 PGRST100。

过滤运算符

值支持情况
eq支持
neq支持
gt支持
gte支持
lt支持
lte支持
like支持
ilike支持
in支持
is支持
cs支持
cd支持
ov支持
fts不支持
plfts不支持
phfts不支持
wfts不支持
match不支持
imatch不支持
isdistinct不支持
sl不支持
sr不支持
nxl不支持
nxr不支持
adj不支持

Prefer

值支持情况
return=minimal支持
return=headers-only支持
return=representation支持
count=exact支持
count=planned部分支持
count=estimated部分支持
resolution=merge-duplicates支持
resolution=ignore-duplicates支持
missing=default部分支持
handling=strict支持
handling=lenient支持

Accept

值支持情况
application/json支持
*/*支持
application/vnd.pgrst.object+json支持
text/csv不支持
application/geo+json不支持
application/vnd.pgrst.plan*不支持

查询语法

值支持情况
not支持
and/or/not.and/not.or支持
JSON paths (->, ->>)支持
aliases支持
link embedding支持
!field hint支持
embedded filters/order/pagination不支持
casts (::)不支持
aggregates不支持
spread (...)不支持
!inner/!left不支持
operator(any)/operator(all)不支持

planned/estimated 当前返回精确计数;字段可以配置 default:批量插入中有的行提供、有的行缺失的列,带 missing=default 时缺失处取字段 default,否则按 PostgREST 写 null;所有行都未提供的列始终取 default(没有 default 时为 null)。cs/cd/ov 接收数组({a,b} 或 ["a"]);json 字段上的 cs/cd 还接受 JSON 对象,按 jsonb 包含判断,例如 meta=cs.{"color":"red"}(键值逐层包含);cs 还接受 JSON 标量,数组顶层含该元素即匹配,例如 meta=cs."a"。cs.{}/cd.{} 在 json 字段上是空对象,在数组字段上是空数组。一次 DELETE 删除的行之间互相引用不阻断删除,只要有引用者不在本次删除中就返回 409 23503。like/ilike 只适用于 string 字段与 ->> 文本路径,用在其他类型返回 400 42883。字符串按二进制序(区分大小写,大写在小写前)比较与排序,不支持按 lower() 排序;需要不区分大小写排序时,另存一个小写字段并按它排序。GET/HEAD 带 If-None-Match 且与当前 ETag 匹配时返回 304、无正文。不支持的 Accept 返回 406 PGRST107。upsert 仅接受 id 或单个 unique 字段。

Prefer 中的未知值默认忽略;handling=strict 时返回 400 PGRST122。单对象 Accept 恰好匹配一行时返回对象,否则返回 406 PGRST116。 其他不支持的 Accept 返回 406 PGRST107。

未开放服务

路径HTTPcode
/supabase/{database_id}/auth/v1/{+path}501not_implemented
/supabase/{database_id}/storage/v1/{+path}501not_implemented
/supabase/{database_id}/realtime/v1/{+path}501not_implemented
/supabase/{database_id}/functions/v1/{+path}501not_implemented
/supabase/{database_id}/graphql/v1/{+path}501not_implemented

这些服务返回 x-should-retry: false。它们的错误体与表端点不同,只有 code 和 message。

错误码表与错误体

读写行

指南 →

/supabase/{database_id}/rest/v1/{table}

与同一库的其它入口读写相同的行;错误使用 PostgREST code。

支持矩阵与初始化

参数与请求头

名称位置说明
database_idpath库 ID。
tablepath表 ID 或名称。
selectquery列名列表;支持 *、别名、JSON 路径及 link 关联展开。不支持类型转换、聚合、展开运算和连接修饰。
{column}query把 {column} 换为字段名或 JSON 路径,例如 title=eq.summary;不同列的条件同时生效。
andquery括号内的条件全部成立,例如 (done.eq.false,title.neq.draft)。
orquery括号内任一条件成立。
not.andquery否定全部条件成立。
not.orquery否定任一条件成立。
orderquery逗号分隔的字段,可带 asc/desc、nullsfirst/nullslast;支持 JSON 路径。
limitquery最多返回的条数。
offsetquery跳过的行数。
on_conflictqueryupsert 的冲突键:id 或单个 unique 字段;配合 Prefer 的 resolution。
columnsquery写入列的逗号分隔列表;列表之外的输入键被忽略。
RangeheaderGET/HEAD 的闭区间,例如 0-9;与 limit/offset 取交集。
Range-Unitheaderitems;其它单位使 Range 被忽略。
Preferheader逗号分隔的偏好。未知值默认被忽略;handling=strict 时返回 400 PGRST122。
Acceptheaderapplication/json、/ 或 application/vnd.pgrst.object+json;单对象模式必须恰好匹配一行,否则返回 406 PGRST116。其他媒体类型返回 406 PGRST107;text/csv、application/geo+json 与 application/vnd.pgrst.plan 返回 400 PGRST127。
If-None-Matchheader上次 GET/HEAD 返回的 ETag(弱比较);与当前 ETag 匹配时返回 304,无正文。

POST 接受单个对象或对象数组;PATCH 接受对象。系统列由服务管理。写入默认不返回正文,使用 Prefer: return=representation(SDK 的 .select())返回行。PATCH 和 DELETE 只影响匹配过滤器的行;省略过滤器会影响全部匹配行。

响应头说明
Content-Range本次行范围/总数;未请求计数时总数为 *。
Preference-Applied已应用的偏好。
ETagGET/HEAD 返回的版本标记;请求带 If-None-Match 且与之匹配时返回 304、无正文。
LocationPOST 使用 return=headers-only 时的新行地址。

读取通常为 200;请求计数且只返回部分行时为 206。POST 为 201。PATCH/DELETE 使用 representation 时为 200,否则为 204。HEAD 没有正文。If-None-Match 与当前 ETag 匹配时返回 304。datetime 值统一按 UTC、3 位毫秒保存和读出(如 2026-10-11T00:30:00.000Z),精度为毫秒,超过 3 位的小数秒四舍五入。

查询行

GET /supabase/{database_id}/rest/v1/{table}

const { data, error } = await supabase.from("tasks").select("*").order("title").limit(10);
if (error) throw error;
console.log(data);

响应

HTTP 200

Success; write bodies require Prefer: return=representation

application/json

名称类型说明
[].idstring
[].versioninteger
[].created_atstring
[].updated_atstring

application/vnd.pgrst.object+json

名称类型说明
idstring
versioninteger
created_atstring
updated_atstring

HTTP 206

Partial range with requested count

application/json

名称类型说明
[].idstring
[].versioninteger
[].created_atstring
[].updated_atstring

application/vnd.pgrst.object+json

名称类型说明
idstring
versioninteger
created_atstring
updated_atstring

响应示例 — HTTP 200

响应头值
content-range0-0/*
etagW/"5.1"
range-unititems
[
  {
    "id": "rec_e88fcbd357aa49c9",
    "version": 1,
    "created_at": "2026-10-11T17:42:00.094Z",
    "updated_at": "2026-10-11T17:42:00.094Z",
    "title": "Write a summary",
    "done": false
  }
]

统计行

HEAD /supabase/{database_id}/rest/v1/{table}

const { data, error, count } = await supabase.from("tasks").select("*", { head: true, count: "exact" });
if (error) throw error;
console.log(count);

响应

HTTP 200

Success; write bodies require Prefer: return=representation

未声明响应体。

HTTP 206

Partial range with requested count

未声明响应体。

响应示例 — HTTP 200

响应头值
content-range0-0/1
preference-appliedcount=exact
etagW/"5.1"
range-unititems

无响应正文。

插入行

POST /supabase/{database_id}/rest/v1/{table}

const { data, error } = await supabase.from("tasks").insert({"title":"Write a summary","done":false}).select();
if (error) throw error;
console.log(data);

响应

HTTP 201

Success; write bodies require Prefer: return=representation

application/json

名称类型说明
[].idstring
[].versioninteger
[].created_atstring
[].updated_atstring

application/vnd.pgrst.object+json

名称类型说明
idstring
versioninteger
created_atstring
updated_atstring

响应示例 — HTTP 201

响应头值
content-range0-0/*
preference-appliedreturn=representation
range-unititems
[
  {
    "id": "rec_e88fcbd357aa49c9",
    "version": 1,
    "created_at": "2026-10-11T17:42:00.094Z",
    "updated_at": "2026-10-11T17:42:00.094Z",
    "title": "Write a summary",
    "done": false
  }
]

更新行

PATCH /supabase/{database_id}/rest/v1/{table}

const { data, error } = await supabase.from("tasks").update({ done: true }).eq("title", "Write a summary").select();
if (error) throw error;
console.log(data);

响应

HTTP 200

Success; write bodies require Prefer: return=representation

application/json

名称类型说明
[].idstring
[].versioninteger
[].created_atstring
[].updated_atstring

application/vnd.pgrst.object+json

名称类型说明
idstring
versioninteger
created_atstring
updated_atstring

HTTP 204

Success without a body

未声明响应体。

响应示例 — HTTP 200

响应头值
content-range0-0/*
preference-appliedreturn=representation
range-unititems
[
  {
    "id": "rec_e88fcbd357aa49c9",
    "version": 2,
    "created_at": "2026-10-11T17:42:00.094Z",
    "updated_at": "2026-10-11T17:42:01.047Z",
    "title": "Write a summary",
    "done": true
  }
]

合并行

POST /supabase/{database_id}/rest/v1/{table}

const { data, error } = await supabase.from("tasks").upsert({"title":"Write a summary","done":true}, { onConflict: "title" }).select();
if (error) throw error;
console.log(data);

响应

HTTP 201

Success; write bodies require Prefer: return=representation

application/json

名称类型说明
[].idstring
[].versioninteger
[].created_atstring
[].updated_atstring

application/vnd.pgrst.object+json

名称类型说明
idstring
versioninteger
created_atstring
updated_atstring

响应示例 — HTTP 201

响应头值
content-range0-0/*
preference-appliedresolution=merge-duplicates, return=representation
range-unititems
[
  {
    "id": "rec_e88fcbd357aa49c9",
    "version": 3,
    "created_at": "2026-10-11T17:42:00.094Z",
    "updated_at": "2026-10-11T17:42:01.735Z",
    "title": "Write a summary",
    "done": true
  }
]

删除行

DELETE /supabase/{database_id}/rest/v1/{table}

const { data, error } = await supabase.from("tasks").delete().eq("title", "Write a summary").select();
if (error) throw error;
console.log(data);

响应

HTTP 200

Success; write bodies require Prefer: return=representation

application/json

名称类型说明
[].idstring
[].versioninteger
[].created_atstring
[].updated_atstring

application/vnd.pgrst.object+json

名称类型说明
idstring
versioninteger
created_atstring
updated_atstring

HTTP 204

Success without a body

未声明响应体。

响应示例 — HTTP 200

响应头值
content-range0-0/*
preference-appliedreturn=representation
range-unititems
[
  {
    "id": "rec_e88fcbd357aa49c9",
    "version": 3,
    "created_at": "2026-10-11T17:42:00.094Z",
    "updated_at": "2026-10-11T17:42:01.735Z",
    "title": "Write a summary",
    "done": true
  }
]

Cloudinary 兼容接口

用官方 Cloudinary SDK 管理一个素材库。只需以下三项配置;API Key 作为 Bearer 凭据发送。

指南 →

https://api.deepraxis.ai/cloudinary/v1_1/{library_id}

配置值
cloud_namelibrary_id
oauth_tokenAPI Key
upload_prefixhttps://api.deepraxis.ai/cloudinary

Node.js

npm install cloudinary@2
import { v2 as cloudinary } from "cloudinary";

cloudinary.config({
  cloud_name: process.env.LIBRARY_ID,
  oauth_token: process.env.PRAXIS_API_KEY,
  upload_prefix: "https://api.deepraxis.ai/cloudinary",
});

Python

python -m pip install cloudinary
import os
import cloudinary
import cloudinary.uploader
import cloudinary.api

cloudinary.config(
    cloud_name=os.environ["LIBRARY_ID"],
    oauth_token=os.environ["PRAXIS_API_KEY"],
    upload_prefix="https://api.deepraxis.ai/cloudinary",
)

支持矩阵

操作支持
GET /v1_1/{library_id}/resources/visual_search支持
POST /v1_1/{library_id}/resources/visual_search支持
POST /v1_1/{library_id}/{resource_type}/upload支持
POST /v1_1/{library_id}/{resource_type}/destroy支持
POST /v1_1/{library_id}/{resource_type}/rename支持
POST /v1_1/{library_id}/{resource_type}/tags支持
POST /v1_1/{library_id}/{resource_type}/context支持
POST /v1_1/{library_id}/{resource_type}/explicit支持
GET /v1_1/{library_id}/resources/search支持
POST /v1_1/{library_id}/resources/search支持
GET /v1_1/{library_id}/resources支持
GET /v1_1/{library_id}/resources/{resource_type}支持
GET /v1_1/{library_id}/resources/{resource_type}/upload支持
GET /v1_1/{library_id}/resources/{asset_id}支持
GET /v1_1/{library_id}/resources/by_asset_ids支持
GET /v1_1/{library_id}/resources/by_asset_folder支持
GET /v1_1/{library_id}/resources/{resource_type}/tags/{tag}支持
GET /v1_1/{library_id}/resources/{resource_type}/context支持
GET /v1_1/{library_id}/resources/{resource_type}/upload/{public_id}支持
POST /v1_1/{library_id}/resources/by_asset_ids支持
POST /v1_1/{library_id}/resources/{resource_type}/upload/{public_id}支持
PUT /v1_1/{library_id}/resources/{resource_type}/upload/{public_id}支持
DELETE /v1_1/{library_id}/resources/{resource_type}/upload支持
DELETE /v1_1/{library_id}/resources/{resource_type}/tags/{tag}支持
GET /v1_1/{library_id}/tags/{resource_type}支持
GET /v1_1/{library_id}/folders支持
GET /v1_1/{library_id}/folders/{folder}支持
POST /v1_1/{library_id}/folders/{folder}支持
PUT /v1_1/{library_id}/folders/{folder}支持
DELETE /v1_1/{library_id}/folders/{folder}支持
GET /v1_1/{library_id}/ping支持
GET /v1_1/{library_id}/usage部分支持
GET /v1_1/{library_id}/usage/{date}部分支持

usage 只返回当前存储字节数与素材数,日期不选择历史统计。

不支持的操作

端点HTTP
upload_presets400
metadata_fields400
transformations400
streaming_profiles400
upload_mappings400
triggers400
derived_resources400
relations400
restore400
backups400
text400
sprite400
multi400
explode400
generate_archive400
create_slideshow400
download_backup_asset400
folders/search400

上述端点错误消息含 is not supported;private 与 authenticated 交付类型也返回 400。

上传参数

参数支持
file支持
public_id支持
public_id_prefix支持
display_name支持
asset_folder支持
use_filename支持
unique_filename支持
use_filename_as_display_name支持
filename_override支持
overwrite支持
tags支持
context支持
auto_tagging部分支持
resource_type支持
eager不支持
eager_async不支持
eager_notification_url不支持
async不支持
notification_url不支持
upload_preset不支持
moderation不支持
detection不支持
ocr不支持
raw_convert不支持
background_removal不支持
categorization不支持
transformation不支持
responsive_breakpoints不支持
proxy不支持
backup不支持
return_delete_token不支持
access_control不支持
access_mode不支持
metadata不支持
face_coordinates不支持
custom_coordinates不支持
regions不支持
quality_analysis不支持
accessibility_analysis不支持
cinemagraph_analysis不支持
media_metadata不支持
phash不支持
colors不支持
faces不支持
image_metadata不支持
exif不支持
invalidate不支持
type不支持

不支持的上传参数返回 400,消息为 Unsupported upload parameter: 参数名。

错误体与错误码

上传与管理

官方 SDK 的 upload("file_…") 会把字符串当作本地路径。从文件导入请使用自有接口 POST /media/v1/libraries/{library_id}/assets/import,见导入文件。

指南 →

上传接受文件字节、HTTPS URL 或 data URI。音频使用 video,自动识别使用 auto。SDK 的 upload_large 将分片发送到同一 upload 端点。

tags 可写成逗号分隔字符串、数组或多个 tags 字段(-F tags=a -F tags=b),三者等价;逗号分隔时每项去首尾空白并丢弃空项。0 字节文件返回 FILE_EMPTY;读不出宽高的图片返回 Invalid image file;其他任意文件作为 raw 接受。

await new Promise((resolve, reject) => {
  cloudinary.uploader.upload_large("./video.mp4", {
    resource_type: "video",
    chunk_size: 20 * 1024 * 1024,
  }, (error, result) => error ? reject(error) : resolve(result));
});

每片共享 X-Unique-Upload-Id。Content-Range 为 bytes 起点-终点/总字节数;未知总数用 -1,末片给最终大小。非末片至少 5 MiB 且等长。会话有效期 24 小时。中间片返回 done=false 与 upload_id;末片返回素材和 done=true。

指南 →

基础地址与鉴权

上传素材

POST /cloudinary/v1_1/{library_id}/{resource_type}/upload

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / raw / autoimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
X-Unique-Upload-Idheaderstring—
Content-Rangeheaderstring—

请求体

字段类型必填说明
filestring / string是文件字节、HTTPS URL、data URI 或同账户 file_…
public_idstring否交付地址中的素材名称,可带路径
public_id_prefixstring否public_id 的路径前缀;末尾的 / 可有可无,前缀与 ID 之间只保留一个 /
display_namestring否显示名称
asset_folderstring否组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
use_filenameboolean否用文件名生成 public_id
unique_filenameboolean否自动附加唯一后缀
use_filename_as_display_nameboolean否用文件名作为显示名称
filename_overridestring否覆盖原文件名称
overwriteboolean否是否覆盖同名素材
tagsstring / string[]否素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextstring / object否自定义文字键值;PATCH 整体替换,传 {} 清空
auto_taggingnumber否理解后将达到阈值的标签合并;0–1
resource_typeResourceType / "auto"否image、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400

返回: CloudinaryResource.

响应

HTTP 200

Successful response.

application/json

名称类型说明
asset_idstring
public_idstring
display_namestring
asset_folderstring
resource_typestring
typestring
formatstring
versionnumber
version_idstring
bytesnumber
etagstring
widthnumber
heightnumber
durationnumber
pagesnumber
is_audioboolean
original_filenamestring
tagsarray<string>
contextobject
context.customobject
created_atstring
urlstring
secure_urlstring
placeholderboolean
existingboolean
processingobject
processing.statestring
processing.kindsobject
processing.updated_atstring
doneboolean
upload_idstring
curl -X POST "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/image/upload" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"file":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==","public_id":"walk-lib-r1-MDP-1791733789929-plain","tags":["docs"]}'

HTTP 200

{
  "asset_id": "85b7ef616a8b4719a41777a036ebc1d2",
  "public_id": "walk-lib-r1-MDP-1791733789929-plain",
  "display_name": "walk-lib-r1-MDP-1791733789929-plain",
  "asset_folder": "",
  "resource_type": "image",
  "type": "upload",
  "format": "png",
  "version": 1791733810,
  "version_id": "fdf3c8cd40c2424d86e8397425a69857",
  "bytes": 70,
  "etag": "b357a19c87624c7c4d131aeeb4ae677f",
  "width": 1,
  "height": 1,
  "original_filename": "file",
  "tags": [
    "docs"
  ],
  "created_at": "2026-10-11T15:50:10.842Z",
  "url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733810/walk-lib-r1-MDP-1791733789929-plain.png",
  "secure_url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733810/walk-lib-r1-MDP-1791733789929-plain.png",
  "placeholder": false
}

删除素材

POST /cloudinary/v1_1/{library_id}/{resource_type}/destroy

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / raw / autoimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400

请求体

字段类型必填说明
public_idstring是交付地址中的素材名称,可带路径

返回: DestroyResult.

响应

HTTP 200

Successful response.

application/json

名称类型说明
resultstring
curl -X POST "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/image/destroy" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"public_id":"docs/renamed"}'

HTTP 200

{
  "result": "ok"
}

重命名

POST /cloudinary/v1_1/{library_id}/{resource_type}/rename

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / raw / autoimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400

请求体

字段类型必填说明
from_public_idstring是原 public_id
to_public_idstring是新 public_id
overwriteboolean否是否覆盖同名素材

返回: CloudinaryResource.

响应

HTTP 200

Successful response.

application/json

名称类型说明
asset_idstring
public_idstring
display_namestring
asset_folderstring
resource_typestring
typestring
formatstring
versionnumber
version_idstring
bytesnumber
etagstring
widthnumber
heightnumber
durationnumber
pagesnumber
is_audioboolean
original_filenamestring
tagsarray<string>
contextobject
context.customobject
created_atstring
urlstring
secure_urlstring
placeholderboolean
existingboolean
processingobject
processing.statestring
processing.kindsobject
processing.updated_atstring
curl -X POST "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/image/rename" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"from_public_id":"docs/pixel","to_public_id":"docs/renamed"}'

HTTP 200

{
  "asset_id": "9339cdae93804c0c8c65d5189ef1f646",
  "public_id": "docs/renamed",
  "display_name": "Sample image",
  "asset_folder": "examples",
  "resource_type": "image",
  "type": "upload",
  "format": "png",
  "version": 1791538418,
  "version_id": "35848c1529994e338e7aa634a1c13d9c",
  "bytes": 70,
  "etag": "b357a19c87624c7c4d131aeeb4ae677f",
  "width": 1,
  "height": 1,
  "original_filename": "file",
  "tags": [
    "docs"
  ],
  "context": {
    "custom": {
      "alt": "Sample"
    }
  },
  "created_at": "2026-10-09T09:33:38.899Z",
  "url": "https://media-develop.praxisusercontent.com/lib_77374d4ee73b4ae79c4aa430f3ba3885/image/upload/v1791538418/docs/renamed.png",
  "secure_url": "https://media-develop.praxisusercontent.com/lib_77374d4ee73b4ae79c4aa430f3ba3885/image/upload/v1791538418/docs/renamed.png",
  "placeholder": false
}

修改标签

POST /cloudinary/v1_1/{library_id}/{resource_type}/tags

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / raw / autoimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400

请求体

字段类型必填说明
public_idsstring[]是素材 public_id 列表
tagstring否标签名称
commandadd / remove / replace / remove_all是标签或上下文操作

返回: PublicIds.

响应

HTTP 200

Successful response.

application/json

名称类型说明
public_idsarray<string>
curl -X POST "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/image/tags" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"public_ids":["docs/pixel"],"tag":"sample","command":"add"}'

HTTP 200

{
  "public_ids": [
    "docs/pixel"
  ]
}

修改上下文

POST /cloudinary/v1_1/{library_id}/{resource_type}/context

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / raw / autoimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400

请求体

字段类型必填说明
public_idsstring[]是素材 public_id 列表
contextstring / object否自定义文字键值;PATCH 整体替换,传 {} 清空
commandadd / remove_all是标签或上下文操作

返回: PublicIds.

响应

HTTP 200

Successful response.

application/json

名称类型说明
public_idsarray<string>
curl -X POST "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/image/context" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"public_ids":["docs/pixel"],"context":"alt=Sample","command":"add"}'

HTTP 200

{
  "public_ids": [
    "docs/pixel"
  ]
}

更新素材

POST /cloudinary/v1_1/{library_id}/{resource_type}/explicit

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / raw / autoimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400

请求体

字段类型必填说明
public_idstring是交付地址中的素材名称,可带路径
tagsstring / string[]否素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextstring / object否自定义文字键值;PATCH 整体替换,传 {} 清空

返回: CloudinaryResource.

响应

HTTP 200

Successful response.

application/json

名称类型说明
asset_idstring
public_idstring
display_namestring
asset_folderstring
resource_typestring
typestring
formatstring
versionnumber
version_idstring
bytesnumber
etagstring
widthnumber
heightnumber
durationnumber
pagesnumber
is_audioboolean
original_filenamestring
tagsarray<string>
contextobject
context.customobject
created_atstring
urlstring
secure_urlstring
placeholderboolean
existingboolean
processingobject
processing.statestring
processing.kindsobject
processing.updated_atstring
curl -X POST "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/image/explicit" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"public_id":"docs/pixel","tags":["docs"]}'

HTTP 200

{
  "asset_id": "9339cdae93804c0c8c65d5189ef1f646",
  "public_id": "docs/pixel",
  "display_name": "Sample image",
  "asset_folder": "examples",
  "resource_type": "image",
  "type": "upload",
  "format": "png",
  "version": 1791538418,
  "version_id": "35848c1529994e338e7aa634a1c13d9c",
  "bytes": 70,
  "etag": "b357a19c87624c7c4d131aeeb4ae677f",
  "width": 1,
  "height": 1,
  "original_filename": "file",
  "tags": [
    "docs"
  ],
  "context": {
    "custom": {
      "alt": "Sample"
    }
  },
  "created_at": "2026-10-09T09:33:38.899Z",
  "url": "https://media-develop.praxisusercontent.com/lib_77374d4ee73b4ae79c4aa430f3ba3885/image/upload/v1791538418/docs/pixel.png",
  "secure_url": "https://media-develop.praxisusercontent.com/lib_77374d4ee73b4ae79c4aa430f3ba3885/image/upload/v1791538418/docs/pixel.png",
  "placeholder": false
}

CloudinaryResource

字段类型必填说明
asset_idAssetId是素材 ID
public_idstring是交付地址中的素材名称,可带路径
display_namestring是显示名称
asset_folderstring是组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
resource_typeResourceType是image、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
typeDeliveryType是资源或事件类型
formatstring是文件格式
versionnumber是交付版本号
version_idstring是版本标识
bytesnumber是文件字节数
etagstring是文件校验标识
widthnumber否宽度像素
heightnumber否高度像素
durationnumber否时长秒数
pagesnumber否文档页数
is_audioboolean否是否为音频
original_filenamestring否原文件名称
tagsstring[]是素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextobject否自定义文字键值;PATCH 整体替换,传 {} 清空
created_atIsoTimestamp是创建时间
urlstring是原文件地址
secure_urlstring是HTTPS 交付地址
placeholderfalse是固定为 false
existingboolean否未覆盖时是否返回已有素材
processingProcessing否整体与各项理解状态

DestroyResult

字段类型必填说明
resultok / not found是操作结果

PublicIds

字段类型必填说明
public_idsstring[]是素材 public_id 列表

ChunkPending

字段类型必填说明
donefalse是已完成数量;分片响应中表示是否完成
upload_idstring是分片会话标识

ChunkComplete

字段类型必填说明
asset_idAssetId是素材 ID
public_idstring是交付地址中的素材名称,可带路径
display_namestring是显示名称
asset_folderstring是组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
resource_typeResourceType是image、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
typeDeliveryType是资源或事件类型
formatstring是文件格式
versionnumber是交付版本号
version_idstring是版本标识
bytesnumber是文件字节数
etagstring是文件校验标识
widthnumber否宽度像素
heightnumber否高度像素
durationnumber否时长秒数
pagesnumber否文档页数
is_audioboolean否是否为音频
original_filenamestring否原文件名称
tagsstring[]是素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextobject否自定义文字键值;PATCH 整体替换,传 {} 清空
created_atIsoTimestamp是创建时间
urlstring是原文件地址
secure_urlstring是HTTPS 交付地址
placeholderfalse是固定为 false
existingboolean否未覆盖时是否返回已有素材
processingProcessing否整体与各项理解状态
字段类型必填说明
donetrue是已完成数量;分片响应中表示是否完成

资源管理

Admin 管理当前库的素材。usage 只返回当前存储量和素材数。

指南 →

基础地址与鉴权

读取素材

GET /cloudinary/v1_1/{library_id}/resources

参数位置类型说明
library_idpathstring库 ID
prefixquerystring—
public_idsquerystring[]素材 public_id 列表
asset_idsquerystring[]—
asset_folderquerystring组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
keyquerystring—
valuequerystring—
tagsquerystring素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextquerystring自定义文字键值;PATCH 整体替换,传 {} 清空
directionquerystring—
max_resultsqueryinteger最多 500;检索默认 100,Admin 默认 10
next_cursorquerystring下一页游标;没有时为 null 或省略

返回: ResourcePage.

响应

HTTP 200

Successful response.

application/json

名称类型说明
resourcesarray<object>
resources[].asset_idstring
resources[].public_idstring
resources[].display_namestring
resources[].asset_folderstring
resources[].resource_typestring
resources[].typestring
resources[].formatstring
resources[].versionnumber
resources[].version_idstring
resources[].bytesnumber
resources[].etagstring
resources[].widthnumber
resources[].heightnumber
resources[].durationnumber
resources[].pagesnumber
resources[].is_audioboolean
resources[].original_filenamestring
resources[].tagsarray<string>
resources[].contextobject
resources[].created_atstring
resources[].urlstring
resources[].secure_urlstring
resources[].placeholderboolean
resources[].existingboolean
resources[].processingobject
next_cursorstring
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "resources": [
    {
      "asset_id": "9dfa312ef9bc4b00816339b598b1152c",
      "public_id": "walk-lib-r1-MDP-1791733789929-tagged",
      "display_name": "walk-lib-r1-MDP-1791733789929-tagged",
      "asset_folder": "",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791733815,
      "version_id": "26cb8171caa5431b8373ad417fd71e32",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "processing": {
        "state": "processing",
        "kinds": {
          "embedding": "running",
          "visual": "failed",
          "tagging": "failed"
        },
        "updated_at": "2026-10-11T15:50:21.512Z"
      },
      "created_at": "2026-10-11T15:50:15.996Z",
      "url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733815/walk-lib-r1-MDP-1791733789929-tagged.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733815/walk-lib-r1-MDP-1791733789929-tagged.png",
      "placeholder": false
    },
    {
      "asset_id": "85b7ef616a8b4719a41777a036ebc1d2",
      "public_id": "walk-lib-r1-MDP-1791733789929-plain",
      "display_name": "walk-lib-r1-MDP-1791733789929-plain",
      "asset_folder": "",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791733810,
      "version_id": "fdf3c8cd40c2424d86e8397425a69857",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "created_at": "2026-10-11T15:50:10.842Z",
      "url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733810/walk-lib-r1-MDP-1791733789929-plain.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733810/walk-lib-r1-MDP-1791733789929-plain.png",
      "placeholder": false
    }
  ]
}

读取素材

GET /cloudinary/v1_1/{library_id}/resources/{resource_type}

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / rawimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
prefixquerystring—
public_idsquerystring[]素材 public_id 列表
asset_idsquerystring[]—
asset_folderquerystring组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
keyquerystring—
valuequerystring—
tagsquerystring素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextquerystring自定义文字键值;PATCH 整体替换,传 {} 清空
directionquerystring—
max_resultsqueryinteger最多 500;检索默认 100,Admin 默认 10
next_cursorquerystring下一页游标;没有时为 null 或省略

返回: ResourcePage.

响应

HTTP 200

Successful response.

application/json

名称类型说明
resourcesarray<object>
resources[].asset_idstring
resources[].public_idstring
resources[].display_namestring
resources[].asset_folderstring
resources[].resource_typestring
resources[].typestring
resources[].formatstring
resources[].versionnumber
resources[].version_idstring
resources[].bytesnumber
resources[].etagstring
resources[].widthnumber
resources[].heightnumber
resources[].durationnumber
resources[].pagesnumber
resources[].is_audioboolean
resources[].original_filenamestring
resources[].tagsarray<string>
resources[].contextobject
resources[].created_atstring
resources[].urlstring
resources[].secure_urlstring
resources[].placeholderboolean
resources[].existingboolean
resources[].processingobject
next_cursorstring
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/image" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "resources": [
    {
      "asset_id": "e5f3de0d8609482d8b351894b133c8cb",
      "public_id": "examples/pixel",
      "display_name": "pixel",
      "asset_folder": "examples",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791538435,
      "version_id": "001fb6336c9b4a4c9e4597b69fdec3cd",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "created_at": "2026-10-09T09:33:55.536Z",
      "url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
      "placeholder": false
    }
  ]
}

读取素材

GET /cloudinary/v1_1/{library_id}/resources/{resource_type}/upload

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / rawimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
prefixquerystring—
public_idsquerystring[]素材 public_id 列表
asset_idsquerystring[]—
asset_folderquerystring组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
keyquerystring—
valuequerystring—
tagsquerystring素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextquerystring自定义文字键值;PATCH 整体替换,传 {} 清空
directionquerystring—
max_resultsqueryinteger最多 500;检索默认 100,Admin 默认 10
next_cursorquerystring下一页游标;没有时为 null 或省略

返回: ResourcePage.

响应

HTTP 200

Successful response.

application/json

名称类型说明
resourcesarray<object>
resources[].asset_idstring
resources[].public_idstring
resources[].display_namestring
resources[].asset_folderstring
resources[].resource_typestring
resources[].typestring
resources[].formatstring
resources[].versionnumber
resources[].version_idstring
resources[].bytesnumber
resources[].etagstring
resources[].widthnumber
resources[].heightnumber
resources[].durationnumber
resources[].pagesnumber
resources[].is_audioboolean
resources[].original_filenamestring
resources[].tagsarray<string>
resources[].contextobject
resources[].created_atstring
resources[].urlstring
resources[].secure_urlstring
resources[].placeholderboolean
resources[].existingboolean
resources[].processingobject
next_cursorstring
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/image/upload" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "resources": [
    {
      "asset_id": "e5f3de0d8609482d8b351894b133c8cb",
      "public_id": "examples/pixel",
      "display_name": "pixel",
      "asset_folder": "examples",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791538435,
      "version_id": "001fb6336c9b4a4c9e4597b69fdec3cd",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "created_at": "2026-10-09T09:33:55.536Z",
      "url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
      "placeholder": false
    }
  ]
}

读取素材

GET /cloudinary/v1_1/{library_id}/resources/{asset_id}

参数位置类型说明
library_idpathstring库 ID
asset_idpathstring素材 ID
prefixquerystring—
public_idsquerystring[]素材 public_id 列表
asset_idsquerystring[]—
asset_folderquerystring组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
keyquerystring—
valuequerystring—
tagsquerystring素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextquerystring自定义文字键值;PATCH 整体替换,传 {} 清空
directionquerystring—
max_resultsqueryinteger最多 500;检索默认 100,Admin 默认 10
next_cursorquerystring下一页游标;没有时为 null 或省略

返回: CloudinaryResource.

响应

HTTP 200

Successful response.

application/json

名称类型说明
asset_idstring
public_idstring
display_namestring
asset_folderstring
resource_typestring
typestring
formatstring
versionnumber
version_idstring
bytesnumber
etagstring
widthnumber
heightnumber
durationnumber
pagesnumber
is_audioboolean
original_filenamestring
tagsarray<string>
contextobject
context.customobject
created_atstring
urlstring
secure_urlstring
placeholderboolean
existingboolean
processingobject
processing.statestring
processing.kindsobject
processing.updated_atstring
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/9dfa312ef9bc4b00816339b598b1152c" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "asset_id": "9dfa312ef9bc4b00816339b598b1152c",
  "public_id": "walk-lib-r1-MDP-1791733789929-tagged",
  "display_name": "walk-lib-r1-MDP-1791733789929-tagged",
  "asset_folder": "",
  "resource_type": "image",
  "type": "upload",
  "format": "png",
  "version": 1791733815,
  "version_id": "26cb8171caa5431b8373ad417fd71e32",
  "bytes": 70,
  "etag": "b357a19c87624c7c4d131aeeb4ae677f",
  "width": 1,
  "height": 1,
  "original_filename": "file",
  "tags": [
    "docs"
  ],
  "processing": {
    "state": "processing",
    "kinds": {
      "embedding": "running",
      "visual": "failed",
      "tagging": "failed"
    },
    "updated_at": "2026-10-11T15:50:21.512Z"
  },
  "created_at": "2026-10-11T15:50:15.996Z",
  "url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733815/walk-lib-r1-MDP-1791733789929-tagged.png",
  "secure_url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733815/walk-lib-r1-MDP-1791733789929-tagged.png",
  "placeholder": false
}

读取素材

GET /cloudinary/v1_1/{library_id}/resources/by_asset_ids

参数位置类型说明
library_idpathstring库 ID
prefixquerystring—
public_idsquerystring[]素材 public_id 列表
asset_idsquerystring[]—
asset_folderquerystring组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
keyquerystring—
valuequerystring—
tagsquerystring素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextquerystring自定义文字键值;PATCH 整体替换,传 {} 清空
directionquerystring—
max_resultsqueryinteger最多 500;检索默认 100,Admin 默认 10
next_cursorquerystring下一页游标;没有时为 null 或省略

返回: ResourcePage.

响应

HTTP 200

Successful response.

application/json

名称类型说明
resourcesarray<object>
resources[].asset_idstring
resources[].public_idstring
resources[].display_namestring
resources[].asset_folderstring
resources[].resource_typestring
resources[].typestring
resources[].formatstring
resources[].versionnumber
resources[].version_idstring
resources[].bytesnumber
resources[].etagstring
resources[].widthnumber
resources[].heightnumber
resources[].durationnumber
resources[].pagesnumber
resources[].is_audioboolean
resources[].original_filenamestring
resources[].tagsarray<string>
resources[].contextobject
resources[].created_atstring
resources[].urlstring
resources[].secure_urlstring
resources[].placeholderboolean
resources[].existingboolean
resources[].processingobject
next_cursorstring
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/by_asset_ids?asset_ids[]=e5f3de0d8609482d8b351894b133c8cb" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "resources": [
    {
      "asset_id": "e5f3de0d8609482d8b351894b133c8cb",
      "public_id": "examples/pixel",
      "display_name": "pixel",
      "asset_folder": "examples",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791538435,
      "version_id": "001fb6336c9b4a4c9e4597b69fdec3cd",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "created_at": "2026-10-09T09:33:55.536Z",
      "url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
      "placeholder": false
    }
  ]
}

读取素材

GET /cloudinary/v1_1/{library_id}/resources/by_asset_folder

参数位置类型说明
library_idpathstring库 ID
prefixquerystring—
public_idsquerystring[]素材 public_id 列表
asset_idsquerystring[]—
asset_folderquerystring组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
keyquerystring—
valuequerystring—
tagsquerystring素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextquerystring自定义文字键值;PATCH 整体替换,传 {} 清空
directionquerystring—
max_resultsqueryinteger最多 500;检索默认 100,Admin 默认 10
next_cursorquerystring下一页游标;没有时为 null 或省略

返回: ResourcePage.

响应

HTTP 200

Successful response.

application/json

名称类型说明
resourcesarray<object>
resources[].asset_idstring
resources[].public_idstring
resources[].display_namestring
resources[].asset_folderstring
resources[].resource_typestring
resources[].typestring
resources[].formatstring
resources[].versionnumber
resources[].version_idstring
resources[].bytesnumber
resources[].etagstring
resources[].widthnumber
resources[].heightnumber
resources[].durationnumber
resources[].pagesnumber
resources[].is_audioboolean
resources[].original_filenamestring
resources[].tagsarray<string>
resources[].contextobject
resources[].created_atstring
resources[].urlstring
resources[].secure_urlstring
resources[].placeholderboolean
resources[].existingboolean
resources[].processingobject
next_cursorstring
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/by_asset_folder?asset_folder=examples" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "resources": [
    {
      "asset_id": "e5f3de0d8609482d8b351894b133c8cb",
      "public_id": "examples/pixel",
      "display_name": "pixel",
      "asset_folder": "examples",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791538435,
      "version_id": "001fb6336c9b4a4c9e4597b69fdec3cd",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "created_at": "2026-10-09T09:33:55.536Z",
      "url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
      "placeholder": false
    }
  ]
}

读取素材

GET /cloudinary/v1_1/{library_id}/resources/{resource_type}/tags/{tag}

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / rawimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
tagpathstring标签名称
prefixquerystring—
public_idsquerystring[]素材 public_id 列表
asset_idsquerystring[]—
asset_folderquerystring组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
keyquerystring—
valuequerystring—
tagsquerystring素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextquerystring自定义文字键值;PATCH 整体替换,传 {} 清空
directionquerystring—
max_resultsqueryinteger最多 500;检索默认 100,Admin 默认 10
next_cursorquerystring下一页游标;没有时为 null 或省略

返回: ResourcePage.

响应

HTTP 200

Successful response.

application/json

名称类型说明
resourcesarray<object>
resources[].asset_idstring
resources[].public_idstring
resources[].display_namestring
resources[].asset_folderstring
resources[].resource_typestring
resources[].typestring
resources[].formatstring
resources[].versionnumber
resources[].version_idstring
resources[].bytesnumber
resources[].etagstring
resources[].widthnumber
resources[].heightnumber
resources[].durationnumber
resources[].pagesnumber
resources[].is_audioboolean
resources[].original_filenamestring
resources[].tagsarray<string>
resources[].contextobject
resources[].created_atstring
resources[].urlstring
resources[].secure_urlstring
resources[].placeholderboolean
resources[].existingboolean
resources[].processingobject
next_cursorstring
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/image/tags/docs" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "resources": [
    {
      "asset_id": "e5f3de0d8609482d8b351894b133c8cb",
      "public_id": "examples/pixel",
      "display_name": "pixel",
      "asset_folder": "examples",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791538435,
      "version_id": "001fb6336c9b4a4c9e4597b69fdec3cd",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "created_at": "2026-10-09T09:33:55.536Z",
      "url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
      "placeholder": false
    }
  ]
}

读取素材

GET /cloudinary/v1_1/{library_id}/resources/{resource_type}/context

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / rawimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
prefixquerystring—
public_idsquerystring[]素材 public_id 列表
asset_idsquerystring[]—
asset_folderquerystring组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
keyquerystring—
valuequerystring—
tagsquerystring素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextquerystring自定义文字键值;PATCH 整体替换,传 {} 清空
directionquerystring—
max_resultsqueryinteger最多 500;检索默认 100,Admin 默认 10
next_cursorquerystring下一页游标;没有时为 null 或省略

返回: ResourcePage.

响应

HTTP 200

Successful response.

application/json

名称类型说明
resourcesarray<object>
resources[].asset_idstring
resources[].public_idstring
resources[].display_namestring
resources[].asset_folderstring
resources[].resource_typestring
resources[].typestring
resources[].formatstring
resources[].versionnumber
resources[].version_idstring
resources[].bytesnumber
resources[].etagstring
resources[].widthnumber
resources[].heightnumber
resources[].durationnumber
resources[].pagesnumber
resources[].is_audioboolean
resources[].original_filenamestring
resources[].tagsarray<string>
resources[].contextobject
resources[].created_atstring
resources[].urlstring
resources[].secure_urlstring
resources[].placeholderboolean
resources[].existingboolean
resources[].processingobject
next_cursorstring
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/image/context?key=alt&value=sample" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "resources": [
    {
      "asset_id": "e5f3de0d8609482d8b351894b133c8cb",
      "public_id": "examples/pixel",
      "display_name": "pixel",
      "asset_folder": "examples",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791538435,
      "version_id": "001fb6336c9b4a4c9e4597b69fdec3cd",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "created_at": "2026-10-09T09:33:55.536Z",
      "url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
      "placeholder": false
    }
  ]
}

读取素材

GET /cloudinary/v1_1/{library_id}/resources/{resource_type}/upload/{public_id}

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / rawimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
public_idpathstring交付地址中的素材名称,可带路径
prefixquerystring—
public_idsquerystring[]素材 public_id 列表
asset_idsquerystring[]—
asset_folderquerystring组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
keyquerystring—
valuequerystring—
tagsquerystring素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextquerystring自定义文字键值;PATCH 整体替换,传 {} 清空
directionquerystring—
max_resultsqueryinteger最多 500;检索默认 100,Admin 默认 10
next_cursorquerystring下一页游标;没有时为 null 或省略

返回: CloudinaryResource.

响应

HTTP 200

Successful response.

application/json

名称类型说明
asset_idstring
public_idstring
display_namestring
asset_folderstring
resource_typestring
typestring
formatstring
versionnumber
version_idstring
bytesnumber
etagstring
widthnumber
heightnumber
durationnumber
pagesnumber
is_audioboolean
original_filenamestring
tagsarray<string>
contextobject
context.customobject
created_atstring
urlstring
secure_urlstring
placeholderboolean
existingboolean
processingobject
processing.statestring
processing.kindsobject
processing.updated_atstring
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/image/upload/examples/pixel" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "asset_id": "e5f3de0d8609482d8b351894b133c8cb",
  "public_id": "examples/pixel",
  "display_name": "pixel",
  "asset_folder": "examples",
  "resource_type": "image",
  "type": "upload",
  "format": "png",
  "version": 1791538435,
  "version_id": "001fb6336c9b4a4c9e4597b69fdec3cd",
  "bytes": 70,
  "etag": "b357a19c87624c7c4d131aeeb4ae677f",
  "width": 1,
  "height": 1,
  "original_filename": "file",
  "tags": [
    "docs"
  ],
  "context": {
    "custom": {
      "alt": "sample"
    }
  },
  "created_at": "2026-10-09T09:33:55.536Z",
  "url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
  "secure_url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
  "placeholder": false
}

按 ID 读取

POST /cloudinary/v1_1/{library_id}/resources/by_asset_ids

参数位置类型说明
library_idpathstring库 ID

请求体

字段类型必填说明
asset_idsstring[]是—
max_resultsinteger否最多 500;检索默认 100,Admin 默认 10
next_cursorstring否下一页游标;没有时为 null 或省略

返回: ResourcePage.

响应

HTTP 200

Successful response.

application/json

名称类型说明
resourcesarray<object>
resources[].asset_idstring
resources[].public_idstring
resources[].display_namestring
resources[].asset_folderstring
resources[].resource_typestring
resources[].typestring
resources[].formatstring
resources[].versionnumber
resources[].version_idstring
resources[].bytesnumber
resources[].etagstring
resources[].widthnumber
resources[].heightnumber
resources[].durationnumber
resources[].pagesnumber
resources[].is_audioboolean
resources[].original_filenamestring
resources[].tagsarray<string>
resources[].contextobject
resources[].created_atstring
resources[].urlstring
resources[].secure_urlstring
resources[].placeholderboolean
resources[].existingboolean
resources[].processingobject
next_cursorstring
curl -X POST "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/by_asset_ids" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"asset_ids":["e5f3de0d8609482d8b351894b133c8cb"]}'

HTTP 200

{
  "resources": [
    {
      "asset_id": "e5f3de0d8609482d8b351894b133c8cb",
      "public_id": "examples/pixel",
      "display_name": "pixel",
      "asset_folder": "examples",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791538435,
      "version_id": "001fb6336c9b4a4c9e4597b69fdec3cd",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "created_at": "2026-10-09T09:33:55.536Z",
      "url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
      "placeholder": false
    }
  ]
}

更新素材

POST /cloudinary/v1_1/{library_id}/resources/{resource_type}/upload/{public_id}

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / rawimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
public_idpathstring交付地址中的素材名称,可带路径

请求体

字段类型必填说明
display_namestring否显示名称
asset_folderstring否组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
tagsstring[]否素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextobject否自定义文字键值;PATCH 整体替换,传 {} 清空

返回: CloudinaryResource.

响应

HTTP 200

Successful response.

application/json

名称类型说明
asset_idstring
public_idstring
display_namestring
asset_folderstring
resource_typestring
typestring
formatstring
versionnumber
version_idstring
bytesnumber
etagstring
widthnumber
heightnumber
durationnumber
pagesnumber
is_audioboolean
original_filenamestring
tagsarray<string>
contextobject
context.customobject
created_atstring
urlstring
secure_urlstring
placeholderboolean
existingboolean
processingobject
processing.statestring
processing.kindsobject
processing.updated_atstring
curl -X POST "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/image/upload/examples/pixel" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"display_name":"Sample image"}'

HTTP 200

{
  "asset_id": "e5f3de0d8609482d8b351894b133c8cb",
  "public_id": "examples/pixel",
  "display_name": "Sample image",
  "asset_folder": "examples",
  "resource_type": "image",
  "type": "upload",
  "format": "png",
  "version": 1791538435,
  "version_id": "001fb6336c9b4a4c9e4597b69fdec3cd",
  "bytes": 70,
  "etag": "b357a19c87624c7c4d131aeeb4ae677f",
  "width": 1,
  "height": 1,
  "original_filename": "file",
  "tags": [
    "docs"
  ],
  "context": {
    "custom": {
      "alt": "sample"
    }
  },
  "created_at": "2026-10-09T09:33:55.536Z",
  "url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
  "secure_url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
  "placeholder": false
}

更新素材

PUT /cloudinary/v1_1/{library_id}/resources/{resource_type}/upload/{public_id}

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / rawimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
public_idpathstring交付地址中的素材名称,可带路径

请求体

字段类型必填说明
display_namestring否显示名称
asset_folderstring否组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
tagsstring[]否素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextobject否自定义文字键值;PATCH 整体替换,传 {} 清空

返回: CloudinaryResource.

响应

HTTP 200

Successful response.

application/json

名称类型说明
asset_idstring
public_idstring
display_namestring
asset_folderstring
resource_typestring
typestring
formatstring
versionnumber
version_idstring
bytesnumber
etagstring
widthnumber
heightnumber
durationnumber
pagesnumber
is_audioboolean
original_filenamestring
tagsarray<string>
contextobject
context.customobject
created_atstring
urlstring
secure_urlstring
placeholderboolean
existingboolean
processingobject
processing.statestring
processing.kindsobject
processing.updated_atstring
curl -X PUT "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/image/upload/examples/pixel" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"tags":["docs"]}'

HTTP 200

{
  "asset_id": "e5f3de0d8609482d8b351894b133c8cb",
  "public_id": "examples/pixel",
  "display_name": "Sample image",
  "asset_folder": "examples",
  "resource_type": "image",
  "type": "upload",
  "format": "png",
  "version": 1791538435,
  "version_id": "001fb6336c9b4a4c9e4597b69fdec3cd",
  "bytes": 70,
  "etag": "b357a19c87624c7c4d131aeeb4ae677f",
  "width": 1,
  "height": 1,
  "original_filename": "file",
  "tags": [
    "docs"
  ],
  "context": {
    "custom": {
      "alt": "sample"
    }
  },
  "created_at": "2026-10-09T09:33:55.536Z",
  "url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
  "secure_url": "https://media-develop.praxisusercontent.com/lib_b762c40631bd42278a204cd0370fed36/image/upload/v1791538435/examples/pixel.png",
  "placeholder": false
}

删除素材

DELETE /cloudinary/v1_1/{library_id}/resources/{resource_type}/upload

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / rawimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
public_idsquerystring[]素材 public_id 列表
prefixquerystring—
allqueryboolean—
next_cursorquerystring下一页游标;没有时为 null 或省略

返回: DeletedResources.

响应

HTTP 200

Successful response.

application/json

名称类型说明
deletedobject
partialboolean
next_cursorstring
curl -X DELETE "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/image/upload" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"prefix":"imported/"}'

HTTP 200

{
  "deleted": {},
  "partial": false
}

删除素材

DELETE /cloudinary/v1_1/{library_id}/resources/{resource_type}/tags/{tag}

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / rawimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
tagpathstring标签名称
public_idsquerystring[]素材 public_id 列表
prefixquerystring—
allqueryboolean—
next_cursorquerystring下一页游标;没有时为 null 或省略

返回: DeletedResources.

响应

HTTP 200

Successful response.

application/json

名称类型说明
deletedobject
partialboolean
next_cursorstring
curl -X DELETE "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/image/tags/remove-me" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{}'

HTTP 200

{
  "deleted": {
    "tagged/pixel": "deleted"
  },
  "partial": false
}

列出标签

GET /cloudinary/v1_1/{library_id}/tags/{resource_type}

参数位置类型说明
library_idpathstring库 ID
resource_typepathimage / video / rawimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
prefixquerystring—
max_resultsqueryinteger最多 500;检索默认 100,Admin 默认 10
next_cursorquerystring下一页游标;没有时为 null 或省略

返回: Tags.

响应

HTTP 200

Successful response.

application/json

名称类型说明
tagsarray<string>
next_cursorstring
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/tags/image" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "tags": [
    "docs"
  ]
}

列出文件夹

GET /cloudinary/v1_1/{library_id}/folders

参数位置类型说明
library_idpathstring库 ID
max_resultsqueryinteger最多 500;检索默认 100,Admin 默认 10
next_cursorquerystring下一页游标;没有时为 null 或省略

返回: CompatFolders.

响应

HTTP 200

Successful response.

application/json

名称类型说明
foldersarray<object>
folders[].namestring
folders[].pathstring
total_countnumber
next_cursorstring
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/folders" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "folders": [
    {
      "name": "examples",
      "path": "examples"
    }
  ],
  "total_count": 1
}

列出文件夹

GET /cloudinary/v1_1/{library_id}/folders/{folder}

参数位置类型说明
library_idpathstring库 ID
folderpathstring—
max_resultsqueryinteger最多 500;检索默认 100,Admin 默认 10
next_cursorquerystring下一页游标;没有时为 null 或省略

返回: CompatFolders.

响应

HTTP 200

Successful response.

application/json

名称类型说明
foldersarray<object>
folders[].namestring
folders[].pathstring
total_countnumber
next_cursorstring
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/folders/examples" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "folders": [],
  "total_count": 0
}

创建文件夹

POST /cloudinary/v1_1/{library_id}/folders/{folder}

参数位置类型说明
library_idpathstring库 ID
folderpathstring—

返回: FolderResult.

响应

HTTP 200

Successful response.

application/json

名称类型说明
$object
curl -X POST "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/folders/sample" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{}'

HTTP 200

{
  "success": true,
  "path": "sample"
}

重命名文件夹

PUT /cloudinary/v1_1/{library_id}/folders/{folder}

参数位置类型说明
library_idpathstring库 ID
folderpathstring—

请求体

字段类型必填说明
to_folderstring是目标文件夹路径

返回: FolderResult.

响应

HTTP 200

Successful response.

application/json

名称类型说明
$object

删除文件夹

DELETE /cloudinary/v1_1/{library_id}/folders/{folder}

参数位置类型说明
library_idpathstring库 ID
folderpathstring—

返回: FolderResult.

响应

HTTP 200

Successful response.

application/json

名称类型说明
$object
curl -X DELETE "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/folders/sample" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{}'

HTTP 200

{
  "success": true,
  "path": "sample"
}

检查连接

GET /cloudinary/v1_1/{library_id}/ping

参数位置类型说明
library_idpathstring库 ID

返回: Ping.

响应

HTTP 200

Successful response.

application/json

名称类型说明
statusstring
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/ping" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "status": "ok"
}

读取用量

GET /cloudinary/v1_1/{library_id}/usage

参数位置类型说明
library_idpathstring库 ID

返回: Usage.

响应

HTTP 200

Successful response.

application/json

名称类型说明
storageobject
storage.usagenumber
objectsobject
objects.usagenumber
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/usage" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "storage": {
    "usage": 70
  },
  "objects": {
    "usage": 1
  }
}

读取用量

GET /cloudinary/v1_1/{library_id}/usage/{date}

参数位置类型说明
library_idpathstring库 ID
datepathstring—

返回: Usage.

响应

HTTP 200

Successful response.

application/json

名称类型说明
storageobject
storage.usagenumber
objectsobject
objects.usagenumber
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/usage/2026-10-09" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "storage": {
    "usage": 70
  },
  "objects": {
    "usage": 1
  }
}

ResourcePage

字段类型必填说明
resourcesSearchResource[]是本页素材
next_cursorstring否下一页游标;没有时为 null 或省略

CloudinaryResource

字段类型必填说明
asset_idAssetId是素材 ID
public_idstring是交付地址中的素材名称,可带路径
display_namestring是显示名称
asset_folderstring是组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
resource_typeResourceType是image、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
typeDeliveryType是资源或事件类型
formatstring是文件格式
versionnumber是交付版本号
version_idstring是版本标识
bytesnumber是文件字节数
etagstring是文件校验标识
widthnumber否宽度像素
heightnumber否高度像素
durationnumber否时长秒数
pagesnumber否文档页数
is_audioboolean否是否为音频
original_filenamestring否原文件名称
tagsstring[]是素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextobject否自定义文字键值;PATCH 整体替换,传 {} 清空
created_atIsoTimestamp是创建时间
urlstring是原文件地址
secure_urlstring是HTTPS 交付地址
placeholderfalse是固定为 false
existingboolean否未覆盖时是否返回已有素材
processingProcessing否整体与各项理解状态

DeletedResources

字段类型必填说明
deletedobject是删除结果
partialboolean是是否还有未处理的后续页
next_cursorstring否下一页游标;没有时为 null 或省略

Tags

字段类型必填说明
tagsstring[]是素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
next_cursorstring否下一页游标;没有时为 null 或省略

CompatFolders

字段类型必填说明
foldersobject[]是文件夹列表
total_countnumber是匹配总数
next_cursorstring否下一页游标;没有时为 null 或省略

FolderResult

字段类型必填说明

Ping

字段类型必填说明
status"ok"是资源状态

Usage

字段类型必填说明
storageobject是存储字节用量
objectsobject是素材数量

检索

指南 →

表达式检索仅支持以下子集。不支持的语法或字段返回 HTTP 400 INVALID_EXPRESSION;兼容错误体只包含消息。默认省略 tags 与 context;需要时用 with_field 请求。

语法含义
AND / OR / NOT / - / ( )布尔组合;相邻条件默认 AND
field:value / field=value字段匹配
bytes > 1000 / width >= 160数值比较;也支持 height、duration
created_at >= 2026-01-01 / uploaded_at > 7d日期或相对时间,支持 d/w/m/y
tags:docs / context.alt:"sample image"标签和自定义文字
public_id:docs*仅末尾通配符
"sample image"短语
sunset裸词:在 public_id、display_name、tags、context 以及理解得到的描述、图片文字、转写中做全文匹配,不区分大小写
~ / ^ / [a TO z] / prefix / ab不支持,返回 400

字段名不区分大小写(RESOURCE_TYPE:image 等同 resource_type:image);resource_type、type、format 的值不区分大小写;tags、context 等其他字段的值区分大小写。空表达式返回全部素材;无法解析的表达式返回 400 INVALID_EXPRESSION。

查询字段: asset_id, resource_type, type, format, public_id, asset_folder, display_name, tags, bytes, width, height, duration, created_at, uploaded_at, context.<key>.

排序字段: created_at, public_id, display_name, bytes, uploaded_at.

统计字段: resource_type, format, asset_folder, processing_state. 指南 →

基础地址与鉴权

以图搜图

GET /cloudinary/v1_1/{library_id}/resources/visual_search

参数位置类型说明
library_idpathstring库 ID
image_asset_idquerystring本库素材 ID
image_urlquerystring仅接受本库交付 URL,不支持抓取外部 URL
textquerystring自然语言查询,使用语义检索
max_resultsqueryinteger最多 500;检索默认 100,Admin 默认 10
filterquerystring表达式筛选条件

返回: VisualResources.

库的 search.image 为 true 时可用;不支持的库返回 LIBRARY_INVALID_STATE。图片仅接受 JPEG、PNG、WebP、GIF,解码后最大 10 MiB。每个素材返回最高分命中,视频定位到最佳帧。qwen3-vl-embedding 的图片相似度门槛为 0.35。标定来自 2026-10-10 的测试:同图变体 0.82–0.96,同类场景 0.38–0.66,无关图片最高 0.34。

image_asset_id、image_file(multipart)、image_url、text 必须且只能传一个。text 使用纯语义检索;返回 { "resources": [...] }。image_url 只接受本库交付 URL,不抓取外部 URL;外部 URL 返回 400「不支持抓取外部 URL」。

响应

HTTP 200

Successful response.

application/json

名称类型说明
resourcesarray<object>
resources[].asset_idstring
resources[].public_idstring
resources[].display_namestring
resources[].asset_folderstring
resources[].resource_typestring
resources[].typestring
resources[].formatstring
resources[].versionnumber
resources[].version_idstring
resources[].bytesnumber
resources[].etagstring
resources[].widthnumber
resources[].heightnumber
resources[].durationnumber
resources[].pagesnumber
resources[].is_audioboolean
resources[].original_filenamestring
resources[].tagsarray<string>
resources[].contextobject
resources[].created_atstring
resources[].urlstring
resources[].secure_urlstring
resources[].placeholderboolean
resources[].existingboolean
resources[].processingobject

以图搜图

POST /cloudinary/v1_1/{library_id}/resources/visual_search

参数位置类型说明
library_idpathstring库 ID

请求体

字段类型必填说明
image_asset_idstring否本库素材 ID
image_urlstring否仅接受本库交付 URL,不支持抓取外部 URL
image_filestring否JPEG、PNG、WebP 或 GIF 文件,最大 10 MiB
textstring否自然语言查询,使用语义检索
max_resultsinteger否最多 500;检索默认 100,Admin 默认 10
filterstring否表达式筛选条件

返回: VisualResources.

库的 search.image 为 true 时可用;不支持的库返回 LIBRARY_INVALID_STATE。图片仅接受 JPEG、PNG、WebP、GIF,解码后最大 10 MiB。每个素材返回最高分命中,视频定位到最佳帧。qwen3-vl-embedding 的图片相似度门槛为 0.35。标定来自 2026-10-10 的测试:同图变体 0.82–0.96,同类场景 0.38–0.66,无关图片最高 0.34。

image_asset_id、image_file(multipart)、image_url、text 必须且只能传一个。text 使用纯语义检索;返回 { "resources": [...] }。image_url 只接受本库交付 URL,不抓取外部 URL;外部 URL 返回 400「不支持抓取外部 URL」。

响应

HTTP 200

Successful response.

application/json

名称类型说明
resourcesarray<object>
resources[].asset_idstring
resources[].public_idstring
resources[].display_namestring
resources[].asset_folderstring
resources[].resource_typestring
resources[].typestring
resources[].formatstring
resources[].versionnumber
resources[].version_idstring
resources[].bytesnumber
resources[].etagstring
resources[].widthnumber
resources[].heightnumber
resources[].durationnumber
resources[].pagesnumber
resources[].is_audioboolean
resources[].original_filenamestring
resources[].tagsarray<string>
resources[].contextobject
resources[].created_atstring
resources[].urlstring
resources[].secure_urlstring
resources[].placeholderboolean
resources[].existingboolean
resources[].processingobject

表达式检索

GET /cloudinary/v1_1/{library_id}/resources/search

参数位置类型说明
library_idpathstring库 ID
expressionquerystring结构化查询表达式;空表达式返回全部素材
sort_byquerystring排序字段与方向
max_resultsqueryinteger最多 500;检索默认 100,Admin 默认 10
next_cursorquerystring下一页游标;没有时为 null 或省略
with_fieldquerystring[]额外返回 tags 或 context
aggregatequerystring[]统计字段

返回: CompatExpressionSearchResult.

响应

HTTP 200

Successful response.

application/json

名称类型说明
total_countnumber
timenumber
next_cursorstring
resourcesarray<object>
resources[].asset_idstring
resources[].public_idstring
resources[].display_namestring
resources[].asset_folderstring
resources[].resource_typestring
resources[].typestring
resources[].formatstring
resources[].versionnumber
resources[].version_idstring
resources[].bytesnumber
resources[].etagstring
resources[].widthnumber
resources[].heightnumber
resources[].durationnumber
resources[].pagesnumber
resources[].is_audioboolean
resources[].original_filenamestring
resources[].tagsarray<string>
resources[].contextobject
resources[].created_atstring
resources[].urlstring
resources[].secure_urlstring
resources[].placeholderboolean
resources[].existingboolean
resources[].processingobject
aggregationsobject
curl -X GET "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/search?expression=tags%3Adocs" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "total_count": 1,
  "time": 0,
  "resources": [
    {
      "asset_id": "9339cdae93804c0c8c65d5189ef1f646",
      "public_id": "docs/pixel",
      "display_name": "Sample image",
      "asset_folder": "examples",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791538418,
      "version_id": "35848c1529994e338e7aa634a1c13d9c",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "created_at": "2026-10-09T09:33:38.899Z",
      "url": "https://media-develop.praxisusercontent.com/lib_77374d4ee73b4ae79c4aa430f3ba3885/image/upload/v1791538418/docs/pixel.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_77374d4ee73b4ae79c4aa430f3ba3885/image/upload/v1791538418/docs/pixel.png",
      "placeholder": false
    }
  ]
}

表达式检索

POST /cloudinary/v1_1/{library_id}/resources/search

参数位置类型说明
library_idpathstring库 ID

请求体

字段类型必填说明
expressionstring否结构化查询表达式;空表达式返回全部素材
sort_byobject[]否排序字段与方向
max_resultsinteger否最多 500;检索默认 100,Admin 默认 10
next_cursorstring否下一页游标;没有时为 null 或省略
with_field"tags" / "context"[]否额外返回 tags 或 context
aggregateAggregateField[]否统计字段

返回: CompatExpressionSearchResult.

响应

HTTP 200

Successful response.

application/json

名称类型说明
total_countnumber
timenumber
next_cursorstring
resourcesarray<object>
resources[].asset_idstring
resources[].public_idstring
resources[].display_namestring
resources[].asset_folderstring
resources[].resource_typestring
resources[].typestring
resources[].formatstring
resources[].versionnumber
resources[].version_idstring
resources[].bytesnumber
resources[].etagstring
resources[].widthnumber
resources[].heightnumber
resources[].durationnumber
resources[].pagesnumber
resources[].is_audioboolean
resources[].original_filenamestring
resources[].tagsarray<string>
resources[].contextobject
resources[].created_atstring
resources[].urlstring
resources[].secure_urlstring
resources[].placeholderboolean
resources[].existingboolean
resources[].processingobject
aggregationsobject
curl -X POST "https://api.deepraxis.ai/cloudinary/v1_1/${LIBRARY_ID}/resources/search" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"expression":"tags:docs"}'

HTTP 200

{
  "total_count": 2,
  "time": 0,
  "resources": [
    {
      "asset_id": "9dfa312ef9bc4b00816339b598b1152c",
      "public_id": "walk-lib-r1-MDP-1791733789929-tagged",
      "display_name": "walk-lib-r1-MDP-1791733789929-tagged",
      "asset_folder": "",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791733815,
      "version_id": "26cb8171caa5431b8373ad417fd71e32",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "processing": {
        "state": "processing",
        "kinds": {
          "embedding": "running",
          "visual": "failed",
          "tagging": "failed"
        },
        "updated_at": "2026-10-11T15:50:21.512Z"
      },
      "created_at": "2026-10-11T15:50:15.996Z",
      "url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733815/walk-lib-r1-MDP-1791733789929-tagged.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733815/walk-lib-r1-MDP-1791733789929-tagged.png",
      "placeholder": false
    },
    {
      "asset_id": "85b7ef616a8b4719a41777a036ebc1d2",
      "public_id": "walk-lib-r1-MDP-1791733789929-plain",
      "display_name": "walk-lib-r1-MDP-1791733789929-plain",
      "asset_folder": "",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791733810,
      "version_id": "fdf3c8cd40c2424d86e8397425a69857",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "created_at": "2026-10-11T15:50:10.842Z",
      "url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733810/walk-lib-r1-MDP-1791733789929-plain.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733810/walk-lib-r1-MDP-1791733789929-plain.png",
      "placeholder": false
    }
  ]
}

VisualResources

字段类型必填说明
resourcesCloudinaryResource[]是本页素材

CompatExpressionSearchResult

字段类型必填说明
total_countnumber是匹配总数
timenumber是检索耗时,整数毫秒,由服务端测得
next_cursorstring否下一页游标;没有时为 null 或省略
resourcesSearchResource[]是本页素材
aggregationsobject否按请求字段统计

SearchResource

字段类型必填说明
asset_idAssetId是素材 ID
public_idstring是交付地址中的素材名称,可带路径
display_namestring是显示名称
asset_folderstring是组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
resource_typeResourceType是image、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
typeDeliveryType是资源或事件类型
formatstring是文件格式
versionnumber是交付版本号
version_idstring是版本标识
bytesnumber是文件字节数
etagstring是文件校验标识
widthnumber否宽度像素
heightnumber否高度像素
durationnumber否时长秒数
pagesnumber否文档页数
is_audioboolean否是否为音频
original_filenamestring否原文件名称
tagsstring[]否素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextobject否自定义文字键值;PATCH 整体替换,传 {} 清空
created_atIsoTimestamp是创建时间
urlstring是原文件地址
secure_urlstring是HTTPS 交付地址
placeholderfalse是固定为 false
existingboolean否未覆盖时是否返回已有素材
processingProcessing否整体与各项理解状态

交付与变换

指南 →

用上传响应的 secure_url 读取原文件,在 upload 与版本之间插入变换。

https://media-develop.praxisusercontent.com/{library_id}/{resource_type}/upload/{transformation}/v{version}/{public_id}.{format}

原文件省略 transformation 及其后斜杠。仅接受以下白名单;其它变换返回错误。

参数允许值
w_160, 320, 640, 1280
c_fill, fit, limit, scale, pad
g_auto, center
f_auto, jpg, png, webp, avif
q_auto, auto:good, auto:eco
dpr_1, 2
so_视频秒数,扩展名 .jpg;源文件不超过 100 MiB
w_160,c_fit
w_320,c_fill,g_center,f_webp,q_auto,dpr_2

用户内容安全

交付使用独立的可注册域 praxisusercontent.com,与 API 和登录域隔离:Develop 为 media-develop.praxisusercontent.com,生产为 media.praxisusercontent.com。URL 路径形状不变,交付不携带任何 cookie。

  • 只允许 GET 和 HEAD;其他方法返回 405。
  • 不向上游转发 cookie 和凭据,响应移除 Set-Cookie。
  • 所有响应都带 X-Content-Type-Options: nosniff。
  • HTML、SVG、XML、JavaScript 类内容都带 Content-Security-Policy: sandbox 和 Content-Disposition: attachment。
  • 支持 Range 请求,部分内容返回 206。

Browserbase

连接与使用指南

基础地址: https://api-develop.deepraxis.ai/browserbase

请求头: X-BB-API-Key: $PRAXIS_API_KEY

请求 ID 响应头: X-Request-Id

官方 SDK 设置 baseURL 后使用以下接口。代理、反检测、扩展和 Selenium 不可用;region 与 solveCaptchas 接受但忽略。删除登录态返回 200 和 deleted=true;会话响应还可能包含 currentUrl、clients、handoff。

操作方法与路径
创建浏览器会话POST /browserbase/v1/sessions
列出浏览器会话GET /browserbase/v1/sessions
读取浏览器会话GET /browserbase/v1/sessions/{id}
关闭浏览器会话POST /browserbase/v1/sessions/{id}
读取调试地址GET /browserbase/v1/sessions/{id}/debug
读取会话日志GET /browserbase/v1/sessions/{id}/logs
读取会话录像GET /browserbase/v1/sessions/{id}/recording
创建登录态POST /browserbase/v1/contexts
读取登录态GET /browserbase/v1/contexts/{id}
删除登录态DELETE /browserbase/v1/contexts/{id}

创建浏览器会话

POST /browserbase/v1/sessions● 支持

Browserbase

请求参数

  • projectIdstring可选

    The Project ID. Can be found in [Settings](https://www.browserbase.com/settings). Optional - if not provided, the project will be inferred from the API key.

  • extensionIdstring可选○ 未支持

    不支持此配置。

  • browserSettingsobject可选
    ▸ 展开子字段(14)
    • contextobject可选
      ▸ 展开子字段(2)
      • idstring必填

        The Context ID.

      • persistboolean可选

        Whether or not to persist the context after browsing. Defaults to `false`.

    • extensionIdstring可选○ 未支持

      不支持此配置。

    • viewportobject可选
      ▸ 展开子字段(2)
      • widthinteger可选

        The width of the browser.

      • heightinteger可选

        The height of the browser.

    • blockAdsboolean可选◐ 部分支持

      接受但忽略;不会启用此能力。

    • solveCaptchasboolean可选◐ 部分支持

      接受但忽略;不会启用此能力。

    • recordSessionboolean可选◐ 部分支持

      接受但忽略;不会启用此能力。

    • logSessionboolean可选◐ 部分支持

      接受但忽略;不会启用此能力。

    • advancedStealthboolean可选○ 未支持

      不支持此配置。

    • verifiedboolean可选○ 未支持

      不支持此配置。

    • captchaImageSelectorstring可选

      Custom selector for captcha image. See [Custom Captcha Solving](/features/stealth-mode#custom-captcha-solving)

    • captchaInputSelectorstring可选

      Custom selector for captcha input. See [Custom Captcha Solving](/features/stealth-mode#custom-captcha-solving)

    • osstring可选○ 未支持

      不支持此配置。

      取值 windowsmaclinuxmobiletablet
    • allowedDomainsarray可选○ 未支持
      默认 []

      不支持此配置。

    • ignoreCertificateErrorsboolean可选○ 未支持

      不支持此配置。

  • timeoutinteger可选

    Duration in seconds after which the session will automatically end. Defaults to the Project's `defaultTimeout`. Minimum 60 seconds, maximum 21600 seconds (6 hours).

  • keepAliveboolean可选

    Set to true to keep the session alive even after disconnections. Available on the Hobby Plan and above.

  • proxiesunion可选◐ 部分支持

    仅省略、false 或 [{type: 'none'}] 可用,其它代理配置返回 501。

  • proxySettingsobject可选

    Supplementary proxy settings. Optional.

    ▸ 展开子字段(1)
    • caCertificatesarray可选
      默认 []

      The TLS certificate IDs to trust. Optional.

  • regionstring可选◐ 部分支持
    默认 "us-west-2"

    接受但忽略;不会启用此能力。

    取值 us-west-2us-east-1eu-central-1ap-southeast-1
  • userMetadataobject可选

    Arbitrary user metadata to attach to the session. To learn more about user metadata, see [User Metadata](/features/sessions#user-metadata).

返回

201

仅支持服务指南列出的能力;部分官方请求参数不可用。

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

代理、反检测、扩展和 Selenium 不可用。region 和 solveCaptchas 接受但忽略;不提供区域选择或验证码代解。

响应

HTTP 201

The request has succeeded and a new resource has been created as a result.

application/json

名称类型说明
idstring
createdAtstring
updatedAtstring
projectIdstringThe Project ID linked to the Session.
startedAtstring
endedAtstring
expiresAtstring
statusstring
proxyBytesintegerBytes used via the Proxy
keepAlivebooleanIndicates if the Session was created to be kept alive upon disconnections
contextIdstringOptional. The Context linked to the Session.
regionstringThe region where the Session is running.
userMetadataobjectArbitrary user metadata to attach to the session. To learn more about user metadata, see User Metadata.
connectUrlstringWebSocket URL to connect to the Session.
seleniumRemoteUrlstringHTTP URL to connect to the Session.
signingKeystringSigning key to use when connecting to the Session via HTTP.

列出浏览器会话

GET /browserbase/v1/sessions● 支持

Browserbase

请求参数

  • statusstring可选
    取值 PENDINGRUNNINGERRORTIMED_OUTCOMPLETED
  • qstring可选

    Query sessions by user metadata. See [Querying Sessions by User Metadata](/features/sessions#querying-sessions-by-user-metadata) for the schema of this query.

返回

200

仅支持服务指南列出的能力;部分官方请求参数不可用。

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

代理、反检测、扩展和 Selenium 不可用。region 和 solveCaptchas 接受但忽略;不提供区域选择或验证码代解。

响应

HTTP 200

The request has succeeded.

application/json

名称类型说明
[].idstring
[].createdAtstring
[].updatedAtstring
[].projectIdstringThe Project ID linked to the Session.
[].startedAtstring
[].endedAtstring
[].expiresAtstring
[].statusstring
[].proxyBytesintegerBytes used via the Proxy
[].keepAlivebooleanIndicates if the Session was created to be kept alive upon disconnections
[].contextIdstringOptional. The Context linked to the Session.
[].regionstringThe region where the Session is running.
[].userMetadataobjectArbitrary user metadata to attach to the session. To learn more about user metadata, see User Metadata.

读取浏览器会话

GET /browserbase/v1/sessions/{id}● 支持

Browserbase

请求参数

  • idstring必填

返回

200

仅支持服务指南列出的能力;部分官方请求参数不可用。

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

代理、反检测、扩展和 Selenium 不可用。region 和 solveCaptchas 接受但忽略;不提供区域选择或验证码代解。

响应

HTTP 200

The request has succeeded.

application/json

名称类型说明
idstring
createdAtstring
updatedAtstring
projectIdstringThe Project ID linked to the Session.
startedAtstring
endedAtstring
expiresAtstring
statusstring
proxyBytesintegerBytes used via the Proxy
keepAlivebooleanIndicates if the Session was created to be kept alive upon disconnections
contextIdstringOptional. The Context linked to the Session.
regionstringThe region where the Session is running.
userMetadataobjectArbitrary user metadata to attach to the session. To learn more about user metadata, see User Metadata.
connectUrlstringWebSocket URL to connect to the Session.
seleniumRemoteUrlstringHTTP URL to connect to the Session.
signingKeystringSigning key to use when connecting to the Session via HTTP.

关闭浏览器会话

POST /browserbase/v1/sessions/{id}● 支持

Browserbase

请求参数

  • idstring必填
  • statusstring必填

    Set to `REQUEST_RELEASE` to request that the session complete. Use before session's timeout to avoid additional charges.

    取值 REQUEST_RELEASE

返回

200

仅支持服务指南列出的能力;部分官方请求参数不可用。

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

代理、反检测、扩展和 Selenium 不可用。region 和 solveCaptchas 接受但忽略;不提供区域选择或验证码代解。

响应

HTTP 200

The request has succeeded.

application/json

名称类型说明
idstring
createdAtstring
updatedAtstring
projectIdstringThe Project ID linked to the Session.
startedAtstring
endedAtstring
expiresAtstring
statusstring
proxyBytesintegerBytes used via the Proxy
keepAlivebooleanIndicates if the Session was created to be kept alive upon disconnections
contextIdstringOptional. The Context linked to the Session.
regionstringThe region where the Session is running.
userMetadataobjectArbitrary user metadata to attach to the session. To learn more about user metadata, see User Metadata.

读取调试地址

GET /browserbase/v1/sessions/{id}/debug● 支持

Browserbase

请求参数

  • expiresIninteger可选

    Time-to-live of the generated live view URLs, in seconds. If omitted, the URLs expire with the session, up to a maximum of 21600 seconds (6 hours).

  • idstring必填

返回

200

仅支持服务指南列出的能力;部分官方请求参数不可用。

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

代理、反检测、扩展和 Selenium 不可用。region 和 solveCaptchas 接受但忽略;不提供区域选择或验证码代解。

响应

HTTP 200

The request has succeeded.

application/json

名称类型说明
debuggerFullscreenUrlstring
debuggerUrlstring
pagesarray<object>
pages[].idstring
pages[].urlstring
pages[].faviconUrlstring
pages[].titlestring
pages[].debuggerUrlstring
pages[].debuggerFullscreenUrlstring
wsUrlstring

读取会话日志

GET /browserbase/v1/sessions/{id}/logs● 支持

Browserbase

请求参数

  • idstring必填

返回

200

仅支持服务指南列出的能力;部分官方请求参数不可用。

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

代理、反检测、扩展和 Selenium 不可用。region 和 solveCaptchas 接受但忽略;不提供区域选择或验证码代解。

响应

HTTP 200

The request has succeeded.

application/json

名称类型说明
[].methodstring
[].pageIdinteger
[].sessionIdstring
[].requestobject
[].request.timestampintegermilliseconds that have elapsed since the UNIX epoch
[].request.paramsobject
[].request.rawBodystring
[].responseobject
[].response.timestampintegermilliseconds that have elapsed since the UNIX epoch
[].response.resultobject
[].response.rawBodystring
[].timestampintegermilliseconds that have elapsed since the UNIX epoch
[].frameIdstring
[].loaderIdstring

读取会话录像

GET /browserbase/v1/sessions/{id}/recording● 支持

Browserbase

请求参数

  • idstring必填

返回

200

仅支持服务指南列出的能力;部分官方请求参数不可用。

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

代理、反检测、扩展和 Selenium 不可用。region 和 solveCaptchas 接受但忽略;不提供区域选择或验证码代解。

响应

HTTP 200

The request has succeeded.

application/json

名称类型说明
[].idstring
[].dataobjectSee rrweb documentation.
[].sessionIdstring
[].timestampintegermilliseconds that have elapsed since the UNIX epoch
[].typeinteger

创建登录态

POST /browserbase/v1/contexts● 支持

Browserbase

请求参数

  • projectIdstring可选

    The Project ID. Can be found in [Settings](https://www.browserbase.com/settings). Optional - if not provided, the project will be inferred from the API key.

  • namestring可选

    Optional user-defined name for the Context. Leading and trailing whitespace is trimmed before storage. Names are unique within the project among active Contexts, compared case-insensitively.

返回

201

仅支持服务指南列出的能力;部分官方请求参数不可用。

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

代理、反检测、扩展和 Selenium 不可用。region 和 solveCaptchas 接受但忽略;不提供区域选择或验证码代解。

响应

HTTP 201

The request has succeeded and a new resource has been created as a result.

application/json

名称类型说明
idstring
publicKeystringThe public key to encrypt the user-data-directory.
cipherAlgorithmstringThe cipher algorithm used to encrypt the user-data-directory. AES-256-CBC is currently the only supported algorithm.
initializationVectorSizeintegerThe initialization vector size used to encrypt the user-data-directory. Read more about how to use it.

读取登录态

GET /browserbase/v1/contexts/{id}● 支持

Browserbase

请求参数

  • idstring必填

返回

200

仅支持服务指南列出的能力;部分官方请求参数不可用。

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

代理、反检测、扩展和 Selenium 不可用。region 和 solveCaptchas 接受但忽略;不提供区域选择或验证码代解。

响应

HTTP 200

The request has succeeded.

application/json

名称类型说明
idstring
createdAtstring
updatedAtstring
projectIdstringThe Project ID linked to the uploaded Context.
namestringOptional user-defined name for the Context. Leading and trailing whitespace is trimmed before storage. Names are unique within the project among active Contexts, compared case-insensitively.

删除登录态

DELETE /browserbase/v1/contexts/{id}● 支持

Browserbase

请求参数

  • idstring必填

返回

200

仅支持服务指南列出的能力;部分官方请求参数不可用。

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

代理、反检测、扩展和 Selenium 不可用。region 和 solveCaptchas 接受但忽略;不提供区域选择或验证码代解。

此接口返回 200 和 JSON 确认;Browserbase 官方为 204。

响应

HTTP 200

Context deleted. Praxis returns JSON instead of Browserbase's 204.

application/json

名称类型说明
deletedboolean

智能体 API

基础地址

加载中…

接入

加载中…

智能体域的概念与整体介绍见智能体服务;鉴权方式见鉴权。

端点

电脑(10 个端点,10 个可用)

方法路径说明支持
POST/v1/computers创建电脑● 支持
GET/v1/computers列出电脑● 支持
GET/v1/computers/{computer_id}读取电脑● 支持
POST/v1/computers/{computer_id}更新电脑● 支持
POST/v1/computers/{computer_id}/archive归档电脑● 支持
DELETE/v1/computers/{computer_id}删除已归档电脑● 支持
GET/v1/computers/{computer_id}/files浏览电脑文件● 支持
GET/v1/computers/{computer_id}/files/content读取电脑文件内容● 支持
POST/v1/computers/{computer_id}/connect连接电脑● 支持
POST/v1/computers/{computer_id}/attachments上传电脑附件● 支持

会话资源(4 个端点,4 个可用)

方法路径说明支持
POST/v1/sessions/{session_id}/resources添加会话资源◐ 部分支持
GET/v1/sessions/{session_id}/resources列出会话资源◐ 部分支持
GET/v1/sessions/{session_id}/resources/{resource_id}读取会话资源◐ 部分支持
DELETE/v1/sessions/{session_id}/resources/{resource_id}删除会话资源◐ 部分支持

智能体(6 个端点,6 个可用)

方法路径说明支持
GET/v1/agents列出智能体● 支持
POST/v1/agents创建智能体◐ 部分支持
GET/v1/agents/{agent_id}读取智能体● 支持
POST/v1/agents/{agent_id}更新智能体◐ 部分支持
GET/v1/agents/{agent_id}/versions列出版本● 支持
POST/v1/agents/{agent_id}/archive归档智能体● 支持

会话与事件(16 个端点,16 个可用)

方法路径说明支持
GET/v1/sessions列出会话◐ 部分支持
POST/v1/sessions创建会话◐ 部分支持
GET/v1/sessions/{session_id}读取会话● 支持
POST/v1/sessions/{session_id}/fork分支会话(扩展)● 支持
GET/v1/sessions/{session_id}/context读取会话上下文(扩展)● 支持
GET/v1/sessions/{session_id}/background_tasks列出后台任务(扩展)● 支持
GET/v1/sessions/{session_id}/background_tasks/{task_id}/output读取后台任务输出(扩展)● 支持
POST/v1/sessions/{session_id}/background_tasks/{task_id}/stop停止后台任务(扩展)● 支持
POST/v1/sessions/{session_id}/compact压缩会话(扩展)● 支持
GET/v1/sessions/{session_id}/compact/{operation_id}读取压缩操作(扩展)● 支持
GET/v1/sessions/{session_id}/compactions列出压缩历史(扩展)● 支持
GET/v1/sessions/{session_id}/events列出事件● 支持
POST/v1/sessions/{session_id}/events发送事件◐ 部分支持
GET/v1/sessions/{session_id}/events/stream订阅事件◐ 部分支持
POST/v1/sessions/{session_id}更新会话◐ 部分支持
POST/v1/sessions/{session_id}/archive归档会话● 支持

会话线程(5 个端点,5 个可用)

方法路径说明支持
GET/v1/sessions/{session_id}/threads列出线程◐ 部分支持
GET/v1/sessions/{session_id}/threads/{thread_id}读取线程◐ 部分支持
GET/v1/sessions/{session_id}/threads/{thread_id}/events列出线程事件◐ 部分支持
GET/v1/sessions/{session_id}/threads/{thread_id}/stream订阅线程事件◐ 部分支持
POST/v1/sessions/{session_id}/threads/{thread_id}/archive归档线程◐ 部分支持

执行环境(5 个端点,5 个可用)

方法路径说明支持
POST/v1/environments创建环境◐ 部分支持
POST/v1/environments/{environment_id}更新环境◐ 部分支持
POST/v1/environments/{environment_id}/archive归档环境◐ 部分支持
GET/v1/environments列出环境◐ 部分支持
GET/v1/environments/{environment_id}读取环境◐ 部分支持

工具集(1 个端点,1 个可用)

方法路径说明支持
GET/v1/toolsets列出工具集● 支持

与官方的差异

  • 本面只声明列出的 30 个端点(含工具集目录、上下文快照、压缩操作与后台任务):官方其余 Managed Agents 操作不在本面,调用得到 404。需要 Anthropic 协议兼容接入时用兼容面 /anthropic —— 官方有、平台未支持的操作在那里如实返回 501(not_implemented_error),不产生任何副作用。
  • 创建环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 更新环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 归档环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 创建电脑:Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
  • 列出电脑:Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
  • 读取电脑:Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
  • 更新电脑:Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
  • 归档电脑:Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
  • 删除已归档电脑:Praxis 扩展:Managed Agents 没有持久 Computer 的删除生命周期。仅允许已归档的电脑;active 返回 400 COMPUTER_ACTIVE(先归档),先销毁电脑数据再删除登记,成功返回 id 和 type=computer_deleted;不存在或跨租户返回 404。
  • 浏览电脑文件:Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
  • 读取电脑文件内容:Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。
  • 连接电脑:Praxis 自有扩展:Managed Agents 没有持久 Computer 连接。返回 SDK 可用的公开 sandbox_id、envd_access_token 和 template_id。归档电脑仍可连接;跨租户或不存在返回 404。连接凭证不可缓存。
  • 上传电脑附件:Praxis 扩展:Managed Agents 没有持久 Computer 附件目录。用户上传可以覆盖同名附件,智能体始终只读;运行令牌调用上传返回 403 READ_ONLY。name 是单个文件名、最多 255 UTF-8 字节,MIME 始终按扩展名推断,上传的 Content-Type 不持久保存,digest 可省略。上限 16 MiB,超限 413、非法名字 400;归档电脑也可上传,跨租户 404。
  • 添加会话资源:支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 列出会话资源:支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 读取会话资源:支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 删除会话资源:支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 创建智能体:agent_toolset_20260401 是原生工具集,包含 bash、edit、glob、grep、read、write、web_search、web_fetch,以及 TaskOutput、TaskStop、Monitor、Agent、SendMessage。新建智能体默认全部启用;configs 可逐个设置 name、enabled、permission_policy,未列出的工具遵循 default_config(默认启用)。后台任务、Monitor 和子智能体依赖 bash;启用任一后台工具时,bash 提供 run_in_background。兼容 API /anthropic 只接受和返回官方 8 个工具,经该入口创建的会话也只注册这 8 个工具。 支持文本提示词、模型、元数据与内置工具。model.settings.reasoning 可选 low、medium、high、xhigh、none,为会话提供默认思考档位;会话显式 thinking 优先,不支持的默认值回退到模型 default_effort。示例 model: {id: "deepseek-v4-flash", settings: {reasoning: "high"}}。Skills 及其它额外模型控制尚不支持,传入会返回 400。可在工具集 permissions 中设置 allow、ask、deny 规则,最多共 100 条,用于以后的对话。 multiagent 接受 null 或 coordinator 名册,1–20 项:智能体 ID、{type:"agent",id,version?} 或最多一个 {type:"self"}。创建/更新时固定版本;成员去重且须存在、未归档、不能自身带 multiagent。名册可启用 Agent,仍需启用 bash;SendMessage 遵循工具配置。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。 /agent/v1 顶层 subagent_model 是可空模型 ID,随智能体版本保存;省略保留、null 清除。模型须存在。优先级为调用 model > subagent_model > 成员模型(内置类型用父会话模型)。/anthropic 不接受或返回此字段。
  • 读取智能体:tools 在一个 agent_toolset_20260401 条目中返回全部原生工具的有效配置,可原样用于更新。将示例中的资源 ID 替换成你创建的资源 ID。
  • 更新智能体:通过 agent_toolset_20260401.configs 逐个开关原生工具并设置权限。未列出的工具遵循 default_config;后台任务、Monitor 和子智能体依赖 bash。version 可用于乐观并发控制,版本冲突返回 409;无变化的更新不增加版本。Skills 尚不支持。更新工具集 permissions 可把允许的同类操作保存到智能体的新版本,供以后的对话使用。 multiagent 接受 null 或 coordinator 名册,1–20 项:智能体 ID、{type:"agent",id,version?} 或最多一个 {type:"self"}。创建/更新时固定版本;成员去重且须存在、未归档、不能自身带 multiagent。名册可启用 Agent,仍需启用 bash;SendMessage 遵循工具配置。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。 /agent/v1 顶层 subagent_model 是可空模型 ID,随智能体版本保存;省略保留、null 清除。模型须存在。优先级为调用 model > subagent_model > 成员模型(内置类型用父会话模型)。/anthropic 不接受或返回此字段。
  • 列出版本:将示例中的资源 ID 替换成你创建的资源 ID。
  • 归档智能体:归档后保留查询与历史版本,不能继续更新。请只归档自己的测试智能体。
  • 列出会话:支持 limit、page 与 agent_id;agent_version、时间范围、deployment_id、memory_store_id、include_archived、order、statuses 尚不支持,传入返回 400。
  • 创建会话:可在创建时传 model(models.allowed 内的 ID 字符串;无 allowed 时只允许默认模型)与 thinking({effort: "low|medium|high|xhigh|none"} 或 null),在首条 initial_events 执行前保存。省略或 null 继承智能体默认,再使用模型默认。档位必须在 model.thinking.efforts 内;none 要求 can_disable 为 true,否则返回 400 invalid_request_error。响应包含 thinking 与 model.thinking: {efforts, can_disable, default_effort};未知能力为 null,默认档位也可为 null。示例:{"agent":"agent_123","model":"deepseek-v4-flash","thinking":{"effort":"xhigh"}}。这些选择字段只在 /agent/v1 提供。先创建智能体,将示例 agent_123 换成返回的 id。省略 environment_id 得到轻量机器(light),有默认或显式 computer_id 时使用该 Computer;指定 node22 或租户自建 cloud 环境则使用沙箱配方。无配方时响应省略 environment_id。不支持内联智能体覆盖、预算与凭据库。支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
  • 读取会话:将示例中的资源 ID 替换成你创建的资源 ID。
  • 分支会话(扩展):仅在 /agent/v1 提供。message_id 来自 /agent/v1 事件的同名字段,不是事件 id。复制截至并包含该消息的全部对话与工具调用结果;父会话不变,其他轮次正在运行不影响已有完成轮次的分支。新会话沿用智能体及版本、当前模型与思考设置和 cwd 工作目录,标题为父标题加「 的分支」,作为普通根会话出现在列表中。父会话有沙箱时复制沙箱及内存快照,新会话独立拥有该沙箱;继承的运行中后台任务被终止,门铃目标只保留新会话,新后台任务表为空。父会话没有沙箱时保留懒创建。返回 201,响应与读取会话相同,forked_from 为 {session_id, message_id},普通会话为 null。新会话历史末尾有 session.forked 事件,包含 forked_from_session_id 与 forked_from_message_id。上述字段和事件仅在 /agent/v1 可见。非法请求返回 400;不满足分支条件返回 409 FORK_TARGET_INVALID;会话不存在或不属于调用者返回 404。初始化失败时不公开新会话,并回收已分出的沙箱。
  • 读取会话上下文(扩展):扩展:仅在 /agent/v1 提供,形状参照 Claude Agent SDK getContextUsage(),字段使用 snake_case。detail 固定为 summary:总量优先使用上次模型实测,各来源按本地估算占比摊分,used 分类之和等于 total_tokens。categories 只列非零来源,按 kind(used/free/buffer/deferred)判断用途。key 是稳定来源标识扩展;客户端须容忍未知 key 和新增来源,未知名称回退显示 name。MCP 按服务器归组,插件按 id 归组,摘要单独计量。excluded_items 暂为零。尚无测量时 total_tokens、total_tokens_source、measured_at 为 null,categories 为空,明细为零或空数组。切换模型后 max_tokens、auto_compact_threshold 与 free/buffer 立即按新模型重算,保留最近测量值。窗口未知或自动压缩熔断时 is_auto_compact_enabled 为 false。例如 model.thinking 为 {efforts: [high, xhigh], can_disable: true, default_effort: high}。model.thinking 返回 efforts(支持的档位)、can_disable(是否允许 none)及 default_effort(模型默认档位,可为 null);能力未知时整个 thinking 为 null。会话不存在或调用者不可见时返回 404。
  • 列出后台任务(扩展):仅在 /agent/v1 提供。kind 是开放字符串。subagent 行的 thread_id 指向对应子线程,其他 kind 为 null。completed 且 delivery=pending 显示 result_pending。notified_at 是系统通知批次被受理开轮的时间,无则 null。trigger_count 仅监视器返回已受理的事件批次数,无记录则 null。时间为 RFC3339。会话不存在或不可见返回 404。
  • 读取后台任务输出(扩展):offset 默认 0;max_bytes 默认 65536,上限 262144。返回 text、next_offset、eof。沙箱已暂停或不存在时返回空 text、原 offset、eof=true、unavailable=true。读取不确认模型结果。
  • 停止后台任务(扩展):复用 TaskStop:持久化 stop_requested_at 并终止进程组。返回 BackgroundTask;终止尚未观察到时仍可为 running,但不可取消。已结束或不支持停止的任务返回 409。
  • 压缩会话(扩展):仅在 /agent/v1 提供。请求体可省略或为 {},可选 instructions 必须为字符串且原样传递。Idempotency-Key 请求头原样传递;缺失时生成 UUID。响应为 { type: session_compaction, id, status, reason? },id 是操作 ID。queued/running 返回 202;skipped/succeeded/failed 返回 200。非字符串 instructions 返回 400 invalid_request_error。不存在或不可见的托管会话返回 404 not_found_error。
  • 读取压缩操作(扩展):仅在 /agent/v1 提供。响应为 { type: session_compaction, id, status, reason? },所有状态均返回 200。操作不存在或会话不可见时返回 404 not_found_error。
  • 列出压缩历史(扩展):仅在 /agent/v1 提供。返回 { data: [...] }。每项包含 type、id、event_id、trigger、status、model、compacted_message_count、input_tokens_before、input_tokens_after、summary、error、created_at,字段按服务记录原样返回。不存在或不可见的托管会话返回 404 not_found_error。
  • 列出事件:先发送消息再读取历史;处理完成前可能只看到已接纳的输入。支持分页、事件类型和时间过滤。会话等待工具授权时停在 session.status_idle,stop_reason 为 requires_action,event_ids 列出待确认的 agent.tool_use;运行失败时先出现 session.error,再出现 session.status_terminated。agent.thinking 带思考内容 content。使用网页搜索或读取网页时,/agent/v1 与 /anthropic 的工具结果均为官方 search_result 块;回答文本块的 citations 是 /agent/v1 的扩展字段,/anthropic 将回答引用显示为正文中的 [n]。
  • 发送事件:将 sesn_123 换成创建会话返回的 id。每条 user.message 只接受一个非空文本块。支持文本 user.message、user.interrupt 和工具确认;可发送 user.withdraw 并用 event_id 指向仍在排队的消息来撤回它,消息已开始处理时返回 409。运行中需要提前补充要求时,发送 user.steer 事件,并用 event_id 指向仍在排队的消息:当前工具继续执行,消息在下一次模型请求前进入当前回合。返回带 processed_at 的 user.steer 回执,重复标记返回同一回执;已开始或已撤回返回 409,事件不存在返回 404。有待授权时继续等待;若当前回合先结束,消息仍按普通队列处理。默认发送消息仍然排队,/anthropic 不接受 user.steer。其它事件变体尚不支持。返回的是已接纳事件;模型回复从事件历史或订阅读取。会话等待工具授权时发送的 user.message 会排队:返回的事件 processed_at 为 null,授权处理完成后按发送顺序执行。允许工具调用时可在 updated_permissions 中原样提交该调用的 permission_suggestions,让本次对话记住同类操作;危险操作不提供可记住的建议。使用网页搜索或读取网页时,/agent/v1 与 /anthropic 的工具结果均为官方 search_result 块;回答文本块的 citations 是 /agent/v1 的扩展字段,/anthropic 将回答引用显示为正文中的 [n]。
  • 订阅事件:保持 SSE 连接以接收事件;请求不会像普通 JSON 接口一样立刻结束。先创建会话并替换 sesn_123,再从另一请求发送消息;停止按钮只断开订阅,不会停止智能体。SDK 0.124.0 会过滤 session.usage,完整用量请读历史。传 event_deltas[]=agent.message 或 event_deltas[]=agent.thinking 可在最终事件到达前收到逐段预览(event_start 与 event_delta)。传 event_deltas[]=agent.tool_use 可以在参数生成过程中收到 input_json_delta 片段。使用网页搜索或读取网页时,/agent/v1 与 /anthropic 的工具结果均为官方 search_result 块;回答文本块的 citations 是 /agent/v1 的扩展字段,/anthropic 将回答引用显示为正文中的 [n]。
  • 更新会话:可选 model 为钉住版本 allowed 内的 ID,thinking 为 {effort: "low|medium|high|xhigh|none"} 或 null。省略保留原值,null 恢复继承;仅换模型会清除不支持的会话档位。两者同时传入按新模型校验,不支持返回 400 且原选择不变。下一轮生效,在途一轮不变。示例:{"model":"deepseek-v4-flash","thinking":{"effort":"xhigh"}}。响应含 thinking 及 model.thinking: {efforts, can_disable, default_effort},能力未知为 null。这些选择字段仅在 /agent/v1 提供。支持 title 与 metadata(官方补丁语义:字符串值写入、null 删除该键、整包 null 清空,未提及的键保留)。官方的 agent 覆盖(tools/mcp_servers)、budget 与 vault_ids 不支持,传入返回 400 并点名字段。归档后的会话更新返回 409。
  • 归档会话:归档后的会话拒绝新消息(400 invalid_request_error,写明会话已归档),读取与事件历史仍可用;重复归档幂等,archived_at 保持首次归档时间。
  • 列出线程:按 created_at 升序返回主线程及全部子线程。线程 id 为 sthr_ 加所属会话 id 的后缀;子线程的 parent_thread_id 指向主线程,session_id 始终为父会话。agent 是实际运行的定义,内置类型的 name 为类型名,未注册的 id/version 为 null。归档子线程的 status 为 terminated,archived_at 为归档时间;stats/usage 无线程级追踪时如实为 null。
  • 读取线程:返回本会话的主线程或子线程,与列表项逐字段一致。其他会话的线程、未知线程或非 sthr_ id 一律返回 404,不泄露其存在性。
  • 列出线程事件:读取所选线程自己的事件记录:主线程读主会话,子线程读对应子会话。沿用会话事件接口的查询参数、公开事件类型和 data + next_page 信封。使用网页工具时,两个接口均返回 search_result 块;回答 citations 为 /agent/v1 扩展,/anthropic 将引用显示为正文 [n]。
  • 订阅线程事件:订阅所选线程自己的实时事件流。复用会话 SSE 实现;/agent 接口支持同址只读 WebSocket。主会话流同时包含子线程创建、状态和消息事件,子线程审批带 session_thread_id 上浮;确认或中断携带该字段时路由到所属子线程。
  • 归档线程:主线程沿用会话归档动作;子线程仅归档对应子会话,不归档父会话或其他子线程。子线程归档后 status 为 terminated,带 archived_at;历史事件仍可读。
  • 列出环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 读取环境:支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。
  • 列出工具集:返回工具集说明、插件名称与版本,以及每个工具的名称、说明、参数定义、是否只读和默认授权方式。通过 /agent/v1/toolsets 读取此目录;目录不会更改智能体配置。agent_toolset_20260401 包含全部 13 个原生工具;TaskOutput、TaskStop、Monitor、Agent、SendMessage 与其他工具一样可逐个开关及设置权限,它们都依赖 bash。兼容 API 只提供官方 8 个工具。

原生工具与参数以本站各端点说明及 /meta/v1/openapi.yaml 为准;Claude Managed Agents 官方文档描述兼容 API 的官方字段。

错误按 Anthropic 错误格式返回(type / message / request_id),参见错误;额度与响应头参见限流。

POST /agent/v1/environments◐ 部分支持

请求体

  • namestring必填

    Human-readable name for the environment

  • metadataobject可选

    User-provided metadata key-value pairs

  • configobject可选

    Environment configuration

    ▸ 展开子字段(3)
    • typestring必填

      Environment type

      取值 self_hosted
    • networkingobject可选

      Network configuration policy. Omit on update to preserve the existing value.

    • packagesobject可选

      Specify packages (and optionally their versions) available in this environment. When versioning, use the version semantics relevant for the package manager, e.g. for `pip` use `package==1.0.0`. You are responsible for validating the package and version exist. Unversioned installs the latest. Under `limited` networking, requires `networking.allow_package_managers` to be `true`.

  • descriptionstring可选

    Optional description of the environment

  • scopestring可选

    The visibility scope for this environment. 'organization' makes the environment visible to all accounts. 'account' restricts visibility to the owning account only. API organizations support only 'organization'; 'account' is rejected. If not specified, defaults based on organization type.

返回

200

支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringEnvironment identifier (e.g., 'env_...')
archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
config.networkingobjectNetwork configuration policy.
config.packagesobjectPackage manager configuration.
config.typestringEnvironment type
created_atstringRFC 3339 timestamp when environment was created
descriptionnull | stringUser-provided description for the environment; null when unset
metadataobjectUser-provided metadata key-value pairs
namestringHuman-readable name for the environment
typestringThe type of object (always 'environment')
updated_atstringRFC 3339 timestamp when environment was last updated
scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

先调用「创建环境」,用返回的环境 ID 替换 env_123。

POST /agent/v1/environments/{environment_id}◐ 部分支持

请求参数

  • environment_idstring必填

    path: Environment id, as returned by environments.create or environments.list. Built-in environments can be read but not changed.

  • namestring可选

    Updated name for the environment

  • metadataobject可选

    User-provided metadata key-value pairs. Set a value to null or empty string to delete the key.

  • configobject可选

    Updated environment configuration

    ▸ 展开子字段(3)
    • typestring必填

      Environment type

      取值 self_hosted
    • networkingobject可选

      Network configuration policy. Omit on update to preserve the existing value.

    • packagesobject可选

      Specify packages (and optionally their versions) available in this environment. When versioning, use the version semantics relevant for the package manager, e.g. for `pip` use `package==1.0.0`. You are responsible for validating the package and version exist. Unversioned installs the latest. Under `limited` networking, requires `networking.allow_package_managers` to be `true`.

  • descriptionstring可选

    Updated description of the environment. Omit to preserve; null clears to null; an empty string is stored as an empty string.

  • scopestring可选

    The visibility scope for this environment. 'organization' makes the environment visible to all accounts. 'account' restricts visibility to the owning account only.

返回

200

支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringEnvironment identifier (e.g., 'env_...')
archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
config.networkingobjectNetwork configuration policy.
config.packagesobjectPackage manager configuration.
config.typestringEnvironment type
created_atstringRFC 3339 timestamp when environment was created
descriptionnull | stringUser-provided description for the environment; null when unset
metadataobjectUser-provided metadata key-value pairs
namestringHuman-readable name for the environment
typestringThe type of object (always 'environment')
updated_atstringRFC 3339 timestamp when environment was last updated
scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

先调用「创建环境」,用返回的环境 ID 替换 env_123。

POST /agent/v1/environments/{environment_id}/archive◐ 部分支持

请求参数

  • environment_idstring必填

    path: Environment id, as returned by environments.create or environments.list. Built-in environments can be read but not changed.

返回

200

支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringEnvironment identifier (e.g., 'env_...')
archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
config.networkingobjectNetwork configuration policy.
config.packagesobjectPackage manager configuration.
config.typestringEnvironment type
created_atstringRFC 3339 timestamp when environment was created
descriptionnull | stringUser-provided description for the environment; null when unset
metadataobjectUser-provided metadata key-value pairs
namestringHuman-readable name for the environment
typestringThe type of object (always 'environment')
updated_atstringRFC 3339 timestamp when environment was last updated
scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

创建电脑

POST /agent/v1/computers● 支持

请求体

  • namestring必填

    Name of the entry or object.

  • environment_idstring可选

    Environment recipe id; null or omitted when none was selected.

返回

201

Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 201

Computer result

application/json

名称类型说明
typestringAlways `computer`. A computer.
idstringComputer id (cmp_...), the computer_id of computer calls.
namestringDisplay name of the computer, 1 to 255 characters.
sandbox_idstring | nullPublic id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created.
environment_idstring | nullEnvironment recipe the computer was created with; null when none.
statusstringactive computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions.
created_atstringRFC 3339 time at which the computer was created.
updated_atstringRFC 3339 time at which the computer was last modified.
archived_atstring | nullRFC 3339 time at which the computer was archived; null while active.

列出电脑

GET /agent/v1/computers● 支持

请求参数

  • limitinteger可选
    默认 20

    query: Maximum number of items to return in this page: a positive integer, at most 100 (default 20; for session resources default and maximum are 1000). A larger value returns 400.

  • pagestring可选

    query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.

返回

200

Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Computer result

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].typestringAlways `computer`. A computer.
data[].idstringComputer id (cmp_...), the computer_id of computer calls.
data[].namestringDisplay name of the computer, 1 to 255 characters.
data[].sandbox_idstring | nullPublic id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created.
data[].environment_idstring | nullEnvironment recipe the computer was created with; null when none.
data[].statusstringactive computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions.
data[].created_atstringRFC 3339 time at which the computer was created.
data[].updated_atstringRFC 3339 time at which the computer was last modified.
data[].archived_atstring | nullRFC 3339 time at which the computer was archived; null while active.
has_morebooleanWhether more items exist beyond this page.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

读取电脑

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

GET /agent/v1/computers/{computer_id}● 支持

请求参数

  • computer_idstring必填

    path: Computer id (cmp_...), as returned by computers.create or computers.list.

返回

200

Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Computer result

application/json

名称类型说明
typestringAlways `computer`. A computer.
idstringComputer id (cmp_...), the computer_id of computer calls.
namestringDisplay name of the computer, 1 to 255 characters.
sandbox_idstring | nullPublic id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created.
environment_idstring | nullEnvironment recipe the computer was created with; null when none.
statusstringactive computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions.
created_atstringRFC 3339 time at which the computer was created.
updated_atstringRFC 3339 time at which the computer was last modified.
archived_atstring | nullRFC 3339 time at which the computer was archived; null while active.
implementationstringHow the computer is backed: a virtual file store or a real sandbox.
storage_bytesintegerBytes stored on the computer.
file_countintegerNumber of files stored on the computer.

更新电脑

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

POST /agent/v1/computers/{computer_id}● 支持

请求参数

  • computer_idstring必填

    path: Computer id (cmp_...), as returned by computers.create or computers.list.

  • namestring必填

    Name of the entry or object.

返回

200

Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Computer result

application/json

名称类型说明
typestringAlways `computer`. A computer.
idstringComputer id (cmp_...), the computer_id of computer calls.
namestringDisplay name of the computer, 1 to 255 characters.
sandbox_idstring | nullPublic id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created.
environment_idstring | nullEnvironment recipe the computer was created with; null when none.
statusstringactive computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions.
created_atstringRFC 3339 time at which the computer was created.
updated_atstringRFC 3339 time at which the computer was last modified.
archived_atstring | nullRFC 3339 time at which the computer was archived; null while active.

归档电脑

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

POST /agent/v1/computers/{computer_id}/archive● 支持

请求参数

  • computer_idstring必填

    path: Computer id (cmp_...), as returned by computers.create or computers.list.

返回

200

Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Computer result

application/json

名称类型说明
typestringAlways `computer`. A computer.
idstringComputer id (cmp_...), the computer_id of computer calls.
namestringDisplay name of the computer, 1 to 255 characters.
sandbox_idstring | nullPublic id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created.
environment_idstring | nullEnvironment recipe the computer was created with; null when none.
statusstringactive computers can be used by new sessions; archived ones keep their files readable but cannot start new sessions.
created_atstringRFC 3339 time at which the computer was created.
updated_atstringRFC 3339 time at which the computer was last modified.
archived_atstring | nullRFC 3339 time at which the computer was archived; null while active.

删除已归档电脑

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

DELETE /agent/v1/computers/{computer_id}● 支持

请求参数

  • computer_idstring必填

    path: Computer id (cmp_...), as returned by computers.create or computers.list.

返回

200

Praxis 扩展:Managed Agents 没有持久 Computer 的删除生命周期。仅允许已归档的电脑;active 返回 400 COMPUTER_ACTIVE(先归档),先销毁电脑数据再删除登记,成功返回 id 和 type=computer_deleted;不存在或跨租户返回 404。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Computer result

application/json

名称类型说明
idstringId of the deleted computer.
typestringAlways `computer_deleted`. Confirms that a computer was deleted.

浏览电脑文件

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

GET /agent/v1/computers/{computer_id}/files● 支持

请求参数

  • computer_idstring必填

    path: Computer id (cmp_...), as returned by computers.create or computers.list.

  • pathstring可选
    默认 "/"

    query: Directory on the computer to list; absolute path as returned in the path field of an earlier listing. Omit it to list from the computer's root.

返回

200

Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Computer result

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].pathstringAbsolute path of the entry on the computer.
data[].namestringName of the entry or object.
data[].typestringKind of entry: a file, a directory or a symbolic link.
data[].sizeintegerSize in bytes.
data[].mime_typestringMIME type of the file.
data[].read_onlybooleanTrue when the entry cannot be modified through the API.
data[].digeststring | nullContent digest of the file; null when not computed.
data[].updated_atstring | nullRFC 3339 time at which the object was last modified.
has_morebooleanWhether more items exist beyond this page.

读取电脑文件内容

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

GET /agent/v1/computers/{computer_id}/files/content● 支持

请求参数

  • computer_idstring必填

    path: Computer id (cmp_...), as returned by computers.create or computers.list.

  • pathstring必填

    query: Absolute path of the file whose content to download, as returned in the path field of computers.files.list.

返回

200

Praxis 超集:MA 只有会话级临时容器与 memory_stores,没有可长期存续、可浏览的整台电脑。归档后文件仍可读,但不能用于新会话。environment_id 是可空配方引用;电脑默认使用 light sandbox,sandbox_id 为 SDK 可用的公开 ID。分页包含归档电脑。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Raw file bytes (at most 16 MiB); Content-Type is inferred from the extension. ETag is present only when a digest is available. Larger files require the sandbox connection issued by connect.

application/octet-stream

名称类型说明
$string (binary)

HTTP 206

Single byte range

application/octet-stream

名称类型说明
$string (binary)

连接电脑

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

POST /agent/v1/computers/{computer_id}/connect● 支持

请求参数

  • computer_idstring必填

    path: Computer id (cmp_...), as returned by computers.create or computers.list.

返回

200

Praxis 自有扩展:Managed Agents 没有持久 Computer 连接。返回 SDK 可用的公开 sandbox_id、envd_access_token 和 template_id。归档电脑仍可连接;跨租户或不存在返回 404。连接凭证不可缓存。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Computer result

application/json

名称类型说明
sandbox_idstringPublic id of the sandbox that backs the computer, usable with the sandbox API; null while none has been created.
envd_access_tokenstringAccess token for the sandbox's environment daemon, returned by the connect call; treat it as a secret.
template_idstringSandbox template the computer's sandbox was created from.

上传电脑附件

先调用「创建计算机」,用返回的计算机 ID 替换 cmp_123。

POST /agent/v1/computers/{computer_id}/attachments● 支持

请求参数

  • computer_idstring必填

    path: Computer id (cmp_...), as returned by computers.create or computers.list.

  • namestring必填

    query: Single filename, at most 255 UTF-8 bytes, excluding slash, dot segments and control characters.

返回

201

Praxis 扩展:Managed Agents 没有持久 Computer 附件目录。用户上传可以覆盖同名附件,智能体始终只读;运行令牌调用上传返回 403 READ_ONLY。name 是单个文件名、最多 255 UTF-8 字节,MIME 始终按扩展名推断,上传的 Content-Type 不持久保存,digest 可省略。上限 16 MiB,超限 413、非法名字 400;归档电脑也可上传,跨租户 404。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 201

Computer result

application/json

名称类型说明
pathstringAbsolute path of the entry on the computer.
namestringName of the entry or object.
typestringKind of entry: a file, a directory or a symbolic link.
sizeintegerSize in bytes.
mime_typestringMIME type of the file.
read_onlybooleanTrue when the entry cannot be modified through the API.
digeststring | nullContent digest of the file; null when not computed.
updated_atstring | nullRFC 3339 time at which the object was last modified.

先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。 先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /agent/v1/sessions/{session_id}/resources◐ 部分支持

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • typestring必填

    query: Resource type selector for the body; only file resources are supported. Normally you send type inside the JSON body and omit this parameter.

    取值 file
  • file_idstring必填

    ID of a previously uploaded file.

  • mount_pathstring可选

    Mount path in the container. Defaults to `/mnt/session/uploads/<file_id>`.

返回

200

支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringResource id, the resource_id of sessions.resources calls.
created_atstringA timestamp in RFC 3339 format
file_idstringId of the uploaded file; it must exist and belong to your tenant.
mount_pathstringPath inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there.
typestringAlways `file`. A file resource: an uploaded file mounted into the session's machine.
updated_atstringA timestamp in RFC 3339 format

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/resources◐ 部分支持

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • limitnumber可选

    query: Number of items per page.

  • pagestring可选

    query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.

返回

200

支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringResource id, the resource_id of sessions.resources calls.
data[].created_atstringA timestamp in RFC 3339 format
data[].mount_pathstring | null | stringPath inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. / Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.
data[].typestringAlways `github_repository`. A GitHub repository resource; not supported on this platform. / Always `file`. A file resource: an uploaded file mounted into the session's machine. / Always `memory_store`. A memory store resource; not supported on this platform.
data[].updated_atstringA timestamp in RFC 3339 format
data[].urlstringRepository URL.
data[].checkoutnull | objectBranch or commit to check out.
data[].file_idstringId of the uploaded file; it must exist and belong to your tenant.
data[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
data[].accessnull | stringAccess mode for an attached memory store.
data[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
data[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
data[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。 先调用「添加会话资源」,用返回的资源 ID 替换 sesrsc_123。

GET /agent/v1/sessions/{session_id}/resources/{resource_id}◐ 部分支持

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • resource_idstring必填

    path: Id of a resource attached to the session, as returned by sessions.resources.add or sessions.resources.list.

  • session_idstring必填

    query: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

返回

200

支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringResource id, the resource_id of sessions.resources calls.
created_atstringA timestamp in RFC 3339 format
mount_pathstring | null | stringPath inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. / Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.
typestringAlways `github_repository`. A GitHub repository resource; not supported on this platform. / Always `file`. A file resource: an uploaded file mounted into the session's machine. / Always `memory_store`. A memory store resource; not supported on this platform.
updated_atstringA timestamp in RFC 3339 format
urlstringRepository URL.
checkoutnull | objectBranch or commit to check out.
checkout.namestringBranch name to check out.
checkout.typestringAlways `branch`. Check out the named branch. / Always `commit`. Check out the commit with the given SHA.
checkout.shastringFull commit SHA to check out.
file_idstringId of the uploaded file; it must exist and belong to your tenant.
memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
accessnull | stringAccess mode for an attached memory store.
descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。 先调用「添加会话资源」,用返回的资源 ID 替换 sesrsc_123。

DELETE /agent/v1/sessions/{session_id}/resources/{resource_id}◐ 部分支持

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • resource_idstring必填

    path: Id of a resource attached to the session, as returned by sessions.resources.add or sessions.resources.list.

  • session_idstring必填

    query: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

返回

200

支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
typestringAlways `session_resource_deleted`. Confirms that a resource was detached from the session.

列出智能体

GET /agent/v1/agents● 支持

Claude 官方文档 ↗

请求参数

  • created_at[gte]string可选

    query: Return agents created at or after this time (inclusive).

  • created_at[lte]string可选

    query: Return agents created at or before this time (inclusive).

  • include_archivedboolean可选

    query: Include archived agents in results. Defaults to false.

  • limitnumber可选

    query: Number of items per page.

  • pagestring可选

    query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.

返回

200

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].created_atstringA timestamp in RFC 3339 format
data[].descriptionnull | stringFree-text description of what the agent is for; null when none was set.
data[].mcp_serversarray<object>URL MCP servers the agent can call, paired one-to-one with mcp_toolset entries in tools and saved with the agent version. No credentials are stored here.
data[].metadataobjectFree-form string key/value pairs stored with the agent for your own bookkeeping.
data[].modelobjectModel identifier and configuration.
data[].multiagentnull | objectResolved coordinator topology with a concrete agent roster.
data[].namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
data[].skillsarray<object>Skills attached to the agent. Setting skills is not supported on this platform and returns 400, so do not send this field on create or update.
data[].systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
data[].toolsarray<object>Tools of the agent: one agent_toolset_20260401 entry for the native tools (all resolved settings are returned, ready to send back on update), plus mcp_toolset entries and custom tool definitions.
data[].typestringAlways `agent`. An agent definition.
data[].updated_atstringA timestamp in RFC 3339 format
data[].versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.
data[].computer_idstringPraxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected.
data[].subagent_modelstring | nullPraxis extension: default subagent model ID, pinned in the agent revision. Call model overrides this; otherwise it overrides the roster member model or the parent model for built-ins. Null clears the default. /agent/v1 only.
data[].modelsobject扩展 / Praxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

POST /agent/v1/agents◐ 部分支持

Claude 官方文档 ↗

请求体

  • namestring必填

    智能体名称,1–255 个字符,工作区内可读。

  • modelstring | object必填

    智能体使用的模型:直接写模型名字符串(如 claude-opus-5),或传对象做附加配置(见子字段)。

    ▸ 展开子字段(5)
    • idstring必填

      模型名字符串,如 claude-opus-5。

    • effortstring | object可选

      每次推理的思考力度:可传级别字符串(如 high)或 {type: high} 对象。创建时省略取该模型的默认值;更新时省略保持不变。

    • inference_geostring可选

      模型推理的地理区域;不传沿用工作区默认。model 是整体替换字段,更新时省略子字段即清除该项。

    • speedstring可选

      推理速度模式:fast 出字显著更快但按溢价计费;并非所有模型都支持,不支持的组合在创建时被拒。

    • settingsobject可选

      Platform model settings. Only reasoning is supported; other model controls return 400.

  • systemstring可选

    智能体的系统提示词。

  • metadataobject可选

    自定义元数据键值对,最多 16 个键、每个值最长 512 字符。

  • descriptionstring可选

    智能体的用途说明。

  • mcp_serversarray可选

    智能体连接的 MCP 服务器列表,最多 20 个,名称必须唯一;每个服务器都要被 tools 里的 mcp_toolset 引用,否则整笔请求被拒。

    ▸ 展开子字段(3)
    • typestring必填

      服务器类型,目前只支持 url。

      取值 url
    • namestring必填

      MCP 服务器在本列表内的唯一名称,1–255 个字符,供 mcp_toolset 配置引用。

    • urlstring必填

      MCP 服务器的端点地址。

  • multiagentobject可选◐ 部分支持

    多智能体协作拓扑:会话主线程作为协调者,从 agents 名单派生会话线程执行工作。

    ▸ 展开子字段(2)
    • agentsarray必填

      协调者可以派生为会话线程的智能体名单,1–20 项;支持 ID 字符串、{type: agent, id, version?} 和最多一个 {type: self}。创建/更新时固定版本。成员须唯一、存在且未归档,不能自身带 multiagent。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。

    • typestring必填

      拓扑类型,目前只有 coordinator。

      取值 coordinator
  • skillsarray可选

    智能体可用的 Skill 列表。

  • toolsarray可选

    智能体可用的工具配置,所有工具合计最多 128 个。

  • computer_idstring可选

    Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined.

  • ▸ 更多参数(2)
    • subagent_modelstring可选

      /agent/v1 扩展:智能体级子智能体默认模型 ID,随修订固定。省略保持,null 清除。调用 model 优先,其次本字段,再其次名册成员模型或内置类型的父会话模型。/anthropic 不接受或返回此字段。

    • modelsobject可选

      扩展:可切换模型列表,仅 /agent/v1 支持。

      ▸ 展开子字段(1)
      • allowedarray必填

        必须包含默认模型;创建时省略表示只能使用默认模型。更新时省略保持不变。会话使用其钉住版本的列表。

返回

200

agent_toolset_20260401 是原生工具集,包含 bash、edit、glob、grep、read、write、web_search、web_fetch,以及 TaskOutput、TaskStop、Monitor、Agent、SendMessage。新建智能体默认全部启用;configs 可逐个设置 name、enabled、permission_policy,未列出的工具遵循 default_config(默认启用)。后台任务、Monitor 和子智能体依赖 bash;启用任一后台工具时,bash 提供 run_in_background。兼容 API /anthropic 只接受和返回官方 8 个工具,经该入口创建的会话也只注册这 8 个工具。 支持文本提示词、模型、元数据与内置工具。model.settings.reasoning 可选 low、medium、high、xhigh、none,为会话提供默认思考档位;会话显式 thinking 优先,不支持的默认值回退到模型 default_effort。示例 model: {id: "deepseek-v4-flash", settings: {reasoning: "high"}}。Skills 及其它额外模型控制尚不支持,传入会返回 400。可在工具集 permissions 中设置 allow、ask、deny 规则,最多共 100 条,用于以后的对话。 multiagent 接受 null 或 coordinator 名册,1–20 项:智能体 ID、{type:"agent",id,version?} 或最多一个 {type:"self"}。创建/更新时固定版本;成员去重且须存在、未归档、不能自身带 multiagent。名册可启用 Agent,仍需启用 bash;SendMessage 遵循工具配置。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。 /agent/v1 顶层 subagent_model 是可空模型 ID,随智能体版本保存;省略保留、null 清除。模型须存在。优先级为调用 model > subagent_model > 成员模型(内置类型用父会话模型)。/anthropic 不接受或返回此字段。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | stringFree-text description of what the agent is for; null when none was set.
mcp_serversarray<object>URL MCP servers the agent can call, paired one-to-one with mcp_toolset entries in tools and saved with the agent version. No credentials are stored here.
mcp_servers[].typestringAlways `url`. An MCP server reached over a URL.
mcp_servers[].namestringName of the MCP server; the mcp_toolset entry that refers to it uses the same name in mcp_server_name.
mcp_servers[].urlstringhttp(s) endpoint of the MCP server, at most 2048 characters.
metadataobjectFree-form string key/value pairs stored with the agent for your own bookkeeping.
modelobjectModel identifier and configuration.
model.idstringThe model that will power your agent. See models for additional details and options.
model.effortobjectHow hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes.
model.inference_geostringGeographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo.
model.speedstringInference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.
model.settingsobjectPlatform model settings. Only reasoning is supported; other model controls return 400.
multiagentnull | objectResolved coordinator topology with a concrete agent roster.
multiagent.agentsarray<object>Agents the coordinator may spawn as session threads, each resolved to a specific version.
multiagent.typestringAlways `coordinator`. The agent coordinates the roster in agents and can delegate to its members.
namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
skillsarray<object>Skills attached to the agent. Setting skills is not supported on this platform and returns 400, so do not send this field on create or update.
skills[].skill_idstringId of the skill to attach.
skills[].typestringAlways `anthropic`. A skill provided by Anthropic, identified by skill_id. / Always `custom`. A skill created by you, identified by skill_id.
skills[].versionstringVersion of the skill; a string.
systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
toolsarray<object>Tools of the agent: one agent_toolset_20260401 entry for the native tools (all resolved settings are returned, ready to send back on update), plus mcp_toolset entries and custom tool definitions.
tools[].configsarray<object> | array | nullPer-tool settings that override default_config. Tools that are not listed follow default_config.
tools[].default_configobject | object | nullResolved default configuration for agent tools. / Settings applied to every tool of this toolset that configs does not name. When omitted, tools are enabled with the always_allow policy.
tools[].typestringAlways `agent_toolset_20260401`. The native toolset entry (bash, edit, glob, grep, read, write, web_search, web_fetch, TaskOutput, TaskStop, Monitor, Agent, SendMessage). / Always `mcp_toolset`. An entry that exposes the tools of one MCP server from mcp_servers. / Always `custom`. A custom tool defined by name, description and input_schema; its calls are answered by the client with user.custom_tool_result.
tools[].mcp_server_namestringName of the MCP server in mcp_servers whose tools this entry exposes.
tools[].descriptionstringWhat the custom tool does and when the model should call it.
tools[].input_schemaobjectJSON Schema for custom tool input parameters.
tools[].namestringName of the custom tool, as the model sees and calls it.
typestringAlways `agent`. An agent definition.
updated_atstringA timestamp in RFC 3339 format
versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.
computer_idstringPraxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected.
subagent_modelstring | nullPraxis extension: default subagent model ID, pinned in the agent revision. Call model overrides this; otherwise it overrides the roster member model or the parent model for built-ins. Null clears the default. /agent/v1 only.
modelsobject扩展 / Praxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable.
models.allowedarray<string>Model ids a session may select with its model field; it must be non-empty and must contain the agent's default model.

读取智能体

先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。

GET /agent/v1/agents/{agent_id}● 支持

Claude 官方文档 ↗

请求参数

  • agent_idstring必填

    path: Agent id, as returned by agents.create or agents.list (for a session filter, the agent the session was created with). Not the agent name.

  • versionnumber可选

    query: Agent version to read; omit for the latest. Integer of at least 1; versions are listed by agents.versions.list.

返回

200

tools 在一个 agent_toolset_20260401 条目中返回全部原生工具的有效配置,可原样用于更新。将示例中的资源 ID 替换成你创建的资源 ID。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | stringFree-text description of what the agent is for; null when none was set.
mcp_serversarray<object>URL MCP servers the agent can call, paired one-to-one with mcp_toolset entries in tools and saved with the agent version. No credentials are stored here.
mcp_servers[].typestringAlways `url`. An MCP server reached over a URL.
mcp_servers[].namestringName of the MCP server; the mcp_toolset entry that refers to it uses the same name in mcp_server_name.
mcp_servers[].urlstringhttp(s) endpoint of the MCP server, at most 2048 characters.
metadataobjectFree-form string key/value pairs stored with the agent for your own bookkeeping.
modelobjectModel identifier and configuration.
model.idstringThe model that will power your agent. See models for additional details and options.
model.effortobjectHow hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes.
model.inference_geostringGeographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo.
model.speedstringInference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.
model.settingsobjectPlatform model settings. Only reasoning is supported; other model controls return 400.
multiagentnull | objectResolved coordinator topology with a concrete agent roster.
multiagent.agentsarray<object>Agents the coordinator may spawn as session threads, each resolved to a specific version.
multiagent.typestringAlways `coordinator`. The agent coordinates the roster in agents and can delegate to its members.
namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
skillsarray<object>Skills attached to the agent. Setting skills is not supported on this platform and returns 400, so do not send this field on create or update.
skills[].skill_idstringId of the skill to attach.
skills[].typestringAlways `anthropic`. A skill provided by Anthropic, identified by skill_id. / Always `custom`. A skill created by you, identified by skill_id.
skills[].versionstringVersion of the skill; a string.
systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
toolsarray<object>Tools of the agent: one agent_toolset_20260401 entry for the native tools (all resolved settings are returned, ready to send back on update), plus mcp_toolset entries and custom tool definitions.
tools[].configsarray<object> | array | nullPer-tool settings that override default_config. Tools that are not listed follow default_config.
tools[].default_configobject | object | nullResolved default configuration for agent tools. / Settings applied to every tool of this toolset that configs does not name. When omitted, tools are enabled with the always_allow policy.
tools[].typestringAlways `agent_toolset_20260401`. The native toolset entry (bash, edit, glob, grep, read, write, web_search, web_fetch, TaskOutput, TaskStop, Monitor, Agent, SendMessage). / Always `mcp_toolset`. An entry that exposes the tools of one MCP server from mcp_servers. / Always `custom`. A custom tool defined by name, description and input_schema; its calls are answered by the client with user.custom_tool_result.
tools[].mcp_server_namestringName of the MCP server in mcp_servers whose tools this entry exposes.
tools[].descriptionstringWhat the custom tool does and when the model should call it.
tools[].input_schemaobjectJSON Schema for custom tool input parameters.
tools[].namestringName of the custom tool, as the model sees and calls it.
typestringAlways `agent`. An agent definition.
updated_atstringA timestamp in RFC 3339 format
versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.
computer_idstringPraxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected.
subagent_modelstring | nullPraxis extension: default subagent model ID, pinned in the agent revision. Call model overrides this; otherwise it overrides the roster member model or the parent model for built-ins. Null clears the default. /agent/v1 only.
modelsobject扩展 / Praxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable.
models.allowedarray<string>Model ids a session may select with its model field; it must be non-empty and must contain the agent's default model.

先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。

POST /agent/v1/agents/{agent_id}◐ 部分支持

Claude 官方文档 ↗

请求参数

  • agent_idstring必填

    path: Agent id, as returned by agents.create or agents.list (for a session filter, the agent the session was created with). Not the agent name.

  • namestring可选

    智能体名称;省略保持不变,不能传空串清除。

  • modelstring | object可选

    智能体使用的模型:直接写模型名字符串(如 claude-opus-5),或传对象做附加配置(见子字段)。

    ▸ 展开子字段(5)
    • idstring必填

      模型名字符串,如 claude-opus-5。

    • effortstring | object可选

      每次推理的思考力度:可传级别字符串(如 high)或 {type: high} 对象。创建时省略取该模型的默认值;更新时省略保持不变。

    • inference_geostring可选

      模型推理的地理区域;不传沿用工作区默认。model 是整体替换字段,更新时省略子字段即清除该项。

    • speedstring可选

      推理速度模式:fast 出字显著更快但按溢价计费;并非所有模型都支持,不支持的组合在创建时被拒。

    • settingsobject可选

      Platform model settings. Only reasoning is supported; other model controls return 400.

  • systemstring可选

    系统提示词;省略保持不变,传空串或 null 清除。

  • versionnumber可选

    智能体当前版本号,用于并发保护:必须与最近一次创建/读取返回的版本一致,否则返回冲突。

  • metadataobject可选

    元数据补丁:键设为字符串即写入,设为 null 即删除;省略该字段保持不变。存储上限 16 个键、每个值 512 字符。

  • descriptionstring可选

    用途说明;省略保持不变,传空串或 null 清除。

  • mcp_serversarray可选

    整体替换的 MCP 服务器列表;省略保持不变,传空数组或 null 清除。

  • multiagentobject可选◐ 部分支持

    多智能体协作拓扑:会话主线程作为协调者,从 agents 名单派生会话线程执行工作。

    ▸ 展开子字段(2)
    • agentsarray必填

      协调者可以派生为会话线程的智能体名单,1–20 项;支持 ID 字符串、{type: agent, id, version?} 和最多一个 {type: self}。创建/更新时固定版本。成员须唯一、存在且未归档,不能自身带 multiagent。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。

    • typestring必填

      拓扑类型,目前只有 coordinator。

      取值 coordinator
  • skillsarray可选

    整体替换的 Skill 列表;省略保持不变,传空数组或 null 清除。

  • ▸ 更多参数(4)
    • toolsarray可选

      整体替换的工具配置;省略保持不变,传空数组或 null 清除。

    • computer_idstring可选

      Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined.

    • subagent_modelstring可选

      /agent/v1 扩展:智能体级子智能体默认模型 ID,随修订固定。省略保持,null 清除。调用 model 优先,其次本字段,再其次名册成员模型或内置类型的父会话模型。/anthropic 不接受或返回此字段。

    • modelsobject可选

      扩展:可切换模型列表,仅 /agent/v1 支持。

      ▸ 展开子字段(1)
      • allowedarray必填

        必须包含默认模型;创建时省略表示只能使用默认模型。更新时省略保持不变。会话使用其钉住版本的列表。

返回

200

通过 agent_toolset_20260401.configs 逐个开关原生工具并设置权限。未列出的工具遵循 default_config;后台任务、Monitor 和子智能体依赖 bash。version 可用于乐观并发控制,版本冲突返回 409;无变化的更新不增加版本。Skills 尚不支持。更新工具集 permissions 可把允许的同类操作保存到智能体的新版本,供以后的对话使用。 multiagent 接受 null 或 coordinator 名册,1–20 项:智能体 ID、{type:"agent",id,version?} 或最多一个 {type:"self"}。创建/更新时固定版本;成员去重且须存在、未归档、不能自身带 multiagent。名册可启用 Agent,仍需启用 bash;SendMessage 遵循工具配置。每个 coordinator 最多一个 advisor,模型须可用且不同于智能体模型;仅主会话可咨询,每次咨询为独立 advisor 线程,建议以 agent.thread_message_received 返回。 /agent/v1 顶层 subagent_model 是可空模型 ID,随智能体版本保存;省略保留、null 清除。模型须存在。优先级为调用 model > subagent_model > 成员模型(内置类型用父会话模型)。/anthropic 不接受或返回此字段。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | stringFree-text description of what the agent is for; null when none was set.
mcp_serversarray<object>URL MCP servers the agent can call, paired one-to-one with mcp_toolset entries in tools and saved with the agent version. No credentials are stored here.
mcp_servers[].typestringAlways `url`. An MCP server reached over a URL.
mcp_servers[].namestringName of the MCP server; the mcp_toolset entry that refers to it uses the same name in mcp_server_name.
mcp_servers[].urlstringhttp(s) endpoint of the MCP server, at most 2048 characters.
metadataobjectFree-form string key/value pairs stored with the agent for your own bookkeeping.
modelobjectModel identifier and configuration.
model.idstringThe model that will power your agent. See models for additional details and options.
model.effortobjectHow hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes.
model.inference_geostringGeographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo.
model.speedstringInference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.
model.settingsobjectPlatform model settings. Only reasoning is supported; other model controls return 400.
multiagentnull | objectResolved coordinator topology with a concrete agent roster.
multiagent.agentsarray<object>Agents the coordinator may spawn as session threads, each resolved to a specific version.
multiagent.typestringAlways `coordinator`. The agent coordinates the roster in agents and can delegate to its members.
namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
skillsarray<object>Skills attached to the agent. Setting skills is not supported on this platform and returns 400, so do not send this field on create or update.
skills[].skill_idstringId of the skill to attach.
skills[].typestringAlways `anthropic`. A skill provided by Anthropic, identified by skill_id. / Always `custom`. A skill created by you, identified by skill_id.
skills[].versionstringVersion of the skill; a string.
systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
toolsarray<object>Tools of the agent: one agent_toolset_20260401 entry for the native tools (all resolved settings are returned, ready to send back on update), plus mcp_toolset entries and custom tool definitions.
tools[].configsarray<object> | array | nullPer-tool settings that override default_config. Tools that are not listed follow default_config.
tools[].default_configobject | object | nullResolved default configuration for agent tools. / Settings applied to every tool of this toolset that configs does not name. When omitted, tools are enabled with the always_allow policy.
tools[].typestringAlways `agent_toolset_20260401`. The native toolset entry (bash, edit, glob, grep, read, write, web_search, web_fetch, TaskOutput, TaskStop, Monitor, Agent, SendMessage). / Always `mcp_toolset`. An entry that exposes the tools of one MCP server from mcp_servers. / Always `custom`. A custom tool defined by name, description and input_schema; its calls are answered by the client with user.custom_tool_result.
tools[].mcp_server_namestringName of the MCP server in mcp_servers whose tools this entry exposes.
tools[].descriptionstringWhat the custom tool does and when the model should call it.
tools[].input_schemaobjectJSON Schema for custom tool input parameters.
tools[].namestringName of the custom tool, as the model sees and calls it.
typestringAlways `agent`. An agent definition.
updated_atstringA timestamp in RFC 3339 format
versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.
computer_idstringPraxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected.
subagent_modelstring | nullPraxis extension: default subagent model ID, pinned in the agent revision. Call model overrides this; otherwise it overrides the roster member model or the parent model for built-ins. Null clears the default. /agent/v1 only.
modelsobject扩展 / Praxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable.
models.allowedarray<string>Model ids a session may select with its model field; it must be non-empty and must contain the agent's default model.

列出版本

先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。

GET /agent/v1/agents/{agent_id}/versions● 支持

Claude 官方文档 ↗

请求参数

  • agent_idstring必填

    path: Agent id, as returned by agents.create or agents.list (for a session filter, the agent the session was created with). Not the agent name.

  • limitnumber可选

    query: Number of items per page.

  • pagestring可选

    query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.

返回

200

将示例中的资源 ID 替换成你创建的资源 ID。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].created_atstringA timestamp in RFC 3339 format
data[].descriptionnull | stringFree-text description of what the agent is for; null when none was set.
data[].mcp_serversarray<object>URL MCP servers the agent can call, paired one-to-one with mcp_toolset entries in tools and saved with the agent version. No credentials are stored here.
data[].metadataobjectFree-form string key/value pairs stored with the agent for your own bookkeeping.
data[].modelobjectModel identifier and configuration.
data[].multiagentnull | objectResolved coordinator topology with a concrete agent roster.
data[].namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
data[].skillsarray<object>Skills attached to the agent. Setting skills is not supported on this platform and returns 400, so do not send this field on create or update.
data[].systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
data[].toolsarray<object>Tools of the agent: one agent_toolset_20260401 entry for the native tools (all resolved settings are returned, ready to send back on update), plus mcp_toolset entries and custom tool definitions.
data[].typestringAlways `agent`. An agent definition.
data[].updated_atstringA timestamp in RFC 3339 format
data[].versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.
data[].computer_idstringPraxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected.
data[].subagent_modelstring | nullPraxis extension: default subagent model ID, pinned in the agent revision. Call model overrides this; otherwise it overrides the roster member model or the parent model for built-ins. Null clears the default. /agent/v1 only.
data[].modelsobject扩展 / Praxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

归档智能体

先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。

POST /agent/v1/agents/{agent_id}/archive● 支持

Claude 官方文档 ↗

请求参数

  • agent_idstring必填

    path: Agent id, as returned by agents.create or agents.list (for a session filter, the agent the session was created with). Not the agent name.

返回

200

归档后保留查询与历史版本,不能继续更新。请只归档自己的测试智能体。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
descriptionnull | stringFree-text description of what the agent is for; null when none was set.
mcp_serversarray<object>URL MCP servers the agent can call, paired one-to-one with mcp_toolset entries in tools and saved with the agent version. No credentials are stored here.
mcp_servers[].typestringAlways `url`. An MCP server reached over a URL.
mcp_servers[].namestringName of the MCP server; the mcp_toolset entry that refers to it uses the same name in mcp_server_name.
mcp_servers[].urlstringhttp(s) endpoint of the MCP server, at most 2048 characters.
metadataobjectFree-form string key/value pairs stored with the agent for your own bookkeeping.
modelobjectModel identifier and configuration.
model.idstringThe model that will power your agent. See models for additional details and options.
model.effortobjectHow hard Claude works on each turn. Sets `output_config.effort` on every Messages call the session makes.
model.inference_geostringGeographic region for model inference. When unset, requests fall through to the workspace's default_inference_geo.
model.speedstringInference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.
model.settingsobjectPlatform model settings. Only reasoning is supported; other model controls return 400.
multiagentnull | objectResolved coordinator topology with a concrete agent roster.
multiagent.agentsarray<object>Agents the coordinator may spawn as session threads, each resolved to a specific version.
multiagent.typestringAlways `coordinator`. The agent coordinates the roster in agents and can delegate to its members.
namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
skillsarray<object>Skills attached to the agent. Setting skills is not supported on this platform and returns 400, so do not send this field on create or update.
skills[].skill_idstringId of the skill to attach.
skills[].typestringAlways `anthropic`. A skill provided by Anthropic, identified by skill_id. / Always `custom`. A skill created by you, identified by skill_id.
skills[].versionstringVersion of the skill; a string.
systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
toolsarray<object>Tools of the agent: one agent_toolset_20260401 entry for the native tools (all resolved settings are returned, ready to send back on update), plus mcp_toolset entries and custom tool definitions.
tools[].configsarray<object> | array | nullPer-tool settings that override default_config. Tools that are not listed follow default_config.
tools[].default_configobject | object | nullResolved default configuration for agent tools. / Settings applied to every tool of this toolset that configs does not name. When omitted, tools are enabled with the always_allow policy.
tools[].typestringAlways `agent_toolset_20260401`. The native toolset entry (bash, edit, glob, grep, read, write, web_search, web_fetch, TaskOutput, TaskStop, Monitor, Agent, SendMessage). / Always `mcp_toolset`. An entry that exposes the tools of one MCP server from mcp_servers. / Always `custom`. A custom tool defined by name, description and input_schema; its calls are answered by the client with user.custom_tool_result.
tools[].mcp_server_namestringName of the MCP server in mcp_servers whose tools this entry exposes.
tools[].descriptionstringWhat the custom tool does and when the model should call it.
tools[].input_schemaobjectJSON Schema for custom tool input parameters.
tools[].namestringName of the custom tool, as the model sees and calls it.
typestringAlways `agent`. An agent definition.
updated_atstringA timestamp in RFC 3339 format
versionnumberThe agent's current version. Starts at 1 and increments when the agent is modified.
computer_idstringPraxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected.
subagent_modelstring | nullPraxis extension: default subagent model ID, pinned in the agent revision. Call model overrides this; otherwise it overrides the roster member model or the parent model for built-ins. Null clears the default. /agent/v1 only.
modelsobject扩展 / Praxis extension: switchable model ids on /agent/v1 only. The default model must be included. When omitted, only the default model is selectable.
models.allowedarray<string>Model ids a session may select with its model field; it must be non-empty and must contain the agent's default model.

GET /agent/v1/sessions◐ 部分支持

Claude 官方文档 ↗

请求参数

  • agent_idstring可选

    query: Return only sessions created with this agent id (from agents.list or agents.create). This is one of the three filters sessions.list supports.

  • agent_versionnumber可选

    query: 按智能体版本过滤;仅在同时设置 agent_id 时生效。

  • created_at[gt]string可选

    query: Exclusive created-at lower bound for sessions. Declared by the Managed Agents shape but not supported here; sending it returns 400.

  • created_at[gte]string可选

    query: Created-at lower bound for sessions. Declared by the Managed Agents shape but not supported here: sessions.list honors only limit, page and agent_id, and other filters return 400.

  • created_at[lt]string可选

    query: Exclusive created-at upper bound for sessions. Declared by the Managed Agents shape but not supported here; sending it returns 400.

  • created_at[lte]string可选

    query: Created-at upper bound for sessions. Declared by the Managed Agents shape but not supported here: sessions.list honors only limit, page and agent_id, and other filters return 400.

  • deployment_idstring可选

    query: Declared by the Managed Agents shape but not supported by sessions.list; sending it returns 400.

  • include_archivedboolean可选

    query: Declared by the Managed Agents shape but not supported by sessions.list; sending it returns 400. Archived sessions are retrievable by id.

  • memory_store_idstring可选

    query: Declared by the Managed Agents shape but not supported by sessions.list; sending it returns 400.

  • orderstring可选

    query: 按创建时间排序:asc 从旧到新,desc 从新到旧(默认)。

  • ▸ 更多参数(3)
    • statusesarray可选

      query: 按会话状态过滤,可重复该参数匹配多种状态。

    • limitnumber可选

      query: Number of items per page.

    • pagestring可选

      query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.

返回

200

支持 limit、page 与 agent_id;agent_version、时间范围、deployment_id、memory_store_id、include_archived、order、statuses 尚不支持,传入返回 400。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringSession id (sesn_...). Pass it as session_id in every session call.
data[].agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
data[].created_atstringA timestamp in RFC 3339 format
data[].environment_idstringId of the environment recipe the session's sandbox was created from. Omitted when no recipe was selected, that is, for a light machine or the Computer chosen by computer_id.
data[].metadataobjectFree-form string key/value pairs stored with the session, changed through sessions.update patch semantics.
data[].outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
data[].resourcesarray<object>Resources attached to the session, at most 500; each is a file reference mounted into the session's machine.
data[].statsobjectTiming statistics for a session.
data[].statusstringSessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion.
data[].titlenull | stringTitle of the session, set on create or through sessions.update; null when none was set.
data[].typestringAlways `session`. A session, one conversation of an agent on a machine.
data[].updated_atstringA timestamp in RFC 3339 format
data[].usageobjectCumulative token usage for a session across all turns.
data[].vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
data[].deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.
data[].cwdstringNormalized session working directory; defaults to /home/user/workspace. Forks inherit this directory.
data[].computer_idstringPraxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected.
data[].modelobject扩展 / Praxis extension: the currently selected session model.
data[].thinkingobject | nullPraxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error.
data[].forked_fromobject | nullPraxis extension: source of a forked session; null for other sessions. Available only on /agent/v1.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。

POST /agent/v1/sessions◐ 部分支持

Claude 官方文档 ↗

请求体

  • modelstring可选

    智能体使用的模型:直接写模型名字符串(如 claude-opus-5),或传对象做附加配置(见子字段)。

  • agentstring | object必填

    会话要运行的智能体:直接写智能体 ID 字符串(固定用最新版本),或传对象指定 id 与 version(见子字段)。

    ▸ 展开子字段(8)
    • idstring必填

      会话要运行的智能体 ID。

    • typestring必填

      引用类型,目前只有 agent。

      取值 agent_with_overrides
    • versionnumber可选

      固定使用的智能体版本;省略用最新版本。

    • mcp_serversarray可选

      替换本会话的 MCP 服务器列表:传入的数组整体生效;传空数组清除,省略沿用智能体的配置。

    • modelstring | object可选

      替换本会话的模型:模型名字符串(如 claude-opus-5)或配置对象;省略沿用智能体自身的模型。

    • skillsarray可选

      替换本会话的 Skill 列表;传空数组清除,省略沿用智能体的配置。

    • systemstring可选

      替换本会话的系统提示词,最长 100,000 字符;传 null 清除,省略沿用智能体的。

    • toolsarray可选

      替换本会话的工具配置;传空数组清除,省略沿用智能体的配置。

  • environment_idstring可选

    会话运行所在的环境 ID,决定容器的基础环境。

  • titlestring可选

    会话标题,便于在控制台辨认。

  • metadataobject可选

    会话的自定义元数据键值对。

  • budgetobject可选

    会话的预算上限设置。

    ▸ 展开子字段(2)
    • max_list_costobject必填

      预算内列表类调用的花费上限。

    • typestring必填

      预算类型,目前只有 max_list_cost。

      取值 limit
  • initial_eventsarray可选

    创建时按顺序发给会话的初始事件,支持 user.message 与 user.define_outcome,一次最多 50 条。

  • resourcesarray可选

    要挂载进会话容器的资源(如代码仓库、文件)。

  • vault_idsarray可选

    保险库 ID 列表:会话里智能体可以使用这些已存凭据。

  • cwdstring可选
    默认 "/home/user/workspace"

    Session working directory on any machine. Must be an absolute path within /home/user with no . or .. segments. Repeated and trailing slashes are normalized. Invalid values return 400 invalid_request_error with Invalid cwd.

  • ▸ 更多参数(3)
    • computer_idstring可选

      Praxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined.

    • time_zonestring可选
      默认 "UTC"

      Praxis extension: the session's IANA time zone name (e.g. Asia/Shanghai) — the clock the runtime environment block renders for every turn. Absent means UTC. Only IANA names are accepted; fixed offsets ("+08:00") and unknown names return 400. Never stored in `metadata`.

    • thinkingobject可选

      Praxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error.

      ▸ 展开子字段(1)
      • effortstring必填

        Thinking level for this session. The model must support the chosen effort; none requires can_disable. Null on thinking restores inheritance from the agent and model.

        取值 lowmediumhighxhighnone

返回

200

可在创建时传 model(models.allowed 内的 ID 字符串;无 allowed 时只允许默认模型)与 thinking({effort: "low|medium|high|xhigh|none"} 或 null),在首条 initial_events 执行前保存。省略或 null 继承智能体默认,再使用模型默认。档位必须在 model.thinking.efforts 内;none 要求 can_disable 为 true,否则返回 400 invalid_request_error。响应包含 thinking 与 model.thinking: {efforts, can_disable, default_effort};未知能力为 null,默认档位也可为 null。示例:{"agent":"agent_123","model":"deepseek-v4-flash","thinking":{"effort":"xhigh"}}。这些选择字段只在 /agent/v1 提供。先创建智能体,将示例 agent_123 换成返回的 id。省略 environment_id 得到轻量机器(light),有默认或显式 computer_id 时使用该 Computer;指定 node22 或租户自建 cloud 环境则使用沙箱配方。无配方时响应省略 environment_id。不支持内联智能体覆盖、预算与凭据库。支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 201

Successful response

application/json

名称类型说明
idstringSession id (sesn_...). Pass it as session_id in every session call.
agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
agent.idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
agent.descriptionnull | stringFree-text description of what the agent is for; null when none was set.
agent.mcp_serversarray<object>URL MCP servers the agent can call, paired one-to-one with mcp_toolset entries in tools and saved with the agent version. No credentials are stored here.
agent.modelobjectModel identifier and configuration.
agent.multiagentnull | objectResolved coordinator topology with full agent definitions for each roster member.
agent.namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
agent.skillsarray<object>Skills attached to the agent. Setting skills is not supported on this platform and returns 400, so do not send this field on create or update.
agent.systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
agent.toolsarray<object>Tools of the agent: one agent_toolset_20260401 entry for the native tools (all resolved settings are returned, ready to send back on update), plus mcp_toolset entries and custom tool definitions.
agent.typestringAlways `agent`. An agent definition.
agent.versionnumberThe agent's current version. Starts at 1 and increments each time the agent is modified.
archived_atnull | stringA timestamp in RFC 3339 format
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestringAlways `limit`. A spending limit.
created_atstringA timestamp in RFC 3339 format
environment_idstringId of the environment recipe the session's sandbox was created from. Omitted when no recipe was selected, that is, for a light machine or the Computer chosen by computer_id.
metadataobjectFree-form string key/value pairs stored with the session, changed through sessions.update patch semantics.
outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
outcome_evaluations[].completed_atnull | stringA timestamp in RFC 3339 format
outcome_evaluations[].descriptionstringWhat the agent should produce.
outcome_evaluations[].explanationnull | stringGrader's verdict text from the most recent evaluation. For `satisfied`, explains why criteria are met; for `needs_revision` (intermediate), what's missing; for `failed`, why unrecoverable.
outcome_evaluations[].iterationnumber0-indexed revision cycle the outcome is currently on.
outcome_evaluations[].outcome_idstringServer-generated outc_ ID for this outcome.
outcome_evaluations[].resultstringCurrent evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.
outcome_evaluations[].typestringAlways `outcome_evaluation`. Record of one outcome evaluation.
resourcesarray<object>Resources attached to the session, at most 500; each is a file reference mounted into the session's machine.
resources[].idstringResource id, the resource_id of sessions.resources calls.
resources[].created_atstringA timestamp in RFC 3339 format
resources[].mount_pathstring | null | stringPath inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. / Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.
resources[].typestringAlways `github_repository`. A GitHub repository resource; not supported on this platform. / Always `file`. A file resource: an uploaded file mounted into the session's machine. / Always `memory_store`. A memory store resource; not supported on this platform.
resources[].updated_atstringA timestamp in RFC 3339 format
resources[].urlstringRepository URL.
resources[].checkoutnull | objectBranch or commit to check out.
resources[].file_idstringId of the uploaded file; it must exist and belong to your tenant.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
resources[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
statsobjectTiming statistics for a session.
stats.active_secondsnumberCumulative time in seconds the session spent in `running` status. Excludes idle time.
stats.duration_secondsnumberElapsed time since session creation in seconds. For terminated sessions, frozen at the final update.
statusstringSessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion.
titlenull | stringTitle of the session, set on create or through sessions.update; null when none was set.
typestringAlways `session`. A session, one conversation of an agent on a machine.
updated_atstringA timestamp in RFC 3339 format
usageobjectCumulative token usage for a session across all turns.
usage.active_secondsnumberCumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime cost is priced on.
usage.cache_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.
vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.
cwdstringNormalized session working directory; defaults to /home/user/workspace. Forks inherit this directory.
computer_idstringPraxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected.
modelobject扩展 / Praxis extension: the currently selected session model.
model.idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
model.thinkingobject | nullSupported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable.
thinkingobject | nullPraxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error.
thinking.effortstringThinking level saved for this session: low, medium, high, xhigh, or none to turn thinking off. Null or absent means the session inherits the agent default and then the model default.
forked_fromobject | nullPraxis extension: source of a forked session; null for other sessions. Available only on /agent/v1.
forked_from.session_idstringId of the parent session this session was forked from; it is left unchanged by the fork.
forked_from.message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.

读取会话

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}● 支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

返回

200

将示例中的资源 ID 替换成你创建的资源 ID。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringSession id (sesn_...). Pass it as session_id in every session call.
agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
agent.idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
agent.descriptionnull | stringFree-text description of what the agent is for; null when none was set.
agent.mcp_serversarray<object>URL MCP servers the agent can call, paired one-to-one with mcp_toolset entries in tools and saved with the agent version. No credentials are stored here.
agent.modelobjectModel identifier and configuration.
agent.multiagentnull | objectResolved coordinator topology with full agent definitions for each roster member.
agent.namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
agent.skillsarray<object>Skills attached to the agent. Setting skills is not supported on this platform and returns 400, so do not send this field on create or update.
agent.systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
agent.toolsarray<object>Tools of the agent: one agent_toolset_20260401 entry for the native tools (all resolved settings are returned, ready to send back on update), plus mcp_toolset entries and custom tool definitions.
agent.typestringAlways `agent`. An agent definition.
agent.versionnumberThe agent's current version. Starts at 1 and increments each time the agent is modified.
archived_atnull | stringA timestamp in RFC 3339 format
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestringAlways `limit`. A spending limit.
created_atstringA timestamp in RFC 3339 format
environment_idstringId of the environment recipe the session's sandbox was created from. Omitted when no recipe was selected, that is, for a light machine or the Computer chosen by computer_id.
metadataobjectFree-form string key/value pairs stored with the session, changed through sessions.update patch semantics.
outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
outcome_evaluations[].completed_atnull | stringA timestamp in RFC 3339 format
outcome_evaluations[].descriptionstringWhat the agent should produce.
outcome_evaluations[].explanationnull | stringGrader's verdict text from the most recent evaluation. For `satisfied`, explains why criteria are met; for `needs_revision` (intermediate), what's missing; for `failed`, why unrecoverable.
outcome_evaluations[].iterationnumber0-indexed revision cycle the outcome is currently on.
outcome_evaluations[].outcome_idstringServer-generated outc_ ID for this outcome.
outcome_evaluations[].resultstringCurrent evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.
outcome_evaluations[].typestringAlways `outcome_evaluation`. Record of one outcome evaluation.
resourcesarray<object>Resources attached to the session, at most 500; each is a file reference mounted into the session's machine.
resources[].idstringResource id, the resource_id of sessions.resources calls.
resources[].created_atstringA timestamp in RFC 3339 format
resources[].mount_pathstring | null | stringPath inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. / Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.
resources[].typestringAlways `github_repository`. A GitHub repository resource; not supported on this platform. / Always `file`. A file resource: an uploaded file mounted into the session's machine. / Always `memory_store`. A memory store resource; not supported on this platform.
resources[].updated_atstringA timestamp in RFC 3339 format
resources[].urlstringRepository URL.
resources[].checkoutnull | objectBranch or commit to check out.
resources[].file_idstringId of the uploaded file; it must exist and belong to your tenant.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
resources[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
statsobjectTiming statistics for a session.
stats.active_secondsnumberCumulative time in seconds the session spent in `running` status. Excludes idle time.
stats.duration_secondsnumberElapsed time since session creation in seconds. For terminated sessions, frozen at the final update.
statusstringSessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion.
titlenull | stringTitle of the session, set on create or through sessions.update; null when none was set.
typestringAlways `session`. A session, one conversation of an agent on a machine.
updated_atstringA timestamp in RFC 3339 format
usageobjectCumulative token usage for a session across all turns.
usage.active_secondsnumberCumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime cost is priced on.
usage.cache_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.
vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.
cwdstringNormalized session working directory; defaults to /home/user/workspace. Forks inherit this directory.
computer_idstringPraxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected.
modelobject扩展 / Praxis extension: the currently selected session model.
model.idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
model.thinkingobject | nullSupported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable.
thinkingobject | nullPraxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error.
thinking.effortstringThinking level saved for this session: low, medium, high, xhigh, or none to turn thinking off. Null or absent means the session inherits the agent default and then the model default.
forked_fromobject | nullPraxis extension: source of a forked session; null for other sessions. Available only on /agent/v1.
forked_from.session_idstringId of the parent session this session was forked from; it is left unchanged by the fork.
forked_from.message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.

分支会话(扩展)

POST /agent/v1/sessions/{session_id}/fork● 支持

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • message_idstring必填

    分支点的 UI 消息 ID,取自自有面事件的 message_id 字段;须为成功完成轮次的最后一条助手消息。

返回

201

仅在 /agent/v1 提供。message_id 来自 /agent/v1 事件的同名字段,不是事件 id。复制截至并包含该消息的全部对话与工具调用结果;父会话不变,其他轮次正在运行不影响已有完成轮次的分支。新会话沿用智能体及版本、当前模型与思考设置和 cwd 工作目录,标题为父标题加「 的分支」,作为普通根会话出现在列表中。父会话有沙箱时复制沙箱及内存快照,新会话独立拥有该沙箱;继承的运行中后台任务被终止,门铃目标只保留新会话,新后台任务表为空。父会话没有沙箱时保留懒创建。返回 201,响应与读取会话相同,forked_from 为 {session_id, message_id},普通会话为 null。新会话历史末尾有 session.forked 事件,包含 forked_from_session_id 与 forked_from_message_id。上述字段和事件仅在 /agent/v1 可见。非法请求返回 400;不满足分支条件返回 409 FORK_TARGET_INVALID;会话不存在或不属于调用者返回 404。初始化失败时不公开新会话,并回收已分出的沙箱。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 201

Forked session (same shape as session retrieval)

application/json

名称类型说明
idstringSession id (sesn_...). Pass it as session_id in every session call.
agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
agent.idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
agent.descriptionnull | stringFree-text description of what the agent is for; null when none was set.
agent.mcp_serversarray<object>URL MCP servers the agent can call, paired one-to-one with mcp_toolset entries in tools and saved with the agent version. No credentials are stored here.
agent.modelobjectModel identifier and configuration.
agent.multiagentnull | objectResolved coordinator topology with full agent definitions for each roster member.
agent.namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
agent.skillsarray<object>Skills attached to the agent. Setting skills is not supported on this platform and returns 400, so do not send this field on create or update.
agent.systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
agent.toolsarray<object>Tools of the agent: one agent_toolset_20260401 entry for the native tools (all resolved settings are returned, ready to send back on update), plus mcp_toolset entries and custom tool definitions.
agent.typestringAlways `agent`. An agent definition.
agent.versionnumberThe agent's current version. Starts at 1 and increments each time the agent is modified.
archived_atnull | stringA timestamp in RFC 3339 format
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestringAlways `limit`. A spending limit.
created_atstringA timestamp in RFC 3339 format
environment_idstringId of the environment recipe the session's sandbox was created from. Omitted when no recipe was selected, that is, for a light machine or the Computer chosen by computer_id.
metadataobjectFree-form string key/value pairs stored with the session, changed through sessions.update patch semantics.
outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
outcome_evaluations[].completed_atnull | stringA timestamp in RFC 3339 format
outcome_evaluations[].descriptionstringWhat the agent should produce.
outcome_evaluations[].explanationnull | stringGrader's verdict text from the most recent evaluation. For `satisfied`, explains why criteria are met; for `needs_revision` (intermediate), what's missing; for `failed`, why unrecoverable.
outcome_evaluations[].iterationnumber0-indexed revision cycle the outcome is currently on.
outcome_evaluations[].outcome_idstringServer-generated outc_ ID for this outcome.
outcome_evaluations[].resultstringCurrent evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.
outcome_evaluations[].typestringAlways `outcome_evaluation`. Record of one outcome evaluation.
resourcesarray<object>Resources attached to the session, at most 500; each is a file reference mounted into the session's machine.
resources[].idstringResource id, the resource_id of sessions.resources calls.
resources[].created_atstringA timestamp in RFC 3339 format
resources[].mount_pathstring | null | stringPath inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. / Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.
resources[].typestringAlways `github_repository`. A GitHub repository resource; not supported on this platform. / Always `file`. A file resource: an uploaded file mounted into the session's machine. / Always `memory_store`. A memory store resource; not supported on this platform.
resources[].updated_atstringA timestamp in RFC 3339 format
resources[].urlstringRepository URL.
resources[].checkoutnull | objectBranch or commit to check out.
resources[].file_idstringId of the uploaded file; it must exist and belong to your tenant.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
resources[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
statsobjectTiming statistics for a session.
stats.active_secondsnumberCumulative time in seconds the session spent in `running` status. Excludes idle time.
stats.duration_secondsnumberElapsed time since session creation in seconds. For terminated sessions, frozen at the final update.
statusstringSessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion.
titlenull | stringTitle of the session, set on create or through sessions.update; null when none was set.
typestringAlways `session`. A session, one conversation of an agent on a machine.
updated_atstringA timestamp in RFC 3339 format
usageobjectCumulative token usage for a session across all turns.
usage.active_secondsnumberCumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime cost is priced on.
usage.cache_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.
vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.
cwdstringNormalized session working directory; defaults to /home/user/workspace. Forks inherit this directory.
computer_idstringPraxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected.
modelobject扩展 / Praxis extension: the currently selected session model.
model.idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
model.thinkingobject | nullSupported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable.
thinkingobject | nullPraxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error.
thinking.effortstringThinking level saved for this session: low, medium, high, xhigh, or none to turn thinking off. Null or absent means the session inherits the agent default and then the model default.
forked_fromobject | nullPraxis extension: source of a forked session; null for other sessions. Available only on /agent/v1.
forked_from.session_idstringId of the parent session this session was forked from; it is left unchanged by the fork.
forked_from.message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.

读取会话上下文(扩展)

GET /agent/v1/sessions/{session_id}/context● 支持

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

返回

200

扩展:仅在 /agent/v1 提供,形状参照 Claude Agent SDK getContextUsage(),字段使用 snake_case。detail 固定为 summary:总量优先使用上次模型实测,各来源按本地估算占比摊分,used 分类之和等于 total_tokens。categories 只列非零来源,按 kind(used/free/buffer/deferred)判断用途。key 是稳定来源标识扩展;客户端须容忍未知 key 和新增来源,未知名称回退显示 name。MCP 按服务器归组,插件按 id 归组,摘要单独计量。excluded_items 暂为零。尚无测量时 total_tokens、total_tokens_source、measured_at 为 null,categories 为空,明细为零或空数组。切换模型后 max_tokens、auto_compact_threshold 与 free/buffer 立即按新模型重算,保留最近测量值。窗口未知或自动压缩熔断时 is_auto_compact_enabled 为 false。例如 model.thinking 为 {efforts: [high, xhigh], can_disable: true, default_effort: high}。model.thinking 返回 efforts(支持的档位)、can_disable(是否允许 none)及 default_effort(模型默认档位,可为 null);能力未知时整个 thinking 为 null。会话不存在或调用者不可见时返回 404。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Current model and latest context measurement

application/json

名称类型说明
typestringAlways `session_context`. Snapshot of a session's context window usage.
session_idstringSession whose context this snapshot describes.
modelobjectModel of the session and its context window facts.
model.idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
model.display_namestringHuman-readable name of the model.
model.thinkingobject | nullThinking capability of the model: supported efforts, whether thinking can be disabled, and the default. Null when the capability is unknown.
total_tokensnumber | nullTokens currently occupying the context window; null before the first measurement.
total_tokens_sourcestring | nullWhether total_tokens is the provider-reported input usage (actual) or a local estimate (estimated); null before the first measurement.
max_tokensnumber | nullContext window of the model in tokens; null when the model does not state one.
max_input_tokensnumber | nullMaximum input tokens the model accepts per request; null when not stated.
percentagenumberShare of the context window in use, as a whole-number percent; 0 when the window or usage is unknown.
auto_compact_thresholdnumber | nullToken count at which automatic compaction starts; null when the window is unknown.
is_auto_compact_enabledbooleanWhether automatic compaction is enabled for this session.
clear_tool_results_atnumberToken count at which old tool results are cleared from the context.
detailstringLevel of detail of the snapshot.
categoriesarray<object>Context usage by category; each row has a stable key and a kind.
categories[].keystringPraxis extension: stable source identifier (system, tools, mcp:<server>, plugin:<id>, messages, summary, free, buffer). Clients must tolerate unknown keys and newly added sources; classify rows by kind, not key or name.
categories[].namestringDisplay name of the category.
categories[].tokensnumberTokens used by the category.
categories[].kindstringHow the category counts against the window.
mcp_toolsarray<object>Tokens spent on the tool definitions of each MCP server.
mcp_tools[].namestringName of the MCP tool.
mcp_tools[].server_namestringName of the MCP server that provides the tool.
mcp_tools[].tokensnumberTokens used by the tool definition.
plugin_blocksarray<object>Tokens spent on context blocks injected by each mod.
plugin_blocks[].namestringName of the mod that injected the block.
plugin_blocks[].tokensnumberTokens used by the block.
message_breakdownobjectTokens in the conversation messages, split by role and tool traffic.
message_breakdown.user_message_tokensnumberTokens of user messages.
message_breakdown.assistant_message_tokensnumberTokens of assistant text messages.
message_breakdown.tool_call_tokensnumberTokens of tool-call arguments.
message_breakdown.tool_result_tokensnumberTokens of tool results.
message_breakdown.reasoning_tokensnumberTokens of reasoning content.
message_breakdown.tool_calls_by_typearray<object>Tool-call and tool-result tokens grouped by tool name.
compaction_summaryobject | nullTokens held by the latest compaction summary; null when the session was never compacted.
compaction_summary.tokensnumberTokens of the compaction summary.
excluded_itemsobjectItems removed from the context for content safety, kept for audit only and not counted as usage.
excluded_items.countnumberNumber of excluded items.
excluded_items.tokensnumberTokens of the excluded items.
measured_atstring | nullRFC 3339 time of the measurement; null before the first measurement.

列出后台任务(扩展)

GET /agent/v1/sessions/{session_id}/background_tasks● 支持

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

返回

200

仅在 /agent/v1 提供。kind 是开放字符串。subagent 行的 thread_id 指向对应子线程,其他 kind 为 null。completed 且 delivery=pending 显示 result_pending。notified_at 是系统通知批次被受理开轮的时间,无则 null。trigger_count 仅监视器返回已受理的事件批次数,无记录则 null。时间为 RFC3339。会话不存在或不可见返回 404。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Session background tasks

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
data[].kindstringKind of background task: bash for a command started with run_in_background, monitor for a Monitor watch.
data[].titlestringShort human-readable title of the task or object.
data[].thread_idstring | nullExecution thread the task belongs to; null for the primary thread.
data[].statusstringCurrent lifecycle state.
data[].started_atstringRFC 3339 time at which the task started.
data[].ended_atstring | nullRFC 3339 time at which the task ended; null while it is running.
data[].cancellablebooleanWhether the task can still be stopped.
data[].notified_atstring | nullRFC 3339 time of the latest run that the task's notification started; null while no notification has been delivered.
data[].trigger_countinteger | nullFor a monitor task, how many times its matches woke the session; null for other kinds or before the first notification.

读取后台任务输出(扩展)

GET /agent/v1/sessions/{session_id}/background_tasks/{task_id}/output● 支持

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • task_idstring必填

    path: Background task id (task_...), as listed by sessions.background_tasks.list.

  • offsetinteger可选
    默认 0

    query: Byte offset into the task output to read from; start at 0 and continue with the next_offset of the previous response. Integer of at least 0, default 0.

  • max_bytesinteger可选
    默认 65536

    query: Maximum number of bytes to return: an integer from 1 to 262144, default 65536.

返回

200

offset 默认 0;max_bytes 默认 65536,上限 262144。返回 text、next_offset、eof。沙箱已暂停或不存在时返回空 text、原 offset、eof=true、unavailable=true。读取不确认模型结果。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Background task output byte page

application/json

名称类型说明
textstringText of the block.
next_offsetintegerByte offset to pass as offset to continue reading the output.
eofbooleanTrue when the output has ended and no more bytes will follow.
unavailablebooleanTrue when the output could not be read; text is then empty.

停止后台任务(扩展)

POST /agent/v1/sessions/{session_id}/background_tasks/{task_id}/stop● 支持

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • task_idstring必填

    path: Background task id (task_...), as listed by sessions.background_tasks.list.

返回

200

复用 TaskStop:持久化 stop_requested_at 并终止进程组。返回 BackgroundTask;终止尚未观察到时仍可为 running,但不可取消。已结束或不支持停止的任务返回 409。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Current task after stop request

application/json

名称类型说明
idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
kindstringKind of background task: bash for a command started with run_in_background, monitor for a Monitor watch.
titlestringShort human-readable title of the task or object.
thread_idstring | nullExecution thread the task belongs to; null for the primary thread.
statusstringCurrent lifecycle state.
started_atstringRFC 3339 time at which the task started.
ended_atstring | nullRFC 3339 time at which the task ended; null while it is running.
cancellablebooleanWhether the task can still be stopped.
notified_atstring | nullRFC 3339 time of the latest run that the task's notification started; null while no notification has been delivered.
trigger_countinteger | nullFor a monitor task, how many times its matches woke the session; null for other kinds or before the first notification.

压缩会话(扩展)

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /agent/v1/sessions/{session_id}/compact● 支持

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • instructionsstring可选

    Optional focus instructions for the summary, passed to the summarizing model unchanged.

返回

200

仅在 /agent/v1 提供。请求体可省略或为 {},可选 instructions 必须为字符串且原样传递。Idempotency-Key 请求头原样传递;缺失时生成 UUID。响应为 { type: session_compaction, id, status, reason? },id 是操作 ID。queued/running 返回 202;skipped/succeeded/failed 返回 200。非字符串 instructions 返回 400 invalid_request_error。不存在或不可见的托管会话返回 404 not_found_error。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Skipped, succeeded or failed compaction

application/json

名称类型说明
typestringAlways `session_compaction`. Result of a compaction request.
idstringCompaction operation id; pass it as operation_id to sessions.compact.retrieve.
statusstringState of the compaction operation: queued and running are in progress, skipped means nothing needed compaction, succeeded and failed are final.
reasonstringWhy the compaction was skipped or failed; absent otherwise.

HTTP 202

Queued or running compaction

application/json

名称类型说明
typestringAlways `session_compaction`. Result of a compaction request.
idstringCompaction operation id; pass it as operation_id to sessions.compact.retrieve.
statusstringState of the compaction operation: queued and running are in progress, skipped means nothing needed compaction, succeeded and failed are final.
reasonstringWhy the compaction was skipped or failed; absent otherwise.

读取压缩操作(扩展)

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/compact/{operation_id}● 支持

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • operation_idstring必填

    path: Compaction operation id returned by sessions.compact in the id field of the session_compaction object.

返回

200

仅在 /agent/v1 提供。响应为 { type: session_compaction, id, status, reason? },所有状态均返回 200。操作不存在或会话不可见时返回 404 not_found_error。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Compaction operation

application/json

名称类型说明
typestringAlways `session_compaction`. Result of a compaction request.
idstringCompaction operation id; pass it as operation_id to sessions.compact.retrieve.
statusstringState of the compaction operation: queued and running are in progress, skipped means nothing needed compaction, succeeded and failed are final.
reasonstringWhy the compaction was skipped or failed; absent otherwise.

列出压缩历史(扩展)

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/compactions● 支持

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

返回

200

仅在 /agent/v1 提供。返回 { data: [...] }。每项包含 type、id、event_id、trigger、status、model、compacted_message_count、input_tokens_before、input_tokens_after、summary、error、created_at,字段按服务记录原样返回。不存在或不可见的托管会话返回 404 not_found_error。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Compaction history

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].typestringAlways `context_compaction`. Record of one past compaction.
data[].idstringCompaction record id.
data[].event_idstring | nullId of the agent.thread_context_compacted event emitted for this compaction; null when none.
data[].triggerstringWhat started the compaction.
data[].statusstringFinal outcome of the compaction.
data[].modelstringModel that wrote the summary.
data[].compacted_message_countnumberNumber of messages replaced by the summary.
data[].input_tokens_beforenumberContext tokens before the compaction.
data[].input_tokens_afternumber | nullContext tokens after the compaction; null when not measured.
data[].summarystring | nullSummary text that replaced the messages; null when the compaction failed.
data[].errorstring | nullFailure reason; null when the compaction succeeded.
data[].created_atstringRFC 3339 time at which the compaction was recorded.

列出事件

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/events● 支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • created_at[gt]string可选

    query: Return events created after this time (exclusive). Compared against the event's `processed_at` value.

  • created_at[gte]string可选

    query: Return events created at or after this time (inclusive). Compared against the event's `processed_at` value.

  • created_at[lt]string可选

    query: Return events created before this time (exclusive). Compared against the event's `processed_at` value.

  • created_at[lte]string可选

    query: Return events created at or before this time (inclusive). Compared against the event's `processed_at` value.

  • orderstring可选

    query: 按事件处理时间排序:asc 从早到晚(默认),desc 相反。

  • typesarray可选

    query: 按事件类型过滤,取值与返回事件的 type 字段一致(如 user.message、agent.tool_use);不传返回全部类型。

  • limitnumber可选

    query: Number of items per page.

  • pagestring可选

    query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.

返回

200

先发送消息再读取历史;处理完成前可能只看到已接纳的输入。支持分页、事件类型和时间过滤。会话等待工具授权时停在 session.status_idle,stop_reason 为 requires_action,event_ids 列出待确认的 agent.tool_use;运行失败时先出现 session.error,再出现 session.status_terminated。agent.thinking 带思考内容 content。使用网页搜索或读取网页时,/agent/v1 与 /anthropic 的工具结果均为官方 search_result 块;回答文本块的 citations 是 /agent/v1 的扩展字段,/anthropic 将回答引用显示为正文中的 [n]。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringUnique identifier for this event. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session.
data[].contentarray<object>Array of content blocks comprising the user message. / The result content returned by the tool. / Array of text blocks comprising the agent response. / The result content returned by the tool. / The result content returned by the tool. / Message content blocks. / Message content blocks. / The result content returned by the tool. / System content blocks. Text-only.
data[].typestringAlways `user.message`. A message from the user to the agent, with content blocks. / Always `user.interrupt`. The user interrupted the running turn. / Always `user.tool_confirmation`. The user's decision to allow or deny a tool call that waits for approval. / Always `user.custom_tool_result`. The user's result for a custom tool call. / Always `agent.custom_tool_use`. The agent called a custom tool defined by the client. / Always `agent.message`. A message from the agent, with text content blocks. / Always `agent.thinking`. The agent's thinking text for a step. / Always `agent.mcp_tool_use`. The agent called an MCP tool. / Always `agent.mcp_tool_result`. The result of an MCP tool call. / Always `agent.tool_use`. The agent called a tool. / Always `agent.tool_result`. The result of a tool call. / Always `agent.thread_message_received`. The agent received a message from another thread. / Always `agent.thread_message_sent`. The agent sent a message to another thread. / Always `agent.thread_context_compacted`. The thread's context was compacted into a summary. / Always `session.error`. The session hit an error. / Always `session.status_rescheduled`. The session will retry after a recoverable error. / Always `session.status_running`. The session started running a turn. / Always `session.status_idle`. The session stopped running; stop_reason says why. / Always `session.status_terminated`. The session ended and accepts no more work. / Always `session.thread_created`. A child thread was started. / Always `span.outcome_evaluation_start`. An outcome evaluation started. / Always `span.outcome_evaluation_end`. An outcome evaluation ended. / Always `span.model_request_start`. A model request started. / Always `span.model_request_end`. A model request ended, with its usage. / Always `span.outcome_evaluation_ongoing`. An outcome evaluation is still running. / Always `user.define_outcome`. The user defined the outcome the agent should reach. / Always `session.deleted`. The session was deleted. / Always `session.thread_status_running`. A thread started running. / Always `session.thread_status_idle`. A thread stopped running; stop_reason says why. / Always `session.thread_status_terminated`. A thread ended. / Always `user.tool_result`. The user's result for a client-side tool call. / Always `session.thread_status_rescheduled`. A thread will retry after a recoverable error. / Always `session.updated`. The session's model, title, metadata, agent or budget changed. / Always `system.message`. A message produced by the platform rather than the user or the agent. / Always `session.usage`. Cumulative usage of the session. / Always `session.forked`. The session was created by forking another session. / Always `session.goal_changed`. / Always `session.goal_verification`. / Always `user.steer`. Receipt that a queued user.message was injected into the running turn. / Always `user.tool_confirmation`.
data[].processed_atnull | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | null | string | string | string | null | string | string | string | string | string | string | stringA timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339.
data[].message_idstringUI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID shared with this assistant's message parts.
data[].session_thread_idnull | string | string | string | string | string | null | string | stringIf absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Set by the server to the subagent thread this confirmation was routed to. Omitted when it was routed to the primary thread. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.custom_tool_result` by `custom_tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` by `tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` or `user.tool_result` by `tool_use_id`, so clients do not send it back. / Public `sthr_` ID of the newly created thread. / Public sthr_ ID of the thread that started running. / Public sthr_ ID of the thread that went idle. / Public sthr_ ID of the thread that terminated. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / Public sthr_ ID of the thread that is retrying.
data[].resultstringUserToolConfirmationResult enum / Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress. / Always `allow`.
data[].tool_use_idstringThe id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. / The id of the `agent.tool_use` event this result corresponds to. / The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. / The id of the AskUserQuestion `agent.tool_use` event this answers.
data[].deny_messagenull | stringOptional message providing context for a 'deny' decision. Only allowed when result is 'deny'.
data[].custom_tool_use_idstringThe id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field.
data[].is_errornull | booleanWhether the tool execution resulted in an error. / Whether the model request resulted in an error. / Whether the tool execution resulted in an error.
data[].inputobjectInput parameters for the tool call.
data[].namestringName of the custom tool being called. / Name of the MCP tool being used. / Name of the agent tool being used.
data[].mcp_server_namestringName of the MCP server providing the tool.
data[].evaluated_permissionstringAgentEvaluatedPermission enum
data[].evaluationobjectNames the resolved permission_policy that produced evaluated_permission, and under auto carries the judgement. Open union: clients must tolerate unknown variants.
data[]._metaobjectPraxis extension (MCP Apps, SEP-1865): the `ui` and `openai/ui` keys of the MCP tool definition's `_meta`, verbatim; other `_meta` keys are not exposed. When `ui.resourceUri` is a `ui://` URI, the tool has an interactive view: a client that implements MCP Apps can fetch that resource from the MCP server and render it for this call. Absent when the tool declares neither key. Clients that do not render MCP Apps ignore it. / Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `_meta`, verbatim. Views use it for data that should not reach the model; absent when the tool returned none.
data[].sourcestringPraxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / What caused the change.
data[].parent_tool_use_idstringPraxis extension (MCP Apps, SEP-1865): present when `source` is `codemode`; the id of the codemode tool use whose program made this call. Absent otherwise.
data[].mcp_tool_use_idstringThe id of the `agent.mcp_tool_use` event this result corresponds to.
data[].structured_contentanyPraxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `structuredContent`, verbatim JSON. MCP Apps views read it as the data to render; absent when the tool returned none.
data[].from_session_thread_idstringPublic `sthr_` ID of the thread that sent the message.
data[].from_agent_namenull | stringName of the callable agent this message came from. Absent when received from the primary agent.
data[].to_session_thread_idstringPublic `sthr_` ID of the thread the message was sent to.
data[].to_agent_namenull | stringName of the callable agent this message was sent to. Absent when sent to the primary agent.
data[].errorobjectDescription of the error and what the client should do next.
data[].stop_reasonobjectWhy the session stopped running, with the variant data needed to continue.
data[].agent_namestringName of the callable agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs.
data[].iterationnumber0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc. / 0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`. / 0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.
data[].outcome_idstringThe `outc_` ID of the outcome being evaluated. / Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.
data[].explanationstringHuman-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why.
data[].outcome_evaluation_start_idstringThe id of the corresponding `span.outcome_evaluation_start` event.
data[].usageobjectToken usage for a single model request. / Point-in-time snapshot of a session's cumulative usage.
data[].model_request_start_idstringThe id of the corresponding `span.model_request_start` event.
data[].model_usageobjectToken usage for a single model request.
data[].descriptionstringWhat the agent should produce. Copied from the input event.
data[].max_iterationsnull | numberEvaluate-then-revise cycles before giving up. Default 3, max 20.
data[].rubricobjectRubric for grading the quality of an outcome.
data[].agentnull | objectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
data[].budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
data[].metadataobjectThe session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty.
data[].titlenull | stringThe session's new title. Present only when the update changed it.
data[].modelobject扩展 / Praxis extension: the changed session model, present only on /agent/v1 session.updated events. Model-only updates are omitted on /anthropic.
data[].forked_from_session_idstringId of the parent session this session was forked from.
data[].forked_from_message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.
data[].actionstringWhat changed in the goal.
data[].goalobject | nullThe goal as the change left it, or null when the session has no goal.
data[].previous_goalobject | nullThe goal before the change, or null when there was none.
data[].statusstringWhere the check stands. Read `verification.passed` on the closing event to know whether the goal counts as done.
data[].goal_idstringThe goal this check belongs to.
data[].goal_iterationintegerWhich check of this goal, matching `iteration` on the goal.
data[].verification_idstringIdentifier shared by every event of one check.
data[].anchor_message_idstring | nullThe assistant message the check follows, or null.
data[].verificationobjectThe verdict; absent on `started`.
data[].event_idstringId of the event this event refers to.
data[].answersobjectThe user's answer to each question, keyed by the question text; empty when the questions were dismissed.
data[].annotationsobjectPer-question notes, keyed by the question text.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /agent/v1/sessions/{session_id}/events◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • eventsarray必填

    要发送给会话的事件列表。

返回

200

将 sesn_123 换成创建会话返回的 id。每条 user.message 只接受一个非空文本块。支持文本 user.message、user.interrupt 和工具确认;可发送 user.withdraw 并用 event_id 指向仍在排队的消息来撤回它,消息已开始处理时返回 409。运行中需要提前补充要求时,发送 user.steer 事件,并用 event_id 指向仍在排队的消息:当前工具继续执行,消息在下一次模型请求前进入当前回合。返回带 processed_at 的 user.steer 回执,重复标记返回同一回执;已开始或已撤回返回 409,事件不存在返回 404。有待授权时继续等待;若当前回合先结束,消息仍按普通队列处理。默认发送消息仍然排队,/anthropic 不接受 user.steer。其它事件变体尚不支持。返回的是已接纳事件;模型回复从事件历史或订阅读取。会话等待工具授权时发送的 user.message 会排队:返回的事件 processed_at 为 null,授权处理完成后按发送顺序执行。允许工具调用时可在 updated_permissions 中原样提交该调用的 permission_suggestions,让本次对话记住同类操作;危险操作不提供可记住的建议。使用网页搜索或读取网页时,/agent/v1 与 /anthropic 的工具结果均为官方 search_result 块;回答文本块的 citations 是 /agent/v1 的扩展字段,/anthropic 将回答引用显示为正文中的 [n]。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Sent events
data[].idstringUnique identifier for this event. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session.
data[].contentarray<object>Array of content blocks comprising the user message. / The result content returned by the tool. / The result content returned by the tool. / System content blocks. Text-only.
data[].typestringAlways `user.message`. A message from the user to the agent, with content blocks. / Always `user.interrupt`. The user interrupted the running turn. / Always `user.tool_confirmation`. The user's decision to allow or deny a tool call that waits for approval. / Always `user.custom_tool_result`. The user's result for a custom tool call. / Always `user.define_outcome`. The user defined the outcome the agent should reach. / Always `user.tool_result`. The user's result for a client-side tool call. / Always `system.message`. A message produced by the platform rather than the user or the agent. / Always `user.steer`. Receipt that a queued user.message was injected into the running turn. / Always `user.tool_confirmation`.
data[].processed_atnull | string | string | null | string | null | string | string | stringA timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339.
data[].session_thread_idnull | stringIf absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Set by the server to the subagent thread this confirmation was routed to. Omitted when it was routed to the primary thread. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread.
data[].resultstringUserToolConfirmationResult enum / Always `allow`.
data[].tool_use_idstringThe id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. / The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. / The id of the AskUserQuestion `agent.tool_use` event this answers.
data[].deny_messagenull | stringOptional message providing context for a 'deny' decision. Only allowed when result is 'deny'.
data[].custom_tool_use_idstringThe id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field.
data[].is_errornull | booleanWhether the tool execution resulted in an error.
data[].descriptionstringWhat the agent should produce. Copied from the input event.
data[].max_iterationsnull | numberEvaluate-then-revise cycles before giving up. Default 3, max 20.
data[].outcome_idstringServer-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.
data[].rubricobjectRubric for grading the quality of an outcome.
data[].event_idstringId of the event this event refers to.
data[].answersobjectThe user's answer to each question, keyed by the question text; empty when the questions were dismissed.
data[].annotationsobjectPer-question notes, keyed by the question text.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/events/stream◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • event_deltasarray可选

    query: When set, this connection also receives streaming deltas (`event_start`, `event_delta`) while an event is being produced, before the event itself arrives. Deltas are best-effort; when the final event is produced it carries the complete content. A model request that ends early (an error or interrupt) produces no final event — its terminal `span.model_request_end` closes the preview. Accepts one or more event types to preview and may be repeated: `agent.message` streams `content_delta` fragments; `agent.thinking` is start-only — a signal that the agent has begun extended thinking, concluded by the `agent.thinking` event itself. Only previews of the requested event types are sent.

返回

200

保持 SSE 连接以接收事件;请求不会像普通 JSON 接口一样立刻结束。先创建会话并替换 sesn_123,再从另一请求发送消息;停止按钮只断开订阅,不会停止智能体。SDK 0.124.0 会过滤 session.usage,完整用量请读历史。传 event_deltas[]=agent.message 或 event_deltas[]=agent.thinking 可在最终事件到达前收到逐段预览(event_start 与 event_delta)。传 event_deltas[]=agent.tool_use 可以在参数生成过程中收到 input_json_delta 片段。使用网页搜索或读取网页时,/agent/v1 与 /anthropic 的工具结果均为官方 search_result 块;回答文本块的 citations 是 /agent/v1 的扩展字段,/anthropic 将回答引用显示为正文中的 [n]。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Server-sent events

text/event-stream — chunk / 事件对象

名称类型说明
idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
eventstringServer-Sent Events event name of this frame. / Always `user.message`. SSE event name of this frame; its data is a user.message payload. A message from the user to the agent, with content blocks. / Always `user.interrupt`. SSE event name of this frame; its data is a user.interrupt payload. The user interrupted the running turn. / Always `agent.message`. SSE event name of this frame; its data is a agent.message payload. A message from the agent, with text content blocks. / Always `agent.thinking`. SSE event name of this frame; its data is a agent.thinking payload. The agent's thinking text for a step. / Always `session.status_running`. SSE event name of this frame; its data is a session.status_running payload. The session started running a turn. / Always `session.status_rescheduled`. SSE event name of this frame; its data is a session.status_rescheduled payload. The session will retry after a recoverable error. / Always `session.status_idle`. SSE event name of this frame; its data is a session.status_idle payload. The session stopped running; stop_reason says why. / Always `session.status_terminated`. SSE event name of this frame; its data is a session.status_terminated payload. The session ended and accepts no more work. / Always `agent.thread_context_compacted`. SSE event name of this frame; its data is a agent.thread_context_compacted payload. The thread's context was compacted into a summary. / Always `agent.thread_context_reset`. SSE event name of this frame; its data is a agent.thread_context_reset payload. Content was removed from the model's context after a content-safety refusal. / Always `session.updated`. SSE event name of this frame; its data is a session.updated payload. The session's model, title, metadata, agent or budget changed. / Always `session.error`. SSE event name of this frame; its data is a session.error payload. The session hit an error. / Always `session.usage`. SSE event name of this frame; its data is a session.usage payload. Cumulative usage of the session. / Always `span.model_request_start`. SSE event name of this frame; its data is a span.model_request_start payload. A model request started. / Always `span.model_request_end`. SSE event name of this frame; its data is a span.model_request_end payload. A model request ended, with its usage. / Always `agent.tool_use`. SSE event name of this frame; its data is a agent.tool_use payload. The agent called a tool. / Always `agent.tool_result`. SSE event name of this frame; its data is a agent.tool_result payload. The result of a tool call. / Always `agent.mcp_tool_use`. SSE event name of this frame; its data is a agent.mcp_tool_use payload. The agent called an MCP tool. / Always `agent.mcp_tool_result`. SSE event name of this frame; its data is a agent.mcp_tool_result payload. The result of an MCP tool call. / Always `user.tool_confirmation`. SSE event name of this frame; its data is a user.tool_confirmation payload. The user's decision to allow or deny a tool call that waits for approval. / Always `session.thread_created`. SSE event name of this frame; its data is a session.thread_created payload. A child thread was started. / Always `session.thread_status_running`. SSE event name of this frame; its data is a session.thread_status_running payload. A thread started running. / Always `session.thread_status_idle`. SSE event name of this frame; its data is a session.thread_status_idle payload. A thread stopped running; stop_reason says why. / Always `session.thread_status_rescheduled`. SSE event name of this frame; its data is a session.thread_status_rescheduled payload. A thread will retry after a recoverable error. / Always `session.thread_status_terminated`. SSE event name of this frame; its data is a session.thread_status_terminated payload. A thread ended. / Always `agent.thread_message_sent`. SSE event name of this frame; its data is a agent.thread_message_sent payload. The agent sent a message to another thread. / Always `agent.thread_message_received`. SSE event name of this frame; its data is a agent.thread_message_received payload. The agent received a message from another thread. / Always `user.withdraw`. SSE event name of this frame; its data is a user.withdraw payload. A queued user.message was withdrawn before it ran. / Always `user.steer`. SSE event name of this frame; its data is a user.steer payload. Receipt that a queued user.message was injected into the running turn. / Always `system.notification`. SSE event name of this frame; its data is a system.notification payload. Background work woke the session with a notification. / Always `session.forked`. SSE event name of this frame; its data is a session.forked payload. The session was created by forking another session. / Always `session.goal_changed`. SSE event name of this frame; its data is a session.goal_changed payload. The session's goal was set, changed status, accounted usage or was cleared. / Always `session.goal_verification`. SSE event name of this frame; its data is a session.goal_verification payload. One completion check of the session's goal started or ended. / Always `event_start`. SSE event name of this frame; its data is a event_start payload. Preview that an event of the requested delta types has started. / Always `event_delta`. SSE event name of this frame; its data is a event_delta payload. Incremental fragment of the event being produced. / Always `ping`. SSE event name of this frame; its data is a ping payload. Keep-alive frame; carries no data. / Always `error`. SSE event name of this frame; its data is a error payload. A stream error.
dataobjectDecoded JSON payload of this frame; its shape is selected by the event name. / Praxis extension (AskUserQuestion, own face only): the confirmation of an AskUserQuestion call, with the answers it carried. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Praxis extension (goal mode, own face only): the session's goal was set, moved to another status, accounted usage or was cleared. `goal` is the goal after the change, `previous_goal` the one before; each is null when there was none. / Praxis extension (goal mode, own face only): one completion check of the goal. A `started` event opens it; `completed`, `failed_closed` or `cancelled` closes it. Events of one check share `verification_id`. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name.
data.idstringUnique identifier for this event. / Text of the block. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Event id, unique within the session. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Text of the block. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Event id, unique within the session. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer.
data.contentarray<object>Array of content blocks comprising the user message. / Array of text blocks comprising the agent response. / Content blocks of the event, in order. / The result content returned by the tool. / The result content returned by the tool. / Message content blocks. / Message content blocks. / Array of content blocks comprising the user message. / Array of text blocks comprising the agent response. / Content blocks of the event, in order. / The result content returned by the tool. / The result content returned by the tool. / Message content blocks. / Message content blocks.
data.typestringAlways `user.message`. A message from the user to the agent, with content blocks. / Always `user.interrupt`. The user interrupted the running turn. / Always `agent.message`. A message from the agent, with text content blocks. / Always `agent.thinking`. The agent's thinking text for a step. / Always `session.status_running`. The session started running a turn. / Always `session.status_rescheduled`. The session will retry after a recoverable error. / Always `session.status_idle`. The session stopped running; stop_reason says why. / Always `session.status_terminated`. The session ended and accepts no more work. / Always `agent.thread_context_compacted`. The thread's context was compacted into a summary. / Always `agent.thread_context_reset`. Content was removed from the model's context after a content-safety refusal. / Always `session.updated`. The session's model, title, metadata, agent or budget changed. / Always `session.error`. The session hit an error. / Always `session.usage`. Cumulative usage of the session. / Always `span.model_request_start`. A model request started. / Always `span.model_request_end`. A model request ended, with its usage. / Always `agent.tool_use`. The agent called a tool. / Always `agent.tool_result`. The result of a tool call. / Always `agent.mcp_tool_use`. The agent called an MCP tool. / Always `agent.mcp_tool_result`. The result of an MCP tool call. / Always `user.tool_confirmation`. / Always `session.thread_created`. A child thread was started. / Always `session.thread_status_running`. A thread started running. / Always `session.thread_status_idle`. A thread stopped running; stop_reason says why. / Always `session.thread_status_rescheduled`. A thread will retry after a recoverable error. / Always `session.thread_status_terminated`. A thread ended. / Always `agent.thread_message_sent`. The agent sent a message to another thread. / Always `agent.thread_message_received`. The agent received a message from another thread. / Always `user.withdraw`. A queued user.message was withdrawn before it ran. / Always `user.steer`. Receipt that a queued user.message was injected into the running turn. / Always `system.notification`. Background work woke the session with a notification. / Always `session.forked`. The session was created by forking another session. / Always `session.goal_changed`. / Always `session.goal_verification`. / Always `event_start`. Preview that an event of the requested delta types has started. / Always `event_delta`. Incremental fragment of the event being produced. / Always `ping`. Keep-alive frame; carries no data. / Always `error`. A stream error. / Always `user.message`. A message from the user to the agent, with content blocks. / Always `user.interrupt`. The user interrupted the running turn. / Always `agent.message`. A message from the agent, with text content blocks. / Always `agent.thinking`. The agent's thinking text for a step. / Always `session.status_running`. The session started running a turn. / Always `session.status_rescheduled`. The session will retry after a recoverable error. / Always `session.status_idle`. The session stopped running; stop_reason says why. / Always `session.status_terminated`. The session ended and accepts no more work. / Always `agent.thread_context_compacted`. The thread's context was compacted into a summary. / Always `agent.thread_context_reset`. Content was removed from the model's context after a content-safety refusal. / Always `session.updated`. The session's model, title, metadata, agent or budget changed. / Always `session.error`. The session hit an error. / Always `session.usage`. Cumulative usage of the session. / Always `span.model_request_start`. A model request started. / Always `span.model_request_end`. A model request ended, with its usage. / Always `agent.tool_use`. The agent called a tool. / Always `agent.tool_result`. The result of a tool call. / Always `agent.mcp_tool_use`. The agent called an MCP tool. / Always `agent.mcp_tool_result`. The result of an MCP tool call. / Always `user.tool_confirmation`. / Always `session.thread_created`. A child thread was started. / Always `session.thread_status_running`. A thread started running. / Always `session.thread_status_idle`. A thread stopped running; stop_reason says why. / Always `session.thread_status_rescheduled`. A thread will retry after a recoverable error. / Always `session.thread_status_terminated`. A thread ended. / Always `agent.thread_message_sent`. The agent sent a message to another thread. / Always `agent.thread_message_received`. The agent received a message from another thread. / Always `user.withdraw`. A queued user.message was withdrawn before it ran. / Always `user.steer`. Receipt that a queued user.message was injected into the running turn. / Always `system.notification`. Background work woke the session with a notification. / Always `session.forked`. The session was created by forking another session. / Always `session.goal_changed`. / Always `session.goal_verification`. / Always `event_start`. Preview that an event of the requested delta types has started. / Always `event_delta`. Incremental fragment of the event being produced. / Always `ping`. Keep-alive frame; carries no data. / Always `error`. A stream error.
data.processed_atnull | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | null | string | null | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | stringA timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / When the event was recorded, RFC 3339. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / When the event was recorded, RFC 3339. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339. / RFC 3339 time at which the server processed the event; null while a queued input has not started running.
data.message_idstringUI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID shared with this assistant's message parts. / UI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID shared with this assistant's message parts.
data.session_thread_idnull | string | string | null | string | null | string | string | string | string | string | string | string | string | null | string | string | null | string | null | string | string | string | string | string | string | string | stringIf absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Text of the block. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` or `user.tool_result` by `tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` by `tool_use_id`, so clients do not send it back. / Public `sthr_` ID of the newly created thread. / Public sthr_ ID of the thread that started running. / Public sthr_ ID of the thread that went idle. / Public sthr_ ID of the thread that is retrying. / Public sthr_ ID of the thread that terminated. / Text of the block. / Text of the block. / If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Text of the block. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` or `user.tool_result` by `tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` by `tool_use_id`, so clients do not send it back. / Public `sthr_` ID of the newly created thread. / Public sthr_ ID of the thread that started running. / Public sthr_ ID of the thread that went idle. / Public sthr_ ID of the thread that is retrying. / Public sthr_ ID of the thread that terminated. / Text of the block. / Text of the block.
data.stop_reasonobjectWhy the session stopped running, with the variant data needed to continue.
data.removedarray<object>Content removed from the model's context by this reset.
data.categorystringText of the block.
data.stoppedbooleanTrue when the run was stopped instead of retried after the reset.
data.agentnull | objectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
data.budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
data.metadataobjectThe session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty.
data.titlenull | stringThe session's new title. Present only when the update changed it.
data.modelobject扩展 / Praxis extension: the changed session model, present only on /agent/v1 session.updated events. Model-only updates are omitted on /anthropic.
data.errorobjectDescription of the error and what the client should do next. / Error detail. / Description of the error and what the client should do next. / Error detail.
data.usageobjectPoint-in-time snapshot of a session's cumulative usage.
data.is_errornull | booleanWhether the model request resulted in an error. / Whether the tool execution resulted in an error. / Whether the tool execution resulted in an error. / Whether the model request resulted in an error. / Whether the tool execution resulted in an error. / Whether the tool execution resulted in an error.
data.model_request_start_idstringThe id of the corresponding `span.model_request_start` event.
data.model_usageobjectToken usage for a single model request.
data.inputobjectInput parameters for the tool call.
data.namestringName of the agent tool being used. / Name of the MCP tool being used. / Name of the agent tool being used. / Name of the MCP tool being used.
data.evaluated_permissionstringAgentEvaluatedPermission enum
data.evaluationobjectNames the resolved permission_policy that produced evaluated_permission, and under auto carries the judgement. Open union: clients must tolerate unknown variants.
data.tool_use_idstringThe id of the `agent.tool_use` event this result corresponds to. / The id of the AskUserQuestion `agent.tool_use` event this answers. / The id of the `agent.tool_use` event this result corresponds to. / The id of the AskUserQuestion `agent.tool_use` event this answers.
data.mcp_server_namestringName of the MCP server providing the tool.
data._metaobjectPraxis extension (MCP Apps, SEP-1865): the `ui` and `openai/ui` keys of the MCP tool definition's `_meta`, verbatim; other `_meta` keys are not exposed. When `ui.resourceUri` is a `ui://` URI, the tool has an interactive view: a client that implements MCP Apps can fetch that resource from the MCP server and render it for this call. Absent when the tool declares neither key. Clients that do not render MCP Apps ignore it. / Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `_meta`, verbatim. Views use it for data that should not reach the model; absent when the tool returned none. / Praxis extension (MCP Apps, SEP-1865): the `ui` and `openai/ui` keys of the MCP tool definition's `_meta`, verbatim; other `_meta` keys are not exposed. When `ui.resourceUri` is a `ui://` URI, the tool has an interactive view: a client that implements MCP Apps can fetch that resource from the MCP server and render it for this call. Absent when the tool declares neither key. Clients that do not render MCP Apps ignore it. / Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `_meta`, verbatim. Views use it for data that should not reach the model; absent when the tool returned none.
data.sourcestringPraxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / What caused the change. / Praxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / Praxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / What caused the change.
data.parent_tool_use_idstringPraxis extension (MCP Apps, SEP-1865): present when `source` is `codemode`; the id of the codemode tool use whose program made this call. Absent otherwise.
data.mcp_tool_use_idstringThe id of the `agent.mcp_tool_use` event this result corresponds to.
data.structured_contentanyPraxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `structuredContent`, verbatim JSON. MCP Apps views read it as the data to render; absent when the tool returned none.
data.resultstringAlways `allow`.
data.answersobjectThe user's answer to each question, keyed by the question text; empty when the questions were dismissed.
data.annotationsobjectPer-question notes, keyed by the question text.
data.agent_namestringName of the callable agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the callable agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs.
data.to_session_thread_idstringPublic `sthr_` ID of the thread the message was sent to.
data.to_agent_namenull | stringName of the callable agent this message was sent to. Absent when sent to the primary agent.
data.from_session_thread_idstringPublic `sthr_` ID of the thread that sent the message.
data.from_agent_namenull | stringName of the callable agent this message came from. Absent when received from the primary agent.
data.event_idstringText of the block. / Id of the event this event refers to. / Text of the block. / Text of the block. / Id of the event this event refers to. / Text of the block.
data.sourcesarray<object>Background work that woke the session with this notification.
data.forked_from_session_idstringId of the parent session this session was forked from.
data.forked_from_message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.
data.actionstringWhat changed in the goal.
data.goalobject | nullThe goal as the change left it, or null when the session has no goal.
data.previous_goalobject | nullThe goal before the change, or null when there was none.
data.statusstringWhere the check stands. Read `verification.passed` on the closing event to know whether the goal counts as done.
data.goal_idstringThe goal this check belongs to.
data.goal_iterationintegerWhich check of this goal, matching `iteration` on the goal.
data.verification_idstringIdentifier shared by every event of one check.
data.anchor_message_idstring | nullThe assistant message the check follows, or null.
data.verificationobjectThe verdict; absent on `started`.
data.eventobjectEvent name or event payload.
data.deltaobjectIncremental fragment of the event being produced.

用 WebSocket 接收

同一地址也可以用 wss:// 建立只读 WebSocket,每个事件一帧,适合服务端长连接。连接、帧格式、关闭码与限额见用 WebSocket 订阅事件。

用 WebSocket 订阅事件

会话事件除了用 订阅事件(SSE)拉取,也可以在同一个地址上建立 WebSocket 接收:每个事件一帧,内容与 SSE 的事件数据完全相同。这是本平台在官方 SSE 之外额外提供的接入方式,适合在服务端长期挂着连接、把事件转发给自己系统的场景。

wss://api.deepraxis.ai/agent/v1/sessions/{session_id}/events/stream

这条连接是只读的:它只推送事件,不接收任何消息。发消息、打断仍然用 发送事件。

握手与认证

握手请求带与 HTTP 接口相同的认证头:Authorization: Bearer <API Key> 或 x-api-key: <API Key>。

浏览器原生的 WebSocket 不能设置请求头,所以这是服务端用法。浏览器里请用 SSE,或者由你的服务端建立连接后再转给前端。

握手失败时连接不会建立,服务端直接返回 HTTP 错误(错误体格式见错误):

情况返回
没带凭证,或 Key 无效、已禁用401
会话不存在,或不属于这个 Key 所在的工作区404
同时进行的请求超过 Key 的并发上限429,见限流

一条打开的 WebSocket 和一个进行中的 SSE 一样,会一直占用 Key 的一个并发名额,直到连接关闭。

帧

每一帧都是一个 JSON 文本。连接建立后,第一帧是就绪通知:

{"type":"session.events.ready"}

收到它之后,会话里产生的每个事件以一帧送达,event 字段就是 SSE 里的事件数据:

{"type":"session.event","event":{"id":"d4dc3d96-…","type":"agent.message","processed_at":"2026-09-26T13:35:04.906Z","content":[{"type":"text","text":"好"}]}}
字段说明
typesession.events.ready(就绪,只出现一次)或 session.event(一个事件)
event仅 session.event 帧有;结构与事件列表返回的单个事件相同

同一个事件可能送达不止一次。例如一条 user.message 会先以 processed_at: null(已接纳、待处理)出现,被处理后再以带时间的形式出现一次。请按 event.id 去重,以最后一次为准。

关闭码

关闭码含义你该做什么
1000服务端正常结束订阅需要继续接收就重新连接
1008客户端向连接发送了消息这条连接只读;不要发送任何帧
1011服务端内部中断重新连接,并用事件列表回填
1013暂时超出限额(见下)重新连接,并用事件列表回填

限额

  • 一条连接累计最多推送约 512 KB 的事件,超出后以 1013 关闭。长会话请准备好重连。
  • 服务端与会话之间的内部连接断开时会自动重试;多次重试仍失败,也以 1013 关闭。

断线与回填

断开期间产生的事件不会补发。重新连接后,用事件列表按时间补齐:

GET /agent/v1/sessions/{session_id}/events?order=asc&created_at[gt]=<你收到的最后一个事件的 processed_at>

回填的事件和新连接推送的事件可能重叠,按 event.id 去重即可。

示例

Bun(内置 WebSocket 支持 headers):

const ws = new WebSocket(
  `wss://api.deepraxis.ai/agent/v1/sessions/${sessionId}/events/stream`,
  { headers: { Authorization: `Bearer ${process.env.PRAXIS_API_KEY}` } },
);
ws.addEventListener("message", (message) => {
  const frame = JSON.parse(String(message.data));
  if (frame.type === "session.events.ready") console.log("ready");
  if (frame.type === "session.event") console.log(frame.event.type, frame.event);
});
ws.addEventListener("close", (close) => console.log("closed", close.code));

Node(ws 包):

import WebSocket from "ws";

const ws = new WebSocket(
  `wss://api.deepraxis.ai/agent/v1/sessions/${sessionId}/events/stream`,
  { headers: { Authorization: `Bearer ${process.env.PRAXIS_API_KEY}` } },
);
ws.on("message", (data) => {
  const frame = JSON.parse(String(data));
  if (frame.type === "session.event") console.log(frame.event.type, frame.event);
});
ws.on("close", (code) => console.log("closed", code));

Python(websockets 包):

import asyncio, json, os
import websockets

async def main(session_id: str):
    url = f"wss://api.deepraxis.ai/agent/v1/sessions/{session_id}/events/stream"
    headers = {"Authorization": f"Bearer {os.environ['PRAXIS_API_KEY']}"}
    async with websockets.connect(url, additional_headers=headers) as ws:
        async for message in ws:
            frame = json.loads(message)
            if frame["type"] == "session.event":
                print(frame["event"]["type"], frame["event"])

asyncio.run(main("sesn_123"))

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /agent/v1/sessions/{session_id}◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • modelstring可选

    扩展:模型 ID 字符串,必须属于会话钉住版本的 models.allowed;没有列表时只能选默认模型。下一轮生效,在途一轮不受影响,此处不检查上下文窗口。

  • agentobject可选

    会话要运行的智能体:直接写智能体 ID 字符串(固定用最新版本),或传对象指定 id 与 version(见子字段)。

    ▸ 展开子字段(2)
    • mcp_serversarray可选

      替换本会话的 MCP 服务器列表:传入的数组整体生效;传空数组清除,省略沿用智能体的配置。

    • toolsarray可选

      替换本会话的工具配置;传空数组清除,省略沿用智能体的配置。

  • titlestring可选

    Human-readable session title.

  • metadataobject可选

    Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve.

  • budgetobject可选

    A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.

    ▸ 展开子字段(2)
    • max_list_costobject必填

      预算内列表类调用的花费上限。

    • typestring必填

      预算类型,目前只有 max_list_cost。

      取值 limit
  • vault_idsarray可选

    Vault IDs (`vlt_*`) to attach to the session. Not yet supported; requests setting this field are rejected. Reserved for future use.

  • thinkingobject可选

    Praxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error.

    ▸ 展开子字段(1)
    • effortstring必填

      Thinking level for this session. The model must support the chosen effort; none requires can_disable. Null on thinking restores inheritance from the agent and model.

      取值 lowmediumhighxhighnone

返回

200

可选 model 为钉住版本 allowed 内的 ID,thinking 为 {effort: "low|medium|high|xhigh|none"} 或 null。省略保留原值,null 恢复继承;仅换模型会清除不支持的会话档位。两者同时传入按新模型校验,不支持返回 400 且原选择不变。下一轮生效,在途一轮不变。示例:{"model":"deepseek-v4-flash","thinking":{"effort":"xhigh"}}。响应含 thinking 及 model.thinking: {efforts, can_disable, default_effort},能力未知为 null。这些选择字段仅在 /agent/v1 提供。支持 title 与 metadata(官方补丁语义:字符串值写入、null 删除该键、整包 null 清空,未提及的键保留)。官方的 agent 覆盖(tools/mcp_servers)、budget 与 vault_ids 不支持,传入返回 400 并点名字段。归档后的会话更新返回 409。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringSession id (sesn_...). Pass it as session_id in every session call.
agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
agent.idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
agent.descriptionnull | stringFree-text description of what the agent is for; null when none was set.
agent.mcp_serversarray<object>URL MCP servers the agent can call, paired one-to-one with mcp_toolset entries in tools and saved with the agent version. No credentials are stored here.
agent.modelobjectModel identifier and configuration.
agent.multiagentnull | objectResolved coordinator topology with full agent definitions for each roster member.
agent.namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
agent.skillsarray<object>Skills attached to the agent. Setting skills is not supported on this platform and returns 400, so do not send this field on create or update.
agent.systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
agent.toolsarray<object>Tools of the agent: one agent_toolset_20260401 entry for the native tools (all resolved settings are returned, ready to send back on update), plus mcp_toolset entries and custom tool definitions.
agent.typestringAlways `agent`. An agent definition.
agent.versionnumberThe agent's current version. Starts at 1 and increments each time the agent is modified.
archived_atnull | stringA timestamp in RFC 3339 format
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestringAlways `limit`. A spending limit.
created_atstringA timestamp in RFC 3339 format
environment_idstringId of the environment recipe the session's sandbox was created from. Omitted when no recipe was selected, that is, for a light machine or the Computer chosen by computer_id.
metadataobjectFree-form string key/value pairs stored with the session, changed through sessions.update patch semantics.
outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
outcome_evaluations[].completed_atnull | stringA timestamp in RFC 3339 format
outcome_evaluations[].descriptionstringWhat the agent should produce.
outcome_evaluations[].explanationnull | stringGrader's verdict text from the most recent evaluation. For `satisfied`, explains why criteria are met; for `needs_revision` (intermediate), what's missing; for `failed`, why unrecoverable.
outcome_evaluations[].iterationnumber0-indexed revision cycle the outcome is currently on.
outcome_evaluations[].outcome_idstringServer-generated outc_ ID for this outcome.
outcome_evaluations[].resultstringCurrent evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.
outcome_evaluations[].typestringAlways `outcome_evaluation`. Record of one outcome evaluation.
resourcesarray<object>Resources attached to the session, at most 500; each is a file reference mounted into the session's machine.
resources[].idstringResource id, the resource_id of sessions.resources calls.
resources[].created_atstringA timestamp in RFC 3339 format
resources[].mount_pathstring | null | stringPath inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. / Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.
resources[].typestringAlways `github_repository`. A GitHub repository resource; not supported on this platform. / Always `file`. A file resource: an uploaded file mounted into the session's machine. / Always `memory_store`. A memory store resource; not supported on this platform.
resources[].updated_atstringA timestamp in RFC 3339 format
resources[].urlstringRepository URL.
resources[].checkoutnull | objectBranch or commit to check out.
resources[].file_idstringId of the uploaded file; it must exist and belong to your tenant.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
resources[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
statsobjectTiming statistics for a session.
stats.active_secondsnumberCumulative time in seconds the session spent in `running` status. Excludes idle time.
stats.duration_secondsnumberElapsed time since session creation in seconds. For terminated sessions, frozen at the final update.
statusstringSessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion.
titlenull | stringTitle of the session, set on create or through sessions.update; null when none was set.
typestringAlways `session`. A session, one conversation of an agent on a machine.
updated_atstringA timestamp in RFC 3339 format
usageobjectCumulative token usage for a session across all turns.
usage.active_secondsnumberCumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime cost is priced on.
usage.cache_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.
vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.
cwdstringNormalized session working directory; defaults to /home/user/workspace. Forks inherit this directory.
computer_idstringPraxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected.
modelobject扩展 / Praxis extension: the currently selected session model.
model.idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
model.thinkingobject | nullSupported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable.
thinkingobject | nullPraxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error.
thinking.effortstringThinking level saved for this session: low, medium, high, xhigh, or none to turn thinking off. Null or absent means the session inherits the agent default and then the model default.
forked_fromobject | nullPraxis extension: source of a forked session; null for other sessions. Available only on /agent/v1.
forked_from.session_idstringId of the parent session this session was forked from; it is left unchanged by the fork.
forked_from.message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.

归档会话

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /agent/v1/sessions/{session_id}/archive● 支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

返回

200

归档后的会话拒绝新消息(400 invalid_request_error,写明会话已归档),读取与事件历史仍可用;重复归档幂等,archived_at 保持首次归档时间。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringSession id (sesn_...). Pass it as session_id in every session call.
agentobjectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
agent.idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
agent.descriptionnull | stringFree-text description of what the agent is for; null when none was set.
agent.mcp_serversarray<object>URL MCP servers the agent can call, paired one-to-one with mcp_toolset entries in tools and saved with the agent version. No credentials are stored here.
agent.modelobjectModel identifier and configuration.
agent.multiagentnull | objectResolved coordinator topology with full agent definitions for each roster member.
agent.namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
agent.skillsarray<object>Skills attached to the agent. Setting skills is not supported on this platform and returns 400, so do not send this field on create or update.
agent.systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
agent.toolsarray<object>Tools of the agent: one agent_toolset_20260401 entry for the native tools (all resolved settings are returned, ready to send back on update), plus mcp_toolset entries and custom tool definitions.
agent.typestringAlways `agent`. An agent definition.
agent.versionnumberThe agent's current version. Starts at 1 and increments each time the agent is modified.
archived_atnull | stringA timestamp in RFC 3339 format
budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
budget.max_list_costobjectA monetary amount in a specific currency.
budget.typestringAlways `limit`. A spending limit.
created_atstringA timestamp in RFC 3339 format
environment_idstringId of the environment recipe the session's sandbox was created from. Omitted when no recipe was selected, that is, for a light machine or the Computer chosen by computer_id.
metadataobjectFree-form string key/value pairs stored with the session, changed through sessions.update patch semantics.
outcome_evaluationsarray<object>Per-outcome evaluation state. One entry per `define_outcome` event sent to the session.
outcome_evaluations[].completed_atnull | stringA timestamp in RFC 3339 format
outcome_evaluations[].descriptionstringWhat the agent should produce.
outcome_evaluations[].explanationnull | stringGrader's verdict text from the most recent evaluation. For `satisfied`, explains why criteria are met; for `needs_revision` (intermediate), what's missing; for `failed`, why unrecoverable.
outcome_evaluations[].iterationnumber0-indexed revision cycle the outcome is currently on.
outcome_evaluations[].outcome_idstringServer-generated outc_ ID for this outcome.
outcome_evaluations[].resultstringCurrent evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.
outcome_evaluations[].typestringAlways `outcome_evaluation`. Record of one outcome evaluation.
resourcesarray<object>Resources attached to the session, at most 500; each is a file reference mounted into the session's machine.
resources[].idstringResource id, the resource_id of sessions.resources calls.
resources[].created_atstringA timestamp in RFC 3339 format
resources[].mount_pathstring | null | stringPath inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. / Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.
resources[].typestringAlways `github_repository`. A GitHub repository resource; not supported on this platform. / Always `file`. A file resource: an uploaded file mounted into the session's machine. / Always `memory_store`. A memory store resource; not supported on this platform.
resources[].updated_atstringA timestamp in RFC 3339 format
resources[].urlstringRepository URL.
resources[].checkoutnull | objectBranch or commit to check out.
resources[].file_idstringId of the uploaded file; it must exist and belong to your tenant.
resources[].memory_store_idstringThe memory store ID (memstore_...). Must belong to the caller's organization and workspace.
resources[].accessnull | stringAccess mode for an attached memory store.
resources[].descriptionstringDescription of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.
resources[].instructionsnull | stringPer-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.
resources[].namenull | stringDisplay name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.
statsobjectTiming statistics for a session.
stats.active_secondsnumberCumulative time in seconds the session spent in `running` status. Excludes idle time.
stats.duration_secondsnumberElapsed time since session creation in seconds. For terminated sessions, frozen at the final update.
statusstringSessionStatus enum - `rescheduling` - Transient error occurred, retrying automatically. - `running` - Agent is actively executing. - `idle` - Agent is waiting for input, including user messages or tool confirmations. Sessions start in idle. - `terminated` - Session has ended, either due to an error or completion.
titlenull | stringTitle of the session, set on create or through sessions.update; null when none was set.
typestringAlways `session`. A session, one conversation of an agent on a machine.
updated_atstringA timestamp in RFC 3339 format
usageobjectCumulative token usage for a session across all turns.
usage.active_secondsnumberCumulative time in seconds during which the session had at least one thread in running status. Overlapping activity from concurrent threads is counted once, unlike `stats.active_seconds`, which sums each thread's own active time. This is the duration the session's runtime cost is priced on.
usage.cache_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.
vault_idsarray<string>Vault IDs attached to the session at creation. Empty when no vaults were supplied.
deployment_idnull | stringDeployment ID when the session was created from a deployment reference. Null otherwise.
cwdstringNormalized session working directory; defaults to /home/user/workspace. Forks inherit this directory.
computer_idstringPraxis extension: MA only has session-scoped temporary containers and memory_stores, not durable browsable computers. computer_id selects a tenant-owned active computer. Session selection overrides the agent default; a sandbox environment_id and computer_id cannot be combined. Omitted when no computer is selected.
modelobject扩展 / Praxis extension: the currently selected session model.
model.idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
model.thinkingobject | nullSupported thinking controls, or null when capability is unknown or unavailable. efforts lists selectable strengths; can_disable permits none; default_effort is nullable.
thinkingobject | nullPraxis extension: explicit session thinking effort; null inherits the pinned agent default, then the model default. none disables thinking only when model.thinking.can_disable is true. Unsupported efforts return 400 invalid_request_error.
thinking.effortstringThinking level saved for this session: low, medium, high, xhigh, or none to turn thinking off. Null or absent means the session inherits the agent default and then the model default.
forked_fromobject | nullPraxis extension: source of a forked session; null for other sessions. Available only on /agent/v1.
forked_from.session_idstringId of the parent session this session was forked from; it is left unchanged by the fork.
forked_from.message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/threads◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • limitnumber可选

    query: Number of items per page.

  • pagestring可选

    query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.

返回

200

按 created_at 升序返回主线程及全部子线程。线程 id 为 sthr_ 加所属会话 id 的后缀;子线程的 parent_thread_id 指向主线程,session_id 始终为父会话。agent 是实际运行的定义,内置类型的 name 为类型名,未注册的 id/version 为 null。归档子线程的 status 为 terminated,archived_at 为归档时间;stats/usage 无线程级追踪时如实为 null。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringUnique identifier for this thread.
data[].agentobjectThe resolved agent a `session_thread` runs.
data[].archived_atnull | stringA timestamp in RFC 3339 format
data[].created_atstringA timestamp in RFC 3339 format
data[].parent_thread_idnull | stringParent thread that spawned this thread. Null for the primary thread.
data[].session_idstringThe session this thread belongs to.
data[].statsnull | objectTiming statistics for a session thread.
data[].statusstringSessionThreadStatus enum
data[].typestringAlways `session_thread`. An execution thread of a session.
data[].updated_atstringA timestamp in RFC 3339 format
data[].usagenull | objectCumulative token usage for a session thread across all turns.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/threads/{thread_id}◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • thread_idstring必填

    path: Execution thread id (sthr_...), as listed by sessions.threads.list; the primary thread id equals the session's own thread. Unknown or foreign ids return 404.

  • session_idstring必填

    query: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

返回

200

返回本会话的主线程或子线程,与列表项逐字段一致。其他会话的线程、未知线程或非 sthr_ id 一律返回 404,不泄露其存在性。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this thread.
agentobjectThe resolved agent a `session_thread` runs.
agent.modelstring | objectThe advisor model id. / Model identifier and configuration.
agent.typestringAlways `advisor`. An advisor whose model is consulted for advice in a separate thread (at most one per coordinator). / Always `agent`. A roster member that refers to an agent by id and pinned version.
agent.idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
agent.descriptionnull | stringFree-text description of what the agent is for; null when none was set.
agent.mcp_serversarray<object>URL MCP servers the agent can call, paired one-to-one with mcp_toolset entries in tools and saved with the agent version. No credentials are stored here.
agent.namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
agent.skillsarray<object>Skills attached to the agent. Setting skills is not supported on this platform and returns 400, so do not send this field on create or update.
agent.systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
agent.toolsarray<object>Tools of the agent: one agent_toolset_20260401 entry for the native tools (all resolved settings are returned, ready to send back on update), plus mcp_toolset entries and custom tool definitions.
agent.versionnumberThe agent's current version. Starts at 1 and increments each time the agent is modified.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
parent_thread_idnull | stringParent thread that spawned this thread. Null for the primary thread.
session_idstringThe session this thread belongs to.
statsnull | objectTiming statistics for a session thread.
stats.active_secondsnumberCumulative time in seconds the thread spent actively running. Excludes idle time.
stats.duration_secondsnumberElapsed time since thread creation in seconds. For archived threads, frozen at the final update.
stats.startup_secondsnumberTime in seconds for the thread to begin running. Zero for child threads, which start immediately.
statusstringSessionThreadStatus enum
typestringAlways `session_thread`. An execution thread of a session.
updated_atstringA timestamp in RFC 3339 format
usagenull | objectCumulative token usage for a session thread across all turns.
usage.active_secondsnumberCumulative time in seconds this thread spent in running status. Equal to `stats.active_seconds`; surfaced here so a thread's usage carries every quantity its cost is priced on.
usage.cache_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/threads/{thread_id}/events◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • thread_idstring必填

    path: Execution thread id (sthr_...), as listed by sessions.threads.list; the primary thread id equals the session's own thread. Unknown or foreign ids return 404.

  • session_idstring必填

    query: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • limitnumber可选

    query: Number of items per page.

  • pagestring可选

    query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.

返回

200

读取所选线程自己的事件记录:主线程读主会话,子线程读对应子会话。沿用会话事件接口的查询参数、公开事件类型和 data + next_page 信封。使用网页工具时,两个接口均返回 search_result 块;回答 citations 为 /agent/v1 扩展,/anthropic 将引用显示为正文 [n]。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringUnique identifier for this event. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer.
data[].contentarray<object>Array of content blocks comprising the user message. / The result content returned by the tool. / Array of text blocks comprising the agent response. / The result content returned by the tool. / The result content returned by the tool. / Message content blocks. / Message content blocks. / The result content returned by the tool. / System content blocks. Text-only.
data[].typestringAlways `user.message`. A message from the user to the agent, with content blocks. / Always `user.interrupt`. The user interrupted the running turn. / Always `user.tool_confirmation`. The user's decision to allow or deny a tool call that waits for approval. / Always `user.custom_tool_result`. The user's result for a custom tool call. / Always `agent.custom_tool_use`. The agent called a custom tool defined by the client. / Always `agent.message`. A message from the agent, with text content blocks. / Always `agent.thinking`. The agent's thinking text for a step. / Always `agent.mcp_tool_use`. The agent called an MCP tool. / Always `agent.mcp_tool_result`. The result of an MCP tool call. / Always `agent.tool_use`. The agent called a tool. / Always `agent.tool_result`. The result of a tool call. / Always `agent.thread_message_received`. The agent received a message from another thread. / Always `agent.thread_message_sent`. The agent sent a message to another thread. / Always `agent.thread_context_compacted`. The thread's context was compacted into a summary. / Always `session.error`. The session hit an error. / Always `session.status_rescheduled`. The session will retry after a recoverable error. / Always `session.status_running`. The session started running a turn. / Always `session.status_idle`. The session stopped running; stop_reason says why. / Always `session.status_terminated`. The session ended and accepts no more work. / Always `session.thread_created`. A child thread was started. / Always `span.outcome_evaluation_start`. An outcome evaluation started. / Always `span.outcome_evaluation_end`. An outcome evaluation ended. / Always `span.model_request_start`. A model request started. / Always `span.model_request_end`. A model request ended, with its usage. / Always `span.outcome_evaluation_ongoing`. An outcome evaluation is still running. / Always `user.define_outcome`. The user defined the outcome the agent should reach. / Always `session.deleted`. The session was deleted. / Always `session.thread_status_running`. A thread started running. / Always `session.thread_status_idle`. A thread stopped running; stop_reason says why. / Always `session.thread_status_terminated`. A thread ended. / Always `user.tool_result`. The user's result for a client-side tool call. / Always `session.thread_status_rescheduled`. A thread will retry after a recoverable error. / Always `session.updated`. The session's model, title, metadata, agent or budget changed. / Always `system.message`. A message produced by the platform rather than the user or the agent. / Always `session.usage`. Cumulative usage of the session. / Always `session.forked`. The session was created by forking another session. / Always `session.goal_changed`. / Always `session.goal_verification`. / Always `user.steer`. Receipt that a queued user.message was injected into the running turn.
data[].processed_atnull | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | null | string | string | string | null | string | string | string | string | string | stringA timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running.
data[].message_idstringUI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID shared with this assistant's message parts.
data[].session_thread_idnull | string | string | string | string | string | null | string | stringIf absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Set by the server to the subagent thread this confirmation was routed to. Omitted when it was routed to the primary thread. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.custom_tool_result` by `custom_tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` by `tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` or `user.tool_result` by `tool_use_id`, so clients do not send it back. / Public `sthr_` ID of the newly created thread. / Public sthr_ ID of the thread that started running. / Public sthr_ ID of the thread that went idle. / Public sthr_ ID of the thread that terminated. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / Public sthr_ ID of the thread that is retrying.
data[].resultstringUserToolConfirmationResult enum / Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress.
data[].tool_use_idstringThe id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field. / The id of the `agent.tool_use` event this result corresponds to. / The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field.
data[].deny_messagenull | stringOptional message providing context for a 'deny' decision. Only allowed when result is 'deny'.
data[].custom_tool_use_idstringThe id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` event's `stop_reason.event_ids` field.
data[].is_errornull | booleanWhether the tool execution resulted in an error. / Whether the model request resulted in an error. / Whether the tool execution resulted in an error.
data[].inputobjectInput parameters for the tool call.
data[].namestringName of the custom tool being called. / Name of the MCP tool being used. / Name of the agent tool being used.
data[].mcp_server_namestringName of the MCP server providing the tool.
data[].evaluated_permissionstringAgentEvaluatedPermission enum
data[].evaluationobjectNames the resolved permission_policy that produced evaluated_permission, and under auto carries the judgement. Open union: clients must tolerate unknown variants.
data[].parent_tool_use_idstringPraxis extension (MCP Apps, SEP-1865): present when `source` is `codemode`; the id of the codemode tool use whose program made this call. Absent otherwise.
data[]._metaobjectPraxis extension (MCP Apps, SEP-1865): the `ui` and `openai/ui` keys of the MCP tool definition's `_meta`, verbatim; other `_meta` keys are not exposed. When `ui.resourceUri` is a `ui://` URI, the tool has an interactive view: a client that implements MCP Apps can fetch that resource from the MCP server and render it for this call. Absent when the tool declares neither key. Clients that do not render MCP Apps ignore it. / Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `_meta`, verbatim. Views use it for data that should not reach the model; absent when the tool returned none.
data[].sourcestringPraxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / What caused the change.
data[].mcp_tool_use_idstringThe id of the `agent.mcp_tool_use` event this result corresponds to.
data[].structured_contentanyPraxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `structuredContent`, verbatim JSON. MCP Apps views read it as the data to render; absent when the tool returned none.
data[].from_session_thread_idstringPublic `sthr_` ID of the thread that sent the message.
data[].from_agent_namenull | stringName of the callable agent this message came from. Absent when received from the primary agent.
data[].to_session_thread_idstringPublic `sthr_` ID of the thread the message was sent to.
data[].to_agent_namenull | stringName of the callable agent this message was sent to. Absent when sent to the primary agent.
data[].errorobjectDescription of the error and what the client should do next.
data[].stop_reasonobjectWhy the session stopped running, with the variant data needed to continue.
data[].agent_namestringName of the callable agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs.
data[].iterationnumber0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc. / 0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`. / 0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.
data[].outcome_idstringThe `outc_` ID of the outcome being evaluated. / Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.
data[].explanationstringHuman-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why.
data[].outcome_evaluation_start_idstringThe id of the corresponding `span.outcome_evaluation_start` event.
data[].usageobjectToken usage for a single model request. / Point-in-time snapshot of a session's cumulative usage.
data[].model_request_start_idstringThe id of the corresponding `span.model_request_start` event.
data[].model_usageobjectToken usage for a single model request.
data[].descriptionstringWhat the agent should produce. Copied from the input event.
data[].max_iterationsnull | numberEvaluate-then-revise cycles before giving up. Default 3, max 20.
data[].rubricobjectRubric for grading the quality of an outcome.
data[].agentnull | objectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
data[].budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
data[].metadataobjectThe session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty.
data[].titlenull | stringThe session's new title. Present only when the update changed it.
data[].modelobject扩展 / Praxis extension: the changed session model, present only on /agent/v1 session.updated events. Model-only updates are omitted on /anthropic.
data[].forked_from_session_idstringId of the parent session this session was forked from.
data[].forked_from_message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.
data[].actionstringWhat changed in the goal.
data[].goalobject | nullThe goal as the change left it, or null when the session has no goal.
data[].previous_goalobject | nullThe goal before the change, or null when there was none.
data[].statusstringWhere the check stands. Read `verification.passed` on the closing event to know whether the goal counts as done.
data[].goal_idstringThe goal this check belongs to.
data[].goal_iterationintegerWhich check of this goal, matching `iteration` on the goal.
data[].verification_idstringIdentifier shared by every event of one check.
data[].anchor_message_idstring | nullThe assistant message the check follows, or null.
data[].verificationobjectThe verdict; absent on `started`.
data[].event_idstringId of the event this event refers to.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

GET /agent/v1/sessions/{session_id}/threads/{thread_id}/stream◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • thread_idstring必填

    path: Execution thread id (sthr_...), as listed by sessions.threads.list; the primary thread id equals the session's own thread. Unknown or foreign ids return 404.

  • session_idstring必填

    query: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • event_deltasarray可选

    query: When set, this connection also receives streaming deltas (`event_start`, `event_delta`) while an event is being produced, before the event itself arrives. Deltas are best-effort; when the final event is produced it carries the complete content. A model request that ends early (an error or interrupt) produces no final event — its terminal `span.model_request_end` closes the preview. Accepts one or more event types to preview and may be repeated: `agent.message` streams `content_delta` fragments; `agent.thinking` is start-only — a signal that the agent has begun extended thinking, concluded by the `agent.thinking` event itself. Only previews of the requested event types are sent.

返回

200

订阅所选线程自己的实时事件流。复用会话 SSE 实现;/agent 接口支持同址只读 WebSocket。主会话流同时包含子线程创建、状态和消息事件,子线程审批带 session_thread_id 上浮;确认或中断携带该字段时路由到所属子线程。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Server-sent events

text/event-stream — chunk / 事件对象

名称类型说明
idstringIdentifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
eventstringServer-Sent Events event name of this frame. / Always `user.message`. SSE event name of this frame; its data is a user.message payload. A message from the user to the agent, with content blocks. / Always `user.interrupt`. SSE event name of this frame; its data is a user.interrupt payload. The user interrupted the running turn. / Always `agent.message`. SSE event name of this frame; its data is a agent.message payload. A message from the agent, with text content blocks. / Always `agent.thinking`. SSE event name of this frame; its data is a agent.thinking payload. The agent's thinking text for a step. / Always `session.status_running`. SSE event name of this frame; its data is a session.status_running payload. The session started running a turn. / Always `session.status_rescheduled`. SSE event name of this frame; its data is a session.status_rescheduled payload. The session will retry after a recoverable error. / Always `session.status_idle`. SSE event name of this frame; its data is a session.status_idle payload. The session stopped running; stop_reason says why. / Always `session.status_terminated`. SSE event name of this frame; its data is a session.status_terminated payload. The session ended and accepts no more work. / Always `agent.thread_context_compacted`. SSE event name of this frame; its data is a agent.thread_context_compacted payload. The thread's context was compacted into a summary. / Always `agent.thread_context_reset`. SSE event name of this frame; its data is a agent.thread_context_reset payload. Content was removed from the model's context after a content-safety refusal. / Always `session.updated`. SSE event name of this frame; its data is a session.updated payload. The session's model, title, metadata, agent or budget changed. / Always `session.error`. SSE event name of this frame; its data is a session.error payload. The session hit an error. / Always `session.usage`. SSE event name of this frame; its data is a session.usage payload. Cumulative usage of the session. / Always `span.model_request_start`. SSE event name of this frame; its data is a span.model_request_start payload. A model request started. / Always `span.model_request_end`. SSE event name of this frame; its data is a span.model_request_end payload. A model request ended, with its usage. / Always `agent.tool_use`. SSE event name of this frame; its data is a agent.tool_use payload. The agent called a tool. / Always `agent.tool_result`. SSE event name of this frame; its data is a agent.tool_result payload. The result of a tool call. / Always `agent.mcp_tool_use`. SSE event name of this frame; its data is a agent.mcp_tool_use payload. The agent called an MCP tool. / Always `agent.mcp_tool_result`. SSE event name of this frame; its data is a agent.mcp_tool_result payload. The result of an MCP tool call. / Always `user.tool_confirmation`. SSE event name of this frame; its data is a user.tool_confirmation payload. The user's decision to allow or deny a tool call that waits for approval. / Always `session.thread_created`. SSE event name of this frame; its data is a session.thread_created payload. A child thread was started. / Always `session.thread_status_running`. SSE event name of this frame; its data is a session.thread_status_running payload. A thread started running. / Always `session.thread_status_idle`. SSE event name of this frame; its data is a session.thread_status_idle payload. A thread stopped running; stop_reason says why. / Always `session.thread_status_rescheduled`. SSE event name of this frame; its data is a session.thread_status_rescheduled payload. A thread will retry after a recoverable error. / Always `session.thread_status_terminated`. SSE event name of this frame; its data is a session.thread_status_terminated payload. A thread ended. / Always `agent.thread_message_sent`. SSE event name of this frame; its data is a agent.thread_message_sent payload. The agent sent a message to another thread. / Always `agent.thread_message_received`. SSE event name of this frame; its data is a agent.thread_message_received payload. The agent received a message from another thread. / Always `user.withdraw`. SSE event name of this frame; its data is a user.withdraw payload. A queued user.message was withdrawn before it ran. / Always `user.steer`. SSE event name of this frame; its data is a user.steer payload. Receipt that a queued user.message was injected into the running turn. / Always `system.notification`. SSE event name of this frame; its data is a system.notification payload. Background work woke the session with a notification. / Always `session.forked`. SSE event name of this frame; its data is a session.forked payload. The session was created by forking another session. / Always `session.goal_changed`. SSE event name of this frame; its data is a session.goal_changed payload. The session's goal was set, changed status, accounted usage or was cleared. / Always `session.goal_verification`. SSE event name of this frame; its data is a session.goal_verification payload. One completion check of the session's goal started or ended. / Always `event_start`. SSE event name of this frame; its data is a event_start payload. Preview that an event of the requested delta types has started. / Always `event_delta`. SSE event name of this frame; its data is a event_delta payload. Incremental fragment of the event being produced. / Always `ping`. SSE event name of this frame; its data is a ping payload. Keep-alive frame; carries no data. / Always `error`. SSE event name of this frame; its data is a error payload. A stream error.
dataobjectDecoded JSON payload of this frame; its shape is selected by the event name. / Praxis extension (AskUserQuestion, own face only): the confirmation of an AskUserQuestion call, with the answers it carried. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Praxis extension (goal mode, own face only): the session's goal was set, moved to another status, accounted usage or was cleared. `goal` is the goal after the change, `previous_goal` the one before; each is null when there was none. / Praxis extension (goal mode, own face only): one completion check of the goal. A `started` event opens it; `completed`, `failed_closed` or `cancelled` closes it. Events of one check share `verification_id`. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name. / Decoded JSON payload of this frame; its shape is selected by the event name.
data.idstringUnique identifier for this event. / Text of the block. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Event id, unique within the session. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Text of the block. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Event id, unique within the session. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Unique identifier for this event. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Text of the block. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer. / Event id, unique within the session. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer.
data.contentarray<object>Array of content blocks comprising the user message. / Array of text blocks comprising the agent response. / Content blocks of the event, in order. / The result content returned by the tool. / The result content returned by the tool. / Message content blocks. / Message content blocks. / Array of content blocks comprising the user message. / Array of text blocks comprising the agent response. / Content blocks of the event, in order. / The result content returned by the tool. / The result content returned by the tool. / Message content blocks. / Message content blocks.
data.typestringAlways `user.message`. A message from the user to the agent, with content blocks. / Always `user.interrupt`. The user interrupted the running turn. / Always `agent.message`. A message from the agent, with text content blocks. / Always `agent.thinking`. The agent's thinking text for a step. / Always `session.status_running`. The session started running a turn. / Always `session.status_rescheduled`. The session will retry after a recoverable error. / Always `session.status_idle`. The session stopped running; stop_reason says why. / Always `session.status_terminated`. The session ended and accepts no more work. / Always `agent.thread_context_compacted`. The thread's context was compacted into a summary. / Always `agent.thread_context_reset`. Content was removed from the model's context after a content-safety refusal. / Always `session.updated`. The session's model, title, metadata, agent or budget changed. / Always `session.error`. The session hit an error. / Always `session.usage`. Cumulative usage of the session. / Always `span.model_request_start`. A model request started. / Always `span.model_request_end`. A model request ended, with its usage. / Always `agent.tool_use`. The agent called a tool. / Always `agent.tool_result`. The result of a tool call. / Always `agent.mcp_tool_use`. The agent called an MCP tool. / Always `agent.mcp_tool_result`. The result of an MCP tool call. / Always `user.tool_confirmation`. / Always `session.thread_created`. A child thread was started. / Always `session.thread_status_running`. A thread started running. / Always `session.thread_status_idle`. A thread stopped running; stop_reason says why. / Always `session.thread_status_rescheduled`. A thread will retry after a recoverable error. / Always `session.thread_status_terminated`. A thread ended. / Always `agent.thread_message_sent`. The agent sent a message to another thread. / Always `agent.thread_message_received`. The agent received a message from another thread. / Always `user.withdraw`. A queued user.message was withdrawn before it ran. / Always `user.steer`. Receipt that a queued user.message was injected into the running turn. / Always `system.notification`. Background work woke the session with a notification. / Always `session.forked`. The session was created by forking another session. / Always `session.goal_changed`. / Always `session.goal_verification`. / Always `event_start`. Preview that an event of the requested delta types has started. / Always `event_delta`. Incremental fragment of the event being produced. / Always `ping`. Keep-alive frame; carries no data. / Always `error`. A stream error. / Always `user.message`. A message from the user to the agent, with content blocks. / Always `user.interrupt`. The user interrupted the running turn. / Always `agent.message`. A message from the agent, with text content blocks. / Always `agent.thinking`. The agent's thinking text for a step. / Always `session.status_running`. The session started running a turn. / Always `session.status_rescheduled`. The session will retry after a recoverable error. / Always `session.status_idle`. The session stopped running; stop_reason says why. / Always `session.status_terminated`. The session ended and accepts no more work. / Always `agent.thread_context_compacted`. The thread's context was compacted into a summary. / Always `agent.thread_context_reset`. Content was removed from the model's context after a content-safety refusal. / Always `session.updated`. The session's model, title, metadata, agent or budget changed. / Always `session.error`. The session hit an error. / Always `session.usage`. Cumulative usage of the session. / Always `span.model_request_start`. A model request started. / Always `span.model_request_end`. A model request ended, with its usage. / Always `agent.tool_use`. The agent called a tool. / Always `agent.tool_result`. The result of a tool call. / Always `agent.mcp_tool_use`. The agent called an MCP tool. / Always `agent.mcp_tool_result`. The result of an MCP tool call. / Always `user.tool_confirmation`. / Always `session.thread_created`. A child thread was started. / Always `session.thread_status_running`. A thread started running. / Always `session.thread_status_idle`. A thread stopped running; stop_reason says why. / Always `session.thread_status_rescheduled`. A thread will retry after a recoverable error. / Always `session.thread_status_terminated`. A thread ended. / Always `agent.thread_message_sent`. The agent sent a message to another thread. / Always `agent.thread_message_received`. The agent received a message from another thread. / Always `user.withdraw`. A queued user.message was withdrawn before it ran. / Always `user.steer`. Receipt that a queued user.message was injected into the running turn. / Always `system.notification`. Background work woke the session with a notification. / Always `session.forked`. The session was created by forking another session. / Always `session.goal_changed`. / Always `session.goal_verification`. / Always `event_start`. Preview that an event of the requested delta types has started. / Always `event_delta`. Incremental fragment of the event being produced. / Always `ping`. Keep-alive frame; carries no data. / Always `error`. A stream error.
data.processed_atnull | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | null | string | null | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | stringA timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / When the event was recorded, RFC 3339. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / When the event was recorded, RFC 3339. / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / RFC 3339 time at which the server processed the event; null while a queued input has not started running. / When the event was recorded, RFC 3339. / RFC 3339 time at which the server processed the event; null while a queued input has not started running.
data.message_idstringUI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID shared with this assistant's message parts. / UI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID. Use the last assistant message in a successfully completed turn as the fork target. / UI transcript message ID shared with this assistant's message parts.
data.session_thread_idnull | string | string | null | string | null | string | string | string | string | string | string | string | string | null | string | string | null | string | null | string | string | string | string | string | string | string | stringIf absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Text of the block. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` or `user.tool_result` by `tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` by `tool_use_id`, so clients do not send it back. / Public `sthr_` ID of the newly created thread. / Public sthr_ ID of the thread that started running. / Public sthr_ ID of the thread that went idle. / Public sthr_ ID of the thread that is retrying. / Public sthr_ ID of the thread that terminated. / Text of the block. / Text of the block. / If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Text of the block. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` or `user.tool_result` by `tool_use_id`, so clients do not send it back. / When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Informational only: the server routes the matching `user.tool_confirmation` by `tool_use_id`, so clients do not send it back. / Public `sthr_` ID of the newly created thread. / Public sthr_ ID of the thread that started running. / Public sthr_ ID of the thread that went idle. / Public sthr_ ID of the thread that is retrying. / Public sthr_ ID of the thread that terminated. / Text of the block. / Text of the block.
data.stop_reasonobjectWhy the session stopped running, with the variant data needed to continue.
data.removedarray<object>Content removed from the model's context by this reset.
data.categorystringText of the block.
data.stoppedbooleanTrue when the run was stopped instead of retried after the reset.
data.agentnull | objectResolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.
data.budgetnull | objectA hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches `max_list_cost`.
data.metadataobjectThe session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty.
data.titlenull | stringThe session's new title. Present only when the update changed it.
data.modelobject扩展 / Praxis extension: the changed session model, present only on /agent/v1 session.updated events. Model-only updates are omitted on /anthropic.
data.errorobjectDescription of the error and what the client should do next. / Error detail. / Description of the error and what the client should do next. / Error detail.
data.usageobjectPoint-in-time snapshot of a session's cumulative usage.
data.is_errornull | booleanWhether the model request resulted in an error. / Whether the tool execution resulted in an error. / Whether the tool execution resulted in an error. / Whether the model request resulted in an error. / Whether the tool execution resulted in an error. / Whether the tool execution resulted in an error.
data.model_request_start_idstringThe id of the corresponding `span.model_request_start` event.
data.model_usageobjectToken usage for a single model request.
data.inputobjectInput parameters for the tool call.
data.namestringName of the agent tool being used. / Name of the MCP tool being used. / Name of the agent tool being used. / Name of the MCP tool being used.
data.evaluated_permissionstringAgentEvaluatedPermission enum
data.evaluationobjectNames the resolved permission_policy that produced evaluated_permission, and under auto carries the judgement. Open union: clients must tolerate unknown variants.
data.tool_use_idstringThe id of the `agent.tool_use` event this result corresponds to. / The id of the AskUserQuestion `agent.tool_use` event this answers. / The id of the `agent.tool_use` event this result corresponds to. / The id of the AskUserQuestion `agent.tool_use` event this answers.
data.mcp_server_namestringName of the MCP server providing the tool.
data._metaobjectPraxis extension (MCP Apps, SEP-1865): the `ui` and `openai/ui` keys of the MCP tool definition's `_meta`, verbatim; other `_meta` keys are not exposed. When `ui.resourceUri` is a `ui://` URI, the tool has an interactive view: a client that implements MCP Apps can fetch that resource from the MCP server and render it for this call. Absent when the tool declares neither key. Clients that do not render MCP Apps ignore it. / Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `_meta`, verbatim. Views use it for data that should not reach the model; absent when the tool returned none. / Praxis extension (MCP Apps, SEP-1865): the `ui` and `openai/ui` keys of the MCP tool definition's `_meta`, verbatim; other `_meta` keys are not exposed. When `ui.resourceUri` is a `ui://` URI, the tool has an interactive view: a client that implements MCP Apps can fetch that resource from the MCP server and render it for this call. Absent when the tool declares neither key. Clients that do not render MCP Apps ignore it. / Praxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `_meta`, verbatim. Views use it for data that should not reach the model; absent when the tool returned none.
data.sourcestringPraxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / What caused the change. / Praxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / Praxis extension (MCP Apps, SEP-1865): `app` when the call was made by an MCP Apps view, `codemode` when a program run by the codemode tool called an MCP tool that declares a view (the event pair exists so a client can render that view; the model already has the result in the codemode tool result); absent for the model's own calls. / What caused the change.
data.parent_tool_use_idstringPraxis extension (MCP Apps, SEP-1865): present when `source` is `codemode`; the id of the codemode tool use whose program made this call. Absent otherwise.
data.mcp_tool_use_idstringThe id of the `agent.mcp_tool_use` event this result corresponds to.
data.structured_contentanyPraxis extension (MCP Apps, SEP-1865): the MCP CallToolResult `structuredContent`, verbatim JSON. MCP Apps views read it as the data to render; absent when the tool returned none.
data.resultstringAlways `allow`.
data.answersobjectThe user's answer to each question, keyed by the question text; empty when the questions were dismissed.
data.annotationsobjectPer-question notes, keyed by the question text.
data.agent_namestringName of the callable agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the callable agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs. / Name of the agent the thread runs.
data.to_session_thread_idstringPublic `sthr_` ID of the thread the message was sent to.
data.to_agent_namenull | stringName of the callable agent this message was sent to. Absent when sent to the primary agent.
data.from_session_thread_idstringPublic `sthr_` ID of the thread that sent the message.
data.from_agent_namenull | stringName of the callable agent this message came from. Absent when received from the primary agent.
data.event_idstringText of the block. / Id of the event this event refers to. / Text of the block. / Text of the block. / Id of the event this event refers to. / Text of the block.
data.sourcesarray<object>Background work that woke the session with this notification.
data.forked_from_session_idstringId of the parent session this session was forked from.
data.forked_from_message_idstringmessage_id of the agent message in the parent session up to which the conversation was copied.
data.actionstringWhat changed in the goal.
data.goalobject | nullThe goal as the change left it, or null when the session has no goal.
data.previous_goalobject | nullThe goal before the change, or null when there was none.
data.statusstringWhere the check stands. Read `verification.passed` on the closing event to know whether the goal counts as done.
data.goal_idstringThe goal this check belongs to.
data.goal_iterationintegerWhich check of this goal, matching `iteration` on the goal.
data.verification_idstringIdentifier shared by every event of one check.
data.anchor_message_idstring | nullThe assistant message the check follows, or null.
data.verificationobjectThe verdict; absent on `started`.
data.eventobjectEvent name or event payload.
data.deltaobjectIncremental fragment of the event being produced.

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST /agent/v1/sessions/{session_id}/threads/{thread_id}/archive◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

  • thread_idstring必填

    path: Execution thread id (sthr_...), as listed by sessions.threads.list; the primary thread id equals the session's own thread. Unknown or foreign ids return 404.

  • session_idstring必填

    query: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.

返回

200

主线程沿用会话归档动作;子线程仅归档对应子会话,不归档父会话或其他子线程。子线程归档后 status 为 terminated,带 archived_at;历史事件仍可读。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringUnique identifier for this thread.
agentobjectThe resolved agent a `session_thread` runs.
agent.modelstring | objectThe advisor model id. / Model identifier and configuration.
agent.typestringAlways `advisor`. An advisor whose model is consulted for advice in a separate thread (at most one per coordinator). / Always `agent`. A roster member that refers to an agent by id and pinned version.
agent.idstringAgent id (agent_...). Pass it as agent when creating a session and as agent_id in agent calls.
agent.descriptionnull | stringFree-text description of what the agent is for; null when none was set.
agent.mcp_serversarray<object>URL MCP servers the agent can call, paired one-to-one with mcp_toolset entries in tools and saved with the agent version. No credentials are stored here.
agent.namestringDisplay name of the agent, as set on create or update. It is a label, not a unique key.
agent.skillsarray<object>Skills attached to the agent. Setting skills is not supported on this platform and returns 400, so do not send this field on create or update.
agent.systemnull | stringSystem prompt given to the model at the start of every session of this agent; null when none was set.
agent.toolsarray<object>Tools of the agent: one agent_toolset_20260401 entry for the native tools (all resolved settings are returned, ready to send back on update), plus mcp_toolset entries and custom tool definitions.
agent.versionnumberThe agent's current version. Starts at 1 and increments each time the agent is modified.
archived_atnull | stringA timestamp in RFC 3339 format
created_atstringA timestamp in RFC 3339 format
parent_thread_idnull | stringParent thread that spawned this thread. Null for the primary thread.
session_idstringThe session this thread belongs to.
statsnull | objectTiming statistics for a session thread.
stats.active_secondsnumberCumulative time in seconds the thread spent actively running. Excludes idle time.
stats.duration_secondsnumberElapsed time since thread creation in seconds. For archived threads, frozen at the final update.
stats.startup_secondsnumberTime in seconds for the thread to begin running. Zero for child threads, which start immediately.
statusstringSessionThreadStatus enum
typestringAlways `session_thread`. An execution thread of a session.
updated_atstringA timestamp in RFC 3339 format
usagenull | objectCumulative token usage for a session thread across all turns.
usage.active_secondsnumberCumulative time in seconds this thread spent in running status. Equal to `stats.active_seconds`; surfaced here so a thread's usage carries every quantity its cost is priced on.
usage.cache_creationobjectPrompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokensnumberTotal tokens read from prompt cache.
usage.input_tokensnumberTotal input tokens consumed across all turns.
usage.list_costnull | objectA monetary amount in a specific currency.
usage.output_tokensnumberTotal output tokens generated across all turns.
usage.server_tool_usenull | objectCumulative count of server-executed tool invocations, broken down by tool.

GET /agent/v1/environments◐ 部分支持

Claude 官方文档 ↗

请求参数

  • include_archivedboolean可选

    query: Include archived environments in the response

  • limitnumber可选

    query: Number of items per page.

  • pagestring可选

    query: Opaque pagination cursor: pass the next_page value of the previous response unchanged. Omit it for the first page. A cursor from a different query or a malformed one returns 400.

返回

200

支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].idstringEnvironment identifier (e.g., 'env_...')
data[].archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
data[].configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
data[].created_atstringRFC 3339 timestamp when environment was created
data[].descriptionnull | stringUser-provided description for the environment; null when unset
data[].metadataobjectUser-provided metadata key-value pairs
data[].namestringHuman-readable name for the environment
data[].typestringThe type of object (always 'environment')
data[].updated_atstringRFC 3339 timestamp when environment was last updated
data[].scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.
next_pagestring | nullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

GET /agent/v1/environments/{environment_id}◐ 部分支持

Claude 官方文档 ↗

请求参数

  • environment_idstring必填

    path: Environment id, as returned by environments.create or environments.list. Built-in environments can be read but not changed.

返回

200

支持租户自建 cloud 环境、配置更新与软归档;内置环境只读。列表支持 limit、page 和 include_archived。limited 网络在沙箱创建时生效;安装失败会终止会话,错误码为 ENVIRONMENT_PACKAGE_INSTALL_FAILED。self_hosted、scope 和跨会话包缓存尚不支持。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Successful response

application/json

名称类型说明
idstringEnvironment identifier (e.g., 'env_...')
archived_atnull | stringRFC 3339 timestamp when environment was archived, or null if not archived
configobjectEnvironment configuration (either Anthropic Cloud or self-hosted)
config.networkingobjectNetwork configuration policy.
config.packagesobjectPackage manager configuration.
config.typestringEnvironment type
created_atstringRFC 3339 timestamp when environment was created
descriptionnull | stringUser-provided description for the environment; null when unset
metadataobjectUser-provided metadata key-value pairs
namestringHuman-readable name for the environment
typestringThe type of object (always 'environment')
updated_atstringRFC 3339 timestamp when environment was last updated
scopestringThe visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

列出工具集

GET /agent/v1/toolsets● 支持

返回

200

返回工具集说明、插件名称与版本,以及每个工具的名称、说明、参数定义、是否只读和默认授权方式。通过 /agent/v1/toolsets 读取此目录;目录不会更改智能体配置。agent_toolset_20260401 包含全部 13 个原生工具;TaskOutput、TaskStop、Monitor、Agent、SendMessage 与其他工具一样可逐个开关及设置权限,它们都依赖 bash。兼容 API 只提供官方 8 个工具。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

响应

HTTP 200

Available toolsets

application/json

名称类型说明
dataarray<object>Items of this page, in the order requested by the call.
data[].typestringToolset type id as used in an agent's tools entry, for example agent_toolset_20260401.
data[].pluginobjectUnit that registers the toolset, with its name and version.
data[].descriptionstringFree-text description; null when none was set.
data[].environmentstringEnvironment in which the toolset's tools run, for example node22.
data[].toolsarray<object>Tools offered to the model.
next_pagenullOpaque cursor for the next page: pass it unchanged as page to continue. Null when this is the last page.

模型 API

基础地址

加载中…

接入

加载中…

两家 SDK 怎么配

SDKbase URL认证头能用的端点
OpenAI SDKAuthorization: Bearer对话、生成响应、文本向量、生成图像、模型列表、会话(Conversations)
Anthropic SDK(SDK 自己补 /v1)x-api-key 或 Authorization: Bearer发送消息、统计 token

两家用同一把 Key、同一套模型名、同一个账单,换 SDK 不换别的。会话(创建、条目、删除)是跨调用的状态容器,形状与 OpenAI 官方 conversations 一致。

模型回退与自带 Key

对话的请求体可以带 providerOptions.praxis:

字段作用
models候选模型列表:请求的模型失败时按顺序换下一个
byok自带上游 Key(按供应商名给出);这把 Key 不可用时自动改用平台的
order / only指定供应商的顺序或范围,只在带 byok 时可用

响应里的 providerMetadata.praxis 给出这次调用的 generationId、cost、credential(platform 或 byok)和实际服务的 model;拿 generationId 可以查询生成记录。其它端点目前不接受 providerOptions.praxis,带上会返回 400。

端点

方法路径说明支持
POST/v1/chat/completions对话● 支持
POST/v1/responses生成响应● 支持
GET/v1/responses/{response_id}读取响应● 支持
DELETE/v1/responses/{response_id}删除响应● 支持
POST/v1/responses/{response_id}/cancel取消响应◐ 部分支持
GET/v1/responses/{response_id}/input_items列出响应输入项● 支持
POST/v1/responses/compact压缩响应○ 未支持
POST/v1/responses/input_tokens统计输入 token○ 未支持
POST/v1/embeddings文本向量● 支持
POST/v1/rerank重排文档● 支持
POST/v1/audio/speech合成语音● 支持
POST/v1/audio/transcriptions转写音频● 支持
POST/v1/images/generations生成图像● 支持
POST/v1/images/edits编辑图像● 支持
POST/v1/ocr文档识别● 支持
POST/v1/videos创建视频● 支持
GET/v1/videos列出视频● 支持
GET/v1/videos/{video_id}读取视频● 支持
GET/v1/videos/{video_id}/content下载视频内容● 支持
DELETE/v1/videos/{video_id}删除视频● 支持
POST/v1/videos/{video_id}/remix混剪视频○ 未支持
POST/v1/messages发送消息● 支持
POST/v1/messages/count_tokens统计 token◐ 部分支持
GET/v1/models列出模型● 支持
GET/v1/models/{model}读取模型● 支持
GET/v1/generation查询生成记录● 支持
POST/v1/conversations创建会话● 支持
GET/v1/conversations/{conversation_id}读取会话● 支持
POST/v1/conversations/{conversation_id}更新会话● 支持
POST/v1/conversations/{conversation_id}/items创建会话条目● 支持
GET/v1/conversations/{conversation_id}/items列出会话条目● 支持
GET/v1/conversations/{conversation_id}/items/{item_id}读取会话条目● 支持
DELETE/v1/conversations/{conversation_id}/items/{item_id}删除会话条目● 支持
DELETE/v1/conversations/{conversation_id}删除会话● 支持

与官方的差异

  • 对话:未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。
  • 生成响应:未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。
  • 读取响应:按 ID 读取一条已保存的响应。如果创建时 store 为 false,我们不会保存这次响应,读取会返回 404 response_not_found;超过保留期(默认 30 天)后读取也会返回同样的 404。
  • 删除响应:按 ID 立即删除一条已保存的响应。如果创建时 store 为 false,我们不会保存这次响应,删除会返回 404 response_not_found。
  • 取消响应:仅对以 background:true 创建、且路由到具备后台生成能力的模型的响应可用:取消是 幂等的,重复调用返回同一个终态响应;我方的取消只能停止我方对上游流的继续读取, 不能保证已发往上游的算力停止计算,用量按实际收到的部分结算。对一个非后台 (同步)响应调用 cancel:如果这个响应 id 不存在(未持久化、已过期或 id 有误), 返回 404 object_not_found;如果响应存在但其来源 provider 没有声明支持 cancel 操作(我们目前没有接入任何为同步响应声明该能力的上游),返回 400 native_responses_operation_unsupported。这两种情况都不是尚未实现的 501 gate。
  • 列出响应输入项:列出一条已保存响应的输入项。支持 limit(1–100,默认 20)、order(asc/desc, 默认 desc,与官方一致)与基于条目 id 的 after 游标分页;has_more/first_id/ last_id 均与实际返回页一致,可据此翻页且不重不漏。每个条目都带服务端签发的 id(message 为 msg_ 前缀,function_call/function_call_output/reasoning 各自 对应前缀),本次上线前已保存、尚无服务端 id 的旧数据在读取时按确定性规则补 id,不做破坏性迁移,同一游标反复读取保持稳定。以 previous_response_id 续接 创建的响应,其输入项列出解析后的完整输入:前序响应链已有的输入与输出条目 再加本轮自己提交的输入;若该祖先响应在我方平台未保存(例如创建时 store 为 false)或已过期删除,则只列出本轮自己提交的输入。如果创建时 store 为 false,我们不会保存这次响应,列出会返回 404 response_not_found。
  • 压缩响应:把响应的输入压缩成摘要,依赖 OpenAI Responses 官方的服务端存储(store)语义,我们目前还没有实现;调用会返回 501(message 为 “This platform has not implemented … yet.”,响应头 x-should-retry 为 false),不产生副作用,官方 SDK 不会重试。
  • 统计输入 token:只统计请求输入会消耗的 token 数、不生成内容,依赖 OpenAI Responses 官方的服务端存储(store)语义,我们目前还没有实现;调用会返回 501(message 为 “This platform has not implemented … yet.”,响应头 x-should-retry 为 false),不产生副作用,官方 SDK 不会重试。
  • 文本向量:未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。
  • 重排文档:标准请求字段;不能表达的参数返回 input_not_representable。
  • 合成语音:melotts 输出 WAV,只支持 input(含 text/prompt 别名)、lang 和默认音频选项;aura-2-en 使用原生 speaker 名称。逐字段限制见参数表。
  • 转写音频:标准请求字段;不能表达的参数返回 input_not_representable。
  • 文档识别:采用 Mistral OCR 请求与响应形状,仅提供 /model/v1/ocr。model 必填;document 接受 document_url 或 image_url(HTTPS 或 base64 data URL),也接受 {type:"file", file_id:"<上传所得 ID>"},直接读取当前租户的 File。file_id 读取上限为 24 MiB(25,165,824 字节,共享 96 MiB 内存预算按四倍预留);超过此上限返回 413,并提示改用 HTTPS document_url(PDF 上限 50 MiB)。PNG/JPEG 仍限 10 MiB,按文件头识别类型;不存在或其他租户的文件统一返回 404。pages 是从 0 开始的页码数组;图片如指定 pages,只能为 [0]。文件读取失败不计费,请求日志仅记录 file_id,不保存文件原文。可选功能依模型而定,不支持的选项返回 400。错误为 problem+json;providerOptions.praxis 不适用于此端点。
  • 创建视频:按输出秒数计费;每秒价格见 GET /model/v1/models 的 pricing.video_second(USD/秒)。
  • 列出视频:按输出秒数计费;每秒价格见 GET /model/v1/models 的 pricing.video_second(USD/秒)。
  • 读取视频:按输出秒数计费;每秒价格见 GET /model/v1/models 的 pricing.video_second(USD/秒)。
  • 下载视频内容:按输出秒数计费;每秒价格见 GET /model/v1/models 的 pricing.video_second(USD/秒)。
  • 删除视频:按输出秒数计费;每秒价格见 GET /model/v1/models 的 pricing.video_second(USD/秒)。
  • 混剪视频:未支持,调用返回 400;不要重试。
  • 发送消息:未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。
  • 统计 token:按模型族校准的估算值(包括中文和工具定义),响应头为 x-praxis-token-count: estimated;不能用作精确用量或计费依据。
  • 列出模型:OCR 模型的 type 为 ocr,pricing.page 是 USD/页的十进制字符串,为 Praxis 对 Vercel 模型列表形状的扩展;其余四项 token 价格为 0。其它模型不带 pricing.page。
  • 创建会话:创建一个会话,可选携带初始 items(一次最多 20 条)与 metadata。会话按租户分区,创建者是唯一能引用它的租户。
  • 读取会话:按 ID 读取一个会话。不存在或属于其他租户都返回 404 conversation_not_found。
  • 更新会话:更新一个会话的 metadata——整体替换,不与已有 metadata 合并。
  • 创建会话条目:向一个会话追加 items(一次最多 20 条),返回刚追加的这些 items。
  • 列出会话条目:按创建顺序列出会话的 items,支持 limit/after/order 分页参数。
  • 读取会话条目:按 ID 读取会话里的单条 item。
  • 删除会话条目:删除会话里的单条 item,返回该会话对象(不是被删除的 item)。
  • 删除会话:删除一个会话。删除后该会话与其 items 都不能再被引用(包括作为 Responses create 的 conversation 参数)。

请求与响应字段的权威定义,见每个端点页链接的 OpenAI、Anthropic 或 Mistral 官方文档。OCR 通过 HTTP 调用,不在 OpenAI 或 Anthropic SDK 的端点中。

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

对话

POST /model/v1/chat/completions● 支持

官方文档 ↗

请求参数

  • X-OpenRouter-Metadatastring可选○ 当前不生效

    header: OpenRouter-style request header that asks for routing metadata in the response. It is accepted for compatibility and has no effect: the routing metadata is not returned.

    接受但当前不生效;不会返回请求的路由元数据。

  • modelstring必填

    Model to use for completion

    主模型;提供非空 models 时可省略,使用列表首项。

  • messagesarray必填◐ 部分支持

    List of messages for the conversation

    文本、角色、历史和工具往返生效;图片受模型尺寸限制;file_id 可引用 user_data 图片、文本和 PDF;模型读取能力与失败处理见[文件引用指南](/docs/cloud/services/model/guides/files)。

    ▸ 展开子字段(12)

    元素按 role 区分(assistant / developer / system / tool / user),此处展开其中一种的形状

    • configuration_updateobject可选

      OpenRouter extension. Same as the system message `configuration_update`: changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding turns.

    • contentstring | array可选

      Tool response content

    • namestring可选

      Optional name for the assistant

    • rolestring可选

      Role of the message author; always tool.

      取值 tool
    • audioobject可选

      Audio output data or reference

    • imagesarray可选

      Generated images from image generation models

    • modelstring必填

      Model that generated this assistant message

    • reasoningstring可选

      Reasoning output

    • reasoning_detailsarray可选

      Reasoning details for extended thinking models

    • refusalstring可选

      Refusal message if content was refused

    • tool_callsarray可选

      Tool calls made by the assistant

    • tool_call_idstring可选

      ID of the assistant message tool call this message responds to

  • max_tokensinteger可选◐ 部分支持

    Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16.

    deepseek-v4-flash、glm-5.3-flash 生效;qwen3.8-flash 的小预算可能不生效。与 max_completion_tokens 同传时本字段优先。

  • streamboolean可选◐ 部分支持
    默认 false

    Enable streaming response

    流式正文和工具增量生效;gemini-2.5-flash 可能缺少结束标记,预算耗尽时 finish_reason 可能不准确。

  • temperaturenumber可选◐ 部分支持

    Sampling temperature (0-2)

    在 /openai 的 deepseek-v4-flash 观察到效果;其余模型的采样差异无法确认。

  • top_pnumber可选◐ 部分支持

    Nucleus sampling parameter (0-1)

    仅 /model 的 glm-5.3-flash 观察到效果;其余已测模型或协议面接受但未见效果。

  • toolsarray可选

    Available tools for function calling

    已验证生效。

  • tool_choicestring | object可选◐ 部分支持

    Tool choice configuration

    auto 生效;deepseek-v4-flash 忽略 none/required/具名函数;qwen3.8-flash 的 required/具名函数在思考模式报错;glm-5.3-flash 的具名函数结果不稳定。

    ▸ 展开子字段(2)
    • functionobject必填

      The function the model must call.

    • typestring必填

      OpenRouter server-tool type to force (e.g. `openrouter:web_search`, `web_search`, `web_search_preview`).

  • response_formatobject可选◐ 部分支持

    Response format configuration

    json_object 生效;json_schema 在 deepseek-v4-flash、qwen3.8-flash 生效,glm-5.3-flash 接受但未遵守。

    ▸ 展开子字段(3)

    按 type 区分(grammar / json_object / json_schema / python / text),此处展开其中一种的形状

    • typestring必填

      Always `python`. Discriminator that marks this object as a ChatFormatPythonConfig in a `type`-tagged union.

      取值 python
    • json_schemaobject必填

      JSON Schema configuration object

    • grammarstring必填

      Custom grammar for text generation

  • ▸ 更多参数(49)
    • promptstring可选○ 当前不生效

      接受并忽略;Chat 仍须提供 messages,本字段不替代消息。

    • cache_controlobject可选

      Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format.

      ▸ 展开子字段(2)
      • ttlstring可选

        Lifetime of an Anthropic-style cache breakpoint.

        取值 5m1h
      • typestring必填

        Always `ephemeral`. Discriminator that marks this object as a AnthropicCacheControlDirective in a `type`-tagged union.

        取值 ephemeral
    • debugobject可选

      Debug options for inspecting request transformations (streaming only)

      ▸ 展开子字段(1)
      • echo_upstream_bodyboolean可选○ 当前不生效

        If true, includes the transformed upstream request body in a debug chunk at the start of the stream. Only works with streaming mode.

        接受但当前不生效。流式请求不会回显上游请求体。

    • frequency_penaltynumber可选◐ 部分支持

      Frequency penalty (-2.0 to 2.0)

      deepseek-v4-flash、glm-5.3-flash 部分请求生效;qwen3.8-flash 在部分取值或协议面返回 400。

    • image_configobject可选

      Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details.

    • logit_biasobject可选

      Token logit bias adjustments

    • logprobsboolean可选◐ 部分支持

      Return log probabilities

      qwen3.8-flash 生效;deepseek-v4-flash 仅 /openai 生效,glm-5.3-flash 的两面结果不一致;gemini-2.5-flash 返回 400。

    • max_completion_tokensinteger可选◐ 部分支持

      Maximum tokens in completion

      deepseek-v4-flash、glm-5.3-flash 生效;qwen3.8-flash 的小预算可能不生效或报超限。

    • metadataobject可选

      Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)

    • min_pnumber可选○ 当前不生效

      Minimum probability threshold relative to the most likely token. Tokens with probability below min_p * (probability of top token) are filtered out. Not all providers support this parameter.

      接受但当前不生效。

    • modalitiesarray可选

      Output modalities for the response. Supported values are "text", "image", and "audio".

    • modelsarray可选

      Models to use for completion

      按顺序回退:主模型不存在、无同协议线路或上游失败均尝试下一项。可只给 models;响应 model 和费用归属最终完成请求的模型。

    • parallel_tool_callsboolean可选◐ 部分支持

      Whether to enable parallel function calling during tool use. When true, the model may generate multiple tool calls in a single response.

      false 在 qwen3.8-flash 生效;deepseek-v4-flash 接受但不生效;glm-5.3-flash 的两面结果不一致。

    • pluginsarray可选◐ 部分支持

      Plugins you want to enable for this request, including their settings.

      支持 file-parser(pdf.engine 为 native、mistral-ocr→ocr、ocr、auto)和平台 guardrails。请求覆盖账户默认,锁定设置保留。web 等未实现插件、未知引擎或非法形状返回 400 并点名字段。

      ▸ 展开子字段(27)

      元素按 id 区分(auto-beta-router / auto-router / context-compression / file-parser / fusion / moderation / pareto-router / response-healing / web / web-fetch),此处展开其中一种的形状

      • allowed_modelsarray可选

        List of model patterns to filter which models the auto-beta-router can route between. Supports wildcards (e.g., "anthropic/*" matches all Anthropic models). Up to 1024 patterns, each at most 1024 characters, with 65536 total characters across all patterns. When not specified, every model ranked for the classified task type is a candidate, falling back to a default model set when rankings are unavailable.

      • cost_quality_tradeoffinteger可选

        Deprecated: Use cost_tier instead. Balances routing between cost and quality on a 0-10 scale. The auto-beta-router ranks models for the classified task type by community spend share, then filters candidates by their average cost per generation for that task. Higher values favor cheaper models: 10 keeps only models around the cheapest 10th percentile, while 0 permits models up to the 90th percentile for cost. Defaults to 9 when no cost setting is provided. It remains supported and retains ceiling behavior, but cost_tier takes precedence when both are provided.

      • cost_tierstring可选

        Named cost/quality setting. For auto-beta-router, tiers select cost-percentile bands: low = [0, 20), medium = [20, 40), high = [40, 60), xhigh = [60, 80), and max = [80, 100]. Takes precedence over the deprecated numeric cost_quality_tradeoff when both are provided.

        取值 lowmediumhighxhighmax
      • enabledboolean可选

        Set to false to disable Fusion configuration for a run started by the `openrouter/fusion` model slug or `openrouter:fusion` server tool. Defaults to true.

      • excluded_modelsarray可选

        List of model patterns to exclude from auto-beta-router selection. Supports wildcards (e.g., "meta-llama/*" excludes all Llama models). Up to 1024 patterns, each at most 1024 characters, with 65536 total characters across all patterns. Applied after allowed_models, so an excluded pattern always wins over an allowed one.

      • idstring可选

        Plugin id; always fusion.

        取值 fusion
      • pin_modelboolean可选

        When true, reuses the model from the most recent assistant message's `model` attribute for subsequent turns. Defaults to false.

      • enginestring可选

        The compression engine to use. Defaults to "middle-out".

        取值 middle-out
      • exclude_domainsarray可选

        A list of domains to exclude from web search results. Supports wildcards (e.g. "*.substack.com") and path filtering (e.g. "openai.com/blog").

      • include_domainsarray可选

        A list of domains to restrict web search results to. Supports wildcards (e.g. "*.substack.com") and path filtering (e.g. "openai.com/blog").

      • max_resultsinteger可选

        Maximum number of search results to use.

      • max_usesinteger可选

        Maximum number of web fetches per request. Once exceeded, the tool returns an error.

      • modestring可选

        Engine-native search mode. Exa supports instant, fast, auto (default), deep-lite, deep, and deep-reasoning. Parallel supports turbo, fast, basic (default), and advanced. Modes unsupported by the selected engine are ignored.

        取值 instantfastautodeep-litedeepdeep-reasoningturbobasicadvanced
      • search_promptstring可选

        Prompt that introduces the search results to the model.

      • user_locationobject可选

        Approximate user location for location-biased search results.

      • allowed_domainsarray可选

        Only fetch from these domains.

      • blocked_domainsarray可选

        Never fetch from these domains.

      • max_content_tokensinteger可选

        Maximum content length in approximate tokens. Content exceeding this limit is truncated.

      • pdfobject可选

        Options for PDF parsing.

      • max_pricenumber可选

        Maximum input price in USD per million tokens. When set, quality-tier selection (min_coding_score) is bypassed: the router computes the Pareto frontier over the top coding models and routes to the best-scoring frontier model priced at or below this cap, falling back through cheaper frontier models, then non-frontier models. Enforced against the price source given by price_source. Returns 404 when no candidate satisfies the cap.

      • min_coding_scorenumber可选

        Minimum coding quality score between 0 and 1. Maps to internal quality tiers: >= 0.66 → high (top coding models), >= 0.33 → medium (strong modern flagships), < 0.33 → low (capable coders above the median). Omit to default to the highest tier (equivalent to >= 0.66). Not used when max_price is set (price-based selection takes over).

      • price_sourcestring可选

        Price source for the Pareto frontier cost axis and for enforcing max_price. "prompt" uses catalog list price (endpoint.pricing.prompt). "weighted_avg" uses traffic-weighted effective input price from ClickHouse, falling back to prompt price for models without traffic data. Defaults to "prompt".

        取值 promptweighted_avg
      • analysis_modelsarray可选

        For a Fusion run started by the `openrouter/fusion` model slug or `openrouter:fusion` server tool, slugs of models to run in parallel as the "expert panel" the analyst analyzes. Each model receives the same user prompt with web_search + web_fetch enabled. Capped at 8 models to bound cost amplification. When omitted, defaults to the Quality preset from the /labs/fusion UI (~anthropic/claude-opus-latest, ~openai/gpt-sol-latest, ~google/gemini-pro-latest).

      • max_tool_callsinteger可选

        For a Fusion run started by the `openrouter/fusion` model slug or `openrouter:fusion` server tool, the maximum number of tool-calling steps each panelist (analysis model) and the analyst model may take during their agentic web-research loop. Models with web_search/web_fetch enabled iterate until they produce a text response or hit this ceiling. Defaults to 4. Capped at 16.

      • modelstring必填

        For a Fusion run started by the `openrouter/fusion` model slug or `openrouter:fusion` server tool, the slug of the model that performs both the analyst step (with web_search + web_fetch) and the final synthesis. When omitted, defaults to the first model in the Quality preset.

      • presetstring可选

        Configuration for a Fusion run started by the `openrouter/fusion` model slug or `openrouter:fusion` server tool. A curated OpenRouter preset (slugs follow `<task>-<tier>`, e.g. `general-high`). Expands server-side into the preset's analysis_models panel and analyst model, so callers never name individual models. Explicitly provided `analysis_models` / `model` take precedence.

        取值 general-highgeneral-budgetgeneral-fast
      • toolsarray可选

        For a Fusion run started by the `openrouter/fusion` model slug or `openrouter:fusion` server tool, server tools available to panelist and analyst inner calls. Each entry uses the same `{ type, parameters? }` shorthand as the outer Chat Completions request. When omitted, defaults to `[{ type: "openrouter:web_search" }, { type: "openrouter:web_fetch" }]`. Pass an empty array to disable tools entirely (panelists answer from parametric knowledge only).

    • predictionobject可选

      Static predicted output content. Supported models can use this to reduce latency when much of the response is known in advance.

      ▸ 展开子字段(2)
      • contentstring | array必填

        Predicted output: a string or an array of text parts.

      • typestring必填

        Always `content`. Discriminator that marks this object as a Prediction in a `type`-tagged union.

        取值 content
    • presence_penaltynumber可选◐ 部分支持

      Presence penalty (-2.0 to 2.0)

      deepseek-v4-flash 的 /openai 面观察到效果;qwen3.8-flash 部分请求返回 400,其余不可观测。

    • prompt_cache_keystring可选

      Caller-chosen key that groups requests with a long shared prefix so that they can reuse the provider's prompt cache; null for none.

    • prompt_cache_optionsobject可选

      Request-level prompt-cache controls. `mode: "explicit"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. Only supported by OpenAI GPT-5.6 and newer.

      ▸ 展开子字段(2)
      • modestring必填

        Prompt cache mode; explicit caches only the blocks marked with prompt_cache_breakpoint.

        取值 explicit
      • ttlstring可选

        Lifetime of cache entries, for example 30m; null leaves the provider default.

    • providerobject可选◐ 部分支持

      When multiple model providers are available, optionally indicate your routing preference.

      只有选择具体供应商(order / only / ignore)仅限 BYOK、返回 400;require_parameters 生效,其余选项接受但不生效。

      ▸ 展开子字段(13)
      • allow_fallbacksboolean可选○ 当前不生效

        Whether to allow backup providers to serve requests - true: (default) when the primary provider (or your custom providers in "order") is unavailable, use the next best provider. - false: use only the primary/custom provider, and return the upstream error if it's unavailable.

        接受但当前不生效(不属于供应商选择,平台凭证下可用)。

      • data_collectionstring可选○ 当前不生效

        Data collection setting. If no available model provider meets the requirement, your request will return an error. - allow: (default) allow providers which store user data non-transiently and may train on it - deny: use only providers which do not collect user data.

        接受但当前不生效(不属于供应商选择,平台凭证下可用)。

        取值 denyallownull
      • enforce_distillable_textboolean可选

        Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used.

      • ignorearray可选○ 未支持

        List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request.

        选择具体供应商(order / only / ignore)仅限 BYOK,平台凭证下返回 400 PROVIDER_SELECTION_NOT_ALLOWED。

      • max_priceobject可选○ 当前不生效

        The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.

        接受但当前不生效(不属于供应商选择,平台凭证下可用)。

      • onlyarray可选○ 未支持

        List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request.

        选择具体供应商(order / only / ignore)仅限 BYOK,平台凭证下返回 400 PROVIDER_SELECTION_NOT_ALLOWED。

      • orderarray可选○ 未支持

        An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message.

        选择具体供应商(order / only / ignore)仅限 BYOK,平台凭证下返回 400 PROVIDER_SELECTION_NOT_ALLOWED。

      • preferred_max_latencynumber | object可选

        Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold.

      • preferred_min_throughputnumber | object可选

        Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold.

      • quantizationsarray可选○ 当前不生效

        A list of quantization levels to filter the provider by.

        接受但当前不生效(不属于供应商选择,平台凭证下可用)。

      • require_parametersboolean可选

        Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest.

        只走能表达全部参数的线路;平台凭证下可用。

      • sortstring | object可选○ 当前不生效

        The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed.

        接受但当前不生效(不属于供应商选择,平台凭证下可用)。

      • zdrboolean可选○ 当前不生效

        Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used.

        接受但当前不生效(不属于供应商选择,平台凭证下可用)。

    • reasoningobject可选

      Configuration options for reasoning models

      ▸ 展开子字段(2)
      • effortstring可选◐ 部分支持

        Constrains effort on reasoning for reasoning models

        none 仅在 qwen3.8-flash 可靠关闭思考;deepseek-v4-flash 和 glm-5.3-flash 未遵守。

        取值 maxxhighhighmediumlowminimalnonenull
      • summarystring可选○ 当前不生效

        How detailed the reasoning summary should be.

        接受但当前不生效。deepseek-v4-flash 未返回请求的摘要。

        取值 autoconcisedetailednull
    • reasoning_effortstring可选◐ 部分支持

      Shorthand for setting reasoning effort. Equivalent to setting reasoning.effort. Cannot be used simultaneously with reasoning.effort if they differ.

      none 在 qwen3.8-flash 关闭思考;deepseek-v4-flash 仍思考,glm-5.3-flash 的档位效果不符合预期。

      取值 maxxhighhighmediumlowminimalnonenull
    • repetition_penaltynumber可选

      Penalizes tokens based on how much they have already appeared in the text. A value of 1.0 means no penalty. Values above 1.0 penalize repeated tokens more strongly. Not all providers support this parameter.

    • routestring可选

      **DEPRECATED** Use providers.sort.partition instead. Backwards-compatible alias for providers.sort.partition. Accepts legacy values: "fallback" (maps to "model"), "sort" (maps to "none").

      取值 fallbacksortnull
    • seedinteger可选○ 当前不生效

      Random seed for deterministic outputs

      接受但当前不生效。deepseek-v4-flash、glm-5.3-flash、qwen3.8-flash 同 seed 不能复现输出。

    • service_tierstring可选

      The service tier to use for processing this request. `fast` is accepted as an alias for `priority`.

      取值 autodefaultfastflexpriorityscalenull
    • session_idstring可选

      A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.

    • stopstring | array可选◐ 部分支持

      Stop sequences (up to 4)

      qwen3.8-flash 生效;deepseek-v4-flash、glm-5.3-flash 可能截断思考并返回空正文。

    • stop_server_tools_whenarray可选

      Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides `max_tool_calls`. When a condition fires while the model is still emitting tool calls, the pending tool calls are executed and one final turn is made with tool calls disabled so the response ends with a natural-language answer instead of an unfinished tool call.

      ▸ 展开子字段(6)

      元素按 type 区分(finish_reason_is / has_tool_call / max_cost / max_tokens_used / step_count_is),此处展开其中一种的形状

      • step_countinteger可选

        Number of steps after which the loop stops.

      • typestring可选

        Always `finish_reason_is`. Discriminator that marks this object as a StopServerToolsWhenFinishReasonIs in a `type`-tagged union.

        取值 finish_reason_is
      • tool_namestring可选

        Name of the tool whose call stops the loop.

      • max_tokensinteger可选

        Cumulative token count after which the loop stops.

      • max_cost_in_dollarsnumber可选

        Cumulative cost in USD after which the loop stops.

      • reasonstring可选

        Finish reason that stops the loop.

    • stream_optionsobject可选

      Streaming configuration options

      ▸ 展开子字段(1)
      • include_usageboolean可选○ 当前不生效

        Deprecated: This field has no effect. Full usage details are always included.

        接受但当前不生效。无论 true、false 或省略,流末尾都会返回 usage。

    • top_anumber可选○ 当前不生效

      Consider only tokens with "sufficiently high" probabilities based on the probability of the most likely token. Not all providers support this parameter.

      接受但当前不生效。

    • top_kinteger可选◐ 部分支持

      Limits the model to choose from the top K most likely tokens at each step. A value of 1 means the model will always pick the most likely next token. Not all providers support this parameter.

      已测模型接受但未见采样效果;/model 的 deepseek-v4-flash 返回错误。

    • top_logprobsinteger可选◐ 部分支持

      Number of top log probabilities to return (0-20)

      需与 logprobs=true 同传;支持度随 logprobs 和所选模型而异。

    • traceobject可选

      Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.

      ▸ 展开子字段(5)
      • generation_namestring可选

        Name of this generation in the trace.

      • parent_span_idstring可选

        Id of the parent span in the trace.

      • span_namestring可选

        Name of this request's span in the trace.

      • trace_idstring可选

        Id that groups several requests into one trace.

      • trace_namestring可选

        Name of the trace.

    • userstring可选

      Per-end-user identifier for abuse isolation. Use a stable ID, hash, or pseudonym. When a provider requires a user identity, OpenRouter folds it into the hashed identity sent upstream and never forwards it raw. If omitted, requests use an account-level identity, so provider policy blocks can affect the whole account.

    • storeboolean可选○ 当前不生效

      接受但当前不生效。此结论仅适用于 Chat Completions。

    • max_output_tokensinteger可选○ 当前不生效

      接受但当前不生效。此结论仅适用于 Chat Completions。

    • thinkingobject可选○ 当前不生效

      接受但当前不生效。此结论仅适用于 Chat Completions。

    • web_search_optionsobject可选○ 当前不生效

      接受但当前不生效。此结论仅适用于 Chat Completions。

    • functionsarray可选○ 当前不生效

      接受但当前不生效。此结论仅适用于 Chat Completions。

    • audioobject可选○ 当前不生效

      接受但当前不生效。此结论仅适用于 Chat Completions。

    • ninteger可选◐ 部分支持

      glm-5.3-flash 生效;deepseek-v4-flash 接受但当前不生效;qwen3.8-flash 返回错误。

    • usageobject可选○ 当前不生效

      接受并忽略;用量默认始终返回,include 不改变行为。

    • transformsarray可选○ 当前不生效

      接受并忽略;不执行 middle-out 或其他消息变换,保留原消息。

    • deferred_toolsobject可选○ 当前不生效

      接受并忽略;尚未实现 OpenRouter 延迟工具协议。

    • structured_outputsboolean可选○ 当前不生效

      接受并忽略此开关;结构化输出使用 response_format,支持度见该字段。

    • include_reasoningboolean可选○ 当前不生效

      接受并忽略此旧别名;思考配置使用 reasoning,支持度见该字段。

    • safe_promptboolean可选○ 当前不生效

      接受并忽略;未实现 Mistral 的 safe_prompt 开关。

    • raw_modeboolean可选○ 当前不生效

      接受并忽略;未实现 Hyperbolic 的 raw_mode 开关。

    • providerOptionsobject可选◐ 部分支持

      providerOptions.praxis.models 与顶层 models 使用同一有序回退。order/only 仅允许与已有的请求级 BYOK 凭证同时使用;非 BYOK 返回 400。

      ▸ 展开子字段(1)
      • praxisobject必填

        Platform options: ordered model fallback, request-level BYOK credentials and credential-gated provider selection.

返回

200 chat.completion

stream=true 时以 SSE 增量返回(text/event-stream)。

未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。

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

响应

HTTP 200

Chat completion (application/json) or streamed chunks (text/event-stream)

application/json

名称类型说明
idstringId of the completion.
objectstringObject type; always `chat.completion`.
creatednumberUnix time in seconds at which the completion was created.
modelstringModel that produced the completion; with fallback this is the model that finally answered.
choicesarray<object>Completion choices; one entry per generated answer.
choices[].indexnumberZero-based index of the choice.
choices[].messageobjectThe message the model generated.
choices[].finish_reasonstring | nullWhy generation stopped, for example `stop`, `length` or `tool_calls`; null while a stream is still generating.
choices[].logprobsany | nullLog probabilities of the output tokens, when requested; null otherwise.
usageobjectToken usage of the request.
usage.prompt_tokensnumberNumber of tokens in the prompt.
usage.completion_tokensnumberNumber of tokens in the completion.
usage.total_tokensnumberPrompt plus completion tokens.
usage.prompt_tokens_detailsobjectBreakdown of the prompt tokens.
usage.completion_tokens_detailsobjectBreakdown of the completion tokens.
usage.prompt_cache_hit_tokensnumberPrompt tokens served from the cache, as reported by providers that use this DeepSeek-style counter.
usage.prompt_cache_miss_tokensnumberPrompt tokens not served from the cache, as reported by providers that use this DeepSeek-style counter.
system_fingerprintstring | nullBackend fingerprint; always null on this face.
service_tierstring | nullService tier the provider used; null when not reported.
providerMetadataobjectPlatform metadata of the call.
providerMetadata.praxisobjectPlatform metadata of the call: generation id, cost, credential kind and serving model.

text/event-stream — chunk / 事件对象

名称类型说明
idstringOptional id of the server-sent event.
eventstringName of the server-sent event.
dataobject | stringPayload of the server-sent event.
data.idstringId of the completion; every chunk of one stream carries the same id.
data.objectstringObject type; always `chat.completion.chunk`.
data.creatednumberUnix time in seconds at which the completion was created.
data.modelstringModel that produced the completion; with fallback this is the model that finally answered.
data.choicesarray<object>Completion choices of the chunk.
data.providerMetadataobjectPlatform metadata of the call.

生成响应

POST /model/v1/responses● 支持

官方文档 ↗

请求体

  • modelstring可选◐ 部分支持

    Model id, for example one listed by listModels?type=language. Router support (partial): Verified on glm-5.3-flash and deepseek-flash; models without Responses support return 404.

    已验证支持 glm-5.3-flash、deepseek-flash;没有 Responses 协议的模型返回 404。

  • inputstring | array可选◐ 部分支持

    Input for a response request - can be a string or array of items

    字符串、消息数组、input_text、input_image 和函数往返生效;input_file 在 glm-5.3-flash 报错、deepseek-flash 忽略;托管文件引用返回 400。

  • streamboolean可选◐ 部分支持
    默认 false

    Whether to stream the response as server-sent events. Router support (partial): Works on deepseek-flash; glm-5.3-flash returns 400.

    deepseek-flash 生效;glm-5.3-flash 返回 400。

  • temperaturenumber可选◐ 部分支持

    Sampling temperature between 0 and 2; higher values make output more random. Router support (partial): Partly effective on glm-5.3-flash; 2 may produce empty or garbled text. Effects on deepseek-flash are unobservable.

    glm-5.3-flash 部分生效,2 可能返回空文本或乱码;deepseek-flash 的效果不可观测。

  • top_pnumber可选◐ 部分支持

    Nucleus sampling: only tokens within this cumulative probability are considered. Router support (partial): Sampling changes were observed on glm-5.3-flash; effects on deepseek-flash are unobservable.

    glm-5.3-flash 观察到采样变化;deepseek-flash 不可观测。

  • toolsarray可选◐ 部分支持

    Tools the model may call: functions, built-in tools and MCP servers. Router support (partial): function works. web_search, code_interpreter, image_generation, mcp and computer_use are accepted but currently have no effect; file_search returns 404.

    function 生效;web_search、code_interpreter、image_generation、mcp、computer_use 接受但当前不生效;file_search 返回 404。

  • tool_choicestring | object可选◐ 部分支持

    How the model picks tools: a mode string or a specific tool.

    auto 生效;deepseek-flash 的 required/具名函数需 reasoning.effort=none;allowed_tools 在 glm-5.3-flash 被忽略,在 deepseek-flash 返回 422。

    ▸ 展开子字段(4)
    • namestring必填

      Name of the function or tool the model must call.

    • typestring必填

      Kind of tool the model must call.

      取值 shell
    • modestring必填

      auto lets the model pick among the allowed tools or none; required forces a call to one of them.

    • toolsarray必填

      The allowed tools, each as a tool reference such as {type: function, name}.

  • promptobject可选○ 未支持

    Reference to a saved prompt template and its variables. We don't have a Prompts resource yet — any id you pass returns 404 object_not_found.

    当前没有可引用的提示词模板;传入模板 id 返回 404。

    ▸ 展开子字段(2)
    • idstring必填

      Id of the stored prompt template.

    • variablesobject可选

      Values for the template variables, keyed by variable name; a value is a string or an input text, image or file part.

  • backgroundboolean可选◐ 部分支持

    Whether to run the model response in the background. Available only when the routed model has Router-built background support — Router returns status "queued" immediately, then stream-calls the upstream itself, runs the job to a terminal state, and bills usage exactly once, while the client polls GET /v1/responses/{id} (this does not mean the upstream natively supports OpenAI's background parameter). A provider without this capability still returns HTTP 400 (native_responses_background_unsupported) for background:true. Cancel (POST /v1/responses/{id}/cancel) can only stop our own read of the upstream stream — it cannot guarantee upstream compute already issued stops — and billing reflects only usage actually received, falling back to the platform's general "upstream reported no usage" rule when none was received.

    deepseek-flash 生效;glm-5.3-flash 返回 400。background 与 stream 同传时返回 JSON。

  • includearray可选◐ 部分支持

    Forwarded to the upstream model as-is; only takes effect for capabilities the model has (e.g., reasoning content, web search results). Fields the model doesn't support are ignored.

    deepseek-flash 返回 logprobs;reasoning.encrypted_content 仅为占位串。glm-5.3-flash 接受但当前不生效。

  • ▸ 更多参数(21)
    • instructionsstring可选

      System or developer instructions inserted at the start of the context. Router support (supported): Verified to take effect.

      已验证生效。

    • max_output_tokensinteger可选

      Upper bound on generated tokens, including reasoning tokens. Router support (supported): A positive value controls the output budget; zero returns 400.

      正数控制输出预算;0 返回 400。

    • metadataobject可选◐ 部分支持

      Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed.

      glm-5.3-flash 回显;deepseek-flash 接受但当前不生效,响应及读取均为空对象。

    • parallel_tool_callsboolean可选◐ 部分支持

      Whether the model may call several tools in one turn. Router support (partial): true permits multiple calls; false is accepted but currently has no effect and may still return multiple calls.

      true 可返回多个调用;false 接受但当前不生效,仍可能返回多个调用。

    • previous_response_idany可选

      ID of a previous response. Its owner may continue it; the model field can then be omitted. The platform expands the stored history before calling the upstream.

      平台将祖先的输入与输出和本轮 input 合并,发往上游前移除 previous_response_id;没有活副本或不属于当前租户时返回 404 previous_response_not_found。

    • prompt_cache_keystring可选

      Caller-chosen key that groups requests with a long shared prefix so that they can reuse the provider's prompt cache.

    • prompt_cache_optionsobject可选

      Request-level prompt-cache controls. `mode: "explicit"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. Only supported by OpenAI GPT-5.6 and newer.

      ▸ 展开子字段(2)
      • modestring必填

        Prompt cache mode; explicit caches only the blocks marked with prompt_cache_breakpoint.

        取值 explicit
      • ttlstring可选

        Lifetime of cache entries, for example 30m; null leaves the provider default.

    • reasoningobject可选

      Configuration for reasoning mode in the response

      ▸ 展开子字段(6)
      • contextstring可选

        Controls which reasoning is available to the model. `auto` uses the model default (same as omitting); `all_turns` includes reasoning from earlier turns passed in input; `current_turn` limits to the current turn only. Only supported by OpenAI GPT-5.6 and newer.

        取值 autoall_turnscurrent_turnnull
      • effortstring可选◐ 部分支持

        How much reasoning the model should spend.

        deepseek-flash 的 none 可关闭思考,其余档位不保证单调;glm-5.3-flash 接受但当前不生效,none 仍思考。

        取值 maxxhighhighmediumlowminimalnonenull
      • modestring可选

        Selects the reasoning mode. `standard` is the default; `pro` engages deeper reasoning on models that support it, billed at standard token rates. Only supported by OpenAI GPT-5.6 and newer.

        取值 standardpronull
      • summarystring可选◐ 部分支持

        How detailed the reasoning summary should be.

        glm-5.3-flash 的 concise 偶发有摘要,auto/detailed 未见;deepseek-flash 接受但当前不生效。

        取值 autoconcisedetailednull
      • enabledboolean可选

        Whether reasoning is on for models that let you switch it.

      • max_tokensinteger可选

        Upper bound on reasoning tokens, for models that take a reasoning budget.

    • safety_identifierstring可选

      Recommended per-end-user identifier for abuse isolation. Use a stable ID, hash, or pseudonym. When a provider requires a user identity, we fold it into the hashed identity sent upstream and never forward it raw. If omitted, requests use an account-level identity, so provider policy blocks can affect the whole account.

    • service_tierstring可选
      默认 "auto"

      Requested service tier; its effect is currently unobservable.

      取值 autodefaultfastflexpriorityscalenull
    • storeboolean可选
      默认 true

      Whether to store the response server-side so it can be retrieved or continued later via previous_response_id. Defaults to true; pass false to opt out.

      true 保存响应供读取;false 不保存,读取返回 404。

    • textobject可选

      Text output configuration including format and verbosity

      ▸ 展开子字段(2)
      • formatobject可选◐ 部分支持

        Text response format configuration

        json_object、json_schema 生效(预算需足够);text 在 glm-5.3-flash 偶发 400,在 deepseek-flash 生效。

      • verbositystring可选○ 当前不生效

        How long the answer should be. Router support (ignored): Accepted but currently has no effect. No verbosity effect was observed on glm-5.3-flash or deepseek-flash.

        接受但当前不生效。glm-5.3-flash、deepseek-flash 均未观察到长度变化。

        取值 lowmediumhighxhighmaxnull
    • top_logprobsinteger可选◐ 部分支持

      Number of most likely tokens whose log probabilities are returned per position, from 0 to 20. Router support (partial): Works on deepseek-flash with values 0–20; glm-5.3-flash returns empty logprobs.

      deepseek-flash 生效,允许 0–20;glm-5.3-flash 返回空 logprobs。

    • truncationstring可选

      How to handle input that exceeds the context window.

      取值 autodisablednull
    • userstring可选

      A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 256 characters.

    • conversationstring可选

      The conversation this response belongs to (a conversation id string, or a `{id}` object). Before the request reaches the upstream provider, we prepend that conversation's existing items to this request's input; after the response completes, this turn's input and output items are appended back to the conversation. Only the conversation's owner may reference it — otherwise 404 object_not_found; cannot be used together with previous_response_id — sending both returns 400.

      会话历史进入本次输入,响应条目追加到会话;不能与 previous_response_id 同传。

    • context_managementarray可选

      Context management configuration for this request (e.g. automatic compaction once a token threshold is exceeded).

    • moderationobject可选

      Configuration for running moderation on the input and output of this response.

    • prompt_cache_retentionstring可选

      The retention policy for the prompt cache. Set to 24h to keep cached prefixes active for up to 24 hours.

    • stream_optionsobject可选

      Options for streaming responses. Only set this when stream=true (e.g. whether to include usage statistics at the end of the stream).

    • access_programsobject可选○ 未支持

      已识别的官方字段;平台未实现访问计划,传入返回 400 并明确说明不支持。

返回

200 response

stream=true 时以 SSE 增量返回(text/event-stream)。

未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。

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

响应

HTTP 200

Successful response

application/json

名称类型说明
backgroundboolean | nullWhether the response was started in background mode.
completed_atinteger | nullUnix time in seconds at which the response finished; null while it has not finished.
created_atintegerUnix time in seconds at which the response was created.
errorobject | nullError information returned from the API
error.codestringMachine-readable error code.
error.messagestringHuman-readable error message.
frequency_penaltynumber | nullThe frequency penalty that applied to the request, if any.
idstringUnique id of the response; use it as response_id to retrieve, cancel or delete it, or as previous_response_id to continue the conversation.
incomplete_detailsobject | nullWhy the response stopped before finishing; null for complete responses.
incomplete_details.reasonstringWhy the response is incomplete.
instructionsstring | array<object> | nullInput of the request: a string or an array of input items.
max_output_tokensinteger | nullUpper bound on generated tokens that applied to the request; null when none was set.
max_tool_callsinteger | nullUpper bound on built-in tool calls that applied to the request; null when none was set.
metadataobject | nullMetadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed.
modelstringModel that produced the response.
objectstringObject type; always `response`.
outputarray<object>Items the model produced, in order: messages, reasoning, tool calls and tool results.
output[].contentarray<object> | array | null | stringContent parts of the message: output text or refusal. / Reasoning text parts, when the provider returns them. / Text content of the fetched page.
output[].idstringId of the message item. / Id of the reasoning item. / Id of the function call item. / Id of the web search call item. / Id of the file search call item. / Id of the image generation call item. / Id of the code interpreter call item. / Id of the computer call item. / Id of the datetime server tool item. / Id of the web search server tool item. / Id of the code interpreter server tool item. / Id of the file search server tool item. / Id of the image generation server tool item. / Id of the browser use server tool item. / Id of the bash server tool item. / Id of the text editor server tool item. / Id of the apply_patch server tool item. / Id of the apply_patch call item. / Id of the shell call item. / Id of the shell call output item. / Id of the shell server tool item. / Id of the web fetch server tool item. / Id of the tool search server tool item. / Id of the memory server tool item. / Id of the MCP server tool item. / Id of the model search server tool item. / Id of the fusion server tool item. / Id of the advisor server tool item. / Id of the subagent server tool item. / Id of the files server tool item. / Id of the custom tool call item.
output[].phasestring | nullThe phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages.
output[].rolestringRole of the author; always assistant.
output[].statusstringStatus of the message item. / Status of the reasoning item. / Status of the function call item. / Status of a web search call. / Status of a web search call. / Status of an image generation call. / Status of the code interpreter call. / Status of the computer call item. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call that can fail. / Status of a tool call. / Status of a tool call. / Lifecycle state of an `apply_patch_call` output item. / Status of a shell call or its output. / Status of a shell call or its output. / Status of a tool call that can fail. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call. / Status of a tool call that can fail. / Status of a tool call that can fail. / Status of a tool call. / Status of the custom tool call item.
output[].typestringAlways `message`. Discriminator that marks this object as a OutputMessage in a `type`-tagged union. / Always `reasoning`. Discriminator that marks this object as a OutputItemReasoning in a `type`-tagged union. / Always `function_call`. Discriminator that marks this object as a OutputItemFunctionCall in a `type`-tagged union. / Always `web_search_call`. Discriminator that marks this object as a OutputItemWebSearchCall in a `type`-tagged union. / Always `file_search_call`. Discriminator that marks this object as a OutputItemFileSearchCall in a `type`-tagged union. / Always `image_generation_call`. Discriminator that marks this object as a OutputItemImageGenerationCall in a `type`-tagged union. / Always `code_interpreter_call`. Discriminator that marks this object as a OutputItemCodeInterpreterCall in a `type`-tagged union. / Always `computer_call`. Discriminator that marks this object as a OutputComputerCallItem in a `type`-tagged union. / Always `openrouter:datetime`. Discriminator that marks this object as a OutputDatetimeItem in a `type`-tagged union. / Always `openrouter:web_search`. Discriminator that marks this object as a OutputWebSearchServerToolItem in a `type`-tagged union. / Always `openrouter:code_interpreter`. Discriminator that marks this object as a OutputCodeInterpreterServerToolItem in a `type`-tagged union. / Always `openrouter:file_search`. Discriminator that marks this object as a OutputFileSearchServerToolItem in a `type`-tagged union. / Always `openrouter:image_generation`. Discriminator that marks this object as a OutputImageGenerationServerToolItem in a `type`-tagged union. / Always `openrouter:browser_use`. Discriminator that marks this object as a OutputBrowserUseServerToolItem in a `type`-tagged union. / Always `openrouter:bash`. Discriminator that marks this object as a OutputBashServerToolItem in a `type`-tagged union. / Always `openrouter:text_editor`. Discriminator that marks this object as a OutputTextEditorServerToolItem in a `type`-tagged union. / Always `openrouter:apply_patch`. Discriminator that marks this object as a OutputApplyPatchServerToolItem in a `type`-tagged union. / Always `apply_patch_call`. Discriminator that marks this object as a OutputApplyPatchCallItem in a `type`-tagged union. / Always `shell_call`. Discriminator that marks this object as a OutputShellCallItem in a `type`-tagged union. / Always `shell_call_output`. Discriminator that marks this object as a OutputShellCallOutputItem in a `type`-tagged union. / Always `openrouter:shell`. Discriminator that marks this object as a OutputShellServerToolItem in a `type`-tagged union. / Always `openrouter:web_fetch`. Discriminator that marks this object as a OutputWebFetchServerToolItem in a `type`-tagged union. / Always `openrouter:tool_search`. Discriminator that marks this object as a OutputToolSearchServerToolItem in a `type`-tagged union. / Always `openrouter:memory`. Discriminator that marks this object as a OutputMemoryServerToolItem in a `type`-tagged union. / Always `openrouter:mcp`. Discriminator that marks this object as a OutputMcpServerToolItem in a `type`-tagged union. / Always `openrouter:experimental__search_models`. Discriminator that marks this object as a OutputSearchModelsServerToolItem in a `type`-tagged union. / Always `openrouter:fusion`. Discriminator that marks this object as a OutputFusionServerToolItem in a `type`-tagged union. / Always `openrouter:advisor`. Discriminator that marks this object as a OutputAdvisorServerToolItem in a `type`-tagged union. / Always `openrouter:subagent`. Discriminator that marks this object as a OutputSubagentServerToolItem in a `type`-tagged union. / Always `openrouter:files`. Discriminator that marks this object as a OutputFilesServerToolItem in a `type`-tagged union. / Always `custom_tool_call`. Discriminator that marks this object as a OutputCustomToolCallItem in a `type`-tagged union.
output[].encrypted_contentstring | nullOpaque encrypted reasoning; send it back unchanged to let the model continue its reasoning on the next turn.
output[].summaryarray<object>Summary parts of the reasoning.
output[].formatstring | nullWire format of the reasoning details, which names the provider family that produced them.
output[].signaturestring | nullA signature for the reasoning content, used for verification
output[].argumentsstring | string | null | string | null | string | null | string | string | nullJSON-encoded arguments the model produced for the function. / The raw tool-call arguments string as emitted by the model. / The raw tool-call arguments string as emitted by the model. Echo back unchanged when replaying history; used verbatim to preserve provider prompt-cache prefixes. / The raw tool-call arguments string as emitted by the model. / The JSON arguments submitted to the search tool (e.g. {"query":"Claude"}) / The raw tool-call arguments string as emitted by the model.
output[].asyncbooleanTrue when the model called a tool declared with `async: true` and may continue its turn before the output is returned. Return the result in a later request as a `function_call_output` with this `call_id`.
output[].call_idstring | string | null | string | string | string | string | string | null | string | string | null | stringId of the call; the function_call_output item that answers it repeats it as call_id. / Id of the call; the computer_call_output item that answers it repeats it as call_id. / The model-generated tool call id from the originating turn. / Id of the apply_patch tool call. / Id of the call; the apply_patch_call_output item that answers it repeats it as call_id. / Id of the call; the shell_call_output item that answers it repeats it as call_id. / Id of the shell call this output answers. / The model-generated tool call id from the originating turn. / EXPERIMENTAL — subject to change without notice. The `call_id` of the tool call that spawned this subagent. This id will also be included as the `subagent_id` on any `function_call` items created by the subagent. This must be returned in the request so the `function_call` can be matched with the correct subagent. A suspended `in_progress` item is announced once and never re-emitted or terminally closed — completion arrives as a new item with the same `call_id`. / The model-generated tool call id from the originating turn. / Id of the call; the custom_tool_call_output item that answers it repeats it as call_id.
output[].namestringName of the function being called. / Configured name of the subagent that executed the task (the `name` on its tool entry). Present only for named subagents; omitted for an unnamed (default) subagent. / Name of the custom tool being called.
output[].namespacestringNamespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)
output[].subagent_idstringEXPERIMENTAL — subject to change without notice. String id that matches the `call_id` of the `openrouter:subagent` server tool call that spawned the subagent. Present on every `function_call` item the subagent projects; absent on ordinary function calls.
output[].subagent_itemsarray<object>EXPERIMENTAL — subject to change without notice. The subagent's output items produced on this turn. Treat this as an opaque object; you must replay it in the request so that the subagent can continue execution of the tool with the same context. If a subagent created multiple parallel tool calls, only the first tool call will have this field. The other tool calls will only have `subagent_id`. Present only if the tool call originates from a subagent spawned by the `openrouter:subagent` server tool.
output[].actionobject | any | object | string | object | object | stringThe search action the model took: a search, opening a page, or finding a pattern in a page. / The action the model asks the client to perform on the computer. / The search action performed, matching OpenAI web_search_call.action shape. Includes the query the model issued and optional source URLs returned by the search provider. / The browser action that was performed. / The commands the model asks the client to run. / The commands that were run. / Memory action that was performed.
output[].queriesarray<string>Queries the model ran against the vector stores. / Queries that ran against the vector stores.
output[].resultstring | null | stringBase64-encoded generated image; null while generation has not finished. / The generated image as a base64-encoded string or URL, matching OpenAI image_generation_call format / JSON-serialized result of the file operation.
output[].promptstringThe prompt (possibly rewritten) that the image was generated from. / The prompt the executor sent to the advisor.
output[].codestring | null | stringThe code the interpreter ran; null while it is still being written. / The code that ran.
output[].container_idstringId of the container the code ran in. / The canonical container id the command ran under — the `{container_id}` for the Container Files API, reusable as a `container_reference` in later requests. Present on every sandbox-executed call, even when no files changed. / The canonical container id the command ran under — the `{container_id}` for the Container Files API, reusable as a `container_reference` in later requests. Present on every sandbox-executed call, even when no files changed. / The canonical container id the command ran under — the `{container_id}` for the Container Files API, reusable as a `container_reference` in later requests. Present on every sandbox-executed call, even when no files changed.
output[].outputsarray | nullOutputs of the run: logs and images; null while the run has not finished.
output[].pending_safety_checksarray<object>Safety checks that must be acknowledged before the action is performed.
output[].datetimestringISO 8601 datetime string
output[].timezonestringIANA timezone name
output[].exitCodeintegerExit code of the run; 0 means success. / Exit code of the command; 0 means success.
output[].languagestringLanguage of the code that ran.
output[].stderrstringStandard error output of the code. / Standard error output of the command.
output[].stdoutstringStandard output of the code. / Standard output of the command.
output[].imageB64stringBase64-encoded generated image.
output[].imageUrlstringURL of the generated image.
output[].revisedPromptstringPrompt after the image model rewrote it.
output[].screenshotB64stringBase64-encoded screenshot taken after the action.
output[].commandstringThe bash command that ran. / Editor command that ran.
output[].errorstringThe error message when the sandbox call failed before producing a result (for example, the per-user container limit was reached). Set together with `status: 'failed'`; absent on a successful call. A non-zero `exitCode` is a command failure, not a tool failure. / The error message when the sandbox call failed before producing a result (for example, the per-user container limit was reached). Set together with `status: 'incomplete'` and an empty `output`; absent on a successful call. / The error message when the sandbox call failed before producing a result (for example, the per-user container limit was reached). Set together with `status: 'failed'`; absent on a successful call. `output` is omitted when `error` is set. / The error message if the fetch failed. / Error message when the fusion run did not produce an analysis result. / Error message when the advisor call did not produce advice. Set together with `status: 'failed'` on the terminal item. / Error message when the subagent task did not produce an outcome. Set together with `status: 'failed'` on the terminal item. / Error message when the file operation failed.
output[].filesarray<object>Citations for the files the sandbox command created or modified, most-recently-touched first (at most 10). Retrieve them via the Container Files API.
output[].filePathstringPath of the file the command worked on.
output[].operationobject | stringThe patch operation requested by an `apply_patch_call`. `create_file` and `update_file` carry a V4A diff; `delete_file` omits it. / The file operation performed (list, read, write, or edit).
output[].max_output_lengthinteger | nullMaximum number of characters of output that was kept; null for no limit.
output[].outputarray<object>Output of each command, in the order the commands ran.
output[].httpStatusintegerThe HTTP status code returned by the upstream URL fetch.
output[].titlestringTitle of the fetched page.
output[].urlstringURL that was fetched.
output[].querystringThe tool search query. / The model search query.
output[].keystringKey of the memory entry.
output[].valueanyValue of the memory entry; absent for reads that found nothing and for deletes.
output[].serverLabelstringLabel of the MCP server.
output[].toolNamestringName of the MCP tool that was called.
output[].analysisobjectStructured analysis produced by the fusion analyst model.
output[].failed_modelsarray<object>Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel.
output[].failure_reasonstringTyped failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, invalid_model, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion. The four analysis-stage codes keep their pre-rename `judge_` spelling so existing consumers keep matching. The consumer-cancellation code is `cancelled`.
output[].responsesarray<object>Analysis models that produced a response in this fusion run, with each model's full panel content.
output[].sourcesarray<object>Web pages the analysis panels and analyst retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source.
output[].advicestringThe advisor model's response (the advice text returned to the executor).
output[].instance_namestringProvider-safe function name of the specific advisor instance that produced this item (e.g. `openrouter_advisor__1`). Present only when more than one advisor tool is configured; omitted for the default single advisor. Echo this field back unchanged so the advisor's cross-request memory stays namespaced to the correct instance. This identity is positional: it is derived from the index of the advisor entry in the request `tools` array, so clients must keep the order of advisor tool entries stable across requests in a conversation. Reordering or inserting advisor entries shifts these names and causes each advisor's cross-request memory to be attributed to the wrong instance. / Provider-safe function name of the specific subagent instance that produced this item (e.g. `openrouter_subagent__1`). Present only on items from non-default instances — the second and later subagent entries in the request `tools` array. The first (default) instance omits it, even when multiple subagents are configured. When a replayed item echoes this field back, the transcript rehydrates the call under that instance's tool. This identity is positional: it is derived from the index of the subagent entry in the request `tools` array, so keep the order of subagent entries stable across requests in a conversation.
output[].modelstringSlug of the advisor model that was consulted. / Slug of the worker model that executed the task.
output[].outcomestringThe worker model's result (the outcome text returned to the delegating model).
output[].task_descriptionstringThe task description the delegating model sent to the worker.
output[].task_namestringThe short task identifier the delegating model supplied.
output[].file_idstringThe target file id supplied in the tool-call arguments.
output[].filenamestringThe target filename supplied in the tool-call arguments.
output[].inputstringFree-form input the model produced for the custom tool.
output_textstringConvenience concatenation of all output text of the response.
parallel_tool_callsbooleanWhether the model was allowed to call several tools in one turn.
presence_penaltynumber | nullThe presence penalty that applied to the request, if any.
previous_response_idstring | nullId of the response this one continued; null when it started a new conversation.
promptobject | nullReference to a stored prompt template with its variables.
prompt.idstringId of the stored prompt template.
prompt.variablesobject | nullValues for the template variables, keyed by variable name; a value is a string or an input text, image or file part.
prompt_cache_keystring | nullCache key the request supplied to improve prompt cache hits; null when none was set.
prompt_cache_optionsobject | nullRequest-level prompt-cache controls. `mode: "explicit"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. Only supported by OpenAI GPT-5.6 and newer.
prompt_cache_options.modestringPrompt cache mode; explicit caches only the blocks marked with prompt_cache_breakpoint.
prompt_cache_options.ttlstring | nullLifetime of cache entries, for example 30m; null leaves the provider default.
reasoningobject | nullReasoning settings that applied: effort, summary verbosity, mode and context.
reasoning.contextstring | nullControls which reasoning is available to the model. `auto` uses the model default (same as omitting); `all_turns` includes reasoning from earlier turns passed in input; `current_turn` limits to the current turn only. Only supported by OpenAI GPT-5.6 and newer.
reasoning.effortstring | nullHow much reasoning the model should spend.
reasoning.modestring | nullSelects the reasoning mode. `standard` is the default; `pro` engages deeper reasoning on models that support it, billed at standard token rates. Only supported by OpenAI GPT-5.6 and newer.
reasoning.summarystring | nullHow detailed the reasoning summary should be.
safety_identifierstring | nullEnd-user identifier the request supplied for abuse monitoring; null when none was set.
service_tierstring | nullService tier the provider used for the response; null when not reported.
statusstringLifecycle status of the response.
storebooleanWhether the response is stored so it can be retrieved later.
temperaturenumber | nullSampling temperature that applied to the request, if any.
textobjectText output configuration including format and verbosity
text.formatobjectText response format configuration
text.verbositystring | nullHow long the answer should be.
tool_choicestring | objectHow the model picks tools: a mode string or a specific tool.
tool_choice.namestringName of the function or tool the model must call.
tool_choice.typestringKind of tool the model must call. / Always `allowed_tools`. Discriminator that marks this object as a ToolChoiceAllowed in a `type`-tagged union. / Kind of tool the model must call. / Kind of tool the model must call.
tool_choice.modestringauto lets the model pick among the allowed tools or none; required forces a call to one of them.
tool_choice.toolsarray<object>The allowed tools, each as a tool reference such as {type: function, name}.
toolsarray<object>Tools that were available to the model for this response.
tools[].descriptionstring | null | string | stringWhat the function does and when to use it; the model reads this to decide whether to call it. / What the custom tool does and when to use it. / What the group of tools is for.
tools[].namestringName of the function; the model uses it in function_call items. / Name of the custom tool. / Name of the namespace that groups the tools.
tools[].parametersobject | nullJSON Schema of the function arguments; null when the function takes none.
tools[].strictboolean | nullWhether to enforce strict argument validation against the schema; null leaves the provider default.
tools[].typestringAlways `function`. Discriminator that marks this object as a FunctionTool in a `type`-tagged union. / Always `web_search_preview`. Discriminator that marks this object as a Preview_WebSearchServerTool in a `type`-tagged union. / Always `web_search_preview_2025_03_11`. Discriminator that marks this object as a Preview_20250311_WebSearchServerTool in a `type`-tagged union. / Always `web_search`. Discriminator that marks this object as a Legacy_WebSearchServerTool in a `type`-tagged union. / Always `web_search_2025_08_26`. Discriminator that marks this object as a WebSearchServerTool in a `type`-tagged union. / Comparison operator. / Always `computer_use_preview`. Discriminator that marks this object as a ComputerUseServerTool in a `type`-tagged union. / Always `code_interpreter`. Discriminator that marks this object as a CodeInterpreterServerTool in a `type`-tagged union. / Always `mcp`. Discriminator that marks this object as a McpServerTool in a `type`-tagged union. / Always `image_generation`. Discriminator that marks this object as a ImageGenerationServerTool in a `type`-tagged union. / Always `local_shell`. Discriminator that marks this object as a CodexLocalShellTool in a `type`-tagged union. / Always `shell`. Discriminator that marks this object as a ShellServerTool in a `type`-tagged union. / Always `apply_patch`. Discriminator that marks this object as a ApplyPatchServerTool in a `type`-tagged union. / Always `custom`. Discriminator that marks this object as a CustomTool in a `type`-tagged union. / Always `namespace`. Discriminator that marks this object as a NamespaceTool in a `type`-tagged union.
tools[].asyncbooleanLets the model keep working after calling this tool instead of waiting for its output. The tool is still executed by the client; return the result in a later request as a `function_call_output` with the original `call_id`. Only honored by providers whose Responses API supports async tools; ignored elsewhere.
tools[].defer_loadingbooleanWithhold this tool from the model until `openrouter:tool_search` finds it. Requires the tool search server tool; at least one tool must remain non-deferred.
tools[].enginestringWhich search engine to use. "auto" (default) uses native if the provider supports it, otherwise Exa. "native" forces the provider's built-in search. "exa" forces the Exa search API. "firecrawl" uses Firecrawl (requires BYOK). "parallel" uses the Parallel search API. "perplexity" uses the Perplexity Search API (raw ranked results).
tools[].filtersobject | nullRestricts web search by domain. / Attribute filter applied to the search: a comparison or a compound filter.
tools[].max_resultsintegerMaximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped.
tools[].max_usesintegerMaximum number of web searches the model may perform in a single request. Once reached, further search calls return an error result instead of executing. Applies to the Exa, Firecrawl, Parallel, and Perplexity engines. With native provider search, forwarded only to Anthropic (as `max_uses`); other native search providers have no equivalent parameter and ignore it.
tools[].modestringEngine-native search mode. Exa supports instant, fast, auto (default), deep-lite, deep, and deep-reasoning. Parallel supports turbo, fast, basic (default), and advanced. Modes unsupported by the selected engine are ignored.
tools[].search_context_sizestringSize of the search context for web search tools
tools[].user_locationobject | nullApproximate location of the user, used to bias web search results. / User location information for web search / User location information for web search
tools[].max_num_resultsintegerMaximum number of results to return, between 1 and 50.
tools[].ranking_optionsobjectRanking options for the search.
tools[].vector_store_idsarray<string>Ids of the vector stores to search.
tools[].display_heightintegerHeight of the computer display in pixels.
tools[].display_widthintegerWidth of the computer display in pixels.
tools[].environmentstringKind of environment that is controlled.
tools[].containerstring | objectContainer for the code to run in: a container id or an automatic container with files.
tools[].allowed_toolsarray<string> | object | nullTools of the server the model may use: a list of names or a filter.
tools[].authorizationstringOAuth access token for the MCP server.
tools[].connector_idstringId of a built-in connector; give this or server_url.
tools[].headersobject | nullHTTP headers sent to the MCP server; null for none.
tools[].require_approvalobject | string | nullWhether tool calls need approval before they run: always, never, or a filter per tool.
tools[].server_descriptionstringWhat the MCP server is for, which helps the model decide when to use it.
tools[].server_labelstringLabel that names the MCP server in the conversation.
tools[].server_urlstringURL of the MCP server; give this or connector_id.
tools[].backgroundstringBackground of the generated image.
tools[].input_fidelitystring | nullHow closely to preserve details of input images; null uses the default.
tools[].input_image_maskobjectMask that marks the region of the input image to edit.
tools[].modelstringImage model to use.
tools[].moderationstringModeration level applied to the generated image.
tools[].output_compressionintegerCompression level from 0 to 100 for jpeg and webp output.
tools[].output_formatstringFile format of the generated image.
tools[].partial_imagesintegerNumber of partial images to stream while generating, from 0 to 3.
tools[].qualitystringQuality of the generated image.
tools[].sizestringSize of the generated image; auto lets the model choose.
tools[].formatobjectFormat of the tool input: free text or a grammar.
tools[].toolsarray<object>Function tools in the namespace.
top_logprobsintegerNumber of most likely tokens whose log probabilities were requested per position.
top_pnumber | nullNucleus sampling value that applied to the request, if any.
truncationstring | nullHow to handle input that exceeds the context window.
usageobject | nullToken usage information for the response
usage.input_tokensintegerNumber of input tokens, cached tokens included.
usage.input_tokens_detailsobjectBreakdown of the input tokens.
usage.output_tokensintegerNumber of output tokens, reasoning tokens included.
usage.output_tokens_detailsobjectBreakdown of the output tokens.
usage.total_tokensintegerInput plus output tokens.
usage.costnumber | nullCost of the completion
usage.cost_detailsobjectBreakdown of the upstream inference cost.
usage.is_byokbooleanWhether a request was made using a Bring Your Own Key configuration
usage.server_tool_use_detailsobject | nullUsage for server-side tool execution (e.g., web search)
userstring | nullEnd-user identifier the request supplied; null when none was set.
error_typestringCanonical OpenRouter error type, stable across all API formats
openrouter_metadataobjectRouting report: what was requested, how the router chose, and what was attempted.
openrouter_metadata.attemptintegerNumber of the attempt that served the request, starting at 1.
openrouter_metadata.attemptsarray<object>Every attempt that was made, in order.
openrouter_metadata.endpointsobjectWhich endpoints were available and which one was chosen.
openrouter_metadata.generation_timeintegerMilliseconds measured for the generation, from dispatching the upstream request until its response body ended. Divide the completion token count by this for throughput. Absent when no upstream request was dispatched.
openrouter_metadata.is_byokbooleanWhether the request used a key supplied by the caller.
openrouter_metadata.paramsobjectRouter parameters that applied to the request.
openrouter_metadata.pipelinearray<object>Stages the request went through before and after the model call.
openrouter_metadata.regionstring | nullRegion that served the request; null when unknown.
openrouter_metadata.requestedstringThe model or alias the request asked for.
openrouter_metadata.strategystringHow the router picked the model or provider for this request.
openrouter_metadata.summarystringOne-line summary of the routing decision.

text/event-stream — chunk / 事件对象

名称类型说明
idstringOptional id of the server-sent event.
eventstringName of the server-sent event.
dataobject | stringPayload of the server-sent event.
data.responseobjectComplete non-streaming response from the Responses API
data.sequence_numberintegerPosition of this event in the stream. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream; it increases with every event, so use it to order events or detect a gap. / Position of this event in the stream.
data.typestringAlways `response.created`. Discriminator that marks this object as a CreatedEvent in a `type`-tagged union. / Always `response.in_progress`. Discriminator that marks this object as a InProgressEvent in a `type`-tagged union. / Always `response.completed`. Discriminator that marks this object as a CompletedEvent in a `type`-tagged union. / Always `response.incomplete`. Discriminator that marks this object as a IncompleteEvent in a `type`-tagged union. / Always `response.failed`. Discriminator that marks this object as a FailedEvent in a `type`-tagged union. / Always `error`. Discriminator that marks this object as a BaseErrorEvent in a `type`-tagged union. / Always `response.output_item.added`. Discriminator that marks this object as a OutputItemAddedEvent in a `type`-tagged union. / Always `response.output_item.done`. Discriminator that marks this object as a OutputItemDoneEvent in a `type`-tagged union. / Always `response.content_part.added`. Discriminator that marks this object as a BaseContentPartAddedEvent in a `type`-tagged union. / Always `response.content_part.done`. Discriminator that marks this object as a BaseContentPartDoneEvent in a `type`-tagged union. / Always `response.output_text.delta`. Discriminator that marks this object as a BaseTextDeltaEvent in a `type`-tagged union. / Always `response.output_text.done`. Discriminator that marks this object as a BaseTextDoneEvent in a `type`-tagged union. / Always `response.refusal.delta`. Discriminator that marks this object as a BaseRefusalDeltaEvent in a `type`-tagged union. / Always `response.refusal.done`. Discriminator that marks this object as a BaseRefusalDoneEvent in a `type`-tagged union. / Always `response.output_text.annotation.added`. Discriminator that marks this object as a BaseAnnotationAddedEvent in a `type`-tagged union. / Always `response.function_call_arguments.delta`. Discriminator that marks this object as a BaseFunctionCallArgsDeltaEvent in a `type`-tagged union. / Always `response.function_call_arguments.done`. Discriminator that marks this object as a BaseFunctionCallArgsDoneEvent in a `type`-tagged union. / Always `response.reasoning_text.delta`. Discriminator that marks this object as a BaseReasoningDeltaEvent in a `type`-tagged union. / Always `response.reasoning_text.done`. Discriminator that marks this object as a BaseReasoningDoneEvent in a `type`-tagged union. / Always `response.reasoning_summary_part.added`. Discriminator that marks this object as a BaseReasoningSummaryPartAddedEvent in a `type`-tagged union. / Always `response.reasoning_summary_part.done`. Discriminator that marks this object as a BaseReasoningSummaryPartDoneEvent in a `type`-tagged union. / Always `response.reasoning_summary_text.delta`. Discriminator that marks this object as a BaseReasoningSummaryTextDeltaEvent in a `type`-tagged union. / Always `response.reasoning_summary_text.done`. Discriminator that marks this object as a BaseReasoningSummaryTextDoneEvent in a `type`-tagged union. / Always `response.image_generation_call.in_progress`. Discriminator that marks this object as a OpenAIResponsesImageGenCallInProgress in a `type`-tagged union. / Always `response.image_generation_call.generating`. Discriminator that marks this object as a OpenAIResponsesImageGenCallGenerating in a `type`-tagged union. / Always `response.image_generation_call.partial_image`. Discriminator that marks this object as a OpenAIResponsesImageGenCallPartialImage in a `type`-tagged union. / Always `response.image_generation_call.completed`. Discriminator that marks this object as a OpenAIResponsesImageGenCallCompleted in a `type`-tagged union. / Always `response.code_interpreter_call.in_progress`. Discriminator that marks this object as a OpenAIResponsesCodeInterpreterCallInProgress in a `type`-tagged union. / Always `response.code_interpreter_call.interpreting`. Discriminator that marks this object as a OpenAIResponsesCodeInterpreterCallInterpreting in a `type`-tagged union. / Always `response.code_interpreter_call.completed`. Discriminator that marks this object as a OpenAIResponsesCodeInterpreterCallCompleted in a `type`-tagged union. / Always `response.code_interpreter_call_code.delta`. Discriminator that marks this object as a OpenAIResponsesCodeInterpreterCallCodeDelta in a `type`-tagged union. / Always `response.code_interpreter_call_code.done`. Discriminator that marks this object as a OpenAIResponsesCodeInterpreterCallCodeDone in a `type`-tagged union. / Always `response.web_search_call.in_progress`. Discriminator that marks this object as a OpenAIResponsesWebSearchCallInProgress in a `type`-tagged union. / Always `response.web_search_call.searching`. Discriminator that marks this object as a OpenAIResponsesWebSearchCallSearching in a `type`-tagged union. / Always `response.web_search_call.completed`. Discriminator that marks this object as a OpenAIResponsesSearchCompleted in a `type`-tagged union. / Always `response.custom_tool_call_input.delta`. Discriminator that marks this object as a BaseCustomToolCallInputDeltaEvent in a `type`-tagged union. / Always `response.custom_tool_call_input.done`. Discriminator that marks this object as a BaseCustomToolCallInputDoneEvent in a `type`-tagged union. / Always `response.apply_patch_call_operation_diff.delta`. Discriminator that marks this object as a ApplyPatchCallOperationDiffDeltaEvent in a `type`-tagged union. / Always `response.apply_patch_call_operation_diff.done`. Discriminator that marks this object as a ApplyPatchCallOperationDiffDoneEvent in a `type`-tagged union. / Always `response.fusion_call.in_progress`. Discriminator that marks this object as a FusionCallInProgressEvent in a `type`-tagged union. / Always `response.fusion_call.panel.added`. Discriminator that marks this object as a FusionCallPanelAddedEvent in a `type`-tagged union. / Always `response.fusion_call.panel.delta`. Discriminator that marks this object as a FusionCallPanelDeltaEvent in a `type`-tagged union. / Always `response.fusion_call.panel.reasoning.delta`. Discriminator that marks this object as a FusionCallPanelReasoningDeltaEvent in a `type`-tagged union. / Always `response.fusion_call.panel.completed`. Discriminator that marks this object as a FusionCallPanelCompletedEvent in a `type`-tagged union. / Always `response.fusion_call.panel.failed`. Discriminator that marks this object as a FusionCallPanelFailedEvent in a `type`-tagged union. / Always `response.fusion_call.analysis.in_progress`. Discriminator that marks this object as a FusionCallAnalysisInProgressEvent in a `type`-tagged union. / Always `response.fusion_call.analysis.completed`. Discriminator that marks this object as a FusionCallAnalysisCompletedEvent in a `type`-tagged union. / Always `response.fusion_call.completed`. Discriminator that marks this object as a FusionCallCompletedEvent in a `type`-tagged union. / Always `response.debug`. Discriminator that marks this object as a DebugEvent in a `type`-tagged union.
data.codestring | null | stringError code; null when the upstream gave none. / The complete code the interpreter runs.
data.messagestringHuman-readable error message.
data.paramstring | nullName of the request parameter the error is about; null when it is not about a parameter.
data.itemobjectAn output item from the response
data.output_indexintegerIndex of the item in the response output array that this event belongs to.
data.content_indexintegerIndex of the content part inside the output item that this event belongs to.
data.item_idstringId of the output item this event belongs to; it equals the id of that item in the response output.
data.partobjectThe content part as it starts: output text or refusal. / The content part in its final form: output text or refusal. / A reasoning summary part. / A reasoning summary part.
data.deltastringText fragment to append to the output text of this content part. / Refusal text fragment to append. / Fragment of the JSON-encoded function arguments to append. / Reasoning text fragment to append. / Reasoning summary text fragment to append. / Fragment of the code the interpreter will run, to append. / Fragment of the custom tool call input to append. / Fragment of the patch diff to append. / Text fragment the panel model produced. / Reasoning text fragment the panel model produced.
data.logprobsarray<object>Log probabilities of the tokens in this fragment, when requested. / Log probabilities of the tokens in the complete text, when requested.
data.textstringThe complete output text of this content part. / The complete reasoning text of this content part. / The complete reasoning summary text of this part.
data.refusalstringThe complete refusal text.
data.annotationobjectAnnotation attached to output text: a file citation, URL citation or file path.
data.annotation_indexintegerIndex of the new annotation inside the content part's annotations array.
data.argumentsstringThe complete JSON-encoded arguments of the function call.
data.namestringName of the function being called.
data.summary_indexintegerIndex of the reasoning summary part inside the reasoning item that this event belongs to.
data.partial_image_b64stringBase64-encoded partial image produced while generation is still running.
data.partial_image_indexintegerZero-based index of this partial image among the partial images of the call.
data.inputstringThe complete input of the custom tool call.
data.diffstringThe complete patch diff.
data.modelstringSlug of the panel model that started. / Slug of the panel model that produced the fragment. / Slug of the panel model that produced the fragment. / Slug of the panel model that finished. / Slug of the panel model that failed.
data.contentstringThe complete answer of the panel model.
data.errorstringError message that explains why the panel model failed.
data.status_codeintegerHTTP status code of the failed upstream call, when one is available.
data.analyst_modelstringSlug of the model producing the structured analysis.
data.judge_modelstringDeprecated alias of `analyst_model`, kept so existing consumers keep working. Always carries the same value. Use `analyst_model`.
data.analysisobjectStructured analysis produced by the fusion analyst model.
data.debugobjectDebug information.

读取响应

先调用「生成响应」,用返回的 ID 替换 resp_123。

GET /model/v1/responses/{response_id}● 支持

官方文档 ↗

请求参数

  • response_idstring必填

    path: Id of the stored response, the `id` returned by createResponse (it looks like resp_...). An unknown id, a response created with store false, an expired response and another tenant's response all answer 404.

返回

200 response

按 ID 读取一条已保存的响应。如果创建时 store 为 false,我们不会保存这次响应,读取会返回 404 response_not_found;超过保留期(默认 30 天)后读取也会返回同样的 404。

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

响应

HTTP 200

Native Responses API response

application/json

名称类型说明
$object

删除响应

先调用「生成响应」,用返回的 ID 替换 resp_123。

DELETE /model/v1/responses/{response_id}● 支持

官方文档 ↗

请求参数

  • response_idstring必填

    path: Id of the stored response, the `id` returned by createResponse (it looks like resp_...). An unknown id, a response created with store false, an expired response and another tenant's response all answer 404.

返回

200 response

按 ID 立即删除一条已保存的响应。如果创建时 store 为 false,我们不会保存这次响应,删除会返回 404 response_not_found。

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

响应

HTTP 200

Native Responses API delete response

application/json

名称类型说明
$object

先调用「生成响应」,用返回的 ID 替换 resp_123。

POST /model/v1/responses/{response_id}/cancel◐ 部分支持

官方文档 ↗

请求参数

  • response_idstring必填

    path: Id of the stored response, the `id` returned by createResponse (it looks like resp_...). An unknown id, a response created with store false, an expired response and another tenant's response all answer 404.

返回

200 response

仅对以 background:true 创建、且路由到具备后台生成能力的模型的响应可用:取消是 幂等的,重复调用返回同一个终态响应;我方的取消只能停止我方对上游流的继续读取, 不能保证已发往上游的算力停止计算,用量按实际收到的部分结算。对一个非后台 (同步)响应调用 cancel:如果这个响应 id 不存在(未持久化、已过期或 id 有误), 返回 404 object_not_found;如果响应存在但其来源 provider 没有声明支持 cancel 操作(我们目前没有接入任何为同步响应声明该能力的上游),返回 400 native_responses_operation_unsupported。这两种情况都不是尚未实现的 501 gate。

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

响应

HTTP 200

Native Responses API cancel response

application/json

名称类型说明
$object

列出响应输入项

先调用「生成响应」,用返回的 ID 替换 resp_123。

GET /model/v1/responses/{response_id}/input_items● 支持

官方文档 ↗

请求参数

  • response_idstring必填

    path: Id of the stored response, the `id` returned by createResponse (it looks like resp_...). An unknown id, a response created with store false, an expired response and another tenant's response all answer 404.

返回

200 list

列出一条已保存响应的输入项。支持 limit(1–100,默认 20)、order(asc/desc, 默认 desc,与官方一致)与基于条目 id 的 after 游标分页;has_more/first_id/ last_id 均与实际返回页一致,可据此翻页且不重不漏。每个条目都带服务端签发的 id(message 为 msg_ 前缀,function_call/function_call_output/reasoning 各自 对应前缀),本次上线前已保存、尚无服务端 id 的旧数据在读取时按确定性规则补 id,不做破坏性迁移,同一游标反复读取保持稳定。以 previous_response_id 续接 创建的响应,其输入项列出解析后的完整输入:前序响应链已有的输入与输出条目 再加本轮自己提交的输入;若该祖先响应在我方平台未保存(例如创建时 store 为 false)或已过期删除,则只列出本轮自己提交的输入。如果创建时 store 为 false,我们不会保存这次响应,列出会返回 404 response_not_found。

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

响应

HTTP 200

Native Responses API input item list

application/json

名称类型说明
$object

POST /model/v1/responses/compact○ 未支持

官方文档 ↗

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

把响应的输入压缩成摘要,依赖 OpenAI Responses 官方的服务端存储(store)语义,我们目前还没有实现;调用会返回 501(message 为 “This platform has not implemented … yet.”,响应头 x-should-retry 为 false),不产生副作用,官方 SDK 不会重试。

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

响应

HTTP 200

Native Responses API compact response

application/json

名称类型说明
$object

POST /model/v1/responses/input_tokens○ 未支持

官方文档 ↗

返回

501 平台还没有实现这个端点;调用会得到下面这个响应:

只统计请求输入会消耗的 token 数、不生成内容,依赖 OpenAI Responses 官方的服务端存储(store)语义,我们目前还没有实现;调用会返回 501(message 为 “This platform has not implemented … yet.”,响应头 x-should-retry 为 false),不产生副作用,官方 SDK 不会重试。

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

响应

HTTP 200

Native Responses API input token count

application/json

名称类型说明
$object

文本向量

POST /model/v1/embeddings● 支持

官方文档 ↗

请求体

  • modelstring必填

    The model to use for embeddings

    已验证生效。

  • inputstring | array必填◐ 部分支持

    Text, token, or multimodal input(s) to embed

    文本及文本数组生效;token 整数数组返回 400。图片仅 qwen3-vl-embedding、doubao-embedding-vision 支持;text-embedding-3-small 的 16 条批量返回 400。

  • dimensionsinteger可选◐ 部分支持

    The number of dimensions for the output embeddings

    仅 text-embedding-3-small、qwen3-vl-embedding 支持已测的 256 维;text-embedding-3-small 也支持 512,100 返回 400。bge-m3、qwen3-embedding-0.6b、doubao-embedding-vision 的 256 维返回 400。

  • encoding_formatstring可选

    The format of the output embeddings

    float 与 base64 均支持;base64 为向量的二进制编码。

    取值 floatbase64
  • input_typestring可选◐ 部分支持

    The type of input (e.g. search_query, search_document)

    query/document 在 bge-m3、qwen3-embedding-0.6b 生效;search_query 返回 400;text-embedding-3-small 接受但当前不生效。

  • providerobject可选◐ 部分支持

    OpenRouter-style provider preferences, accepted for compatibility. Router support (partial): bge-m3 and qwen3-embedding-0.6b return 400; text-embedding-3-small accepts it, with an unobservable effect.

    bge-m3、qwen3-embedding-0.6b 返回 400;text-embedding-3-small 接受,但效果不可观测。

    ▸ 展开子字段(13)
    • allow_fallbacksboolean可选

      Whether to allow backup providers to serve requests - true: (default) when the primary provider (or your custom providers in "order") is unavailable, use the next best provider. - false: use only the primary/custom provider, and return the upstream error if it's unavailable.

    • data_collectionstring可选

      Data collection setting. If no available model provider meets the requirement, your request will return an error. - allow: (default) allow providers which store user data non-transiently and may train on it - deny: use only providers which do not collect user data.

      取值 denyallownull
    • enforce_distillable_textboolean可选

      Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used.

    • ignorearray可选

      List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request.

    • max_priceobject可选

      The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.

    • onlyarray可选

      List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request.

    • orderarray可选

      An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message.

    • preferred_max_latencynumber | object可选

      Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold.

    • preferred_min_throughputnumber | object可选

      Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold.

    • quantizationsarray可选

      A list of quantization levels to filter the provider by.

    • require_parametersboolean可选

      Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest.

    • sortstring | object可选

      The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed.

    • zdrboolean可选

      Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used.

  • session_idstring可选◐ 部分支持

    A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.

    bge-m3、qwen3-embedding-0.6b 返回 400;text-embedding-3-small 接受,但效果不可观测。

  • traceobject可选◐ 部分支持

    Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.

    bge-m3、qwen3-embedding-0.6b 返回 400;text-embedding-3-small 接受,但效果不可观测。

    ▸ 展开子字段(5)
    • generation_namestring可选

      Name of this generation in the trace.

    • parent_span_idstring可选

      Id of the parent span in the trace.

    • span_namestring可选

      Name of this request's span in the trace.

    • trace_idstring可选

      Id that groups several requests into one trace.

    • trace_namestring可选

      Name of the trace.

  • userstring可选◐ 部分支持

    A unique identifier for the end-user

    bge-m3、qwen3-embedding-0.6b 返回 400;text-embedding-3-small 接受,但效果不可观测。

返回

200 list

未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。

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

响应

HTTP 200

Embedding response

application/json

名称类型说明
dataarray<object>List of embedding objects
data[].embeddingarray<number> | stringEmbedding vector as an array of floats or a base64 string
data[].indexintegerIndex of the embedding in the input list
data[].objectstringObject type of the entry; always `embedding`.
idstringUnique identifier for the embeddings response
modelstringThe model used for embeddings
objectstringObject type; always `list`.
usageobjectToken usage statistics
usage.costnumberCost of the request in credits
usage.cost_detailsobject | nullBreakdown of upstream inference costs
usage.is_byokbooleanWhether a request was made using a Bring Your Own Key configuration
usage.prompt_tokensintegerNumber of tokens in the input
usage.prompt_tokens_detailsobjectPer-modality token breakdown. Only present when the input contains 2+ modalities (e.g. text + image) and the upstream provider returns modality-level usage data. Only non-zero modality counts are included.
usage.total_tokensintegerTotal number of tokens used

text/event-stream — chunk / 事件对象

○ 未支持

名称类型说明
idstringOptional id of the server-sent event.
eventstringName of the server-sent event.
datastringPayload of the server-sent event.

重排文档

POST /model/v1/rerank● 支持

官方文档 ↗

请求体

  • modelstring必填

    Rerank model id; list candidates with listModels?type=reranking. Router support (supported): Verified to take effect.

    已验证生效。

  • querystring必填

    Query to rank the documents against, at least 1 character. Router support (supported): Verified to take effect.

    已验证生效。

  • documentsarray必填◐ 部分支持

    Documents to rank, as plain strings, at least one. Router support (partial): Only string arrays are supported; object arrays return 400.

    只支持字符串数组;对象数组返回 400。

  • top_ninteger可选

    Number of best results to return, at least 1; omit it to return every document. Router support (supported): Controls returned result count; zero returns 400.

    控制返回条数;0 返回 400。

  • return_documentsboolean可选○ 未支持

    bge-reranker-base 返回 400;只支持 model、query、documents、top_n。

  • max_tokens_per_docinteger可选○ 未支持

    bge-reranker-base 返回 400;只支持 model、query、documents、top_n。

  • rank_fieldsarray可选○ 未支持

    bge-reranker-base 返回 400;只支持 model、query、documents、top_n。

  • max_chunks_per_docinteger可选○ 未支持

    bge-reranker-base 返回 400;只支持 model、query、documents、top_n。

  • userstring可选○ 未支持

    bge-reranker-base 返回 400;只支持 model、query、documents、top_n。

返回

200

标准请求字段;不能表达的参数返回 input_not_representable。

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

响应

HTTP 200

Cohere v2 rerank results.

application/json

名称类型说明
resultsarray<object>Results ordered by relevance, best first. Each entry points back to a document with `index`.
results[].indexintegerZero-based position of the document in the request `documents` array.
results[].relevance_scorenumberRelevance of the document to the query, from 0 to 1; larger is more relevant.

合成语音

POST /model/v1/audio/speech● 支持

官方文档 ↗

请求体

  • modelstring必填

    Speech model id, for example `melotts` or `aura-2-en`; list candidates with listModels?type=speech. Router support (supported): Verified to take effect.

    已验证生效。

  • inputstring可选

    Text to synthesize, 1 to 4096 characters. `text` and `prompt` are aliases; when several are given, `input` wins. Router support (supported): melotts supports input, lang and response_format=wav; text/prompt aliases also work.

    melotts 支持 input、lang、response_format=wav;也可用 text/prompt 别名。

  • response_formatstring可选◐ 部分支持

    MeloTTS supports only wav (default); all other explicit formats return 400. When omitted the actual upstream format is returned. Aura defaults to mp3 and supports all listed formats.

    melotts 仅 WAV。aura-2-en 支持 mp3/opus/flac/wav/pcm;aac 报错。

    取值 mp3opusaacflacwavpcm
  • promptstring可选

    MeloTTS alias for input; input then text take precedence.

    input 的别名,input 优先。

  • voicestring | object可选◐ 部分支持

    Aura speaker name. Custom voice objects and selectable MeloTTS voices return 400.

    仅 aura-2-en 支持原生说话人名,如 thalia/apollo/orion/luna/zeus;不支持 alloy 或对象。melotts 必须省略。

    ▸ 展开子字段(1)
    • idstring必填

      Id of a custom voice. Custom voice objects are not supported by these models and answer 400; use the string form of `voice` with an Aura speaker name.

  • instructionsstring可选○ 未支持

    Accepted by the protocol; these Cloudflare models reject it with 400.

    melotts、aura-2-en 均返回 400。

  • speednumber可选◐ 部分支持
    默认 1

    Only 1 is representable by these Cloudflare models.

    只接受默认值 1;非默认速度不支持,返回错误。

  • stream_formatstring可选◐ 部分支持
    默认 "audio"

    Only audio is supported; the response is buffered binary audio.

    audio 生效;sse 返回 400。

    取值 audiosse
  • textstring可选

    Native alias for input; input wins.

    input 的别名,input 优先。

  • speakerstring可选◐ 部分支持

    Aura alias for voice; voice wins.

    aura-2-en 支持原生说话人名;melotts 返回 400。

  • ▸ 更多参数(5)
    • langstring可选◐ 部分支持

      MeloTTS language; defaults to en. Use this field to select language; voice is not supported by MeloTTS.

      melotts 支持 en/fr/es/zh;ja/ko 报错。aura-2-en 不支持 lang。

      取值 enfreszhjako
    • encodingstring可选◐ 部分支持

      Aura native encoding; response_format wins; mulaw/alaw return 400.

      melotts 仅 linear16;aura-2-en 支持 linear16/flac 等已测编码,mulaw 返回 400;response_format 优先。

      取值 linear16flacmulawalawmp3opusaac
    • containerstring可选◐ 部分支持

      Aura container; response_format wins.

      aura-2-en 支持 opus+ogg、linear16+none;container=wav 返回 400。melotts 不支持此字段。

      取值 nonewavogg
    • sample_rateinteger可选◐ 部分支持

      Aura WAV supports 8000/16000/24000/32000/48000; FLAC supports 8000/16000/22050/32000/48000; PCM requires 24000; other formats reject this control.

      仅 aura-2-en;wav 已测 8000/16000、pcm 已测 24000;44100 或 mp3 自定义采样率报错。melotts 不支持。

    • bit_rateinteger可选◐ 部分支持

      Aura MP3 supports 32000/48000; Opus 4000–650000; AAC 4000–192000. Other formats reject this control.

      仅 aura-2-en:mp3 已测 32000/48000、opus 已测 64000;mp3=64000 报错。melotts 不支持。

返回

200

melotts 输出 WAV,只支持 input(含 text/prompt 别名)、lang 和默认音频选项;aura-2-en 使用原生 speaker 名称。逐字段限制见参数表。

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

响应

HTTP 200

Audio bytes in the requested format.

audio/mpeg

名称类型说明
$string (binary)

audio/ogg

名称类型说明
$string (binary)

audio/aac

名称类型说明
$string (binary)

audio/flac

名称类型说明
$string (binary)

audio/wav

名称类型说明
$string (binary)

audio/pcm

名称类型说明
$string (binary)

响应体为音频字节;右侧描述对象仅记录实采的 Content-Type 和字节数。

转写音频

POST /model/v1/audio/transcriptions● 支持

官方文档 ↗

请求体

  • modelstring必填

    Transcription model id, for example `whisper-large-v3-turbo` or `qwen3-asr-flash`; list candidates with listModels?type=transcription. Router support (supported): Verified to take effect.

    已验证生效。

  • temperaturenumber可选○ 未支持

    whisper-large-v3-turbo、qwen3-asr-flash 均返回 400。

  • response_formatstring可选◐ 部分支持
    默认 "json"

    Format of the response body. `json` and `text` are the commonly supported formats. Router support (partial): json/text work on both; verbose_json works only on whisper-large-v3-turbo. srt/vtt return 400.

    json/text 均生效;verbose_json 仅 whisper-large-v3-turbo 支持。srt/vtt 均返回 400。

    取值 jsontextverbose_json
  • promptstring可选◐ 部分支持

    Text that primes the model with vocabulary or context. Router support (partial): Vocabulary hints work on whisper-large-v3-turbo only; qwen3-asr-flash returns 400.

    仅 whisper-large-v3-turbo 的词表提示已验证生效;qwen3-asr-flash 返回 400。

  • filestring必填

    Audio file to transcribe, uploaded as multipart/form-data. Router support (supported): Verified to take effect.

    已验证生效。

  • languagestring可选◐ 部分支持

    Language of the audio as an ISO-639-1 code such as `en` or `zh`. Router support (partial): Both models accept ISO language codes. qwen3-asr-flash may translate output to that language; whisper-large-v3-turbo treats it as an input hint. Non-ISO names may return 502.

    两模型接受 ISO 语言码;qwen3-asr-flash 可能按指定语言翻译输出,whisper-large-v3-turbo 用作输入语言提示。非 ISO 名称可能报 502。

  • timestamp_granularities[]array可选◐ 部分支持

    Timestamp levels to include with `verbose_json`; only `segment` exists in this schema. Router support (partial): Only whisper-large-v3-turbo supports segment with verbose_json. word returns 400; qwen3-asr-flash does not support timestamps.

    仅 whisper-large-v3-turbo 在 verbose_json 下支持 segment;word 返回 400;qwen3-asr-flash 不支持时间戳。

返回

200

标准请求字段;不能表达的参数返回 input_not_representable。

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

响应

HTTP 200

Transcription in the requested format.

text/plain

名称类型说明
$string

application/json

名称类型说明
textstringThe transcribed text.
taskstringTask performed; always `transcribe`.
languagestringLanguage of the audio as detected or as requested.
durationnumberDuration of the audio in seconds.
segmentsarray<object>Segments with timestamps, returned with `verbose_json` on models that support it.
segments[].idintegerZero-based index of the segment.
segments[].startnumberStart time of the segment in seconds.
segments[].endnumberEnd time of the segment in seconds.
segments[].textstringThe transcribed text.
segments[].temperaturenumberSampling temperature used for the segment.
segments[].avg_logprobnumberAverage log probability of the tokens of the segment; low values mean low confidence.
segments[].compression_rationumberGzip compression ratio of the segment text; high values indicate repetitive output.
segments[].no_speech_probnumberProbability that the segment contains no speech.

生成图像

POST /model/v1/images/generations● 支持

官方文档 ↗

请求体

  • modelstring必填

    Image model id; list candidates with listModels?type=image. Router support (supported): Verified to take effect.

    已验证生效。

  • response_formatstring可选◐ 部分支持

    Image response encoding. Only b64_json is accepted; url returns 400.

    gpt-image-2 支持 b64_json;url 返回 400。

    取值 b64_json
  • promptstring必填

    Text description of the image to generate. Router support (supported): Verified to take effect.

    已验证生效。

  • ninteger可选
    默认 1

    Number of images to generate, from 1 to 10; defaults to 1. Router support (supported): Controls image count; zero returns 400 and values 1–10 are accepted.

    控制图片数量,0 返回 400,允许 1–10。

  • sizestring可选◐ 部分支持

    Size of the generated images. Router support (partial): gpt-image-2 supports tested 1024x1024 and 1024x1536 sizes; 512x512 returns 400.

    gpt-image-2 已验证 1024x1024、1024x1536;512x512 返回 400。

    取值 1024x10241024x15361536x1024auto
  • qualitystring可选

    Quality of the generated images. Router support (supported): Verified to take effect.

    已验证生效。

    取值 lowmediumhighauto
  • backgroundstring可选

    gpt-image-2 的 transparent 返回透明 PNG。

  • output_formatstring可选

    gpt-image-2 的 jpeg 返回 JPEG。

返回

200

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

响应

HTTP 200

Image generation response

application/json

名称类型说明
createdintegerUnix time in seconds at which the images were created.
dataarray<object>Generated images.
data[].urlstringURL of the image; present when response_format is `url`.
data[].b64_jsonstringBase64-encoded image; present when response_format is `b64_json`.
data[].revised_promptstringPrompt after the image model rewrote it, when the model reports it.

编辑图像

POST /model/v1/images/edits● 支持

官方文档 ↗

请求体

  • modelstring必填

    Image model id; list candidates with listModels?type=image. Router support (supported): Verified to take effect.

    已验证生效。

  • promptstring必填

    Text description of the desired edit. Router support (supported): Verified to take effect.

    已验证生效。

  • imagearray必填

    Source images as base64 data URLs.

  • maskstring可选○ 未支持

    Mask that marks the region to edit, as a base64 data URL or multipart file. Router support (unsupported): The tested PNG mask returns 400 and is currently unusable.

    已测 PNG mask 返回 400;当前不可用。

  • nnumber可选

    Number of edited images to generate. Router support (supported): Verified to take effect.

    已验证生效。

  • sizestring可选

    Size of the edited images. Router support (supported): Verified to take effect.

    已验证生效。

  • image[]array可选

    Source images, uploaded as multipart files. Router support (supported): Accepts multipart files or JSON data URLs.

    支持 multipart 文件或 JSON data URL。

返回

200

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

响应

HTTP 200

Edited images

application/json

名称类型说明
creatednumberUnix time in seconds at which the images were created.
dataarray<object>Edited images.
data[].urlstringURL of the image; present when response_format is `url`.
data[].b64_jsonstringBase64-encoded image; present when response_format is `b64_json`.

文档识别

POST /model/v1/ocr● 支持

官方文档 ↗

请求体

  • modelstring必填

    OCR model ID, for example glm-ocr.

    已验证生效。

  • documentobject必填

    Choose document_url, image_url (HTTPS or data URL), or {type: file, file_id: string}.

    支持 PDF data URL、image_url 和已上传文件的 file_id;远端 URL 需可下载。

    ▸ 展开子字段(5)
    • typestring必填

      Always `file`. Discriminator of the `type`-tagged union this object belongs to.

    • document_urlstring必填

      HTTPS or base64 data URL; required when type is document_url.

    • document_namestring可选

      Optional file name of the document, used by the provider for display.

    • image_urlstring必填

      HTTPS or base64 data URL; required when type is image_url.

    • file_idstring必填

      File ID owned by the authenticated tenant. The file_id read limit is 24 MiB (25165824 bytes; shared 96 MiB memory budget / 4); PNG/JPEG remain limited to 10 MiB. Larger files return 413: use HTTPS document_url for PDFs up to 50 MiB. Image pages must be [0].

  • pagesarray可选

    Zero-based page indices to process.

    零起始页码,可选择多页并去重;越界页会报错。

  • include_image_base64boolean可选◐ 部分支持

    Include extracted images as base64.

    glm-ocr 仅接受 false;true 返回 400。

  • table_formatstring可选◐ 部分支持

    Format for tables that are extracted separately: when set, tables come back in `tables` in this format and the page markdown keeps a link to each; when null they stay inline in the markdown. Router support (partial): glm-ocr accepts markdown or null only; html returns 400.

    glm-ocr 仅接受 markdown 或 null;html 返回 400。

  • extract_headerboolean可选○ 未支持

    Whether to extract page headers separately into `header`. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.

    glm-ocr 不支持,传入返回 400。

  • extract_footerboolean可选○ 未支持

    Whether to extract page footers separately into `footer`. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.

    glm-ocr 不支持,传入返回 400。

  • bbox_annotation_formatobject可选○ 未支持

    Structured image annotations; OCR requires json_schema. Availability depends on the model.

    glm-ocr 不支持,传入返回 400。

    ▸ 展开子字段(2)
    • typestring可选

      Response format type of the annotation.

      取值 textjson_objectjson_schema
    • json_schemaobject可选

      JSON Schema the annotation of each detected image region must follow.

  • document_annotation_formatobject可选○ 未支持

    Structured document annotation; OCR requires json_schema. Availability depends on the model.

    glm-ocr 不支持,传入返回 400。

    ▸ 展开子字段(2)
    • typestring可选

      Response format type of the annotation.

      取值 textjson_objectjson_schema
    • json_schemaobject可选

      JSON Schema the document annotation must follow.

  • document_annotation_promptstring可选○ 未支持

    Instruction for the document annotation, which says what to extract. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.

    glm-ocr 不支持,传入返回 400。

  • ▸ 更多参数(4)
    • image_limitinteger可选○ 未支持

      Maximum number of images to extract per document; null for no limit. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.

      glm-ocr 不支持,传入返回 400。

    • image_min_sizeinteger可选○ 未支持

      Minimum height and width in pixels of images to extract; null for no minimum. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.

      glm-ocr 不支持,传入返回 400。

    • include_blocksboolean可选○ 未支持

      Whether to return layout `blocks` for each page. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.

      glm-ocr 不支持,传入返回 400。

    • confidence_scores_granularitystring可选○ 未支持

      Level at which confidence scores are returned. Router support (unsupported): Unsupported on glm-ocr; passing it returns 400.

      glm-ocr 不支持,传入返回 400。

返回

200

采用 Mistral OCR 请求与响应形状,仅提供 /model/v1/ocr。model 必填;document 接受 document_url 或 image_url(HTTPS 或 base64 data URL),也接受 `{type:"file", file_id:"<上传所得 ID>"}`,直接读取当前租户的 File。file_id 读取上限为 24 MiB(25,165,824 字节,共享 96 MiB 内存预算按四倍预留);超过此上限返回 413,并提示改用 HTTPS document_url(PDF 上限 50 MiB)。PNG/JPEG 仍限 10 MiB,按文件头识别类型;不存在或其他租户的文件统一返回 404。pages 是从 0 开始的页码数组;图片如指定 pages,只能为 `[0]`。文件读取失败不计费,请求日志仅记录 file_id,不保存文件原文。可选功能依模型而定,不支持的选项返回 400。错误为 problem+json;providerOptions.praxis 不适用于此端点。

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

响应

HTTP 200

OCR pages and usage

application/json

名称类型说明
pagesarray<object>Result per processed page, in page order.
pages[].indexintegerZero-based index of the page in the document.
pages[].markdownstringPage content as markdown.
pages[].imagesarray<object>Images found on the page.
pages[].dimensionsobject | nullSize of the rendered page; null when unknown.
pages[].tablesarray<object>Tables extracted from the page when table_format is set.
pages[].hyperlinksarray<string>Hyperlinks found on the page.
pages[].headerstring | nullPage header text; null when none was extracted.
pages[].footerstring | nullPage footer text; null when none was extracted.
pages[].blocksarray<object> | nullLayout blocks of the page, in reading order, when include_blocks is true.
pages[].confidence_scoresobject | nullConfidence scores of the page; null when not requested.
modelstringOCR model that processed the document.
usage_infoobjectUsage of the request.
usage_info.pages_processedintegerNumber of pages that were processed.
usage_info.doc_size_bytesinteger | nullSize of the document in bytes; null when unknown.
document_annotationstring | nullDocument annotation as a JSON string, when document_annotation_format was requested; null otherwise.

创建视频

POST /model/v1/videos● 支持

请求体

  • modelstring可选◐ 部分支持

    Video model id, for example `wan2.7-t2v`; list candidates with listModels?type=video. Router support (partial): Select a registered video model explicitly, for example wan2.7-t2v (size=1280x720, seconds=4). Capability preflight errors are reported before creation.

    请显式选择已注册的视频模型,例如 wan2.7-t2v(size=1280x720,seconds=4)。能力预检失败会在创建前报错。

  • promptstring必填

    Text description of the video, at least 1 character. Router support (supported): Controls video content; missing or empty values return 400.

    控制视频内容;缺失或空值返回 400。

  • secondsstring | integer可选

    同时提供时优先于 duration。

    已验证 wan2.7-t2v 的时长生效;不合法或超出模型能力的值在预检阶段返回 400。

  • durationinteger可选

    Length of the video in whole seconds. `seconds` takes precedence when both are given.

  • sizestring可选◐ 部分支持

    Output resolution as `WIDTHxHEIGHT`, for example `1280x720`. Router support (partial): Subject to model capability preflight. Earlier wan2.7-t2v samples always produced 1280x720; accepted sizes are not guaranteed pixel-for-pixel.

    受模型能力预检限制;早期 wan2.7-t2v 样本始终输出 1280x720,不保证所有接受的尺寸都会按像素兑现。

  • input_referencestring | object可选

    Reference image for image-to-video: a URL or base64 data URL, an object with `image_url`, or an uploaded image file (multipart, at most 20 MiB).

    ▸ 展开子字段(1)
    • image_urlstring | object必填

      URL or base64 data URL of the reference image, as a string or an object with `url`.

  • input_referencesarray可选

    Several reference images; each entry is a URL or base64 data URL, or an object with `image_url`.

    ▸ 展开子字段(1)
    • image_urlstring | object可选

      URL or base64 data URL of the reference image, as a string or an object with `url`.

  • frame_imagesarray可选

    Images that pin the first and last frame; at most 2 entries.

    ▸ 展开子字段(3)
    • typeany可选

      Always `image_url`. Discriminator of the `type`-tagged union this object belongs to.

    • frame_typeany必填

      Frame to constrain with the supplied image: first_frame or last_frame. Each frame type may occur at most once.

      取值 first_framelast_frame
    • image_urlobject必填

      The image to pin.

  • resolutionstring可选

    Output resolution label such as `720p`, for models that take a label instead of `size`.

  • aspect_ratiostring可选

    Aspect ratio of the video such as `16:9`.

  • ▸ 更多参数(4)
    • generate_audioboolean可选

      Whether the video carries a generated audio track. Router support (supported): false produces no audio track on wan2.7-t2v; the default output includes audio.

      wan2.7-t2v 的 false 输出无音轨,默认输出含音轨。

    • seedinteger可选

      Seed for reproducible generation, on models that support it.

    • callback_urlstring可选

      HTTP or HTTPS callback URL, forwarded to models that support completion callbacks.

    • qualitystring可选

      Provider-specific quality setting.

返回

200

按输出秒数计费;每秒价格见 GET /model/v1/models 的 pricing.video_second(USD/秒)。

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

响应

HTTP 200

Success

application/json

名称类型说明
idstringId of the video job; pass it as `video_id` to retrieve, download or delete it.
objectstringObject type; always `video`.
modelstringModel that generates the video.
statusstringLifecycle of the job. Poll until it is `completed` or `failed`.
progressintegerProgress from 0 to 100. It is 0 until the job completes and 100 once it has.
created_atintegerUnix time in seconds at which the job was created.
completed_atinteger | nullUnix time in seconds at which the job completed; null until then.
expires_atinteger | nullUnix time in seconds after which the output expires; null because outputs currently have no expiry.
secondsstringLength of the video in seconds, as a string; for a completed job it is the delivered length.
sizestringResolution of the video as `WIDTHxHEIGHT`; null when the provider did not report one.
promptstring | nullPrompt the job was created with.
remixed_from_video_idnullAlways null; remix is not supported.
errorobject | nullWhy the job failed; null unless status is `failed`.
error.codestringMachine-readable failure code.
error.messagestringHuman-readable failure message.
polling_urlstringRelative URL to poll for the job state; same as retrieveVideo for this job.
unsigned_urlsarray<string>Relative URLs of the finished output; empty until the video is ready. Download them with the same API key.
usageobjectCost of the job; present once a price applies.
usage.costnumberCost of the job in USD: delivered seconds times the per-second price once completed, 0 while running.

创建、轮询与下载

先创建视频,保存返回的 id;再读取视频轮询 status,queued / in_progress 时继续等待,failed 时停止并查看 error;只有 completed 后才下载视频内容。

典型耗时为 10–15 分钟;以下示例最多轮询 30 分钟,超时后可用同一个任务 ID 继续查询。

# Requires curl and jq. Set PRAXIS_API_KEY and API_BASE (your API origin).
job=$(curl --fail-with-body -sS "$API_BASE/model/v1/videos" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" -H "Content-Type: application/json" \
  -d '{"model":"wan2.7-t2v","prompt":"A cat stretching in the morning sun","seconds":"4","size":"1280x720"}') || exit 1
VIDEO_ID=$(printf '%s' "$job" | jq -er '.id') || exit 1
for attempt in $(seq 1 360); do
  job=$(curl --fail-with-body -sS "$API_BASE/model/v1/videos/$VIDEO_ID" \
    -H "Authorization: Bearer $PRAXIS_API_KEY") || exit 1
  status=$(printf '%s' "$job" | jq -er '.status') || exit 1
  case "$status" in
    completed) break ;;
    failed) printf '%s\n' "$job"; exit 1 ;;
    queued|in_progress) sleep 5 ;;
    *) printf 'Unexpected status: %s\n' "$status"; exit 1 ;;
  esac
done
[ "$status" = completed ] || { printf 'Still processing; resume polling %s\n' "$VIDEO_ID"; exit 1; }
curl --fail-with-body -sS "$API_BASE/model/v1/videos/$VIDEO_ID/content" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" -o video.mp4

列出视频

GET /model/v1/videos● 支持

请求参数

  • afterstring可选

    query: Cursor: the id of the video job after which the page starts, normally the `last_id` of the previous page. It must refer to an existing job of yours, otherwise the call fails.

    分页参数生效;limit 为 1–100,order 为 asc/desc,after 必须引用存在的任务。

  • limitinteger可选
    默认 20

    query: Maximum number of jobs per page, from 1 to 100; defaults to 20.

    分页参数生效;limit 为 1–100,order 为 asc/desc,after 必须引用存在的任务。

  • orderany可选
    默认 "desc"

    query: Sort order by creation time: desc (default) lists the newest job first, asc the oldest first.

    分页参数生效;limit 为 1–100,order 为 asc/desc,after 必须引用存在的任务。

    取值 ascdesc

返回

200

按输出秒数计费;每秒价格见 GET /model/v1/models 的 pricing.video_second(USD/秒)。

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

响应

HTTP 200

Success

application/json

名称类型说明
objectstringObject type; always `list`.
dataarray<object>Video jobs of the caller, newest first by default.
data[].idstringId of the video job; pass it as `video_id` to retrieve, download or delete it.
data[].objectstringObject type; always `video`.
data[].modelstringModel that generates the video.
data[].statusstringLifecycle of the job. Poll until it is `completed` or `failed`.
data[].progressintegerProgress from 0 to 100. It is 0 until the job completes and 100 once it has.
data[].created_atintegerUnix time in seconds at which the job was created.
data[].completed_atinteger | nullUnix time in seconds at which the job completed; null until then.
data[].expires_atinteger | nullUnix time in seconds after which the output expires; null because outputs currently have no expiry.
data[].secondsstringLength of the video in seconds, as a string; for a completed job it is the delivered length.
data[].sizestringResolution of the video as `WIDTHxHEIGHT`; null when the provider did not report one.
data[].promptstring | nullPrompt the job was created with.
data[].remixed_from_video_idnullAlways null; remix is not supported.
data[].errorobject | nullWhy the job failed; null unless status is `failed`.
data[].polling_urlstringRelative URL to poll for the job state; same as retrieveVideo for this job.
data[].unsigned_urlsarray<string>Relative URLs of the finished output; empty until the video is ready. Download them with the same API key.
data[].usageobjectCost of the job; present once a price applies.
has_morebooleanWhether more jobs exist beyond this page; pass `last_id` as `after` to read them.
first_idstring | nullId of the first job in this page; null for an empty page.
last_idstring | nullId of the last job in this page; null for an empty page.

先创建视频,保存返回的 id;再读取视频轮询 status,queued / in_progress 时继续等待,failed 时停止并查看 error;只有 completed 后才下载视频内容。

读取视频

先调用「创建视频」,用返回的 ID 替换 video_123;下载前须轮询至 completed。

GET /model/v1/videos/{video_id}● 支持

请求参数

  • video_idstring必填

    path: Id of the video job whose output you want, the `id` returned by createVideo. The job must be completed; before that the call answers 400.

返回

200

按输出秒数计费;每秒价格见 GET /model/v1/models 的 pricing.video_second(USD/秒)。

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

响应

HTTP 200

Success

application/json

名称类型说明
idstringId of the video job; pass it as `video_id` to retrieve, download or delete it.
objectstringObject type; always `video`.
modelstringModel that generates the video.
statusstringLifecycle of the job. Poll until it is `completed` or `failed`.
progressintegerProgress from 0 to 100. It is 0 until the job completes and 100 once it has.
created_atintegerUnix time in seconds at which the job was created.
completed_atinteger | nullUnix time in seconds at which the job completed; null until then.
expires_atinteger | nullUnix time in seconds after which the output expires; null because outputs currently have no expiry.
secondsstringLength of the video in seconds, as a string; for a completed job it is the delivered length.
sizestringResolution of the video as `WIDTHxHEIGHT`; null when the provider did not report one.
promptstring | nullPrompt the job was created with.
remixed_from_video_idnullAlways null; remix is not supported.
errorobject | nullWhy the job failed; null unless status is `failed`.
error.codestringMachine-readable failure code.
error.messagestringHuman-readable failure message.
polling_urlstringRelative URL to poll for the job state; same as retrieveVideo for this job.
unsigned_urlsarray<string>Relative URLs of the finished output; empty until the video is ready. Download them with the same API key.
usageobjectCost of the job; present once a price applies.
usage.costnumberCost of the job in USD: delivered seconds times the per-second price once completed, 0 while running.

先创建视频,保存返回的 id;再读取视频轮询 status,queued / in_progress 时继续等待,failed 时停止并查看 error;只有 completed 后才下载视频内容。

下载视频内容

先调用「创建视频」,用返回的 ID 替换 video_123;下载前须轮询至 completed。

GET /model/v1/videos/{video_id}/content● 支持

请求参数

  • video_idstring必填

    path: Id of the video job whose output you want, the `id` returned by createVideo. The job must be completed; before that the call answers 400.

  • variantany可选◐ 部分支持
    默认 "video"

    query: Spritesheet is not available in this release (400).

    video、thumbnail 生效;spritesheet 返回 400。

    取值 videothumbnailspritesheet
  • indexinteger可选◐ 部分支持

    query: Output index; this release produces index 0. variant takes precedence.

    视频仅支持 index=0;大于 0 或负数返回 400。variant=thumbnail 时 index 接受但当前不生效。

返回

200

按输出秒数计费;每秒价格见 GET /model/v1/models 的 pricing.video_second(USD/秒)。

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

响应

HTTP 200

Video or thumbnail bytes

video/mp4

名称类型说明
$string (binary)

image/jpeg

名称类型说明
$string (binary)

先创建视频,保存返回的 id;再读取视频轮询 status,queued / in_progress 时继续等待,failed 时停止并查看 error;只有 completed 后才下载视频内容。

删除视频

先调用「创建视频」,用返回的 ID 替换 video_123;下载前须轮询至 completed。

DELETE /model/v1/videos/{video_id}● 支持

请求参数

  • video_idstring必填

    path: Id of the video job whose output you want, the `id` returned by createVideo. The job must be completed; before that the call answers 400.

返回

200

按输出秒数计费;每秒价格见 GET /model/v1/models 的 pricing.video_second(USD/秒)。

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

响应

HTTP 200

Success

application/json

名称类型说明
idstringId of the deleted video job.
objectstringObject type; always `video.deleted`.
deletedbooleanAlways true; the job is no longer readable.

先创建视频,保存返回的 id;再读取视频轮询 status,queued / in_progress 时继续等待,failed 时停止并查看 error;只有 completed 后才下载视频内容。

先调用「创建视频」,用返回的 ID 替换 video_123;下载前须轮询至 completed。

POST /model/v1/videos/{video_id}/remix○ 未支持

请求参数

  • video_idstring必填

    path: Id of the video job whose output you want, the `id` returned by createVideo. The job must be completed; before that the call answers 400.

返回

400 混剪尚未支持,请勿重试。

未支持,调用返回 400;不要重试。

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

响应

此端点没有声明成功响应。

先创建视频,保存返回的 id;再读取视频轮询 status,queued / in_progress 时继续等待,failed 时停止并查看 error;只有 completed 后才下载视频内容。

发送消息

POST /model/v1/messages● 支持

官方文档 ↗

请求体

  • modelstring必填◐ 部分支持

    Body param: The model that will complete your prompt. See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    deepseek-v4-pro、glm-5.3-flash、qwen3.8-flash、claude-opus-5 可调用;deepseek-v4-flash 在此协议面返回 400。

  • messagesarray必填◐ 部分支持

    Body param: Input messages. Our models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn. Each input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages. If the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response. Example with a single `user` message: ```json [{ "role": "user", "content": "Hello, Claude" }] ``` Example with multiple conversational turns: ```json [ { "role": "user", "content": "Hello there." }, { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" }, { "role": "user", "content": "Can you explain LLMs in plain English?" } ] ``` Example with a partially-filled response from Claude: ```json [ { "role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun" }, { "role": "assistant", "content": "The best answer is (" } ] ``` Each input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `"text"`. The following input messages are equivalent: ```json { "role": "user", "content": "Hello, Claude" } ``` ```json { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] } ``` See [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages). Note that if you want to include a [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role), you can use the top-level `system` parameter — there is no `"system"` role for input messages in the Messages API. There is a limit of 100,000 messages in a single request.

    文本和工具往返生效;document 的托管 file_id 返回 400,qwen3.8-flash 可读取内联 PDF;图片有模型尺寸限制。

    ▸ 展开子字段(2)
    • contentstring | array必填

      Message content: a plain string (shorthand for one text block) or an array of content blocks such as text, image, document, tool_use and tool_result.

    • rolestring必填

      Who produced the message. Use user for your turns and assistant to replay earlier model turns; system-role messages are accepted by the shape but system instructions normally go in the top-level system field.

  • max_tokensnumber必填

    Body param: The maximum number of tokens to generate before stopping. Note that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate. Set to `0` to populate the [prompt cache](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#pre-warming-the-cache) without generating a response. Different models have different maximum values for this parameter. See [models](https://platform.claude.com/docs/en/about-claude/models/overview) for details.

    限制输出 token,思考也占用预算。

  • streamboolean可选◐ 部分支持

    Body param: Whether to incrementally stream the response using server-sent events. See [streaming](https://platform.claude.com/docs/en/build-with-claude/streaming) for details.

    流式正文和工具事件可用;可能在正文前出现额外 message_delta,message_start 的用量为 0。

  • systemstring | array可选

    Body param: System prompt. A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role).

    已验证生效。

  • temperaturenumber可选

    Sampling temperature between 0 and 1; defaults are model specific.

  • top_pnumber可选

    Nucleus sampling: only tokens within this cumulative probability are considered.

  • toolsarray可选

    Body param: Definitions of tools that the model may use. If you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks. There are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool)). Each tool definition includes: - `name`: Name of the tool. - `description`: Optional, but strongly-recommended description of the tool. - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks. For example, if you defined `tools` as: ```json [ { "name": "get_stock_price", "description": "Get the current stock price for a given ticker symbol.", "input_schema": { "type": "object", "properties": { "ticker": { "type": "string", "description": "The stock ticker symbol, e.g. AAPL for Apple Inc." } }, "required": ["ticker"] } } ] ``` And then asked the model "What's the S&P 500 at today?", the model might produce `tool_use` content blocks in the response like this: ```json [ { "type": "tool_use", "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "name": "get_stock_price", "input": { "ticker": "^GSPC" } } ] ``` You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an input, and return the following back to the model in a subsequent `user` message: ```json [ { "type": "tool_result", "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "content": "259.75 USD" } ] ``` Tools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output. See our [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) for more details.

    已验证生效。

  • tool_choiceobject可选◐ 部分支持

    Body param: How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.

    qwen3.8-flash 四种模式生效;deepseek-v4-pro 忽略 any/tool/none;glm-5.3-flash 忽略 none。

    ▸ 展开子字段(3)
    • typestring必填

      Disable tool calls for this request.

      取值 none
    • disable_parallel_tool_useboolean可选○ 当前不生效

      Whether to disable parallel tool use. Defaults to `false`. If set to `true`, the model will output exactly one tool use.

      接受但当前不生效。true 仍可能返回多个工具调用。

    • namestring必填

      The name of the tool to use.

  • cache_controlobject可选◐ 部分支持

    Body param: Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.

    deepseek-v4-pro、qwen3.8-flash、glm-5.3-flash 有隐式缓存命中,但不能据此确认标记生效;claude-opus-5 未命中缓存,ttl=1h 未见效果。

    ▸ 展开子字段(2)
    • typestring必填

      Always `ephemeral`. Discriminator that marks this object as a CacheControlEphemeral in a `type`-tagged union.

      取值 ephemeral
    • ttlstring可选

      The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.

  • ▸ 更多参数(16)
    • containerstring | object可选○ 当前不生效

      接受并忽略 container;平台尚未实现此能力。

      ▸ 展开子字段(2)
      • idstring可选

        Container id

      • skillsarray可选

        List of skills to load in the container

    • inference_geostring可选○ 当前不生效

      接受并忽略 inference_geo;平台尚未实现此能力。

    • metadataobject可选◐ 部分支持

      Body param: An object describing metadata about the request.

      接受 metadata;metadata.user_id 由同协议线路传递,不承诺上游回显。

      ▸ 展开子字段(1)
      • user_idstring可选

        An external identifier for the user who is associated with the request. This should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number.

    • output_configobject可选

      Body param: Configuration options for the model's output, such as the output format.

      ▸ 展开子字段(2)
      • effortstring可选◐ 部分支持

        All possible effort levels.

        deepseek-v4-pro 仅 high/xhigh 可用,其余返回 400;qwen3.8-flash 全档返回 400;glm-5.3-flash 接受各档但消耗不随档位单调变化。

      • formatobject可选◐ 部分支持

        A schema to specify Claude's output format in responses. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)

        json_schema 在 deepseek-v4-pro、qwen3.8-flash 生效;glm-5.3-flash 与 thinking 同传返回 400。

    • service_tierstring可选○ 当前不生效

      接受并忽略 service_tier;平台尚未实现此能力。

    • stop_sequencesarray可选◐ 部分支持

      Body param: Custom text sequences that will cause the model to stop generating. Our models will normally stop when they have naturally completed their turn, which will result in a response `stop_reason` of `"end_turn"`. If you want the model to stop generating when it encounters custom strings of text, you can use the `stop_sequences` parameter. If the model encounters one of the custom sequences, the response `stop_reason` value will be `"stop_sequence"` and the response `stop_sequence` value will contain the matched stop sequence.

      deepseek-v4-pro、qwen3.8-flash 生效;glm-5.3-flash 文本截断但 stop_reason 和 stop_sequence 未准确反映。

    • thinkingobject可选◐ 部分支持

      Body param: Configuration for enabling Claude's extended thinking. When enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit. See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.

      disabled 在 deepseek-v4-pro、qwen3.8-flash 生效;glm-5.3-flash 携带任何 thinking 都返回 400。adaptive 在已测的 deepseek-v4-pro、qwen3.8-flash 也返回 400。

      ▸ 展开子字段(3)
      • budget_tokensnumber必填◐ 部分支持

        Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality. Must be ≥1024 and less than `max_tokens`. See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.

        deepseek-v4-pro、qwen3.8-flash 接受,但预算不构成可靠上限;glm-5.3-flash 返回 400。

      • typestring必填

        Let the model choose its reasoning budget, subject to output_config.effort when supplied.

        取值 adaptive
      • displaystring可选○ 当前不生效

        Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.

        接受但当前不生效。omitted 仍返回完整思考内容。

    • top_knumber可选

      Sample only from the top K options for each token.

    • context_managementobject可选○ 当前不生效

      接受并忽略 context_management;平台尚未实现此能力。

    • diagnosticsobject可选○ 当前不生效

      接受并忽略 diagnostics;平台尚未实现此能力。

    • mcp_serversarray可选○ 当前不生效

      接受并忽略 mcp_servers;平台尚未实现此能力。

    • speedstring可选○ 当前不生效

      接受并忽略 speed;平台尚未实现此能力。

    • output_formatobject可选○ 当前不生效

      接受并忽略此旧字段;结构化输出使用 output_config.format。

    • compactionobject可选○ 未支持

      已识别 compaction;尚未实现,传入返回 400 并明确说明不支持。

    • fallback_credit_tokenstring可选○ 未支持

      已识别 fallback_credit_token;尚未实现,传入返回 400 并明确说明不支持。

    • fallbacksstring可选○ 未支持

      已识别 fallbacks;尚未实现,传入返回 400 并明确说明不支持。

返回

200

stream=true 时以 SSE 增量返回(text/event-stream)。

未知顶层字段原样转发给同协议上游,由上游决定是否接受;已声明字段的类型与取值范围仍会校验,不合法时返回 400 并点名字段。

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

响应

HTTP 200

Message created

application/json

名称类型说明
idstringUnique object identifier. The format and length of IDs may change over time.
containernull | objectInformation about the container used in the request (for the code execution tool)
container.idstringIdentifier for the container used in this request
container.expires_atstringThe time at which the container will expire.
container.skillsnull | array<object>Skills loaded in the container
contentarray<object>Content generated by the model. This is an array of content blocks, each of which has a `type` that determines its shape. Example: ```json [{ "type": "text", "text": "Hi, I'm Claude." }] ``` If the request input `messages` ended with an `assistant` turn, then the response `content` will continue directly from that last turn. You can use this to constrain the model's output. For example, if the input `messages` were: ```json [ { "role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun" }, { "role": "assistant", "content": "The best answer is (" } ] ``` Then the response `content` might be: ```json [{ "type": "text", "text": "B)" }] ```
content[].citationsnull | array<object>Citations supporting the text block. The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.
content[].textstringThe text generated by the model.
content[].typestringAlways `text`. Discriminator that marks this object as a TextBlock in a `type`-tagged union. / Always `thinking`. Discriminator that marks this object as a ThinkingBlock in a `type`-tagged union. / Always `redacted_thinking`. Discriminator that marks this object as a RedactedThinkingBlock in a `type`-tagged union. / Always `tool_use`. Discriminator that marks this object as a ToolUseBlock in a `type`-tagged union. / Always `server_tool_use`. Discriminator that marks this object as a ServerToolUseBlock in a `type`-tagged union. / Always `web_search_tool_result`. Discriminator that marks this object as a WebSearchToolResultBlock in a `type`-tagged union. / Always `web_fetch_tool_result`. Discriminator that marks this object as a WebFetchToolResultBlock in a `type`-tagged union. / Always `code_execution_tool_result`. Discriminator that marks this object as a CodeExecutionToolResultBlock in a `type`-tagged union. / Always `bash_code_execution_tool_result`. Discriminator that marks this object as a BashCodeExecutionToolResultBlock in a `type`-tagged union. / Always `text_editor_code_execution_tool_result`. Discriminator that marks this object as a TextEditorCodeExecutionToolResultBlock in a `type`-tagged union. / Always `tool_search_tool_result`. Discriminator that marks this object as a ToolSearchToolResultBlock in a `type`-tagged union. / Always `container_upload`. Discriminator that marks this object as a ContainerUploadBlock in a `type`-tagged union.
content[].signaturestringA value used to verify that this thinking block was generated by Claude when it is passed back to the API. This is an opaque field and should not be interpreted or parsed. When passing thinking blocks back to the API (required when using tools with extended thinking), pass them back exactly as received, with this field intact. See extended thinking for details.
content[].thinkingstringThe text of Claude's thinking process for this block.
content[].datastringThe contents of this redacted thinking block, returned when portions of the model's thinking were safety-redacted. This field is opaque and encrypted, with no readable content. Pass `redacted_thinking` blocks back to the API unchanged when continuing a multi-turn conversation. See extended thinking for details.
content[].idstringId of the tool call; send it back as tool_use_id in the tool_result block that answers it. / Id of the server tool call; the matching result block repeats it as tool_use_id.
content[].callerobjectWhich party invoked the tool: the model directly or a code execution tool. / Which party invoked the server tool: the model directly or a code execution tool. / Which party invoked the search: the model directly or a code execution tool. / Which party invoked the fetch: the model directly or a code execution tool.
content[].inputanyArguments the model chose, as a JSON object that follows the tool's input_schema. / Arguments the model passed to the server tool, as a JSON object.
content[].namestringName of the tool the model wants to call. / Name of the server tool the model called, such as web_search, web_fetch or code_execution.
content[].toolset_namenull | stringFor a toolset member tool_use, the toolset family.
content[].contentobject | array<object> | object | object | object | object | objectSearch results (array of web_search_result blocks) or an error object. / The fetched document or an error object. / Result of the code execution: a result block, an encrypted result block, or an error object. / Result of the bash command: a result block or an error object. / Result of the text editor command: a view, create or str_replace result block, or an error object. / Result of the tool search: a search result block that lists tool references, or an error object.
content[].tool_use_idstringId of the web_search server tool call this result belongs to. / Id of the web_fetch server tool call this result belongs to. / Id of the code_execution server tool call this result belongs to. / Id of the bash_code_execution server tool call this result belongs to. / Id of the text_editor_code_execution server tool call this result belongs to. / Id of the tool search server tool call this result belongs to.
content[].file_idstringId of the file that was uploaded into the code execution container.
modelstringThe model that will complete your prompt. See models for additional details and options.
rolestringConversational role of the generated message. This will always be `"assistant"`.
stop_detailsnull | objectStructured information about a refusal.
stop_details.categorynull | stringThe policy category that triggered a refusal. - `cyber` - The request could enable cyber harm, such as malware or exploit development. Benign cybersecurity work can also trigger this category. - `bio` - The request could enable biological harm, such as dangerous lab methods. Beneficial life sciences work can also trigger this category. - `frontier_llm` - The request could assist the development of competing AI models, which is restricted under Anthropic's commercial terms. Benign machine learning work can also trigger this category. - `reasoning_extraction` - The request asks the model to reproduce its internal reasoning in the response text. To get reasoning in a structured form instead, use adaptive thinking. - `general_harms` - The request could be related to an area that was determined as harmful. Benign work might sometimes trigger this category.
stop_details.explanationnull | stringHuman-readable explanation of the refusal. This text is not guaranteed to be stable. `null` when no explanation is available for the category.
stop_details.typestringAlways `refusal`. Discriminator that marks this object as a RefusalStopDetails in a `type`-tagged union.
stop_reasonnull | stringThe reason that we stopped. This may be one the following values: - `"end_turn"`: the model reached a natural stopping point - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated - `"tool_use"`: the model invoked one or more tools - `"pause_turn"`: we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue. - `"refusal"`: when streaming classifiers intervene to handle potential policy violations - `"model_context_window_exceeded"`: we exceeded the model's context window In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.
stop_sequencenull | stringWhich custom stop sequence was generated, if any. This value will be a non-null string if one of your custom stop sequences was generated.
typestringObject type. For Messages, this is always `"message"`.
usageobjectBilling and rate-limit usage. Anthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems. Under the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response. For example, `output_tokens` will be non-zero, even for an empty string response from Claude. Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.
usage.cache_creationnull | objectBreakdown of cached tokens by TTL
usage.cache_creation_input_tokensnull | numberThe number of input tokens used to create the cache entry.
usage.cache_read_input_tokensnull | numberThe number of input tokens read from the cache.
usage.inference_geonull | stringThe geographic region where inference was performed for this request.
usage.input_tokensnumberThe number of input tokens which were used.
usage.output_tokensnumberThe number of output tokens which were used.
usage.output_tokens_detailsnull | objectBreakdown of output tokens by category. `output_tokens` remains the inclusive, authoritative total used for billing. This object provides a read-only decomposition for observability — for example, how many of the billed output tokens were spent on internal reasoning that may have been summarized before being returned to you.
usage.server_tool_usenull | objectThe number of server tool requests.
usage.service_tiernull | stringIf the request used the priority, standard, or batch tier.

text/event-stream — chunk / 事件对象

名称类型说明
idstringOptional id of the server-sent event.
eventstringName of the server-sent event.
dataobject完整 SDK RawMessageStreamEvent union
data.deltaobjectFinal fields of the message sent with message_delta: why generation stopped and the container. / The incremental change to the content block at index.
data.typestringAlways `message_delta`. Discriminator that marks this object as a RawMessageDeltaEvent in a `type`-tagged union. / Always `content_block_delta`. Discriminator that marks this object as a RawContentBlockDeltaEvent in a `type`-tagged union. / Always `message_start`. Discriminator that marks this object as a RawMessageStartEvent in a `type`-tagged union. / Always `message_stop`. Discriminator that marks this object as a RawMessageStopEvent in a `type`-tagged union. / Always `content_block_start`. Discriminator that marks this object as a RawContentBlockStartEvent in a `type`-tagged union. / Always `content_block_stop`. Discriminator that marks this object as a RawContentBlockStopEvent in a `type`-tagged union.
data.usageobjectBilling and rate-limit usage. Anthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems. Under the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response. For example, `output_tokens` will be non-zero, even for an empty string response from Claude. Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.
data.indexnumberZero-based index of the content block this delta applies to. / Zero-based index of the content block that starts. / Zero-based index of the content block that ends.
data.messageobjectThe complete Message object being started; its content is empty at message_start and filled by the following content_block events.
data.content_blockobjectThe content block as it starts, with empty text or input to be filled by deltas.

POST /model/v1/messages/count_tokens◐ 部分支持

官方文档 ↗

请求体

  • modelstring必填○ 当前不生效

    Body param: The model that will complete your prompt. See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    接受但当前不生效。估算与模型无关,缺失或不存在的模型名仍可返回计数。

  • messagesarray必填◐ 部分支持

    Body param: Input messages. Our models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn. Each input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages. If the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response. Example with a single `user` message: ```json [{ "role": "user", "content": "Hello, Claude" }] ``` Example with multiple conversational turns: ```json [ { "role": "user", "content": "Hello there." }, { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" }, { "role": "user", "content": "Can you explain LLMs in plain English?" } ] ``` Example with a partially-filled response from Claude: ```json [ { "role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun" }, { "role": "assistant", "content": "The best answer is (" } ] ``` Each input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `"text"`. The following input messages are equivalent: ```json { "role": "user", "content": "Hello, Claude" } ``` ```json { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] } ``` See [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages). Note that if you want to include a [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role), you can use the top-level `system` parameter — there is no `"system"` role for input messages in the Messages API. There is a limit of 100,000 messages in a single request.

    仅按字符粗估,不能作为模型精确 token 数。

    ▸ 展开子字段(2)
    • contentstring | array必填

      Message content: a plain string (shorthand for one text block) or an array of content blocks such as text, image, document, tool_use and tool_result.

    • rolestring必填

      Who produced the message. Use user for your turns and assistant to replay earlier model turns; system-role messages are accepted by the shape but system instructions normally go in the top-level system field.

  • systemstring | array可选

    Body param: System prompt. A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role).

    计入估算。

  • toolsarray可选

    Body param: Definitions of tools that the model may use. If you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks. There are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool)). Each tool definition includes: - `name`: Name of the tool. - `description`: Optional, but strongly-recommended description of the tool. - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks. For example, if you defined `tools` as: ```json [ { "name": "get_stock_price", "description": "Get the current stock price for a given ticker symbol.", "input_schema": { "type": "object", "properties": { "ticker": { "type": "string", "description": "The stock ticker symbol, e.g. AAPL for Apple Inc." } }, "required": ["ticker"] } } ] ``` And then asked the model "What's the S&P 500 at today?", the model might produce `tool_use` content blocks in the response like this: ```json [ { "type": "tool_use", "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "name": "get_stock_price", "input": { "ticker": "^GSPC" } } ] ``` You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an input, and return the following back to the model in a subsequent `user` message: ```json [ { "type": "tool_result", "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "content": "259.75 USD" } ] ``` Tools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output. See our [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) for more details.

    计入估算。

  • tool_choiceobject可选○ 当前不生效

    Body param: How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.

    接受但当前不生效。不影响计数。

    ▸ 展开子字段(3)
    • typestring必填

      Disable tool calls for this request.

      取值 none
    • disable_parallel_tool_useboolean可选

      Whether to disable parallel tool use. Defaults to `false`. If set to `true`, the model will output exactly one tool use.

    • namestring必填

      The name of the tool to use.

  • cache_controlobject可选○ 当前不生效

    Body param: Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.

    接受但当前不生效。不影响计数。

    ▸ 展开子字段(2)
    • typestring必填

      Always `ephemeral`. Discriminator that marks this object as a CacheControlEphemeral in a `type`-tagged union.

      取值 ephemeral
    • ttlstring可选

      The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`. See [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) for details.

  • output_configobject可选○ 当前不生效

    Body param: Configuration options for the model's output, such as the output format.

    接受但当前不生效。不影响计数。

    ▸ 展开子字段(2)
    • effortstring可选

      All possible effort levels.

    • formatobject可选

      A schema to specify Claude's output format in responses. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)

  • thinkingobject可选○ 当前不生效

    Body param: Configuration for enabling Claude's extended thinking. When enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit. See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.

    接受但当前不生效。不影响计数。

    ▸ 展开子字段(3)
    • budget_tokensnumber必填

      Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality. Must be ≥1024 and less than `max_tokens`. See [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) for details.

    • typestring必填

      Let the model choose its reasoning budget, subject to output_config.effort when supplied.

      取值 adaptive
    • displaystring可选

      Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.

返回

200

按模型族校准的估算值(包括中文和工具定义),响应头为 x-praxis-token-count: estimated;不能用作精确用量或计费依据。

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

响应

HTTP 200

Token count

application/json

名称类型说明
input_tokensnumberThe total number of tokens across the provided list of messages, system prompt, and tools.

列出模型

GET /model/v1/models● 支持

官方文档 ↗

请求参数

  • supported_apiarray可选

    query: Match any comma-separated declared protocol ID; omitted or empty includes all models. Combined with type and output_modalities using AND. Invalid IDs return 400 with all legal values.

  • typearray可选

    query: Filter by one or more model types (comma-separated).

    按 type 筛选,多个值用逗号分隔;非法值返回 400 并列出合法值。

  • output_modalitiesarray可选

    query: Match any comma-separated output modality; all disables modality filtering. Combined with type using AND.

    匹配任一逗号分隔的输出模态;all 不限制模态,与 type 条件同时生效。

  • limitstring可选○ 当前不生效

    query: Accepted for compatibility and ignored: this endpoint always returns the full model catalog. Filter with type and output_modalities instead.

    接受但当前不生效;此端点返回完整模型目录。

  • qstring可选○ 当前不生效

    query: Accepted for compatibility and ignored: this endpoint always returns the full model catalog. Filter with type and output_modalities, or match ids on the client.

    接受但当前不生效;此端点返回完整模型目录。

返回

200 list

OCR 模型的 type 为 ocr,pricing.page 是 USD/页的十进制字符串,为 Praxis 对 Vercel 模型列表形状的扩展;其余四项 token 价格为 0。其它模型不带 pricing.page。

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

响应

HTTP 200

Model list

application/json

名称类型说明
objectstringObject type; always `list`.
dataarray<object>Published models, in the order the catalog returns them, filtered by type and output_modalities when given.
data[].idstringModel id to pass as `model` in other calls. It can carry a creator prefix such as deepseek/deepseek-v4-pro.
data[].objectstringObject type; always `model`.
data[].creatednumberUnix time in seconds at which the model was first published.
data[].owned_bystringOrganization that serves the model on this platform; always `deepractice`.
data[].namestringDisplay name, prefixed with the vendor when one is known, for example `Vendor: Model`.
data[].descriptionstring | nullFree-text description of the model; null when none is published.
data[].context_windownumber | nullMaximum context length in tokens (input plus output); null when the catalog has no figure.
data[].max_tokensnumber | nullMaximum number of output tokens the model can produce in one call; null when the catalog has no figure.
data[].typestringKind of model; it decides which endpoint accepts it.
data[].supported_apisarray<string>Declared protocol IDs in stable lexicographic order; an empty array means no protocol is declared. Use these IDs with supported_api to find models for an operation.
data[].tagsarray<string>Capability tags of the model such as `tools`, `vision` or `reasoning`; use them to filter for features.
data[].architectureobjectNative modalities of the model.
data[].x_praxisobjectPlatform extension. input_modalities states, per input format, how the model takes it.
data[].pricingobjectPrices in USD per named unit, as decimal strings. A unit that is absent is unpriced, which is not the same as free.
data[].releasedstringDate (YYYY-MM-DD, UTC) on which the model was first published.

读取模型

GET /model/v1/models/{model}● 支持

官方文档 ↗

请求参数

  • modelstring必填

    path: Id of the model to read. It may carry a creator prefix with a slash, such as deepseek/deepseek-v4-pro, so the value runs to the end of the path. Ids come from the `id` field of listModels; an unknown id answers 404.

返回

200 model

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

响应

HTTP 200

Model

application/json

名称类型说明
idstringModel id to pass as `model` in other calls. It can carry a creator prefix such as deepseek/deepseek-v4-pro.
objectstringObject type; always `model`.
creatednumberUnix time in seconds at which the model was first published.
owned_bystringOrganization that serves the model on this platform; always `deepractice`.
namestringDisplay name, prefixed with the vendor when one is known, for example `Vendor: Model`.
descriptionstring | nullFree-text description of the model; null when none is published.
context_windownumber | nullMaximum context length in tokens (input plus output); null when the catalog has no figure.
max_tokensnumber | nullMaximum number of output tokens the model can produce in one call; null when the catalog has no figure.
typestringKind of model; it decides which endpoint accepts it.
supported_apisarray<string>Declared protocol IDs in stable lexicographic order; an empty array means no protocol is declared. Use these IDs with supported_api to find models for an operation.
tagsarray<string>Capability tags of the model such as `tools`, `vision` or `reasoning`; use them to filter for features.
architectureobjectNative modalities of the model.
architecture.modalitystringNative modalities as `input+input->output+output`, for example `text+image->text`.
architecture.input_modalitiesarray<string>Input modalities the model accepts natively, for example text, image, file or audio.
architecture.output_modalitiesarray<string>Output modalities the model produces, for example text, image, audio, video, embeddings or rerank.
architecture.tokenizerstring | nullTokenizer family; null because the platform does not publish it.
architecture.instruct_typestring | nullInstruction template type; null because the platform does not publish it.
x_praxisobjectPlatform extension. input_modalities states, per input format, how the model takes it.
x_praxis.input_modalitiesobjectPer input format, whether the model takes it natively, through a conversion step, or not at all. Conversion depends on the file-parser plugin settings.
pricingobjectPrices in USD per named unit, as decimal strings. A unit that is absent is unpriced, which is not the same as free.
pricing.inputstringUSD per input token.
pricing.outputstringUSD per output token.
pricing.input_cache_readstringUSD per input token that is read from the prompt cache.
pricing.input_cache_writestringUSD per input token that is written to the prompt cache.
pricing.imagestringUSD per image; present only for a flat registry price.
pricing.video_secondstringPraxis extension: USD per second of output video.
pricing.audio_input_minutestringPraxis extension: USD per minute of input audio.
pricing.audio_output_minutestringPraxis extension: USD per minute of output audio.
pricing.input_characterstringPraxis extension: USD per input character.
pricing.pagestringPraxis extension: USD per page, present only for OCR models; not a Vercel AI Gateway pricing field.
releasedstringDate (YYYY-MM-DD, UTC) on which the model was first published.

查询生成记录

先调用「对话」,从响应头 X-Praxis-Generation-Id 取得 id,替换 gen_123。

GET /model/v1/generation● 支持

官方文档 ↗

请求参数

  • idstring必填◐ 部分支持

    query: Generation ID from the X-Praxis-Generation-Id response header of the model request.

    使用 /model 响应头 X-Praxis-Generation-Id;响应体 id 和 X-Request-Id 不能查询,返回 404。

返回

200

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

响应

HTTP 200

Generation record

application/json

名称类型说明
idstringGeneration id that was queried.
modelstringModel that served the generation.
costnumber | nullCost charged for the generation in USD; null when not yet priced.
usageobjectToken usage of the generation.
usage.prompt_tokensnumberNumber of prompt tokens.
usage.completion_tokensnumberNumber of tokens in the completion.
usage.total_tokensnumberPrompt plus completion tokens.
usage.cached_input_tokensnumberPrompt tokens served from the prompt cache; null when not reported.
latency_msnumber | nullLatency of the generation in milliseconds; null when not recorded.
creatednumberUnix time in seconds at which the generation was recorded.

创建会话

POST /model/v1/conversations● 支持

官方文档 ↗

请求体

  • itemsarray可选

    Initial items, at most 20 per request. Router support (supported): Verified to take effect.

    已验证生效。

  • metadataobject可选

    Up to 16 string key/value pairs stored with the conversation; keys at most 64 characters and values at most 512. Router support (supported): Verified to take effect.

    已验证生效。

返回

200 conversation

创建一个会话,可选携带初始 items(一次最多 20 条)与 metadata。会话按租户分区,创建者是唯一能引用它的租户。

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

响应

HTTP 200

The created conversation

application/json

名称类型说明
idstringId of the conversation, such as `conv_...`; use it as `conversation_id` in conversation calls and as `conversation` in createResponse.
objectstringObject type; always `conversation`.
created_atintegerUnix time in seconds at which the conversation was created.
metadataobjectUp to 16 string key/value pairs; keys at most 64 characters and values at most 512.

读取会话

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

GET /model/v1/conversations/{conversation_id}● 支持

官方文档 ↗

请求参数

  • 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.

返回

200 conversation

按 ID 读取一个会话。不存在或属于其他租户都返回 404 conversation_not_found。

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

响应

HTTP 200

The conversation

application/json

名称类型说明
idstringId of the conversation, such as `conv_...`; use it as `conversation_id` in conversation calls and as `conversation` in createResponse.
objectstringObject type; always `conversation`.
created_atintegerUnix time in seconds at which the conversation was created.
metadataobjectUp to 16 string key/value pairs; keys at most 64 characters and values at most 512.

更新会话

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

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

官方文档 ↗

请求参数

  • 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.

  • metadataobject必填

    Replacement metadata. The whole object replaces the old one; it is not merged. Up to 16 pairs, keys at most 64 characters and values at most 512. Router support (supported): Verified to take effect.

    已验证生效。

返回

200 conversation

更新一个会话的 metadata——整体替换,不与已有 metadata 合并。

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

响应

HTTP 200

The updated conversation

application/json

名称类型说明
idstringId of the conversation, such as `conv_...`; use it as `conversation_id` in conversation calls and as `conversation` in createResponse.
objectstringObject type; always `conversation`.
created_atintegerUnix time in seconds at which the conversation was created.
metadataobjectUp to 16 string key/value pairs; keys at most 64 characters and values at most 512.

创建会话条目

先调用「创建对话」拿到 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)返回,参见 错误码

响应

HTTP 200

The items just added

application/json

名称类型说明
objectstringObject type; always `list`.
dataarray<object>Items of the conversation, in the order the list requested.
first_idstringId of the first item of this page; null for an empty page.
last_idstringId of the last item of this page; null for an empty page.
has_morebooleanWhether more items exist beyond this page; pass `last_id` as `after` to read them.

列出会话条目

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

GET /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.

  • limitinteger可选
    默认 20

    query: Maximum items per page (values above 100 are clamped).

  • afterstring可选

    query: Item ID from the previous page; returns items after this cursor.

  • orderstring可选
    默认 "desc"

    query: Sort by stored creation order.

    取值 ascdesc

返回

200 list

按创建顺序列出会话的 items,支持 limit/after/order 分页参数。

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

响应

HTTP 200

The conversation's items

application/json

名称类型说明
objectstringObject type; always `list`.
dataarray<object>Items of the conversation, in the order the list requested.
first_idstringId of the first item of this page; null for an empty page.
last_idstringId of the last item of this page; null for an empty page.
has_morebooleanWhether more items exist beyond this page; pass `last_id` as `after` to read them.

读取会话条目

先调用「创建对话」拿到 conv_ 开头的 ID,替换 conv_123。 条目 ID 取自「添加对话条目」或「列出对话条目」,替换 item_123。

GET /model/v1/conversations/{conversation_id}/items/{item_id}● 支持

官方文档 ↗

请求参数

  • 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.

  • item_idstring必填

    path: Id of the item to read, from the `id` of an item returned by createConversationItems or listConversationItems. An id that is not in the conversation answers 404.

返回

200

按 ID 读取会话里的单条 item。

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

响应

HTTP 200

The item

application/json

名称类型说明
$object

删除会话条目

先调用「创建对话」拿到 conv_ 开头的 ID,替换 conv_123。 条目 ID 取自「添加对话条目」或「列出对话条目」,替换 item_123。

DELETE /model/v1/conversations/{conversation_id}/items/{item_id}● 支持

官方文档 ↗

请求参数

  • 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.

  • item_idstring必填

    path: Id of the item to delete, from the `id` of an item returned by createConversationItems or listConversationItems. An id that is not in the conversation answers 404.

返回

200 conversation

删除会话里的单条 item,返回该会话对象(不是被删除的 item)。

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

响应

HTTP 200

The conversation, with the item removed

application/json

名称类型说明
idstringId of the conversation, such as `conv_...`; use it as `conversation_id` in conversation calls and as `conversation` in createResponse.
objectstringObject type; always `conversation`.
created_atintegerUnix time in seconds at which the conversation was created.
metadataobjectUp to 16 string key/value pairs; keys at most 64 characters and values at most 512.

删除会话

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

DELETE /model/v1/conversations/{conversation_id}● 支持

官方文档 ↗

请求参数

  • 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.

返回

200 conversation.deleted

删除一个会话。删除后该会话与其 items 都不能再被引用(包括作为 Responses create 的 conversation 参数)。

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

响应

HTTP 200

Deletion confirmation

application/json

名称类型说明
idstringId of the deleted conversation.
objectstringObject type; always `conversation.deleted`.
deletedbooleanAlways true; neither the conversation nor its items can be referenced again.

沙箱 API

基础地址

加载中…

接入

加载中…

HTTP 与 SDK 接入

用 HTTP 直接调用 /sandbox/v1,请求携带 X-API-Key。官方 E2B SDK 请使用 E2B 兼容接口,不能只修改 API 地址来调用这里的接口。

HTTP 基础地址:。

端点

方法路径说明支持
POST/v1/sandboxes创建沙箱● 支持
POST/v1/sandboxes/{sandboxID}/upgrade升级为完整沙箱● 支持
GET/v1/sandboxes列出沙箱● 支持
GET/v1/sandboxes/{sandboxID}读取沙箱● 支持
PATCH/v1/sandboxes/{sandboxID}重命名沙箱● 支持
GET/v1/sandboxes/{sandboxID}/metrics沙箱指标● 支持
POST/v1/sandboxes/{sandboxID}/timeout设置超时● 支持
POST/v1/sandboxes/{sandboxID}/pause暂停沙箱● 支持
POST/v1/sandboxes/{sandboxID}/connect连接沙箱● 支持
DELETE/v1/sandboxes/{sandboxID}终止沙箱● 支持
GET/v1/templates列出模板● 支持
POST/v1/volumes创建卷● 支持
GET/v1/volumes列出卷● 支持
GET/v1/volumes/{volumeID}读取卷● 支持
DELETE/v1/volumes/{volumeID}删除卷● 支持
POST/v1/sandboxes/{sandboxID}/fork复制沙箱● 支持
POST/v1/sandboxes/{sandboxID}/snapshots创建快照● 支持
GET/v1/snapshots列出快照● 支持
DELETE/v1/snapshots/{snapshotID}删除快照● 支持
PUT/v1/sandboxes/{sandboxID}/network更新网络策略● 支持
GET/v1/sandboxes/{sandboxID}/logs读取沙箱日志● 支持
POST/v1/sandboxes/{sandboxID}/extend延长沙箱● 支持
GET/v1/sandboxes/{sandboxID}/processes列出进程● 支持
GET/v1/sandboxes/{sandboxID}/processes/{processID}/output读取输出● 支持

与官方的差异

  • 快照使用本平台 snap_ 开头的 ID,可作为创建沙箱的 templateID。旧供应商句柄不再接受。暂停的沙箱用「连接沙箱」恢复运行。
  • 仅提供本页声明的端点,webhooks 等未采纳的端点返回 404。
  • 创建沙箱:平台暂未提供 E2B 默认的 base 模板:不带模板参数的 Sandbox.create() 会返回 404,请显式指定模板(可用模板见「列出模板」)。

参数与字段的权威定义以 E2B 官方文档为准。

错误按 E2B 格式返回,参见错误;额度与响应头参见限流。

创建沙箱

POST /sandbox/v1/sandboxes● 支持

E2B 官方文档 ↗

请求体

  • templateIDstring必填

    Identifier of the required template

  • timeoutinteger可选
    默认 300

    Lifetime of the new sandbox in seconds. Defaults to 300 seconds when omitted.

  • autoPauseboolean可选
    默认 false

    Automatically pauses the sandbox after the timeout

  • metadataany可选

    Your own string key/value pairs stored with the sandbox; usable as a filter in listSandboxes.

  • envVarsany可选

    Environment variables as name to value string pairs.

  • allow_internet_accessboolean可选

    Allow sandbox to access the internet. When set to false, it behaves the same as specifying denyOut to 0.0.0.0/0 in the network config.

  • autoPauseMemoryboolean可选
    默认 true

    Controls the snapshot kind taken when the sandbox auto-pauses on timeout (only relevant when autoPause is true). When false, the auto-pause drops the in-memory state and persists only the filesystem (a filesystem-only snapshot); resuming it cold-boots (reboots) the sandbox from disk. Such a snapshot cannot be auto-resumed by traffic and must be resumed explicitly, so it cannot be combined with autoResume. Defaults to true (full memory snapshot).

  • autoResumeobject可选

    Auto-resume configuration for paused sandboxes.

    ▸ 展开子字段(1)
    • enabledboolean必填
      默认 false

      Auto-resume enabled flag for paused sandboxes. Default false.

  • networkobject可选

    Network policy of the sandbox: public access, egress allow and deny lists and proxy.

    ▸ 展开子字段(7)
    • allowPublicTrafficboolean可选
      默认 true

      Specify if the sandbox URLs should be accessible only with authentication.

    • allowOutarray可选

      List of allowed destinations for egress traffic. Each entry can be a CIDR block (e.g. "8.8.8.8/32"), a bare IP address (e.g. "8.8.8.8"), or a domain name (e.g. "example.com", "*.example.com"). Allowed entries always take precedence over denied entries.

    • denyOutarray可选

      List of denied CIDR blocks or IP addresses for egress traffic. Domain names are not supported for deny rules.

    • egressProxyobject可选

      SOCKS5 proxy for sandbox egress. Outbound TCP is tunneled through the proxy after allow/deny filtering; the sandbox is unaware. Domain-matched flows use remote DNS (ATYP=domain).

    • maskRequestHoststring可选

      Specify host mask which will be used for all sandbox requests

    • httpsPortsarray可选

      Sandbox ports that serve HTTPS rather than plaintext HTTP. Affects how the proxy reaches the service inside the sandbox; the public URL is HTTPS either way. Certificates are not verified, so self-signed ones work. The envd port (49983) cannot be listed.

    • rulesobject可选

      Per-domain transform rules applied to matching outbound HTTPS requests. Keys may be exact DNS names (for example, "api.example.com") or a leading wildcard (for example, "*.example.com"), and are normalized to lowercase on write. Wildcards match subdomains at any depth but not the apex domain; a bare "*" is invalid. Exact rules take precedence, followed by the longest matching wildcard suffix, and matching rule sets are not merged. Broad wildcards such as "*.com" are allowed and may expose transformed credentials to every matching destination the sandbox contacts. Rules do not grant network access; configure allowOut separately to permit the destination.

  • mcpobject可选

    MCP configuration for the sandbox

  • ▸ 更多参数(2)
    • iamobject可选

      Sandbox workload identity configuration. A non-empty, valid tokens map enables workload identity for the sandbox.

      ▸ 展开子字段(1)
      • tokensobject可选

        Named workload-token definitions, keyed by a caller-chosen token name.

    • volumeMountsarray可选

      Volumes to mount into the sandbox, each with the volume name and the path inside the sandbox.

      ▸ 展开子字段(2)
      • namestring必填

        Name of the volume

      • pathstring必填

        Path of the volume

返回

201

平台暂未提供 E2B 默认的 base 模板:不带模板参数的 Sandbox.create() 会返回 404,请显式指定模板(可用模板见「列出模板」)。

错误按 E2B 格式返回,参见 错误码

响应

HTTP 201

The sandbox was created successfully

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringBase domain where the sandbox traffic is accessible

升级为完整沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /sandbox/v1/sandboxes/{sandboxID}/upgrade● 支持

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • templateIDstring可选
    默认 "base"

    目标模板,默认 base(node22 别名);必须包含 E2B 镜像,否则返回 INVALID_PARAMS。升级期间文件、进程与数据面操作返回 409。

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Upgraded sandbox detail with a replacement access token

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
aliasstringAlias of the template
sandboxIDstringIdentifier of the sandbox
clientIDstringIdentifier of the client
startedAtstringTime when the sandbox was started
endAtstringTime when the sandbox will expire
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
allowInternetAccessbooleanWhether internet access was explicitly enabled or disabled for the sandbox. Null means it was not explicitly set.
domainstringBase domain where the sandbox traffic is accessible
cpuCountintegerCPU cores for the sandbox
memoryMBintegerMemory for the sandbox in MiB
diskSizeMBintegerDisk size for the sandbox in MiB
metadataanyYour own string key/value pairs stored with the sandbox; usable as a filter in listSandboxes.
statestringState of the sandbox
networkobjectNetwork policy of the sandbox: public access, egress allow and deny lists and proxy.
network.allowPublicTrafficbooleanSpecify if the sandbox URLs should be accessible only with authentication.
network.allowOutarray<string>List of allowed destinations for egress traffic. Each entry can be a CIDR block (e.g. "8.8.8.8/32"), a bare IP address (e.g. "8.8.8.8"), or a domain name (e.g. "example.com", "*.example.com"). Allowed entries always take precedence over denied entries.
network.denyOutarray<string>List of denied CIDR blocks or IP addresses for egress traffic. Domain names are not supported for deny rules.
network.egressProxyobjectSOCKS5 proxy for sandbox egress. Outbound TCP is tunneled through the proxy after allow/deny filtering; the sandbox is unaware. Domain-matched flows use remote DNS (ATYP=domain).
network.maskRequestHoststringSpecify host mask which will be used for all sandbox requests
network.httpsPortsarray<integer>Sandbox ports that serve HTTPS rather than plaintext HTTP. Affects how the proxy reaches the service inside the sandbox; the public URL is HTTPS either way. Certificates are not verified, so self-signed ones work. The envd port (49983) cannot be listed.
network.rulesobjectPer-domain transform rules applied to matching outbound HTTPS requests. Keys may be exact DNS names (for example, "api.example.com") or a leading wildcard (for example, ".example.com"), and are normalized to lowercase on write. Wildcards match subdomains at any depth but not the apex domain; a bare "" is invalid. Exact rules take precedence, followed by the longest matching wildcard suffix, and matching rule sets are not merged. Broad wildcards such as "*.com" are allowed and may expose transformed credentials to every matching destination the sandbox contacts. Rules do not grant network access; configure allowOut separately to permit the destination.
lifecycleobjectSandbox lifecycle policy returned by sandbox info.
lifecycle.autoResumebooleanWhether the sandbox can auto-resume.
lifecycle.onTimeoutstringAction taken when the sandbox times out.
volumeMountsarray<object>Volumes mounted into the sandbox.
volumeMounts[].namestringName of the volume
volumeMounts[].pathstringPath of the volume

列出沙箱

GET /sandbox/v1/sandboxes● 支持

E2B 官方文档 ↗

请求参数

  • metadatastring可选

    query: Metadata query used to filter the sandboxes (e.g. "user=abc&app=prod"). Each key and values must be URL encoded.

  • statearray可选

    query: live:运行中;exited:已退出;all:全部保留记录。默认 live。

  • orderstring可选
    默认 "desc"

    query: Sort direction by sandbox start time. Defaults to desc (newest first).

    取值 ascdesc
  • startedAfterstring可选

    query: Return sandboxes started at or after this timestamp.

  • templatestring可选

    query: Filter sandboxes by a template ID or alias.

  • nextTokenstring可选

    query: Cursor to start the list from

  • limitinteger可选
    默认 100

    query: Maximum number of items to return per page

  • namestring可选

    query: 按名称子串搜索,不区分大小写;中文、%、_ 和反斜杠按原样匹配。去除首尾空白后须为 1–64 个字符。可与状态及分页参数组合;历史空名称不匹配。

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned all running sandboxes

application/json

名称类型说明
[].templateIDstringIdentifier of the template from which is the sandbox created
[].aliasstringAlias of the template
[].sandboxIDstringIdentifier of the sandbox
[].clientIDstringIdentifier of the client
[].startedAtstringTime when the sandbox was started
[].endAtstringTime when the sandbox will expire
[].cpuCountintegerCPU cores for the sandbox
[].memoryMBintegerMemory for the sandbox in MiB
[].diskSizeMBintegerDisk size for the sandbox in MiB
[].metadataanyYour own string key/value pairs stored with the sandbox; usable as a filter in listSandboxes.
[].statestringState of the sandbox
[].envdVersionstringVersion of the envd running in the sandbox
[].volumeMountsarray<object>Volumes mounted into the sandbox.
[].volumeMounts[].namestringName of the volume
[].volumeMounts[].pathstringPath of the volume

读取沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

GET /sandbox/v1/sandboxes/{sandboxID}● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned the sandbox

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
aliasstringAlias of the template
sandboxIDstringIdentifier of the sandbox
clientIDstringIdentifier of the client
startedAtstringTime when the sandbox was started
endAtstringTime when the sandbox will expire
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
allowInternetAccessbooleanWhether internet access was explicitly enabled or disabled for the sandbox. Null means it was not explicitly set.
domainstringBase domain where the sandbox traffic is accessible
cpuCountintegerCPU cores for the sandbox
memoryMBintegerMemory for the sandbox in MiB
diskSizeMBintegerDisk size for the sandbox in MiB
metadataanyYour own string key/value pairs stored with the sandbox; usable as a filter in listSandboxes.
statestringState of the sandbox
networkobjectNetwork policy of the sandbox: public access, egress allow and deny lists and proxy.
network.allowPublicTrafficbooleanSpecify if the sandbox URLs should be accessible only with authentication.
network.allowOutarray<string>List of allowed destinations for egress traffic. Each entry can be a CIDR block (e.g. "8.8.8.8/32"), a bare IP address (e.g. "8.8.8.8"), or a domain name (e.g. "example.com", "*.example.com"). Allowed entries always take precedence over denied entries.
network.denyOutarray<string>List of denied CIDR blocks or IP addresses for egress traffic. Domain names are not supported for deny rules.
network.egressProxyobjectSOCKS5 proxy for sandbox egress. Outbound TCP is tunneled through the proxy after allow/deny filtering; the sandbox is unaware. Domain-matched flows use remote DNS (ATYP=domain).
network.maskRequestHoststringSpecify host mask which will be used for all sandbox requests
network.httpsPortsarray<integer>Sandbox ports that serve HTTPS rather than plaintext HTTP. Affects how the proxy reaches the service inside the sandbox; the public URL is HTTPS either way. Certificates are not verified, so self-signed ones work. The envd port (49983) cannot be listed.
network.rulesobjectPer-domain transform rules applied to matching outbound HTTPS requests. Keys may be exact DNS names (for example, "api.example.com") or a leading wildcard (for example, ".example.com"), and are normalized to lowercase on write. Wildcards match subdomains at any depth but not the apex domain; a bare "" is invalid. Exact rules take precedence, followed by the longest matching wildcard suffix, and matching rule sets are not merged. Broad wildcards such as "*.com" are allowed and may expose transformed credentials to every matching destination the sandbox contacts. Rules do not grant network access; configure allowOut separately to permit the destination.
lifecycleobjectSandbox lifecycle policy returned by sandbox info.
lifecycle.autoResumebooleanWhether the sandbox can auto-resume.
lifecycle.onTimeoutstringAction taken when the sandbox times out.
volumeMountsarray<object>Volumes mounted into the sandbox.
volumeMounts[].namestringName of the volume
volumeMounts[].pathstringPath of the volume

重命名沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

PATCH /sandbox/v1/sandboxes/{sandboxID}● 支持

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • namestring必填

    新名称;去除首尾空白后须为 1–64 个字符。同团队重名返回 409。请求只允许 name 字段。

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Updated sandbox detail

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
aliasstringAlias of the template
sandboxIDstringIdentifier of the sandbox
clientIDstringIdentifier of the client
startedAtstringTime when the sandbox was started
endAtstringTime when the sandbox will expire
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
allowInternetAccessbooleanWhether internet access was explicitly enabled or disabled for the sandbox. Null means it was not explicitly set.
domainstringBase domain where the sandbox traffic is accessible
cpuCountintegerCPU cores for the sandbox
memoryMBintegerMemory for the sandbox in MiB
diskSizeMBintegerDisk size for the sandbox in MiB
metadataanyYour own string key/value pairs stored with the sandbox; usable as a filter in listSandboxes.
statestringState of the sandbox
networkobjectNetwork policy of the sandbox: public access, egress allow and deny lists and proxy.
network.allowPublicTrafficbooleanSpecify if the sandbox URLs should be accessible only with authentication.
network.allowOutarray<string>List of allowed destinations for egress traffic. Each entry can be a CIDR block (e.g. "8.8.8.8/32"), a bare IP address (e.g. "8.8.8.8"), or a domain name (e.g. "example.com", "*.example.com"). Allowed entries always take precedence over denied entries.
network.denyOutarray<string>List of denied CIDR blocks or IP addresses for egress traffic. Domain names are not supported for deny rules.
network.egressProxyobjectSOCKS5 proxy for sandbox egress. Outbound TCP is tunneled through the proxy after allow/deny filtering; the sandbox is unaware. Domain-matched flows use remote DNS (ATYP=domain).
network.maskRequestHoststringSpecify host mask which will be used for all sandbox requests
network.httpsPortsarray<integer>Sandbox ports that serve HTTPS rather than plaintext HTTP. Affects how the proxy reaches the service inside the sandbox; the public URL is HTTPS either way. Certificates are not verified, so self-signed ones work. The envd port (49983) cannot be listed.
network.rulesobjectPer-domain transform rules applied to matching outbound HTTPS requests. Keys may be exact DNS names (for example, "api.example.com") or a leading wildcard (for example, ".example.com"), and are normalized to lowercase on write. Wildcards match subdomains at any depth but not the apex domain; a bare "" is invalid. Exact rules take precedence, followed by the longest matching wildcard suffix, and matching rule sets are not merged. Broad wildcards such as "*.com" are allowed and may expose transformed credentials to every matching destination the sandbox contacts. Rules do not grant network access; configure allowOut separately to permit the destination.
lifecycleobjectSandbox lifecycle policy returned by sandbox info.
lifecycle.autoResumebooleanWhether the sandbox can auto-resume.
lifecycle.onTimeoutstringAction taken when the sandbox times out.
volumeMountsarray<object>Volumes mounted into the sandbox.
volumeMounts[].namestringName of the volume
volumeMounts[].pathstringPath of the volume
namestringCurrent name of the sandbox.

沙箱指标

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

GET /sandbox/v1/sandboxes/{sandboxID}/metrics● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • startinteger可选

    query: Unix timestamp for the start of the interval, in seconds, for which the metrics

  • endinteger可选

    query: Unix timestamp in seconds at which the metrics window ends. Omit it to read up to the latest sample.

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned the sandbox metrics

application/json

名称类型说明
[].timestampstringTimestamp of the metric entry
[].timestampUnixintegerTimestamp of the metric entry in Unix time (seconds since epoch)
[].cpuCountintegerNumber of CPU cores
[].cpuUsedPctnumberCPU usage percentage
[].memUsedintegerMemory used in bytes
[].memTotalintegerTotal memory in bytes
[].memCacheintegerCached memory (page cache) in bytes
[].diskUsedintegerDisk used in bytes
[].diskTotalintegerTotal disk space in bytes

设置超时

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /sandbox/v1/sandboxes/{sandboxID}/timeout● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • timeoutinteger必填

    New lifetime in seconds from now, replacing the current expiry rather than adding to it. May shorten the remaining lifetime.

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

Successfully set the sandbox timeout

未声明响应体。

暂停沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /sandbox/v1/sandboxes/{sandboxID}/pause● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • memoryboolean可选
    默认 true

    Whether to capture a full memory snapshot. When false, only the filesystem is persisted and resuming the sandbox cold-boots (reboots) it from disk, losing in-memory state, running processes, and open connections. Resume it with an explicit request (connect or resume); auto-resume, which can be triggered by arbitrary traffic, refuses such a sandbox. Defaults to true.

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

The sandbox was paused successfully and can be resumed

未声明响应体。

连接沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /sandbox/v1/sandboxes/{sandboxID}/connect● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • timeoutinteger可选
    默认 300

    Requested remaining lifetime in seconds from the connection. Defaults to 300 seconds; an existing later expiry is preserved.

  • memoryboolean可选

    Defaults to true. When false and the sandbox is paused, resume from disk state only: the sandbox cold-boots fresh and any memory in the snapshot is ignored, never modified or deleted. Disk state has crash-recovery semantics — writes not flushed before the pause may be lost. A no-op for snapshots that contain no memory. Rejected with an error in environments where this capability is not enabled, never silently downgraded to a memory restore.

返回

201

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

The sandbox was already running

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringBase domain where the sandbox traffic is accessible

HTTP 201

The sandbox was resumed successfully

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringBase domain where the sandbox traffic is accessible

终止沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

DELETE /sandbox/v1/sandboxes/{sandboxID}● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

The sandbox was killed successfully

未声明响应体。

列出模板

GET /sandbox/v1/templates● 支持

E2B 官方文档 ↗

请求参数

  • teamIDstring可选

    query: Id of the team whose templates to list. Omit it to list the templates of your own team; a team you do not belong to answers 403.

  • nextTokenstring可选

    query: Cursor to start the list from

  • limitinteger可选
    默认 100

    query: Maximum number of items to return per page

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned all templates

application/json

名称类型说明
[].templateIDstringIdentifier of the template
[].buildIDstringIdentifier of the last successful build for given template
[].cpuCountintegerCPU cores for the sandbox
[].memoryMBintegerMemory for the sandbox in MiB
[].diskSizeMBintegerDisk size for the sandbox in MiB
[].publicbooleanWhether the template is public or only accessible by the team
[].aliasesarray<string>Aliases of the template
[].namesarray<string>Names of the template (namespace/alias format when namespaced)
[].createdAtstringTime when the template was created
[].updatedAtstringTime when the template was last updated
[].createdByobjectUser who created the template; null for templates created by the platform.
[].createdBy.idstringIdentifier of the user
[].createdBy.emailstringEmail of the user
[].lastSpawnedAtstringTime when the template was last used
[].spawnCountintegerNumber of times the template was used
[].buildCountintegerNumber of times the template was built
[].envdVersionstringVersion of the envd running in the sandbox
[].buildStatusstringStatus of the template build

创建卷

POST /sandbox/v1/volumes● 支持

E2B 官方文档 ↗

请求体

  • namestring必填

    Volume name, unique within your team. Use one or more ASCII letters, digits, underscores or hyphens.

返回

201

错误按 E2B 格式返回,参见 错误码

响应

HTTP 201

Successfully created a new team volume

application/json

名称类型说明
volumeIDstringID of the volume
namestringName of the volume
tokenstringAuth token to use for interacting with volume content
domainstringDomain to use as the destination for volume content requests, replacing the default `api.<E2B_DOMAIN>`. Only returned when the team is connected to a custom (BYOC) cluster; absent otherwise, in which case the default domain is used.

自有入口在响应对象(列表为每行)追加 createdAt:创建时间,ISO 8601 UTC 字符串。

网关自动设置 X-Praxis-Face: own-v1,客户端无需传入;/e2b 兼容入口会剥除该头,保留厂商响应形状。

列出卷

GET /sandbox/v1/volumes● 支持

E2B 官方文档 ↗

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully listed all team volumes

application/json

名称类型说明
[].volumeIDstringID of the volume
[].namestringName of the volume

自有入口在响应对象(列表为每行)追加 createdAt:创建时间,ISO 8601 UTC 字符串。

网关自动设置 X-Praxis-Face: own-v1,客户端无需传入;/e2b 兼容入口会剥除该头,保留厂商响应形状。

读取卷

GET /sandbox/v1/volumes/{volumeID}● 支持

E2B 官方文档 ↗

请求参数

  • volumeIDstring必填

    path: Id of the team volume, the `volumeID` returned by createVolume or listVolumes.

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully retrieved a team volume

application/json

名称类型说明
volumeIDstringID of the volume
namestringName of the volume
tokenstringAuth token to use for interacting with volume content
domainstringDomain to use as the destination for volume content requests, replacing the default `api.<E2B_DOMAIN>`. Only returned when the team is connected to a custom (BYOC) cluster; absent otherwise, in which case the default domain is used.

自有入口在响应对象(列表为每行)追加 createdAt:创建时间,ISO 8601 UTC 字符串。

网关自动设置 X-Praxis-Face: own-v1,客户端无需传入;/e2b 兼容入口会剥除该头,保留厂商响应形状。

删除卷

DELETE /sandbox/v1/volumes/{volumeID}● 支持

E2B 官方文档 ↗

请求参数

  • volumeIDstring必填

    path: Id of the team volume, the `volumeID` returned by createVolume or listVolumes.

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

Successfully deleted a team volume

未声明响应体。

复制沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /sandbox/v1/sandboxes/{sandboxID}/fork● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • timeoutinteger可选
    默认 15

    新副本的存活时间,单位为秒。

  • countinteger可选
    默认 1

    要创建的独立副本数。所有副本来自同一次快照,每个副本分别返回成功结果或错误。

返回

201

错误按 E2B 格式返回,参见 错误码

响应

HTTP 201

The sandbox was snapshotted and the forks were attempted; each entry reports one fork's outcome

application/json

名称类型说明
[].sandboxobjectSandbox created from a template.
[].sandbox.templateIDstringIdentifier of the template from which is the sandbox created
[].sandbox.sandboxIDstringIdentifier of the sandbox
[].sandbox.aliasstringAlias of the template
[].sandbox.clientIDstringIdentifier of the client
[].sandbox.envdVersionstringVersion of the envd running in the sandbox
[].sandbox.envdAccessTokenstringAccess token used for envd communication
[].sandbox.trafficAccessTokenstringToken required for accessing sandbox via proxy.
[].sandbox.domainstringBase domain where the sandbox traffic is accessible
[].errorobjectError body: numeric code, machine-readable error_code and a message.
[].error.codeintegerError code
[].error.error_codestringMachine-readable semantic error code. Not a closed set; initial values: sandbox_capacity_unavailable, sandbox_placement_timeout, sandbox_no_compatible_node, sandbox_create_failed, internal_server_error.
[].error.messagestringHuman-readable description of the error.

创建快照

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /sandbox/v1/sandboxes/{sandboxID}/snapshots● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • namestring可选

    可选别名。同一主体重复使用该别名会更新既有快照,保留本平台快照 ID。

返回

201

错误按 E2B 格式返回,参见 错误码

响应

HTTP 201

Snapshot created successfully

application/json

名称类型说明
snapshotIDstringIdentifier of the snapshot template including the tag. Uses namespace/alias when a name was provided (e.g. team-slug/my-snapshot:default), otherwise falls back to the raw template ID (e.g. abc123:default).
namesarray<string>Full names of the snapshot template including team namespace and tag (e.g. team-slug/my-snapshot:v2)

自有入口在响应对象(列表为每行)追加 createdAt:创建时间,ISO 8601 UTC 字符串。

快照还包括 sourceSandboxID(string,来源沙箱公开 ID)与 sourceSandboxName(string 或 null)。名称无法取得时返回 null,界面可回退显示 ID。

网关自动设置 X-Praxis-Face: own-v1,客户端无需传入;/e2b 兼容入口会剥除该头,保留厂商响应形状。

向 POST /sandbox/v1/sandboxes/{sandboxID}/snapshots 发送 JSON body {"name":"my-snapshot"} 即可命名;名称会持久保存,并通过 names 返回。

列出快照

GET /sandbox/v1/snapshots● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring可选

    query: 按来源沙箱 ID 筛选。

  • namestring可选

    query: 按原始别名或本平台 snap_ 快照 ID 筛选。

  • limitinteger可选
    默认 100

    query: 每页返回的快照数量上限。

  • nextTokenstring可选

    query: 上一页响应头 X-Next-Token 返回的游标。

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned snapshots

application/json

名称类型说明
[].snapshotIDstringIdentifier of the snapshot template including the tag. Uses namespace/alias when a name was provided (e.g. team-slug/my-snapshot:default), otherwise falls back to the raw template ID (e.g. abc123:default).
[].namesarray<string>Full names of the snapshot template including team namespace and tag (e.g. team-slug/my-snapshot:v2)

自有入口在响应对象(列表为每行)追加 createdAt:创建时间,ISO 8601 UTC 字符串。

快照还包括 sourceSandboxID(string,来源沙箱公开 ID)与 sourceSandboxName(string 或 null)。名称无法取得时返回 null,界面可回退显示 ID。

网关自动设置 X-Praxis-Face: own-v1,客户端无需传入;/e2b 兼容入口会剥除该头,保留厂商响应形状。

删除快照

DELETE /sandbox/v1/snapshots/{snapshotID}● 支持

E2B 官方文档 ↗

请求参数

  • snapshotIDstring必填

    path: 本平台返回的 snap_ 快照 ID。

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

The template was deleted successfully

未声明响应体。

更新网络策略

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

PUT /sandbox/v1/sandboxes/{sandboxID}/network● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • allow_internet_accessboolean可选

    是否允许访问外网。false 等效于 denyOut 包含 0.0.0.0/0。

  • allowOutarray可选

    出站目标白名单,可用 CIDR、IP 或域名;白名单优先于拒绝规则。

  • denyOutarray可选

    出站目标黑名单,支持 CIDR 或 IP,不支持域名。

  • egressProxyobject可选

    上游代理配置字段,当前平台尚未应用。

    ▸ 展开子字段(3)
    • addressstring必填

      SOCKS5 proxy address in host:port format (e.g. "proxy.example.com:1080").

    • usernamestring可选

      Optional SOCKS5 username (RFC 1929), max 255 bytes.

    • passwordstring可选

      Optional SOCKS5 password (RFC 1929), max 255 bytes.

  • rulesobject可选

    上游按域名转换规则字段,当前平台尚未应用。

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

Successfully updated the sandbox network configuration

未声明响应体。

读取沙箱日志

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

GET /sandbox/v1/sandboxes/{sandboxID}/logs● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • cursorinteger可选

    query: 起始时间戳,单位为 Unix 毫秒。

  • limitinteger可选
    默认 1000

    query: 最多返回的日志条数。

  • directionstring可选

    query: forward 按时间向后读取;backward 按时间向前读取。

    取值 forwardbackward
  • levelstring可选

    query: 最低日志级别,低于该级别的日志会被过滤。

    取值 debuginfowarnerror
  • searchstring可选

    query: 按日志正文的子串筛选,区分大小写。

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned the sandbox logs

application/json

名称类型说明
logsarray<object>Sandbox logs structured
logs[].timestampstringTimestamp of the log entry
logs[].messagestringLog message content
logs[].levelstringState of the sandbox
logs[].fieldsobjectStructured key/value fields attached to the log line.

延长沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /sandbox/v1/sandboxes/{sandboxID}/extend● 支持

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • timeoutnumber必填

    从当前时刻起计算的有效秒数:900、1800 或 3600。必须延长现有截止时间。

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Authoritative extended deadline

application/json

名称类型说明
endAtstringNew expiry time of the sandbox, UTC.

列出进程

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

GET /sandbox/v1/sandboxes/{sandboxID}/processes● 支持

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • statestring可选

    query: live:运行中;exited:已退出;all:全部保留记录。默认 live。

    取值 liveexitedall

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Bounded observation with explicit completeness

application/json

名称类型说明
processesarray<object>Processes of the sandbox: running ones and retained observations of exited ones, newest first.
processes[].processIdstringId of the process: `obs-<n>` for a process whose start was observed, `live-<pid>` for one that was only seen running.
processes[].pidintegerOperating-system process id inside the sandbox.
processes[].tagstringTag the process was started with; absent when none.
processes[].configobjectCommand the process was started with.
processes[].ptybooleanWhether the process runs in a pseudo-terminal; present for observed processes.
processes[].startedAtstringTime at which the process start was observed, UTC.
processes[].exitedAtstringTime at which the process exit was observed, UTC; absent until an exit was witnessed.
processes[].exitCodeintegerExit code; present only when the exit was witnessed.
processes[].statestringCurrent state of the process.
processes[].observedbooleanWhether the platform watched this process start. False for a process that was only seen running.
processes[].observationGapbooleanTrue when observation was interrupted, so output or the exit may be missing; the state can then be unknown.
processes[].outputTruncatedbooleanTrue when old output chunks were dropped to stay within the retention limits.

读取输出

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

GET /sandbox/v1/sandboxes/{sandboxID}/processes/{processID}/output● 支持

请求参数

  • sandboxIDstring必填

    path: 沙箱 ID。

  • processIDstring必填

    path: 从进程列表取得的 processId。

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Bounded observation with explicit completeness

application/json

名称类型说明
chunksarray<object>Retained output chunks of the process, oldest first.
chunks[].seqintegerSequence number of the chunk; it increases with time and orders chunks.
chunks[].streamstringWhich stream the chunk came from.
chunks[].datastringOutput bytes of the chunk, base64 encoded.
chunks[].timestampnumberTime at which the chunk was recorded, in Unix milliseconds.
completebooleanTrue when the output is whole: the exit was witnessed, no gap occurred and nothing was truncated.
gapbooleanTrue when observation was interrupted, so chunks or the exit may be missing.
truncatedbooleanTrue when old chunks were dropped to stay within the retention limits.
exitCodeinteger | nullExit code of the process; null until an exit was witnessed.

搜索 API

基础地址

加载中…

接入

加载中…

端点

方法路径说明支持
POST/v1/search搜索● 支持
POST/v1/extract提取网页内容● 支持
POST/v1/crawl站内爬取● 支持
POST/v1/map站点地图● 支持

与官方的差异

  • 站内爬取:调用前要求账户余额大于 0;按本次调用实际消耗的 credits 计费,每 credit $0.01;上游未返回用量时,按本次请求可能消耗的上限计费。
  • 站点地图:调用前要求账户余额大于 0;按本次调用实际消耗的 credits 计费,每 credit $0.01;上游未返回用量时,按本次请求可能消耗的上限计费。

参数与字段的权威定义以 Tavily 官方文档为准。

错误按 Tavily 格式返回,参见错误;额度与响应头参见限流。

搜索

POST /search/v1/search● 支持

Tavily 官方文档 ↗

请求体

  • querystring必填

    The search query to execute with Tavily.

  • search_depthstring可选
    默认 "basic"

    Controls the latency vs. relevance tradeoff and how `results[].content` is generated: - `advanced`: Highest relevance with increased latency. Best for detailed, high-precision queries. Returns multiple semantically relevant snippets per URL (configurable via `chunks_per_source`). - `basic`: A balanced option for relevance and latency. Ideal for general-purpose searches. Returns multiple semantically relevant snippets per URL (configurable via `chunks_per_source`). - `fast`: Prioritizes lower latency while maintaining good relevance. Returns multiple semantically relevant snippets per URL (configurable via `chunks_per_source`). - `ultra-fast`: Minimizes latency above all else. Best for time-critical use cases. Returns one NLP summary per URL. **Cost**: - `basic`, `fast`, `ultra-fast`: 1 API Credit - `advanced`: 2 API Credits See [Search Best Practices](/documentation/best-practices/best-practices-search#search-depth) for guidance on choosing the right search depth.

    取值 advancedbasicfastultra-fast
  • chunks_per_sourceinteger可选
    默认 3

    Chunks are short content snippets (maximum 500 characters each) pulled directly from the source. Use `chunks_per_source` to define the maximum number of relevant chunks returned per source and to control the `content` length. Chunks will appear in the `content` field as: `<chunk 1> [...] <chunk 2> [...] <chunk 3>`. Available when `search_depth` is `advanced`, `basic` or `fast`.

  • max_resultsinteger可选
    默认 10

    The maximum number of search results to return.

  • topicstring可选
    默认 "general"

    The category of the search.`news` is useful for retrieving real-time updates, particularly about politics, sports, and major current events covered by mainstream media sources. `general` is for broader, more general-purpose searches that may include a wide range of sources.

    取值 generalnewsfinance
  • time_rangestring可选
    默认 null

    The time range back from the current date to filter results based on publish date or last updated date. Useful when looking for sources that have published or updated data. By default, results with no detectable published date are not removed; set `filter_by_published_date` to `true` to remove them.

    取值 dayweekmonthyeardwmy
  • start_datestring可选
    默认 null

    Will return all results after the specified start date based on publish date or last updated date. Required to be written in the format YYYY-MM-DD. By default, results with no detectable published date are not removed; set `filter_by_published_date` to `true` to remove them.

  • end_datestring可选
    默认 null

    Will return all results before the specified end date based on publish date or last updated date. Required to be written in the format YYYY-MM-DD. By default, results with no detectable published date are not removed; set `filter_by_published_date` to `true` to remove them.

  • include_published_dateboolean可选
    默认 false

    Include a `published_date` field in each result. The date is Tavily's best estimate of when the source was published or last updated, so it can be later than the original publish date. Results with no detectable date return `null`. Automatically enabled when `topic` is `news`. **Note**: this feature is currently in beta.

  • filter_by_published_dateboolean可选
    默认 false

    Remove results whose published date falls outside the `time_range`, `start_date`, or `end_date` window. Results with no detectable published date are also removed. Setting this to `true` also enables `include_published_date`. If you want date-window filtering but don't want to lose sources without a detectable date, leave this `false` and set `include_published_date: true` together with a date range instead.

  • ▸ 更多参数(15)
    • include_answerboolean | string可选
      默认 false

      Include an LLM-generated answer to the provided query. `basic` or `true` returns a quick answer. `advanced` returns a more detailed answer.

    • include_raw_contentboolean | string可选
      默认 false

      Include the cleaned and parsed HTML content of each search result. `markdown` or `true` returns search result content in markdown format. `text` returns the plain text from the results and may increase latency.

    • include_imagesboolean可选
      默认 false

      Include images in the response. Returns both a top-level `images` list of query-related images and an `images` array inside each result object with images extracted from that specific source.

    • include_image_descriptionsboolean可选
      默认 false

      When `include_images` is `true`, also add a descriptive text for each image.

    • include_faviconboolean可选
      默认 false

      Whether to include the favicon URL for each result.

    • include_domainsarray可选
      默认 []

      A list of domains to specifically include in the search results. Maximum 300 domains.

    • exclude_domainsarray可选
      默认 []

      A list of domains to specifically exclude from the search results. Maximum 150 domains.

    • include_domains_modestring可选
      默认 null

      Controls how `include_domains` is applied. `restrict` limits results to only the listed domains. `prefer` also searches the rest of the web, so results outside `include_domains` can still surface, rather than excluding them. Requires `include_domains` to be set; returns a 400 error otherwise.

      取值 restrictprefer
    • countrystring可选
      默认 null

      Boost search results from a specific country. This will prioritize content from the selected country in the search results. Available only if topic is `general`.

      取值 afghanistanalbaniaalgeriaandorraangolaargentinaarmeniaaustraliaaustriaazerbaijanbahamasbahrainbangladeshbarbadosbelarusbelgiumbelizebeninbhutanboliviabosnia and herzegovinabotswanabrazilbruneibulgariaburkina fasoburundicambodiacamerooncanadacape verdecentral african republicchadchilechinacolombiacomoroscongocosta ricacroatiacubacyprusczech republicdenmarkdjiboutidominican republicecuadoregyptel salvadorequatorial guineaeritreaestoniaethiopiafijifinlandfrancegabongambiageorgiagermanyghanagreeceguatemalaguineahaitihondurashungaryicelandindiaindonesiairaniraqirelandisraelitalyjamaicajapanjordankazakhstankenyakuwaitkyrgyzstanlatvialebanonlesotholiberialibyaliechtensteinlithuanialuxembourgmadagascarmalawimalaysiamaldivesmalimaltamauritaniamauritiusmexicomoldovamonacomongoliamontenegromoroccomozambiquemyanmarnamibianepalnetherlandsnew zealandnicaraguanigernigerianorth koreanorth macedonianorwayomanpakistanpanamapapua new guineaparaguayperuphilippinespolandportugalqatarromaniarussiarwandasaudi arabiasenegalserbiasingaporeslovakiasloveniasomaliasouth africasouth koreasouth sudanspainsri lankasudanswedenswitzerlandsyriataiwantajikistantanzaniathailandtogotrinidad and tobagotunisiaturkeyturkmenistanugandaukraineunited arab emiratesunited kingdomunited statesuruguayuzbekistanvenezuelavietnamyemenzambiazimbabwe
    • languagestring可选
      默认 null

      Boost search results in a specific language. Accepts an ISO 639-1 code (e.g. `en`, `fr`, `zh-cn`) or an English language name (e.g. `english`, `french`). By default this only boosts matching-language results in ranking; pass `filter_by_language: true` to strictly filter out non-matching results instead. For best results, write your `query` in the same language you set here.

    • filter_by_languageboolean可选
      默认 false

      Strictly filter out search results that don't match the `language` parameter, instead of only boosting them in ranking. Requires `language` to be set; returns a 400 error otherwise.

    • auto_parametersboolean可选
      默认 false

      When `auto_parameters` is enabled, Tavily automatically configures search parameters based on your query's content and intent. You can still set other parameters manually, and your explicit values will override the automatic ones. The parameters `include_answer`, `include_raw_content`, and `max_results` must always be set manually, as they directly affect response size. Note: `search_depth` may be automatically set to advanced when it's likely to improve results. This uses 2 API credits per request. To avoid the extra cost, you can explicitly set `search_depth` to `basic`.

    • exact_matchboolean可选
      默认 false

      Ensure that only search results containing the exact quoted phrase(s) in the query are returned, bypassing synonyms or semantic variations. Wrap target phrases in quotes within your query (e.g. `"John Smith" CEO Acme Corp`). Punctuation is typically ignored inside quotes.

    • include_usageboolean可选
      默认 false

      Whether to include credit usage information in the response.

    • safe_searchboolean可选
      默认 false

      Whether to filter out adult or unsafe content from results. Not supported for `fast` or `ultra-fast` search depths.

返回

200

错误按 Tavily 格式返回,参见 错误码

响应

HTTP 200

Search results returned successfully

application/json

名称类型说明
querystringThe search query that was executed.
answerstringA short answer to the user's query, generated by an LLM. Included in the response only if `include_answer` is requested (i.e., set to `true`, `basic`, or `advanced`)
imagesarray<object>A list of query-related images from image search. If `include_image_descriptions` is true, each item will have `url` and `description`. Note: per-result images are also returned inside each result object's `images` field.
images[].urlstringURL of the image.
images[].descriptionstringDescription of the image, when the search was asked to describe images.
resultsarray<object>A list of sorted search results, ranked by relevancy.
results[].titlestringThe title of the search result.
results[].urlstringThe URL of the search result.
results[].contentstringA short description of the search result.
results[].scorenumberThe relevance score of the search result.
results[].raw_contentstringThe cleaned and parsed HTML content of the search result. Only if `include_raw_content` is true.
results[].published_datestringTavily's best estimate of when the source was published or last updated. Can be later than the original publish date. `null` if no date could be detected. Only returned when `include_published_date` is `true` (automatically enabled when `topic` is `news`).
results[].faviconstringThe favicon URL for the result.
results[].imagesarray<object>A list of images extracted from this search result. Only included when `include_images` is `true`. If `include_image_descriptions` is `true`, each item will have `url` and `description`.
results[].idstringUnique identifier for this result
auto_parametersobjectA dictionary of the selected auto_parameters, only shown when `auto_parameters` is true.
response_timenumberTime in seconds it took to complete the request.
usageobjectCredit usage details for the request.
request_idstringA unique request identifier you can share with customer support to help resolve issues with specific requests.

提取网页内容

POST /search/v1/extract● 支持

Tavily 官方文档 ↗

请求体

  • querystring可选

    User intent for reranking extracted content chunks. When provided, chunks are reranked based on relevance to this query.

  • urlsstring | array必填

    URL to extract, or an array of up to 20 URLs. Per-URL failures are listed in `failed_results` of the response, which can come with HTTP 200.

  • chunks_per_sourceinteger可选
    默认 3

    Chunks are short content snippets (maximum 500 characters each) pulled directly from the source. Use `chunks_per_source` to define the maximum number of relevant chunks returned per source and to control the `raw_content` length. Chunks will appear in the `raw_content` field as: `<chunk 1> [...] <chunk 2> [...] <chunk 3>`. Available only when `query` is provided. Must be between 1 and 5.

  • extract_depthstring可选
    默认 "basic"

    The depth of the extraction process. `advanced` extraction retrieves more data, including tables and embedded content, with higher success but may increase latency.`basic` extraction costs 1 credit per 5 successful URL extractions, while `advanced` extraction costs 2 credits per 5 successful URL extractions.

    取值 basicadvanced
  • include_imagesboolean可选
    默认 false

    Include a list of images extracted from the URLs in the response. Default is false.

  • include_faviconboolean可选
    默认 false

    Whether to include the favicon URL for each result.

  • formatstring可选
    默认 "markdown"

    The format of the extracted web page content. `markdown` returns content in markdown format. `text` returns plain text and may increase latency.

    取值 markdowntext
  • timeoutnumber可选
    默认 "None"

    Maximum time in seconds to wait for the URL extraction before timing out. Must be between 1.0 and 60.0 seconds. If not specified, default timeouts are applied based on extract_depth: 10 seconds for basic extraction and 30 seconds for advanced extraction.

  • include_usageboolean可选
    默认 false

    Whether to include credit usage information in the response. `NOTE:`The value may be 0 if the total successful URL extractions has not yet reached 5 calls. See our [Credits & Pricing documentation](https://docs.tavily.com/documentation/api-credits) for details.

返回

200

错误按 Tavily 格式返回,参见 错误码

响应

HTTP 200

Extraction completed. Check results and failed_results for each URL. HTTP 200 can have an empty results array when all valid URLs fail during extraction; output order is not guaranteed.

application/json

名称类型说明
resultsarray<object>A list of extracted content from the provided URLs.
results[].urlstringThe URL from which the content was extracted.
results[].raw_contentstringThe full content extracted from the page. When `query` is provided, contains the top-ranked chunks joined by `[...]` separator.
results[].imagesarray<string>This is only available if `include_images` is set to `true`. A list of image URLs extracted from the page.
results[].faviconstringThe favicon URL for the result.
failed_resultsarray<object>A list of URLs that could not be processed.
failed_results[].urlstringThe URL that failed to be processed.
failed_results[].errorstringAn error message describing why the URL couldn't be processed.
response_timenumberTime in seconds it took to complete the request.
usageobjectCredit usage details for the request.
request_idstringA unique request identifier you can share with customer support to help resolve issues with specific requests.

站内爬取

POST /search/v1/crawl● 支持

Tavily 官方文档 ↗

请求体

  • urlstring必填

    The root URL to begin the crawl.

  • limitinteger可选
    默认 50

    Total number of links the crawler will process before stopping.

  • instructionsstring可选

    Natural language instructions for the crawler. When specified, the mapping cost increases to 2 API credits per 10 successful pages instead of 1 API credit per 10 pages.

  • chunks_per_sourceinteger可选
    默认 3

    Chunks are short content snippets (maximum 500 characters each) pulled directly from the source. Use `chunks_per_source` to define the maximum number of relevant chunks returned per source and to control the `raw_content` length. Chunks will appear in the `raw_content` field as: `<chunk 1> [...] <chunk 2> [...] <chunk 3>`. Available only when `instructions` are provided. Must be between 1 and 5.

  • max_depthinteger可选
    默认 1

    Max depth of the crawl. Defines how far from the base URL the crawler can explore.

  • max_breadthinteger可选
    默认 20

    Max number of links to follow per level of the tree (i.e., per page).

  • select_pathsarray可选
    默认 null

    Regex patterns to select only URLs with specific path patterns (e.g., `/docs/.*`, `/api/v1.*`).

  • select_domainsarray可选
    默认 null

    Regex patterns to select crawling to specific domains or subdomains (e.g., `^docs\.example\.com$`).

  • exclude_pathsarray可选
    默认 null

    Regex patterns to exclude URLs with specific path patterns (e.g., `/private/.*`, `/admin/.*`).

  • exclude_domainsarray可选
    默认 null

    Regex patterns to exclude specific domains or subdomains from crawling (e.g., `^private\.example\.com$`).

  • ▸ 更多参数(7)
    • allow_externalboolean可选
      默认 true

      Whether to include external domain links in the final results list.

    • include_imagesboolean可选
      默认 false

      Whether to include images in the crawl results.

    • extract_depthstring可选
      默认 "basic"

      Advanced extraction retrieves more data, including tables and embedded content, with higher success but may increase latency. `basic` extraction costs 1 credit per 5 successful extractions, while `advanced` extraction costs 2 credits per 5 successful extractions.

      取值 basicadvanced
    • formatstring可选
      默认 "markdown"

      The format of the extracted web page content. `markdown` returns content in markdown format. `text` returns plain text and may increase latency.

      取值 markdowntext
    • include_faviconboolean可选
      默认 false

      Whether to include the favicon URL for each result.

    • timeoutnumber可选
      默认 150

      Maximum time in seconds to wait for the crawl operation before timing out. Must be between 10 and 150 seconds.

    • include_usageboolean可选
      默认 false

      Whether to include credit usage information in the response. `NOTE:`The value may be 0 if the total use of /extract and /map have not yet reached minimum requirements. See our [Credits & Pricing documentation](https://docs.tavily.com/documentation/api-credits) for details.

返回

200

调用前要求账户余额大于 0;按本次调用实际消耗的 credits 计费,每 credit $0.01;上游未返回用量时,按本次请求可能消耗的上限计费。

错误按 Tavily 格式返回,参见 错误码

响应

HTTP 200

Crawl results returned successfully

application/json

名称类型说明
base_urlstringThe base URL that was crawled.
resultsarray<object>A list of extracted content from the crawled URLs.
results[].urlstringThe URL that was crawled.
results[].raw_contentstringThe full content extracted from the page. When `query` is provided, contains the top-ranked chunks joined by `[...]` separator.
results[].faviconstringThe favicon URL for the result.
response_timenumberTime in seconds it took to complete the request.
usageobjectCredit usage details for the request.
request_idstringA unique request identifier you can share with customer support to help resolve issues with specific requests.

站点地图

POST /search/v1/map● 支持

Tavily 官方文档 ↗

请求体

  • urlstring必填

    The root URL to begin the mapping.

  • limitinteger可选
    默认 50

    Total number of links the crawler will process before stopping.

  • instructionsstring可选
    默认 null

    Natural language instructions for the crawler. When specified, the cost increases to 2 API credits per 10 successful pages instead of 1 API credit per 10 pages.

  • max_depthinteger可选
    默认 1

    Max depth of the mapping. Defines how far from the base URL the crawler can explore.

  • max_breadthinteger可选
    默认 20

    Max number of links to follow per level of the tree (i.e., per page).

  • select_pathsarray可选
    默认 null

    Regex patterns to select only URLs with specific path patterns (e.g., `/docs/.*`, `/api/v1.*`).

  • select_domainsarray可选
    默认 null

    Regex patterns to select crawling to specific domains or subdomains (e.g., `^docs\.example\.com$`).

  • exclude_pathsarray可选
    默认 null

    Regex patterns to exclude URLs with specific path patterns (e.g., `/private/.*`, `/admin/.*`).

  • exclude_domainsarray可选
    默认 null

    Regex patterns to exclude specific domains or subdomains from crawling (e.g., `^private\.example\.com$`).

  • allow_externalboolean可选
    默认 true

    Whether to include external domain links in the final results list.

  • ▸ 更多参数(2)
    • timeoutnumber可选
      默认 150

      Maximum time in seconds to wait for the map operation before timing out. Must be between 10 and 150 seconds.

    • include_usageboolean可选
      默认 false

      Whether to include credit usage information in the response.`NOTE:`The value may be 0 if the total successful pages mapped has not yet reached 10 calls. See our [Credits & Pricing documentation](https://docs.tavily.com/documentation/api-credits) for details.

返回

200

调用前要求账户余额大于 0;按本次调用实际消耗的 credits 计费,每 credit $0.01;上游未返回用量时,按本次请求可能消耗的上限计费。

错误按 Tavily 格式返回,参见 错误码

响应

HTTP 200

Map results returned successfully

application/json

名称类型说明
base_urlstringThe base URL that was mapped.
resultsarray<string>A list of URLs that were discovered during the mapping.
response_timenumberTime in seconds it took to complete the request.
usageobjectCredit usage details for the request.
request_idstringA unique request identifier you can share with customer support to help resolve issues with specific requests.

自动化 API

管理动作、发布脚本与工作流、查看运行并接收入站 webhook。

https://api.deepraxis.ai/automation/v1

鉴权

使用 Authorization: Bearer $PRAXIS_API_KEY。入站 webhook 使用创建或轮换时返回的 secret URL,无需 API Key。

TypeScript SDK

SDK 尚未发布到 npm。从本地源码安装,再用 Bun 运行示例;将命令中的路径替换为本地 SDK 目录。

bun add /absolute/path/to/packages/sdk/typescript
bun example.ts

示例使用 develop。curl 请求体带变量时需安装 jq。资源示例名称以 sample- 开头;创建前换成尚未占用的名称。动作、脚本和工作流使用 docs-samples 命名空间,完成后归档;触发器完成后删除。

动作

脚本

工作流

定义工具

运行

触发器与入站 webhook

列出动作

筛选可见动作并读取修订摘要。可按名称或说明筛选,包含近七天统计;不含实现源码,默认排除已归档动作。

GET /automation/v1/actions

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
query: limitinteger可选;每页条数,整数 1–100,默认 20。 minimum: 1;maximum: 100
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。
query: qstring可选;不区分大小写,按名称或说明的字面子串匹配;% 与 _ 无通配含义。
query: namespacestring[]可选;仅返回指定命名空间的定义,名称按小写匹配。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: scope"platform" / "own"[]可选;platform 仅平台定义,own 仅租户自建定义;省略返回两者。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: archivedboolean可选;true 仅已归档,false 仅未归档;默认 false。
query: implementation"code" / "container" / "shell"[]可选;按实现类型筛选:code、container 或 shell;省略不过滤。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: labelsobject可选;按标签过滤,使用 labels[k]=v;同键逗号多值取任一,不同键同时满足。
query: created_at[gte]string可选;创建时间下界,包含边界;使用带时区的 ISO 8601 时间。 format: "date-time"
query: created_at[lte]string可选;创建时间上界,包含边界;使用带时区的 ISO 8601 时间。 format: "date-time"

示例

curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/actions" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  --get \
  --data-urlencode "namespace=docs-samples" \
  --data-urlencode "limit=1"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.actions.list({
  "query": {
    "namespace": [
      "docs-samples"
    ],
    "limit": 1
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的动作(含当前修订摘要与近七天统计),按 created_at 倒序、id 倒序排列。
data[].idstring必填 / 必有;动作 ID,前缀 act_;日常调用使用 namespace 与 name,而不是 id。
data[].namespacestring必填 / 必有;动作命名空间;平台动作为 praxis,裸名引用解析到 praxis。
data[].namestring必填 / 必有;动作名,与 namespace 一起唯一标识动作;小写字母、数字、点、下划线、连字符,最长 64 字符。
data[].descriptionstring必填 / 必有;动作说明,最多 1000 字符。
data[].labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
data[].ownerstring必填 / 必有;动作所属租户,由网关注入;按不透明字符串处理。
data[].builtinboolean必填 / 必有;true 表示平台内置动作(命名空间 praxis);用户创建的动作为 false。
data[].stats_7dobject必填 / 必有;近七天统计;平台动作按调用方租户隔离,只反映当前调用方的调用,不是平台全局统计。 不接受额外字段。
data[].stats_7d.callsnumber必填 / 必有;近七天内对该动作的调用次数,按小时汇总。
data[].stats_7d.failuresnumber必填 / 必有;近七天内失败的调用次数。
data[].stats_7d.p50_msnull / number必填 / 必有;耗时中位数的近似上界,单位毫秒;正耗时向上归入 2 的幂分桶(9 ms → 16 ms),0 独立一桶;无有效耗时样本时为 null。
data[].dependentsobject必填 / 必有;引用该动作的脚本与工作流数量,口径为最新版本加草稿。 不接受额外字段。
data[].dependents.scriptsnumber必填 / 必有;引用该动作的脚本数量。
data[].dependents.workflowsnumber必填 / 必有;引用该动作的工作流数量。
data[].archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不能复用。
data[].created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
data[].updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。
data[].current_revisionobject必填 / 必有;列表使用的修订摘要:只含契约与运行位置,不含实现源码。 不接受额外字段。
data[].current_revision.idstring必填 / 必有;修订 ID,前缀 actr_。
data[].current_revision.implementationobject必填 / 必有;动作列表只返回 {kind, host},不含源码;动作详情返回完整 implementation。 不接受额外字段。
data[].current_revision.implementation.kind"code" / "container" / "shell"必填 / 必有;动作实现方式。code 为源码实现(目前仅 language=ts 可用);container 为容器镜像加命令,暂未开放;shell 为 shell 脚本,暂未开放。
data[].current_revision.implementation.host"builtin" / "isolate" / "sandbox"必填 / 必有;动作运行位置,发布时计算。builtin 为平台内置动作;isolate 为在隔离的 Worker isolate 中运行用户代码;sandbox 为在沙箱中运行(container 与 shell 实现)。
data[].current_revision.host"builtin" / "isolate" / "sandbox"必填 / 必有;动作运行位置,发布时计算。builtin 为平台内置动作;isolate 为在隔离的 Worker isolate 中运行用户代码;sandbox 为在沙箱中运行(container 与 shell 实现)。
data[].current_revision.input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
data[].current_revision.input_schema.*(分支5)object递归 JSON 值。
data[].current_revision.input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[].current_revision.output_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
data[].current_revision.output_schema.*(分支5)object递归 JSON 值。
data[].current_revision.output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[].current_revision.created_atstring必填 / 必有;该修订的创建时间(RFC 3339 UTC)。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [
    {
      "id": "act_00mv67loz4fe4f27bdf89346c885b3a28b2038c091",
      "owner": "tnt_3a9759864ccb4e00",
      "namespace": "docs-samples",
      "name": "sample-action-1791867412840-b05e8a",
      "description": "",
      "labels": {},
      "builtin": false,
      "archived_at": null,
      "created_at": "2026-10-13T04:57:09.039Z",
      "updated_at": "2026-10-13T04:57:09.039Z",
      "current_revision": {
        "id": "actr_00mv67loz3e46938b8ecf54e57b8f31297df016a1c",
        "implementation": {
          "kind": "code",
          "host": "isolate"
        },
        "host": "isolate",
        "input_schema": {
          "type": "object",
          "properties": {
            "n": {
              "type": "number"
            }
          },
          "required": [
            "n"
          ],
          "additionalProperties": false
        },
        "output_schema": {
          "type": "object",
          "properties": {
            "answer": {
              "type": "number"
            }
          },
          "required": [
            "answer"
          ],
          "additionalProperties": false
        },
        "created_at": "2026-10-13T04:57:09.039Z"
      },
      "stats_7d": {
        "calls": 0,
        "failures": 0,
        "p50_ms": null
      },
      "dependents": {
        "scripts": 0,
        "workflows": 0
      }
    }
  ],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

创建动作

创建动作定义和首个修订,名称折叠为小写;同租户重名返回 NAME_TAKEN,praxis 命名空间只读。

POST /automation/v1/actions

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
header: Idempotency-Keystring可选;可选;1–256 字符。24 小时内同一 key 重放首个响应并带 Idempotent-Replayed: true;同 key 不同请求体返回 422;处理中返回 409。 minLength: 1;maxLength: 256

application/json

不接受额外字段。

字段类型说明
namespacestring必填 / 必有;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9.-]{0,63};praxis 只读。 pattern: "^[a-zA-Z0-9][a-zA-Z0-9.-]{0,63}$"
namestring必填 / 必有;名称,存储前转为小写,格式 [a-z0-9][a-z0-9.-]{0,63}。 pattern: "^[a-zA-Z0-9][a-zA-Z0-9.-]{0,63}$"
descriptionstring可选;说明,最多 1000 个字符。 maxLength: 1000
input_schemaobject必填 / 必有;输入 JSON Schema;更新时只能放宽已接受的输入。
input_schema.(分支5).null / string / number / boolean / object / JSON[]递归 JSON 值。
input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
output_schemaobject必填 / 必有;输出 JSON Schema;更新时只能收紧输出约束。
output_schema.(分支5).null / string / number / boolean / object / JSON[]递归 JSON 值。
output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
errorsobject[]可选;声明的错误类型与说明;更新时不能删除已有错误。
errors[].typestring必填 / 必有;错误类型:稳定的 URI,或 Open Workflow 标准类型(如 validation、timeout、communication、runtime)。
errors[].codestring可选;可选的稳定错误码,供调用方按码分支处理。
errors[].descriptionstring必填 / 必有;该错误的含义与触发条件,面向调用方阅读。
annotationsobject可选;read_only 与 idempotent 为布尔值,缺省均为 false。 不接受额外字段。
annotations.read_onlyboolean可选;true 表示动作不修改外部状态,只读取数据。默认 false。
annotations.idempotentboolean可选;true 表示同一输入重复调用与调用一次效果相同;此类动作的重试使用同一幂等键(run_id 加步骤路径,不含尝试次数)。默认 false。
timeout_msnumber可选;正整数毫秒;当前 code 默认且最多 30000,container/shell 暂未开放。
implementationobject / object / object必填 / 必有;实现:code 使用 language=ts 与 source;container(image、command)和 shell(script)暂未开放,创建或更新时返回 OPERATION_NOT_SUPPORTED。
implementation(分支1).kind"code"必填 / 必有;固定为 code:以源码实现。
implementation(分支1).language"ts"必填 / 必有;源码语言,目前只支持 ts(TypeScript)。
implementation(分支1).sourcestring必填 / 必有;动作的完整 TypeScript 源码。
implementation(分支2).kind"container"必填 / 必有;固定为 container:以容器镜像实现(暂未开放,返回 OPERATION_NOT_SUPPORTED)。
implementation(分支2).imagestring必填 / 必有;容器镜像引用。
implementation(分支2).commandstring[]必填 / 必有;在容器中执行的命令及参数列表。
implementation(分支3).kind"shell"必填 / 必有;固定为 shell:以 shell 脚本实现(暂未开放,返回 OPERATION_NOT_SUPPORTED)。
implementation(分支3).scriptstring必填 / 必有;要执行的 shell 脚本全文。
labelsobject可选;最多 50 个标签;键为 1–40 个字符,值最多 500 个字符。
messagestring可选;本次修订的说明。

示例

curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/actions" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "namespace": "docs-samples",
  "name": "sample-action",
  "input_schema": {
    "type": "object",
    "properties": {
      "n": {
        "type": "number"
      }
    },
    "required": [
      "n"
    ],
    "additionalProperties": false
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "answer": {
        "type": "number"
      }
    },
    "required": [
      "answer"
    ],
    "additionalProperties": false
  },
  "implementation": {
    "kind": "code",
    "language": "ts",
    "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
  }
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.actions.create({
  "body": {
    "namespace": "docs-samples",
    "name": "sample-action",
    "input_schema": {
      "type": "object",
      "properties": {
        "n": {
          "type": "number"
        }
      },
      "required": [
        "n"
      ],
      "additionalProperties": false
    },
    "output_schema": {
      "type": "object",
      "properties": {
        "answer": {
          "type": "number"
        }
      },
      "required": [
        "answer"
      ],
      "additionalProperties": false
    },
    "implementation": {
      "kind": "code",
      "language": "ts",
      "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
    }
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
Idempotent-ReplayedbooleanPresent and true when replaying the first response for this key.

application/json

字段类型说明
idstring必填 / 必有;动作 ID,前缀 act_;日常调用使用 namespace 与 name,而不是 id。
namespacestring必填 / 必有;动作命名空间;平台动作为 praxis,裸名引用解析到 praxis。
namestring必填 / 必有;动作名,与 namespace 一起唯一标识动作;小写字母、数字、点、下划线、连字符,最长 64 字符。
descriptionstring必填 / 必有;动作说明,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;动作所属租户,由网关注入;按不透明字符串处理。
builtinboolean必填 / 必有;true 表示平台内置动作(命名空间 praxis);用户创建的动作为 false。
current_revisionobject必填 / 必有;动作的一个不可变修订:契约、实现和运行参数的快照。每次更新兼容的内容变化都会产生新修订。 不接受额外字段。
current_revision.idstring必填 / 必有;修订 ID,前缀 actr_;仅用于展示与回滚(rollback 的 revision),不能被脚本直接引用。
current_revision.digeststring必填 / 必有;契约与实现的内容摘要;内容相同的更新不会产生新修订。
current_revision.input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
current_revision.input_schema.*(分支5)object递归 JSON 值。
current_revision.input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
current_revision.output_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
current_revision.output_schema.*(分支5)object递归 JSON 值。
current_revision.output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
current_revision.errorsobject[]必填 / 必有;动作声明的可能错误列表,每项含 type、code、description。
current_revision.errors[].typestring必填 / 必有;错误类型:稳定的 URI,或 Open Workflow 标准类型(如 validation、timeout、communication、runtime)。
current_revision.errors[].codestring可选;可选的稳定错误码,供调用方按码分支处理。
current_revision.errors[].descriptionstring必填 / 必有;该错误的含义与触发条件,面向调用方阅读。
current_revision.annotationsobject必填 / 必有;动作行为声明 {read_only, idempotent};创建时未给出的键默认为 false。 不接受额外字段。
current_revision.annotations.read_onlyboolean必填 / 必有;true 表示动作不修改外部状态,只读取数据。
current_revision.annotations.idempotentboolean必填 / 必有;true 表示同一输入重复调用与调用一次效果相同;此类动作的重试使用同一幂等键(run_id 加步骤路径,不含尝试次数)。
current_revision.timeout_msnumber必填 / 必有;单次执行的超时毫秒数;创建时未给出,code 实现默认 30000,容器或 shell 实现默认 600000。
current_revision.implementationobject / object / object必填 / 必有;code 使用 language=ts 与 source。container 和 shell 暂未开放,创建时返回 OPERATION_NOT_SUPPORTED。
current_revision.implementation(分支1).kind"code"必填 / 必有;固定为 code:以源码实现。
current_revision.implementation(分支1).language"ts"必填 / 必有;源码语言,目前只支持 ts(TypeScript)。
current_revision.implementation(分支1).sourcestring必填 / 必有;动作的完整 TypeScript 源码;内置动作为空。
current_revision.implementation(分支2).kind"container"必填 / 必有;固定为 container:以容器镜像实现(暂未开放)。
current_revision.implementation(分支2).imagestring必填 / 必有;容器镜像引用。
current_revision.implementation(分支2).commandstring[]必填 / 必有;在容器中执行的命令及参数列表。
current_revision.implementation(分支3).kind"shell"必填 / 必有;固定为 shell:以 shell 脚本实现(暂未开放)。
current_revision.implementation(分支3).scriptstring必填 / 必有;要执行的 shell 脚本全文。
current_revision.host"builtin" / "isolate" / "sandbox"必填 / 必有;动作运行位置,发布时计算。builtin 为平台内置动作;isolate 为在隔离的 Worker isolate 中运行用户代码;sandbox 为在沙箱中运行(container 与 shell 实现)。
current_revision.platform_apisstring[]必填 / 必有;从代码推导出的平台 API 集合,同时是该动作运行令牌的权限范围(最小权限)。
current_revision.created_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
current_revision.created_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
current_revision.created_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
current_revision.messagenull / string必填 / 必有;创建该修订时附带的说明;未提供为 null。
current_revision.created_atstring必填 / 必有;该修订的创建时间(RFC 3339 UTC)。
stats_7dobject必填 / 必有;近七天统计;平台动作按调用方租户隔离,只反映当前调用方的调用,不是平台全局统计。 不接受额外字段。
stats_7d.callsnumber必填 / 必有;近七天内对该动作的调用次数,按小时汇总。
stats_7d.failuresnumber必填 / 必有;近七天内失败的调用次数。
stats_7d.p50_msnull / number必填 / 必有;耗时中位数的近似上界,单位毫秒;正耗时向上归入 2 的幂分桶(9 ms → 16 ms),0 独立一桶;无有效耗时样本时为 null。
dependentsobject必填 / 必有;引用该动作的脚本与工作流数量,口径为最新版本加草稿。 不接受额外字段。
dependents.scriptsnumber必填 / 必有;引用该动作的脚本数量。
dependents.workflowsnumber必填 / 必有;引用该动作的工作流数量。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不能复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "act_00mv67loz4fe4f27bdf89346c885b3a28b2038c091",
  "owner": "tnt_3a9759864ccb4e00",
  "namespace": "docs-samples",
  "name": "sample-action-1791867412840-b05e8a",
  "description": "",
  "labels": {},
  "builtin": false,
  "current_revision": {
    "input_schema": {
      "type": "object",
      "properties": {
        "n": {
          "type": "number"
        }
      },
      "required": [
        "n"
      ],
      "additionalProperties": false
    },
    "output_schema": {
      "type": "object",
      "properties": {
        "answer": {
          "type": "number"
        }
      },
      "required": [
        "answer"
      ],
      "additionalProperties": false
    },
    "errors": [],
    "annotations": {
      "read_only": false,
      "idempotent": false
    },
    "timeout_ms": 30000,
    "implementation": {
      "kind": "code",
      "language": "ts",
      "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
    },
    "host": "isolate",
    "platform_apis": [],
    "id": "actr_00mv67loz3e46938b8ecf54e57b8f31297df016a1c",
    "digest": "e35c209873c60486ca8da455878062cb7ea572a6147ce3ca03e0693b4769fa45",
    "created_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    },
    "message": null,
    "created_at": "2026-10-13T04:57:09.039Z"
  },
  "stats_7d": {
    "calls": 0,
    "failures": 0,
    "p50_ms": null
  },
  "dependents": {
    "scripts": 0,
    "workflows": 0
  },
  "archived_at": null,
  "created_at": "2026-10-13T04:57:09.039Z",
  "updated_at": "2026-10-13T04:57:09.039Z"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 INPUT_INVALID:输入不满足目标契约或业务校验。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
409IDEMPOTENCY_IN_FLIGHT:同一幂等键的请求仍在处理中。 NAME_TAKEN:名称已被同一租户占用。
413PAYLOAD_TOO_LARGE:请求内容超过本操作允许的大小。
422IDEMPOTENCY_KEY_MISMATCH:同一幂等键已用于不同请求内容。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

读取动作

读取动作及当前修订的完整实现;响应 ETag 是当前修订 ID,可用于更新时的 If-Match。

GET /automation/v1/actions/{ns}/{name}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
ACTION_NAME创建动作返回的 name
: "${ACTION_NAME:?Set ACTION_NAME}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/actions/docs-samples/${ACTION_NAME}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.actions.retrieve({
  "path": {
    "ns": "docs-samples",
    "name": env("ACTION_NAME")
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
ETagstringCurrent resource revision for conditional updates.

application/json

字段类型说明
idstring必填 / 必有;动作 ID,前缀 act_;日常调用使用 namespace 与 name,而不是 id。
namespacestring必填 / 必有;动作命名空间;平台动作为 praxis,裸名引用解析到 praxis。
namestring必填 / 必有;动作名,与 namespace 一起唯一标识动作;小写字母、数字、点、下划线、连字符,最长 64 字符。
descriptionstring必填 / 必有;动作说明,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;动作所属租户,由网关注入;按不透明字符串处理。
builtinboolean必填 / 必有;true 表示平台内置动作(命名空间 praxis);用户创建的动作为 false。
current_revisionobject必填 / 必有;动作的一个不可变修订:契约、实现和运行参数的快照。每次更新兼容的内容变化都会产生新修订。 不接受额外字段。
current_revision.idstring必填 / 必有;修订 ID,前缀 actr_;仅用于展示与回滚(rollback 的 revision),不能被脚本直接引用。
current_revision.digeststring必填 / 必有;契约与实现的内容摘要;内容相同的更新不会产生新修订。
current_revision.input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
current_revision.input_schema.*(分支5)object递归 JSON 值。
current_revision.input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
current_revision.output_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
current_revision.output_schema.*(分支5)object递归 JSON 值。
current_revision.output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
current_revision.errorsobject[]必填 / 必有;动作声明的可能错误列表,每项含 type、code、description。
current_revision.errors[].typestring必填 / 必有;错误类型:稳定的 URI,或 Open Workflow 标准类型(如 validation、timeout、communication、runtime)。
current_revision.errors[].codestring可选;可选的稳定错误码,供调用方按码分支处理。
current_revision.errors[].descriptionstring必填 / 必有;该错误的含义与触发条件,面向调用方阅读。
current_revision.annotationsobject必填 / 必有;动作行为声明 {read_only, idempotent};创建时未给出的键默认为 false。 不接受额外字段。
current_revision.annotations.read_onlyboolean必填 / 必有;true 表示动作不修改外部状态,只读取数据。
current_revision.annotations.idempotentboolean必填 / 必有;true 表示同一输入重复调用与调用一次效果相同;此类动作的重试使用同一幂等键(run_id 加步骤路径,不含尝试次数)。
current_revision.timeout_msnumber必填 / 必有;单次执行的超时毫秒数;创建时未给出,code 实现默认 30000,容器或 shell 实现默认 600000。
current_revision.implementationobject / object / object必填 / 必有;code 使用 language=ts 与 source。container 和 shell 暂未开放,创建时返回 OPERATION_NOT_SUPPORTED。
current_revision.implementation(分支1).kind"code"必填 / 必有;固定为 code:以源码实现。
current_revision.implementation(分支1).language"ts"必填 / 必有;源码语言,目前只支持 ts(TypeScript)。
current_revision.implementation(分支1).sourcestring必填 / 必有;动作的完整 TypeScript 源码;内置动作为空。
current_revision.implementation(分支2).kind"container"必填 / 必有;固定为 container:以容器镜像实现(暂未开放)。
current_revision.implementation(分支2).imagestring必填 / 必有;容器镜像引用。
current_revision.implementation(分支2).commandstring[]必填 / 必有;在容器中执行的命令及参数列表。
current_revision.implementation(分支3).kind"shell"必填 / 必有;固定为 shell:以 shell 脚本实现(暂未开放)。
current_revision.implementation(分支3).scriptstring必填 / 必有;要执行的 shell 脚本全文。
current_revision.host"builtin" / "isolate" / "sandbox"必填 / 必有;动作运行位置,发布时计算。builtin 为平台内置动作;isolate 为在隔离的 Worker isolate 中运行用户代码;sandbox 为在沙箱中运行(container 与 shell 实现)。
current_revision.platform_apisstring[]必填 / 必有;从代码推导出的平台 API 集合,同时是该动作运行令牌的权限范围(最小权限)。
current_revision.created_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
current_revision.created_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
current_revision.created_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
current_revision.messagenull / string必填 / 必有;创建该修订时附带的说明;未提供为 null。
current_revision.created_atstring必填 / 必有;该修订的创建时间(RFC 3339 UTC)。
stats_7dobject必填 / 必有;近七天统计;平台动作按调用方租户隔离,只反映当前调用方的调用,不是平台全局统计。 不接受额外字段。
stats_7d.callsnumber必填 / 必有;近七天内对该动作的调用次数,按小时汇总。
stats_7d.failuresnumber必填 / 必有;近七天内失败的调用次数。
stats_7d.p50_msnull / number必填 / 必有;耗时中位数的近似上界,单位毫秒;正耗时向上归入 2 的幂分桶(9 ms → 16 ms),0 独立一桶;无有效耗时样本时为 null。
dependentsobject必填 / 必有;引用该动作的脚本与工作流数量,口径为最新版本加草稿。 不接受额外字段。
dependents.scriptsnumber必填 / 必有;引用该动作的脚本数量。
dependents.workflowsnumber必填 / 必有;引用该动作的工作流数量。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不能复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "act_00mv67loz4fe4f27bdf89346c885b3a28b2038c091",
  "owner": "tnt_3a9759864ccb4e00",
  "namespace": "docs-samples",
  "name": "sample-action-1791867412840-b05e8a",
  "description": "",
  "labels": {},
  "builtin": false,
  "archived_at": null,
  "created_at": "2026-10-13T04:57:09.039Z",
  "updated_at": "2026-10-13T04:57:09.039Z",
  "current_revision": {
    "id": "actr_00mv67loz3e46938b8ecf54e57b8f31297df016a1c",
    "digest": "e35c209873c60486ca8da455878062cb7ea572a6147ce3ca03e0693b4769fa45",
    "input_schema": {
      "type": "object",
      "properties": {
        "n": {
          "type": "number"
        }
      },
      "required": [
        "n"
      ],
      "additionalProperties": false
    },
    "output_schema": {
      "type": "object",
      "properties": {
        "answer": {
          "type": "number"
        }
      },
      "required": [
        "answer"
      ],
      "additionalProperties": false
    },
    "errors": [],
    "annotations": {
      "read_only": false,
      "idempotent": false
    },
    "timeout_ms": 30000,
    "implementation": {
      "kind": "code",
      "language": "ts",
      "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
    },
    "host": "isolate",
    "platform_apis": [],
    "created_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    },
    "message": null,
    "created_at": "2026-10-13T04:57:09.039Z"
  },
  "stats_7d": {
    "calls": 0,
    "failures": 0,
    "p50_ms": null
  },
  "dependents": {
    "scripts": 0,
    "workflows": 0
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404ACTION_NOT_FOUND:动作不存在或当前租户不可见;同名脚本/工作流存在时,hint 指向相应接口。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

更新动作

检查当前和最近五个历史修订的兼容性后更新。输入放宽、输出收紧为兼容,包括长度、条目数、属性数、type(integer/number)与 multipleOf(输入新因子可整除旧因子,输出相反)。dry_run=true 仅返回 CompatResult,可不带 If-Match;带了仍校验,* 匹配任何当前存在的表示。正常更新必须带 If-Match,返回 ActionDef 与 ETag;预检不返回 ETag。省略的可选字段保持原值仅适用于 description、labels;errors 默认 [],annotations 未提供的键默认 false,timeout_ms 默认 30000,message 默认 null。 正常更新不兼容时返回 422 SCHEMA_INCOMPATIBLE 与 issues;内容未变则保留现有修订。

PUT /automation/v1/actions/{ns}/{name}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
query: dry_runboolean可选;true 仅检查兼容性,不落库,可省略 If-Match;省略或 false 正常更新。
header: If-Matchstring可选;正常更新必填;dry_run=true 可省略,提供时仍校验。* 匹配任何当前存在的表示;也可提供当前修订 ETag。

application/json

不接受额外字段。

字段类型说明
descriptionstring可选;说明,最多 1000 个字符。 maxLength: 1000
labelsobject可选;最多 50 个标签;键为 1–40 个字符,值最多 500 个字符。
input_schemaobject必填 / 必有;输入 JSON Schema;更新时只能放宽已接受的输入。
input_schema.(分支5).null / string / number / boolean / object / JSON[]递归 JSON 值。
input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
output_schemaobject必填 / 必有;输出 JSON Schema;更新时只能收紧输出约束。
output_schema.(分支5).null / string / number / boolean / object / JSON[]递归 JSON 值。
output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
errorsobject[]可选;声明的错误类型与说明;更新时不能删除已有错误。
errors[].typestring必填 / 必有;错误类型:稳定的 URI,或 Open Workflow 标准类型(如 validation、timeout、communication、runtime)。
errors[].codestring可选;可选的稳定错误码,供调用方按码分支处理。
errors[].descriptionstring必填 / 必有;该错误的含义与触发条件,面向调用方阅读。
annotationsobject可选;read_only 与 idempotent 为布尔值,缺省均为 false。 不接受额外字段。
annotations.read_onlyboolean可选;true 表示动作不修改外部状态,只读取数据。默认 false。
annotations.idempotentboolean可选;true 表示同一输入重复调用与调用一次效果相同;此类动作的重试使用同一幂等键(run_id 加步骤路径,不含尝试次数)。默认 false。
timeout_msnumber可选;正整数毫秒;当前 code 默认且最多 30000,container/shell 暂未开放。
implementationobject / object / object必填 / 必有;实现:code 使用 language=ts 与 source;container(image、command)和 shell(script)暂未开放,创建或更新时返回 OPERATION_NOT_SUPPORTED。
implementation(分支1).kind"code"必填 / 必有;固定为 code:以源码实现。
implementation(分支1).language"ts"必填 / 必有;源码语言,目前只支持 ts(TypeScript)。
implementation(分支1).sourcestring必填 / 必有;动作的完整 TypeScript 源码。
implementation(分支2).kind"container"必填 / 必有;固定为 container:以容器镜像实现(暂未开放,返回 OPERATION_NOT_SUPPORTED)。
implementation(分支2).imagestring必填 / 必有;容器镜像引用。
implementation(分支2).commandstring[]必填 / 必有;在容器中执行的命令及参数列表。
implementation(分支3).kind"shell"必填 / 必有;固定为 shell:以 shell 脚本实现(暂未开放,返回 OPERATION_NOT_SUPPORTED)。
implementation(分支3).scriptstring必填 / 必有;要执行的 shell 脚本全文。
messagestring可选;本次修订的说明。

示例

先设置以下环境变量,使用你自己的资源:

: "${ACTION_NAME:?Set ACTION_NAME}"
: "${ETAG:?Set ETAG}"
curl --fail-with-body -X PUT "https://api.deepraxis.ai/automation/v1/actions/docs-samples/${ACTION_NAME}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "If-Match: ${ETAG}" \
  -H "Content-Type: application/json" \
  --data '{
  "input_schema": {
    "type": "object",
    "properties": {
      "n": {
        "type": "number"
      }
    },
    "required": [
      "n"
    ],
    "additionalProperties": false
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "answer": {
        "type": "number"
      }
    },
    "required": [
      "answer"
    ],
    "additionalProperties": false
  },
  "implementation": {
    "kind": "code",
    "language": "ts",
    "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
  },
  "message": "Sample revision"
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.actions.update({
  "path": {
    "ns": "docs-samples",
    "name": env("ACTION_NAME")
  },
  "headers": {
    "If-Match": env("ETAG")
  },
  "body": {
    "input_schema": {
      "type": "object",
      "properties": {
        "n": {
          "type": "number"
        }
      },
      "required": [
        "n"
      ],
      "additionalProperties": false
    },
    "output_schema": {
      "type": "object",
      "properties": {
        "answer": {
          "type": "number"
        }
      },
      "required": [
        "answer"
      ],
      "additionalProperties": false
    },
    "implementation": {
      "kind": "code",
      "language": "ts",
      "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
    },
    "message": "Sample revision"
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
ETagstringCurrent revision returned only for normal updates; absent for dry_run=true.

application/json

字段类型说明
(分支1).idstring必填 / 必有;动作 ID,前缀 act_;日常调用使用 namespace 与 name,而不是 id。
(分支1).namespacestring必填 / 必有;动作命名空间;平台动作为 praxis,裸名引用解析到 praxis。
(分支1).namestring必填 / 必有;动作名,与 namespace 一起唯一标识动作;小写字母、数字、点、下划线、连字符,最长 64 字符。
(分支1).descriptionstring必填 / 必有;动作说明,最多 1000 字符。
(分支1).labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
(分支1).ownerstring必填 / 必有;动作所属租户,由网关注入;按不透明字符串处理。
(分支1).builtinboolean必填 / 必有;true 表示平台内置动作(命名空间 praxis);用户创建的动作为 false。
(分支1).current_revisionobject必填 / 必有;动作的一个不可变修订:契约、实现和运行参数的快照。每次更新兼容的内容变化都会产生新修订。 不接受额外字段。
(分支1).current_revision.idstring必填 / 必有;修订 ID,前缀 actr_;仅用于展示与回滚(rollback 的 revision),不能被脚本直接引用。
(分支1).current_revision.digeststring必填 / 必有;契约与实现的内容摘要;内容相同的更新不会产生新修订。
(分支1).current_revision.input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
(分支1).current_revision.input_schema.*(分支5)object递归 JSON 值。
(分支1).current_revision.input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支1).current_revision.output_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
(分支1).current_revision.output_schema.*(分支5)object递归 JSON 值。
(分支1).current_revision.output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支1).current_revision.errorsobject[]必填 / 必有;动作声明的可能错误列表,每项含 type、code、description。
(分支1).current_revision.errors[].typestring必填 / 必有;错误类型:稳定的 URI,或 Open Workflow 标准类型(如 validation、timeout、communication、runtime)。
(分支1).current_revision.errors[].codestring可选;可选的稳定错误码,供调用方按码分支处理。
(分支1).current_revision.errors[].descriptionstring必填 / 必有;该错误的含义与触发条件,面向调用方阅读。
(分支1).current_revision.annotationsobject必填 / 必有;动作行为声明 {read_only, idempotent};创建时未给出的键默认为 false。 不接受额外字段。
(分支1).current_revision.annotations.read_onlyboolean必填 / 必有;true 表示动作不修改外部状态,只读取数据。
(分支1).current_revision.annotations.idempotentboolean必填 / 必有;true 表示同一输入重复调用与调用一次效果相同;此类动作的重试使用同一幂等键(run_id 加步骤路径,不含尝试次数)。
(分支1).current_revision.timeout_msnumber必填 / 必有;单次执行的超时毫秒数;创建时未给出,code 实现默认 30000,容器或 shell 实现默认 600000。
(分支1).current_revision.implementationobject / object / object必填 / 必有;code 使用 language=ts 与 source。container 和 shell 暂未开放,创建时返回 OPERATION_NOT_SUPPORTED。
(分支1).current_revision.implementation(分支1).kind"code"必填 / 必有;固定为 code:以源码实现。
(分支1).current_revision.implementation(分支1).language"ts"必填 / 必有;源码语言,目前只支持 ts(TypeScript)。
(分支1).current_revision.implementation(分支1).sourcestring必填 / 必有;动作的完整 TypeScript 源码;内置动作为空。
(分支1).current_revision.implementation(分支2).kind"container"必填 / 必有;固定为 container:以容器镜像实现(暂未开放)。
(分支1).current_revision.implementation(分支2).imagestring必填 / 必有;容器镜像引用。
(分支1).current_revision.implementation(分支2).commandstring[]必填 / 必有;在容器中执行的命令及参数列表。
(分支1).current_revision.implementation(分支3).kind"shell"必填 / 必有;固定为 shell:以 shell 脚本实现(暂未开放)。
(分支1).current_revision.implementation(分支3).scriptstring必填 / 必有;要执行的 shell 脚本全文。
(分支1).current_revision.host"builtin" / "isolate" / "sandbox"必填 / 必有;动作运行位置,发布时计算。builtin 为平台内置动作;isolate 为在隔离的 Worker isolate 中运行用户代码;sandbox 为在沙箱中运行(container 与 shell 实现)。
(分支1).current_revision.platform_apisstring[]必填 / 必有;从代码推导出的平台 API 集合,同时是该动作运行令牌的权限范围(最小权限)。
(分支1).current_revision.created_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
(分支1).current_revision.created_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
(分支1).current_revision.created_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
(分支1).current_revision.messagenull / string必填 / 必有;创建该修订时附带的说明;未提供为 null。
(分支1).current_revision.created_atstring必填 / 必有;该修订的创建时间(RFC 3339 UTC)。
(分支1).stats_7dobject必填 / 必有;近七天统计;平台动作按调用方租户隔离,只反映当前调用方的调用,不是平台全局统计。 不接受额外字段。
(分支1).stats_7d.callsnumber必填 / 必有;近七天内对该动作的调用次数,按小时汇总。
(分支1).stats_7d.failuresnumber必填 / 必有;近七天内失败的调用次数。
(分支1).stats_7d.p50_msnull / number必填 / 必有;耗时中位数的近似上界,单位毫秒;正耗时向上归入 2 的幂分桶(9 ms → 16 ms),0 独立一桶;无有效耗时样本时为 null。
(分支1).dependentsobject必填 / 必有;引用该动作的脚本与工作流数量,口径为最新版本加草稿。 不接受额外字段。
(分支1).dependents.scriptsnumber必填 / 必有;引用该动作的脚本数量。
(分支1).dependents.workflowsnumber必填 / 必有;引用该动作的工作流数量。
(分支1).archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不能复用。
(分支1).created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
(分支1).updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。
(分支2)(分支1).compatibletrue必填 / 必有;固定为 true:新契约与当前及最近五个历史修订兼容。
(分支2)(分支2).compatiblefalse必填 / 必有;固定为 false:新契约至少在一处与历史修订不兼容。
(分支2)(分支2).issuesobject[]必填 / 必有;全部不兼容之处,每项含 pointer 与 reason。
(分支2)(分支2).issues[].pointerstring必填 / 必有;不兼容位置的 JSON Pointer(RFC 6901),相对于动作的 input_schema 或 output_schema。
(分支2)(分支2).issues[].reasonstring必填 / 必有;该位置为何与历史修订不兼容(输入应放宽、输出应收紧)。

实测响应

HTTP 200

{
  "id": "act_00mv67loz4fe4f27bdf89346c885b3a28b2038c091",
  "owner": "tnt_3a9759864ccb4e00",
  "namespace": "docs-samples",
  "name": "sample-action-1791867412840-b05e8a",
  "description": "",
  "labels": {},
  "builtin": false,
  "archived_at": null,
  "created_at": "2026-10-13T04:57:09.039Z",
  "updated_at": "2026-10-13T04:57:12.709Z",
  "current_revision": {
    "input_schema": {
      "type": "object",
      "properties": {
        "n": {
          "type": "number"
        }
      },
      "required": [
        "n"
      ],
      "additionalProperties": false
    },
    "output_schema": {
      "type": "object",
      "properties": {
        "answer": {
          "type": "number"
        }
      },
      "required": [
        "answer"
      ],
      "additionalProperties": false
    },
    "errors": [],
    "annotations": {
      "read_only": false,
      "idempotent": false
    },
    "timeout_ms": 30000,
    "implementation": {
      "kind": "code",
      "language": "ts",
      "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
    },
    "host": "isolate",
    "platform_apis": [],
    "id": "actr_00mv67lrt1370820a9daaa4fd3882332e4899a4c9e",
    "digest": "e35c209873c60486ca8da455878062cb7ea572a6147ce3ca03e0693b4769fa45",
    "created_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    },
    "message": "Sample revision",
    "created_at": "2026-10-13T04:57:12.709Z"
  },
  "stats_7d": {
    "calls": 0,
    "failures": 0,
    "p50_ms": null
  },
  "dependents": {
    "scripts": 0,
    "workflows": 0
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 INPUT_INVALID:输入不满足目标契约或业务校验。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404ACTION_NOT_FOUND:动作不存在或当前租户不可见;同名脚本/工作流存在时,hint 指向相应接口。
409TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
413PAYLOAD_TOO_LARGE:请求内容超过本操作允许的大小。
422SCHEMA_INCOMPATIBLE:新动作契约与历史修订不兼容。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出动作修订

按创建时间倒序列出修订。结果包含当前标记及通过兼容门回滚的可行性和原因。 默认不带源码;仅 expand=source 带完整源码,其它值返回 400。详情接口保持全文。

GET /automation/v1/actions/{ns}/{name}/revisions

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
query: limitinteger可选;每页条数,整数 1–100,默认 20。 minimum: 1;maximum: 100
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。
query: expand"source"可选;仅接受 source;默认不带源码,其它值返回 400。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
ACTION_NAME创建动作返回的 name
: "${ACTION_NAME:?Set ACTION_NAME}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/actions/docs-samples/${ACTION_NAME}/revisions" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.actions.revisions.list({
  "path": {
    "ns": "docs-samples",
    "name": env("ACTION_NAME")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的动作修订(默认不含实现源码,expand=source 才带),按 created_at 倒序、id 倒序排列。
data[].currentboolean必填 / 必有;true 表示这是动作当前生效的修订。
data[].rollbackobject必填 / 必有;回滚到该修订是否可行,由服务端对当前修订做兼容判定。 不接受额外字段。
data[].rollback.allowedboolean必填 / 必有;true 表示可以回滚到此修订;false 时 issues 说明原因。
data[].rollback.issuesobject[]必填 / 必有;回滚会产生的不兼容项,每项含 pointer 与 reason;allowed 为 true 时为空数组。
data[].rollback.issues[].pointerstring必填 / 必有;不兼容位置的 JSON Pointer(RFC 6901),相对于动作的 input_schema 或 output_schema。
data[].rollback.issues[].reasonstring必填 / 必有;该位置为何与历史修订不兼容(输入应放宽、输出应收紧)。
data[].idstring必填 / 必有;修订 ID,前缀 actr_;仅用于展示与回滚(rollback 的 revision),不能被脚本直接引用。
data[].digeststring必填 / 必有;契约与实现的内容摘要;内容相同的更新不会产生新修订。
data[].input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
data[].input_schema.*(分支5)object递归 JSON 值。
data[].input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[].output_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
data[].output_schema.*(分支5)object递归 JSON 值。
data[].output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[].errorsobject[]必填 / 必有;动作声明的可能错误列表,每项含 type、code、description。
data[].errors[].typestring必填 / 必有;错误类型:稳定的 URI,或 Open Workflow 标准类型(如 validation、timeout、communication、runtime)。
data[].errors[].codestring可选;可选的稳定错误码,供调用方按码分支处理。
data[].errors[].descriptionstring必填 / 必有;该错误的含义与触发条件,面向调用方阅读。
data[].annotationsobject必填 / 必有;动作行为声明 {read_only, idempotent};创建时未给出的键默认为 false。 不接受额外字段。
data[].annotations.read_onlyboolean必填 / 必有;true 表示动作不修改外部状态,只读取数据。
data[].annotations.idempotentboolean必填 / 必有;true 表示同一输入重复调用与调用一次效果相同;此类动作的重试使用同一幂等键(run_id 加步骤路径,不含尝试次数)。
data[].timeout_msnumber必填 / 必有;单次执行的超时毫秒数;创建时未给出,code 实现默认 30000,容器或 shell 实现默认 600000。
data[].implementationobject / object / object / object必填 / 必有;实现信息:完整实现,或仅含 kind;列表不返回源码,需源码用 expand=source 或读取单个修订。
data[].implementation(分支1)(分支1).kind"code"必填 / 必有;固定为 code:以源码实现。
data[].implementation(分支1)(分支1).language"ts"必填 / 必有;源码语言,目前只支持 ts(TypeScript)。
data[].implementation(分支1)(分支1).sourcestring必填 / 必有;动作的完整 TypeScript 源码;内置动作为空。
data[].implementation(分支1)(分支2).kind"container"必填 / 必有;固定为 container:以容器镜像实现(暂未开放)。
data[].implementation(分支1)(分支2).imagestring必填 / 必有;容器镜像引用。
data[].implementation(分支1)(分支2).commandstring[]必填 / 必有;在容器中执行的命令及参数列表。
data[].implementation(分支1)(分支3).kind"shell"必填 / 必有;固定为 shell:以 shell 脚本实现(暂未开放)。
data[].implementation(分支1)(分支3).scriptstring必填 / 必有;要执行的 shell 脚本全文。
data[].implementation(分支2).kind"code" / "container" / "shell"必填 / 必有;动作实现方式。code 为源码实现(目前仅 language=ts 可用);container 为容器镜像加命令,暂未开放;shell 为 shell 脚本,暂未开放。
data[].host"builtin" / "isolate" / "sandbox"必填 / 必有;动作运行位置,发布时计算。builtin 为平台内置动作;isolate 为在隔离的 Worker isolate 中运行用户代码;sandbox 为在沙箱中运行(container 与 shell 实现)。
data[].platform_apisstring[]必填 / 必有;从代码推导出的平台 API 集合,同时是该动作运行令牌的权限范围(最小权限)。
data[].created_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
data[].created_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data[].created_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
data[].messagenull / string必填 / 必有;创建该修订时附带的说明;未提供为 null。
data[].created_atstring必填 / 必有;该修订的创建时间(RFC 3339 UTC)。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [
    {
      "id": "actr_00mv67lrt1370820a9daaa4fd3882332e4899a4c9e",
      "digest": "e35c209873c60486ca8da455878062cb7ea572a6147ce3ca03e0693b4769fa45",
      "input_schema": {
        "type": "object",
        "properties": {
          "n": {
            "type": "number"
          }
        },
        "required": [
          "n"
        ],
        "additionalProperties": false
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "answer": {
            "type": "number"
          }
        },
        "required": [
          "answer"
        ],
        "additionalProperties": false
      },
      "errors": [],
      "annotations": {
        "read_only": false,
        "idempotent": false
      },
      "timeout_ms": 30000,
      "host": "isolate",
      "platform_apis": [],
      "created_by": {
        "type": "api_key",
        "id": "key_3e00b8984967"
      },
      "message": "Sample revision",
      "created_at": "2026-10-13T04:57:12.709Z",
      "current": true,
      "rollback": {
        "allowed": true,
        "issues": []
      },
      "implementation": {
        "kind": "code"
      }
    },
    {
      "id": "actr_00mv67loz3e46938b8ecf54e57b8f31297df016a1c",
      "digest": "e35c209873c60486ca8da455878062cb7ea572a6147ce3ca03e0693b4769fa45",
      "input_schema": {
        "type": "object",
        "properties": {
          "n": {
            "type": "number"
          }
        },
        "required": [
          "n"
        ],
        "additionalProperties": false
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "answer": {
            "type": "number"
          }
        },
        "required": [
          "answer"
        ],
        "additionalProperties": false
      },
      "errors": [],
      "annotations": {
        "read_only": false,
        "idempotent": false
      },
      "timeout_ms": 30000,
      "host": "isolate",
      "platform_apis": [],
      "created_by": {
        "type": "api_key",
        "id": "key_3e00b8984967"
      },
      "message": null,
      "created_at": "2026-10-13T04:57:09.039Z",
      "current": false,
      "rollback": {
        "allowed": true,
        "issues": []
      },
      "implementation": {
        "kind": "code"
      }
    }
  ],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404ACTION_NOT_FOUND:动作不存在或当前租户不可见;同名脚本/工作流存在时,hint 指向相应接口。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

读取动作修订

读取指定修订的完整实现及回滚兼容判定;修订不存在时返回 VERSION_NOT_FOUND。 详情始终返回完整源码。

GET /automation/v1/actions/{ns}/{name}/revisions/{revision}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
path: revisionstring必填;动作修订 ID(actr_);查询参数用于筛选调用记录。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
ACTION_NAME创建动作返回的 name
REVISION_ID已有动作修订 id
: "${ACTION_NAME:?Set ACTION_NAME}"
: "${REVISION_ID:?Set REVISION_ID}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/actions/docs-samples/${ACTION_NAME}/revisions/${REVISION_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.actions.revisions.retrieve({
  "path": {
    "ns": "docs-samples",
    "name": env("ACTION_NAME"),
    "revision": env("REVISION_ID")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
currentboolean必填 / 必有;true 表示这是动作当前生效的修订。
rollbackobject必填 / 必有;回滚到该修订是否可行,由服务端对当前修订做兼容判定。 不接受额外字段。
rollback.allowedboolean必填 / 必有;true 表示可以回滚到此修订;false 时 issues 说明原因。
rollback.issuesobject[]必填 / 必有;回滚会产生的不兼容项,每项含 pointer 与 reason;allowed 为 true 时为空数组。
rollback.issues[].pointerstring必填 / 必有;不兼容位置的 JSON Pointer(RFC 6901),相对于动作的 input_schema 或 output_schema。
rollback.issues[].reasonstring必填 / 必有;该位置为何与历史修订不兼容(输入应放宽、输出应收紧)。
idstring必填 / 必有;修订 ID,前缀 actr_;仅用于展示与回滚(rollback 的 revision),不能被脚本直接引用。
digeststring必填 / 必有;契约与实现的内容摘要;内容相同的更新不会产生新修订。
input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
input_schema.*(分支5)object递归 JSON 值。
input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
output_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
output_schema.*(分支5)object递归 JSON 值。
output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
errorsobject[]必填 / 必有;动作声明的可能错误列表,每项含 type、code、description。
errors[].typestring必填 / 必有;错误类型:稳定的 URI,或 Open Workflow 标准类型(如 validation、timeout、communication、runtime)。
errors[].codestring可选;可选的稳定错误码,供调用方按码分支处理。
errors[].descriptionstring必填 / 必有;该错误的含义与触发条件,面向调用方阅读。
annotationsobject必填 / 必有;动作行为声明 {read_only, idempotent};创建时未给出的键默认为 false。 不接受额外字段。
annotations.read_onlyboolean必填 / 必有;true 表示动作不修改外部状态,只读取数据。
annotations.idempotentboolean必填 / 必有;true 表示同一输入重复调用与调用一次效果相同;此类动作的重试使用同一幂等键(run_id 加步骤路径,不含尝试次数)。
timeout_msnumber必填 / 必有;单次执行的超时毫秒数;创建时未给出,code 实现默认 30000,容器或 shell 实现默认 600000。
implementationobject / object / object必填 / 必有;code 使用 language=ts 与 source。container 和 shell 暂未开放,创建时返回 OPERATION_NOT_SUPPORTED。
implementation(分支1).kind"code"必填 / 必有;固定为 code:以源码实现。
implementation(分支1).language"ts"必填 / 必有;源码语言,目前只支持 ts(TypeScript)。
implementation(分支1).sourcestring必填 / 必有;动作的完整 TypeScript 源码;内置动作为空。
implementation(分支2).kind"container"必填 / 必有;固定为 container:以容器镜像实现(暂未开放)。
implementation(分支2).imagestring必填 / 必有;容器镜像引用。
implementation(分支2).commandstring[]必填 / 必有;在容器中执行的命令及参数列表。
implementation(分支3).kind"shell"必填 / 必有;固定为 shell:以 shell 脚本实现(暂未开放)。
implementation(分支3).scriptstring必填 / 必有;要执行的 shell 脚本全文。
host"builtin" / "isolate" / "sandbox"必填 / 必有;动作运行位置,发布时计算。builtin 为平台内置动作;isolate 为在隔离的 Worker isolate 中运行用户代码;sandbox 为在沙箱中运行(container 与 shell 实现)。
platform_apisstring[]必填 / 必有;从代码推导出的平台 API 集合,同时是该动作运行令牌的权限范围(最小权限)。
created_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
created_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
created_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
messagenull / string必填 / 必有;创建该修订时附带的说明;未提供为 null。
created_atstring必填 / 必有;该修订的创建时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "actr_00mv67loz3e46938b8ecf54e57b8f31297df016a1c",
  "digest": "e35c209873c60486ca8da455878062cb7ea572a6147ce3ca03e0693b4769fa45",
  "input_schema": {
    "type": "object",
    "properties": {
      "n": {
        "type": "number"
      }
    },
    "required": [
      "n"
    ],
    "additionalProperties": false
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "answer": {
        "type": "number"
      }
    },
    "required": [
      "answer"
    ],
    "additionalProperties": false
  },
  "errors": [],
  "annotations": {
    "read_only": false,
    "idempotent": false
  },
  "timeout_ms": 30000,
  "implementation": {
    "kind": "code",
    "language": "ts",
    "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
  },
  "host": "isolate",
  "platform_apis": [],
  "created_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "message": null,
  "created_at": "2026-10-13T04:57:09.039Z",
  "current": false,
  "rollback": {
    "allowed": true,
    "issues": []
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404ACTION_NOT_FOUND:动作不存在或当前租户不可见;同名脚本/工作流存在时,hint 指向相应接口。 VERSION_NOT_FOUND:指定版本或修订不存在。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

回滚动作

用历史内容创建通过兼容检查的新修订。检查覆盖当前及最近五个历史修订;不会把当前指针直接退回旧 ID。可选 If-Match 可指定当前修订或 ; 匹配任何当前存在的表示。

POST /automation/v1/actions/{ns}/{name}/rollback

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
header: If-Matchstring可选;可选当前修订或 ;提供时执行条件校验, 匹配任何当前存在的表示。
header: Idempotency-Keystring可选;可选;1–256 字符。24 小时内同一 key 重放首个响应并带 Idempotent-Replayed: true;同 key 不同请求体返回 422;处理中返回 409。 minLength: 1;maxLength: 256

application/json

不接受额外字段。

字段类型说明
revisionstring必填 / 必有;要回滚到的历史修订 ID(actr_);回滚会创建新修订。
messagestring可选;本次修订的说明。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
ACTION_NAME创建动作返回的 name
REVISION_ID已有动作修订 id
: "${ACTION_NAME:?Set ACTION_NAME}"
: "${REVISION_ID:?Set REVISION_ID}"
BODY=$(jq -n --arg REVISION_ID "$REVISION_ID" '{
  "revision": $REVISION_ID
}')
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/actions/docs-samples/${ACTION_NAME}/rollback" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data "$BODY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.actions.rollback({
  "path": {
    "ns": "docs-samples",
    "name": env("ACTION_NAME")
  },
  "body": {
    "revision": env("REVISION_ID")
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
Idempotent-ReplayedbooleanPresent and true when replaying the first response for this key.
ETagstringCurrent revision ID after rollback.

application/json

字段类型说明
idstring必填 / 必有;动作 ID,前缀 act_;日常调用使用 namespace 与 name,而不是 id。
namespacestring必填 / 必有;动作命名空间;平台动作为 praxis,裸名引用解析到 praxis。
namestring必填 / 必有;动作名,与 namespace 一起唯一标识动作;小写字母、数字、点、下划线、连字符,最长 64 字符。
descriptionstring必填 / 必有;动作说明,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;动作所属租户,由网关注入;按不透明字符串处理。
builtinboolean必填 / 必有;true 表示平台内置动作(命名空间 praxis);用户创建的动作为 false。
current_revisionobject必填 / 必有;动作的一个不可变修订:契约、实现和运行参数的快照。每次更新兼容的内容变化都会产生新修订。 不接受额外字段。
current_revision.idstring必填 / 必有;修订 ID,前缀 actr_;仅用于展示与回滚(rollback 的 revision),不能被脚本直接引用。
current_revision.digeststring必填 / 必有;契约与实现的内容摘要;内容相同的更新不会产生新修订。
current_revision.input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
current_revision.input_schema.*(分支5)object递归 JSON 值。
current_revision.input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
current_revision.output_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
current_revision.output_schema.*(分支5)object递归 JSON 值。
current_revision.output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
current_revision.errorsobject[]必填 / 必有;动作声明的可能错误列表,每项含 type、code、description。
current_revision.errors[].typestring必填 / 必有;错误类型:稳定的 URI,或 Open Workflow 标准类型(如 validation、timeout、communication、runtime)。
current_revision.errors[].codestring可选;可选的稳定错误码,供调用方按码分支处理。
current_revision.errors[].descriptionstring必填 / 必有;该错误的含义与触发条件,面向调用方阅读。
current_revision.annotationsobject必填 / 必有;动作行为声明 {read_only, idempotent};创建时未给出的键默认为 false。 不接受额外字段。
current_revision.annotations.read_onlyboolean必填 / 必有;true 表示动作不修改外部状态,只读取数据。
current_revision.annotations.idempotentboolean必填 / 必有;true 表示同一输入重复调用与调用一次效果相同;此类动作的重试使用同一幂等键(run_id 加步骤路径,不含尝试次数)。
current_revision.timeout_msnumber必填 / 必有;单次执行的超时毫秒数;创建时未给出,code 实现默认 30000,容器或 shell 实现默认 600000。
current_revision.implementationobject / object / object必填 / 必有;code 使用 language=ts 与 source。container 和 shell 暂未开放,创建时返回 OPERATION_NOT_SUPPORTED。
current_revision.implementation(分支1).kind"code"必填 / 必有;固定为 code:以源码实现。
current_revision.implementation(分支1).language"ts"必填 / 必有;源码语言,目前只支持 ts(TypeScript)。
current_revision.implementation(分支1).sourcestring必填 / 必有;动作的完整 TypeScript 源码;内置动作为空。
current_revision.implementation(分支2).kind"container"必填 / 必有;固定为 container:以容器镜像实现(暂未开放)。
current_revision.implementation(分支2).imagestring必填 / 必有;容器镜像引用。
current_revision.implementation(分支2).commandstring[]必填 / 必有;在容器中执行的命令及参数列表。
current_revision.implementation(分支3).kind"shell"必填 / 必有;固定为 shell:以 shell 脚本实现(暂未开放)。
current_revision.implementation(分支3).scriptstring必填 / 必有;要执行的 shell 脚本全文。
current_revision.host"builtin" / "isolate" / "sandbox"必填 / 必有;动作运行位置,发布时计算。builtin 为平台内置动作;isolate 为在隔离的 Worker isolate 中运行用户代码;sandbox 为在沙箱中运行(container 与 shell 实现)。
current_revision.platform_apisstring[]必填 / 必有;从代码推导出的平台 API 集合,同时是该动作运行令牌的权限范围(最小权限)。
current_revision.created_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
current_revision.created_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
current_revision.created_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
current_revision.messagenull / string必填 / 必有;创建该修订时附带的说明;未提供为 null。
current_revision.created_atstring必填 / 必有;该修订的创建时间(RFC 3339 UTC)。
stats_7dobject必填 / 必有;近七天统计;平台动作按调用方租户隔离,只反映当前调用方的调用,不是平台全局统计。 不接受额外字段。
stats_7d.callsnumber必填 / 必有;近七天内对该动作的调用次数,按小时汇总。
stats_7d.failuresnumber必填 / 必有;近七天内失败的调用次数。
stats_7d.p50_msnull / number必填 / 必有;耗时中位数的近似上界,单位毫秒;正耗时向上归入 2 的幂分桶(9 ms → 16 ms),0 独立一桶;无有效耗时样本时为 null。
dependentsobject必填 / 必有;引用该动作的脚本与工作流数量,口径为最新版本加草稿。 不接受额外字段。
dependents.scriptsnumber必填 / 必有;引用该动作的脚本数量。
dependents.workflowsnumber必填 / 必有;引用该动作的工作流数量。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不能复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "act_00mv67loz4fe4f27bdf89346c885b3a28b2038c091",
  "owner": "tnt_3a9759864ccb4e00",
  "namespace": "docs-samples",
  "name": "sample-action-1791867412840-b05e8a",
  "description": "",
  "labels": {},
  "builtin": false,
  "archived_at": null,
  "created_at": "2026-10-13T04:57:09.039Z",
  "updated_at": "2026-10-13T04:57:15.629Z",
  "current_revision": {
    "input_schema": {
      "type": "object",
      "properties": {
        "n": {
          "type": "number"
        }
      },
      "required": [
        "n"
      ],
      "additionalProperties": false
    },
    "output_schema": {
      "type": "object",
      "properties": {
        "answer": {
          "type": "number"
        }
      },
      "required": [
        "answer"
      ],
      "additionalProperties": false
    },
    "errors": [],
    "annotations": {
      "read_only": false,
      "idempotent": false
    },
    "timeout_ms": 30000,
    "implementation": {
      "kind": "code",
      "language": "ts",
      "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
    },
    "host": "isolate",
    "platform_apis": [],
    "id": "actr_00mv67lu25f7f28dd81a924c698b9d2557056a7b62",
    "digest": "e35c209873c60486ca8da455878062cb7ea572a6147ce3ca03e0693b4769fa45",
    "created_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    },
    "message": "回滚到 actr_00mv67loz3e46938b8ecf54e57b8f31297df016a1c",
    "created_at": "2026-10-13T04:57:15.629Z"
  },
  "stats_7d": {
    "calls": 0,
    "failures": 0,
    "p50_ms": null
  },
  "dependents": {
    "scripts": 0,
    "workflows": 0
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 INPUT_INVALID:输入不满足目标契约或业务校验。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404ACTION_NOT_FOUND:动作不存在或当前租户不可见;同名脚本/工作流存在时,hint 指向相应接口。 VERSION_NOT_FOUND:指定版本或修订不存在。
409IDEMPOTENCY_IN_FLIGHT:同一幂等键的请求仍在处理中。 TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
413PAYLOAD_TOO_LARGE:请求内容超过本操作允许的大小。
422IDEMPOTENCY_KEY_MISMATCH:同一幂等键已用于不同请求内容。 SCHEMA_INCOMPATIBLE:新动作契约与历史修订不兼容。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出动作调用

列出该动作的调用记录,可按状态、修订、调用方编排和时间筛选;结果包含所属运行与调用位置。

GET /automation/v1/actions/{ns}/{name}/invocations

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
query: limitinteger可选;每页条数,整数 1–100,默认 20。 minimum: 1;maximum: 100
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。
query: status"running" / "completed" / "faulted" / "cancelled"[]可选;逗号分隔的状态,可选 running、completed、faulted、cancelled;省略不过滤。
query: revisionstring可选;动作修订 ID(actr_);查询参数用于筛选调用记录。
query: callerstring可选;调用方脚本或工作流的精确名称,格式 ns/name。
query: run_kind"script" / "workflow"可选;调用方运行类型:script 或 workflow。
query: created_at[gte]string可选;创建时间下界(包含),RFC 3339 且带时区,如 2026-10-01T00:00:00Z。 format: "date-time"

示例

先设置以下环境变量,使用你自己的资源:

变量来源
ACTION_NAME创建动作返回的 name
: "${ACTION_NAME:?Set ACTION_NAME}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/actions/docs-samples/${ACTION_NAME}/invocations" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.actions.invocations.list({
  "path": {
    "ns": "docs-samples",
    "name": env("ACTION_NAME")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的动作调用记录,按 created_at 倒序、id 倒序排列。
data[].idstring必填 / 必有;调用标识,无独立 inv_ 前缀:脚本为 run_id:seq(运行 ID 与调用序号);工作流为任务执行键加尝试次数。请按不透明字符串保存。
data[].created_atstring必填 / 必有;调用记录的创建时间(RFC 3339 UTC)。
data[].started_atnull / string必填 / 必有;动作开始执行的时间;尚未开始为 null。
data[].ended_atnull / string必填 / 必有;动作结束的时间;仍在执行为 null。
data[].status"running" / "completed" / "faulted" / "cancelled"必填 / 必有;调用状态。running 执行中;completed 已正常返回;faulted 失败,error 给出原因;cancelled 因运行被取消而中止。
data[].duration_msnull / number必填 / 必有;执行耗时毫秒数;未结束为 null。
data[].revisionstring必填 / 必有;本次执行使用的动作修订 ID(actr_ 前缀)。
data[].runobject必填 / 必有;发起这次调用的运行:{id, kind, definition, number, source_digest}。 不接受额外字段。
data[].run.idstring必填 / 必有;发起调用的运行 ID(run_ 前缀),可用于读取该运行。
data[].run.kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
data[].run.definitionnull / object必填 / 必有;该运行所属的脚本或工作流 {namespace, name};临时运行为 null。
data[].run.definition(分支2).namespacestring必填 / 必有;脚本或工作流的命名空间。
data[].run.definition(分支2).namestring必填 / 必有;脚本或工作流的名字。
data[].run.numbernull / number必填 / 必有;运行在其脚本或工作流内的序号;临时运行为 null。
data[].run.source_digestnull / string必填 / 必有;临时运行的源码摘要;由已发布定义启动的运行为 null。
data[].siteobject / object必填 / 必有;调用发生的位置:脚本中的一次调用(kind=call,带 seq),或工作流的一个步骤(kind=task,带 reference 与 iteration)。
data[].site(分支1).kind"call"必填 / 必有;固定为 call:来自脚本中的调用。
data[].site(分支1).seqnumber必填 / 必有;该调用在脚本运行中的序号,与 Call.seq 对应。
data[].site(分支2).kind"task"必填 / 必有;固定为 task:来自工作流步骤。
data[].site(分支2).referencestring必填 / 必有;工作流文档内该步骤的 JSON Pointer,与 Task.reference 对应。
data[].site(分支2).iterationnumber[]必填 / 必有;外层 for 循环的当前迭代下标,由外到内;不在循环中为空数组。
data[].errornull / object必填 / 必有;失败时的 {code, message};成功或仍在执行为 null。
data[].error(分支2).codestring必填 / 必有;错误码,例如动作声明的 code 或平台错误码。
data[].error(分支2).messagestring必填 / 必有;错误说明文字。
data[].result_previewnull / string必填 / 必有;返回值的单行预览,由服务端截断;未结束或失败为 null。
data[].request_idstring / null必填 / 必有;下游响应的 X-Request-Id;响应未提供该头时为 null,可用于追查失败调用。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404ACTION_NOT_FOUND:动作不存在或当前租户不可见;同名脚本/工作流存在时,hint 指向相应接口。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出动作引用方

列出引用该动作的编排。检查范围为脚本和工作流的草稿及最新版本。

GET /automation/v1/actions/{ns}/{name}/dependents

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
query: limitinteger可选;每页条数,整数 1–100,默认 20。 minimum: 1;maximum: 100
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
ACTION_NAME创建动作返回的 name
: "${ACTION_NAME:?Set ACTION_NAME}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/actions/docs-samples/${ACTION_NAME}/dependents" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.actions.dependents.list({
  "path": {
    "ns": "docs-samples",
    "name": env("ACTION_NAME")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的引用方(脚本与工作流,口径为最新版本加草稿),按 created_at 倒序、id 倒序排列。
data[].kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
data[].namespacestring必填 / 必有;引用方的命名空间。
data[].namestring必填 / 必有;引用方的名字。
data[].atstring必填 / 必有;引用所在的草稿或最新版本号:draft 表示草稿,其余值为该编排最新发布的版本号。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404ACTION_NOT_FOUND:动作不存在或当前租户不可见;同名脚本/工作流存在时,hint 指向相应接口。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

归档动作

归档后保留名称和历史,默认列表不再显示;响应包含 dependents_count,便于判断对引用方的影响。

POST /automation/v1/actions/{ns}/{name}/archive

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。

application/json

不接受额外字段。 object

示例

先设置以下环境变量,使用你自己的资源:

变量来源
ACTION_NAME创建动作返回的 name
: "${ACTION_NAME:?Set ACTION_NAME}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/actions/docs-samples/${ACTION_NAME}/archive" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.actions.archive({
  "path": {
    "ns": "docs-samples",
    "name": env("ACTION_NAME")
  },
  "body": {}
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
idstring必填 / 必有;动作 ID,前缀 act_;日常调用使用 namespace 与 name,而不是 id。
namespacestring必填 / 必有;动作命名空间;平台动作为 praxis,裸名引用解析到 praxis。
namestring必填 / 必有;动作名,与 namespace 一起唯一标识动作;小写字母、数字、点、下划线、连字符,最长 64 字符。
descriptionstring必填 / 必有;动作说明,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;动作所属租户,由网关注入;按不透明字符串处理。
builtinboolean必填 / 必有;true 表示平台内置动作(命名空间 praxis);用户创建的动作为 false。
current_revisionobject必填 / 必有;动作的一个不可变修订:契约、实现和运行参数的快照。每次更新兼容的内容变化都会产生新修订。 不接受额外字段。
current_revision.idstring必填 / 必有;修订 ID,前缀 actr_;仅用于展示与回滚(rollback 的 revision),不能被脚本直接引用。
current_revision.digeststring必填 / 必有;契约与实现的内容摘要;内容相同的更新不会产生新修订。
current_revision.input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
current_revision.input_schema.*(分支5)object递归 JSON 值。
current_revision.input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
current_revision.output_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
current_revision.output_schema.*(分支5)object递归 JSON 值。
current_revision.output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
current_revision.errorsobject[]必填 / 必有;动作声明的可能错误列表,每项含 type、code、description。
current_revision.errors[].typestring必填 / 必有;错误类型:稳定的 URI,或 Open Workflow 标准类型(如 validation、timeout、communication、runtime)。
current_revision.errors[].codestring可选;可选的稳定错误码,供调用方按码分支处理。
current_revision.errors[].descriptionstring必填 / 必有;该错误的含义与触发条件,面向调用方阅读。
current_revision.annotationsobject必填 / 必有;动作行为声明 {read_only, idempotent};创建时未给出的键默认为 false。 不接受额外字段。
current_revision.annotations.read_onlyboolean必填 / 必有;true 表示动作不修改外部状态,只读取数据。
current_revision.annotations.idempotentboolean必填 / 必有;true 表示同一输入重复调用与调用一次效果相同;此类动作的重试使用同一幂等键(run_id 加步骤路径,不含尝试次数)。
current_revision.timeout_msnumber必填 / 必有;单次执行的超时毫秒数;创建时未给出,code 实现默认 30000,容器或 shell 实现默认 600000。
current_revision.implementationobject / object / object必填 / 必有;code 使用 language=ts 与 source。container 和 shell 暂未开放,创建时返回 OPERATION_NOT_SUPPORTED。
current_revision.implementation(分支1).kind"code"必填 / 必有;固定为 code:以源码实现。
current_revision.implementation(分支1).language"ts"必填 / 必有;源码语言,目前只支持 ts(TypeScript)。
current_revision.implementation(分支1).sourcestring必填 / 必有;动作的完整 TypeScript 源码;内置动作为空。
current_revision.implementation(分支2).kind"container"必填 / 必有;固定为 container:以容器镜像实现(暂未开放)。
current_revision.implementation(分支2).imagestring必填 / 必有;容器镜像引用。
current_revision.implementation(分支2).commandstring[]必填 / 必有;在容器中执行的命令及参数列表。
current_revision.implementation(分支3).kind"shell"必填 / 必有;固定为 shell:以 shell 脚本实现(暂未开放)。
current_revision.implementation(分支3).scriptstring必填 / 必有;要执行的 shell 脚本全文。
current_revision.host"builtin" / "isolate" / "sandbox"必填 / 必有;动作运行位置,发布时计算。builtin 为平台内置动作;isolate 为在隔离的 Worker isolate 中运行用户代码;sandbox 为在沙箱中运行(container 与 shell 实现)。
current_revision.platform_apisstring[]必填 / 必有;从代码推导出的平台 API 集合,同时是该动作运行令牌的权限范围(最小权限)。
current_revision.created_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
current_revision.created_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
current_revision.created_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
current_revision.messagenull / string必填 / 必有;创建该修订时附带的说明;未提供为 null。
current_revision.created_atstring必填 / 必有;该修订的创建时间(RFC 3339 UTC)。
stats_7dobject必填 / 必有;近七天统计;平台动作按调用方租户隔离,只反映当前调用方的调用,不是平台全局统计。 不接受额外字段。
stats_7d.callsnumber必填 / 必有;近七天内对该动作的调用次数,按小时汇总。
stats_7d.failuresnumber必填 / 必有;近七天内失败的调用次数。
stats_7d.p50_msnull / number必填 / 必有;耗时中位数的近似上界,单位毫秒;正耗时向上归入 2 的幂分桶(9 ms → 16 ms),0 独立一桶;无有效耗时样本时为 null。
dependentsobject必填 / 必有;引用该动作的脚本与工作流数量,口径为最新版本加草稿。 不接受额外字段。
dependents.scriptsnumber必填 / 必有;引用该动作的脚本数量。
dependents.workflowsnumber必填 / 必有;引用该动作的工作流数量。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不能复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。
dependents_countinteger必填 / 必有;归档时仍引用该动作的脚本与工作流数量之和(dependents.scripts 加 dependents.workflows)。 minimum: 0

实测响应

HTTP 200

{
  "id": "act_00mv67loz4fe4f27bdf89346c885b3a28b2038c091",
  "owner": "tnt_3a9759864ccb4e00",
  "namespace": "docs-samples",
  "name": "sample-action-1791867412840-b05e8a",
  "description": "",
  "labels": {},
  "builtin": false,
  "archived_at": "2026-10-13T04:57:17.830Z",
  "created_at": "2026-10-13T04:57:09.039Z",
  "updated_at": "2026-10-13T04:57:17.830Z",
  "current_revision": {
    "id": "actr_00mv67lu25f7f28dd81a924c698b9d2557056a7b62",
    "digest": "e35c209873c60486ca8da455878062cb7ea572a6147ce3ca03e0693b4769fa45",
    "input_schema": {
      "type": "object",
      "properties": {
        "n": {
          "type": "number"
        }
      },
      "required": [
        "n"
      ],
      "additionalProperties": false
    },
    "output_schema": {
      "type": "object",
      "properties": {
        "answer": {
          "type": "number"
        }
      },
      "required": [
        "answer"
      ],
      "additionalProperties": false
    },
    "errors": [],
    "annotations": {
      "read_only": false,
      "idempotent": false
    },
    "timeout_ms": 30000,
    "implementation": {
      "kind": "code",
      "language": "ts",
      "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
    },
    "host": "isolate",
    "platform_apis": [],
    "created_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    },
    "message": "回滚到 actr_00mv67loz3e46938b8ecf54e57b8f31297df016a1c",
    "created_at": "2026-10-13T04:57:15.629Z"
  },
  "stats_7d": {
    "calls": 0,
    "failures": 0,
    "p50_ms": null
  },
  "dependents": {
    "scripts": 0,
    "workflows": 0
  },
  "dependents_count": 0
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404ACTION_NOT_FOUND:动作不存在或当前租户不可见;同名脚本/工作流存在时,hint 指向相应接口。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

恢复动作

恢复已归档动作,保留当前修订。恢复后重新出现在默认列表。

POST /automation/v1/actions/{ns}/{name}/restore

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。

application/json

不接受额外字段。 object

示例

先设置以下环境变量,使用你自己的资源:

变量来源
ACTION_NAME创建动作返回的 name
: "${ACTION_NAME:?Set ACTION_NAME}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/actions/docs-samples/${ACTION_NAME}/restore" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.actions.restore({
  "path": {
    "ns": "docs-samples",
    "name": env("ACTION_NAME")
  },
  "body": {}
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
idstring必填 / 必有;动作 ID,前缀 act_;日常调用使用 namespace 与 name,而不是 id。
namespacestring必填 / 必有;动作命名空间;平台动作为 praxis,裸名引用解析到 praxis。
namestring必填 / 必有;动作名,与 namespace 一起唯一标识动作;小写字母、数字、点、下划线、连字符,最长 64 字符。
descriptionstring必填 / 必有;动作说明,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;动作所属租户,由网关注入;按不透明字符串处理。
builtinboolean必填 / 必有;true 表示平台内置动作(命名空间 praxis);用户创建的动作为 false。
current_revisionobject必填 / 必有;动作的一个不可变修订:契约、实现和运行参数的快照。每次更新兼容的内容变化都会产生新修订。 不接受额外字段。
current_revision.idstring必填 / 必有;修订 ID,前缀 actr_;仅用于展示与回滚(rollback 的 revision),不能被脚本直接引用。
current_revision.digeststring必填 / 必有;契约与实现的内容摘要;内容相同的更新不会产生新修订。
current_revision.input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
current_revision.input_schema.*(分支5)object递归 JSON 值。
current_revision.input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
current_revision.output_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
current_revision.output_schema.*(分支5)object递归 JSON 值。
current_revision.output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
current_revision.errorsobject[]必填 / 必有;动作声明的可能错误列表,每项含 type、code、description。
current_revision.errors[].typestring必填 / 必有;错误类型:稳定的 URI,或 Open Workflow 标准类型(如 validation、timeout、communication、runtime)。
current_revision.errors[].codestring可选;可选的稳定错误码,供调用方按码分支处理。
current_revision.errors[].descriptionstring必填 / 必有;该错误的含义与触发条件,面向调用方阅读。
current_revision.annotationsobject必填 / 必有;动作行为声明 {read_only, idempotent};创建时未给出的键默认为 false。 不接受额外字段。
current_revision.annotations.read_onlyboolean必填 / 必有;true 表示动作不修改外部状态,只读取数据。
current_revision.annotations.idempotentboolean必填 / 必有;true 表示同一输入重复调用与调用一次效果相同;此类动作的重试使用同一幂等键(run_id 加步骤路径,不含尝试次数)。
current_revision.timeout_msnumber必填 / 必有;单次执行的超时毫秒数;创建时未给出,code 实现默认 30000,容器或 shell 实现默认 600000。
current_revision.implementationobject / object / object必填 / 必有;code 使用 language=ts 与 source。container 和 shell 暂未开放,创建时返回 OPERATION_NOT_SUPPORTED。
current_revision.implementation(分支1).kind"code"必填 / 必有;固定为 code:以源码实现。
current_revision.implementation(分支1).language"ts"必填 / 必有;源码语言,目前只支持 ts(TypeScript)。
current_revision.implementation(分支1).sourcestring必填 / 必有;动作的完整 TypeScript 源码;内置动作为空。
current_revision.implementation(分支2).kind"container"必填 / 必有;固定为 container:以容器镜像实现(暂未开放)。
current_revision.implementation(分支2).imagestring必填 / 必有;容器镜像引用。
current_revision.implementation(分支2).commandstring[]必填 / 必有;在容器中执行的命令及参数列表。
current_revision.implementation(分支3).kind"shell"必填 / 必有;固定为 shell:以 shell 脚本实现(暂未开放)。
current_revision.implementation(分支3).scriptstring必填 / 必有;要执行的 shell 脚本全文。
current_revision.host"builtin" / "isolate" / "sandbox"必填 / 必有;动作运行位置,发布时计算。builtin 为平台内置动作;isolate 为在隔离的 Worker isolate 中运行用户代码;sandbox 为在沙箱中运行(container 与 shell 实现)。
current_revision.platform_apisstring[]必填 / 必有;从代码推导出的平台 API 集合,同时是该动作运行令牌的权限范围(最小权限)。
current_revision.created_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
current_revision.created_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
current_revision.created_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
current_revision.messagenull / string必填 / 必有;创建该修订时附带的说明;未提供为 null。
current_revision.created_atstring必填 / 必有;该修订的创建时间(RFC 3339 UTC)。
stats_7dobject必填 / 必有;近七天统计;平台动作按调用方租户隔离,只反映当前调用方的调用,不是平台全局统计。 不接受额外字段。
stats_7d.callsnumber必填 / 必有;近七天内对该动作的调用次数,按小时汇总。
stats_7d.failuresnumber必填 / 必有;近七天内失败的调用次数。
stats_7d.p50_msnull / number必填 / 必有;耗时中位数的近似上界,单位毫秒;正耗时向上归入 2 的幂分桶(9 ms → 16 ms),0 独立一桶;无有效耗时样本时为 null。
dependentsobject必填 / 必有;引用该动作的脚本与工作流数量,口径为最新版本加草稿。 不接受额外字段。
dependents.scriptsnumber必填 / 必有;引用该动作的脚本数量。
dependents.workflowsnumber必填 / 必有;引用该动作的工作流数量。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不能复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "act_00mv67loz4fe4f27bdf89346c885b3a28b2038c091",
  "owner": "tnt_3a9759864ccb4e00",
  "namespace": "docs-samples",
  "name": "sample-action-1791867412840-b05e8a",
  "description": "",
  "labels": {},
  "builtin": false,
  "archived_at": null,
  "created_at": "2026-10-13T04:57:09.039Z",
  "updated_at": "2026-10-13T04:57:18.573Z",
  "current_revision": {
    "id": "actr_00mv67lu25f7f28dd81a924c698b9d2557056a7b62",
    "digest": "e35c209873c60486ca8da455878062cb7ea572a6147ce3ca03e0693b4769fa45",
    "input_schema": {
      "type": "object",
      "properties": {
        "n": {
          "type": "number"
        }
      },
      "required": [
        "n"
      ],
      "additionalProperties": false
    },
    "output_schema": {
      "type": "object",
      "properties": {
        "answer": {
          "type": "number"
        }
      },
      "required": [
        "answer"
      ],
      "additionalProperties": false
    },
    "errors": [],
    "annotations": {
      "read_only": false,
      "idempotent": false
    },
    "timeout_ms": 30000,
    "implementation": {
      "kind": "code",
      "language": "ts",
      "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
    },
    "host": "isolate",
    "platform_apis": [],
    "created_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    },
    "message": "回滚到 actr_00mv67loz3e46938b8ecf54e57b8f31297df016a1c",
    "created_at": "2026-10-13T04:57:15.629Z"
  },
  "stats_7d": {
    "calls": 0,
    "failures": 0,
    "p50_ms": null
  },
  "dependents": {
    "scripts": 0,
    "workflows": 0
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404ACTION_NOT_FOUND:动作不存在或当前租户不可见;同名脚本/工作流存在时,hint 指向相应接口。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出脚本

列出可见脚本的摘要、最新版本、标签及近七天统计;默认排除已归档条目。

GET /automation/v1/scripts

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
query: limitinteger可选;每页条数,整数 1–100,默认 25。 minimum: 1;maximum: 100
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。
query: qstring可选;不区分大小写,按名称或说明的字面子串匹配;% 与 _ 无通配含义。
query: namespacestring[]可选;仅返回指定命名空间的定义,名称按小写匹配。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: scope"platform" / "own"[]可选;platform 仅平台定义,own 仅租户自建定义;省略返回两者。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: archivedboolean可选;true 仅已归档,false 仅未归档;默认 false。
query: labelsobject可选;按标签过滤,使用 labels[k]=v;同键逗号多值取任一,不同键同时满足。
query: created_at[gte]string可选;创建时间下界,包含边界;使用带时区的 ISO 8601 时间。 format: "date-time"
query: created_at[lte]string可选;创建时间上界,包含边界;使用带时区的 ISO 8601 时间。 format: "date-time"

示例

curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/scripts" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  --get \
  --data-urlencode "namespace=docs-samples" \
  --data-urlencode "limit=1"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.scripts.list({
  "query": {
    "namespace": [
      "docs-samples"
    ],
    "limit": 1
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的脚本摘要,按 created_at 倒序、id 倒序排列。
data[].idstring必填 / 必有;编排 ID,脚本前缀 scr_,工作流前缀 wf_;日常使用 namespace 与 name。
data[].kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
data[].namespacestring必填 / 必有;命名空间,引用形如 namespace/name@版本。
data[].namestring必填 / 必有;名字,与 namespace 一起在租户内唯一,脚本与工作流共用命名空间,重名返回 409 NAME_TAKEN。
data[].descriptionstring必填 / 必有;说明文字,最多 1000 字符。
data[].labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
data[].ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
data[].latest_versionnull / object必填 / 必有;latest 标签指向的已发布版本 {version, published_at};尚未发布为 null。
data[].latest_version(分支2).versionstring必填 / 必有;最新发布版本的版本号(semver)。
data[].latest_version(分支2).published_atstring必填 / 必有;该版本的发布时间(RFC 3339 UTC)。
data[].dist_tagsobject必填 / 必有;标签到精确版本号的映射,例如 latest 指向 1.2.0;用 ns/name@标签 运行时按此解析。
data[].draft_changedboolean必填 / 必有;true 表示草稿内容(摘要)不同于 latest 版本,即有未发布的改动。
data[].latest_runnull / object必填 / 必有;该编排最近一次运行的摘要;还没有运行为 null。
data[].latest_run(分支2).idstring必填 / 必有;运行 ID(run_ 前缀),可用于 runs.retrieve。
data[].latest_run(分支2).numbernull / number必填 / 必有;运行在该脚本或工作流内的递增序号。
data[].latest_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
data[].latest_run(分支2).created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
data[].latest_run(分支2).current_waitnull / object必填 / 必有;当前未完成的等待点;没有等待为 null。
data[].latest_run(分支2).current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
data[].latest_run(分支2).current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
data[].latest_run(分支2).current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
data[].latest_run(分支2).current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
data[].latest_run(分支2).current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
data[].latest_run(分支2).current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
data[].latest_run(分支2).current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
data[].latest_run(分支2).current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
data[].latest_run(分支2).current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
data[].latest_run(分支2).current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
data[].latest_run(分支2).current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
data[].latest_run(分支2).current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
data[].latest_run(分支2).current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
data[].stats_7dobject必填 / 必有;近七天的运行统计:按运行结束日期累计,在运行结束时更新,读取时不扫描运行。 不接受额外字段。
data[].stats_7d.runsnumber必填 / 必有;近七天内结束的运行总数(任意终态)。
data[].stats_7d.failuresnumber必填 / 必有;其中以 faulted 结束的运行数。
data[].archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不可复用。
data[].created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
data[].updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [
    {
      "id": "scr_00mv67lwvh08624c70ef824a0d8b14b0315c88452e",
      "owner": "tnt_3a9759864ccb4e00",
      "kind": "script",
      "namespace": "docs-samples",
      "name": "sample-scripts-1791867412840-b05e8a",
      "description": "",
      "labels": {},
      "latest_version": null,
      "dist_tags": {},
      "draft_changed": true,
      "latest_run": null,
      "stats_7d": {
        "runs": 0,
        "failures": 0
      },
      "archived_at": null,
      "created_at": "2026-10-13T04:57:19.277Z",
      "updated_at": "2026-10-13T04:57:19.277Z"
    }
  ],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

创建脚本

创建脚本及可编辑草稿,不会发布或启动运行;脚本与工作流共用名称空间,同租户重名返回 NAME_TAKEN。

POST /automation/v1/scripts

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
header: Idempotency-Keystring可选;可选;1–256 字符。24 小时内同一 key 重放首个响应并带 Idempotent-Replayed: true;同 key 不同请求体返回 422;处理中返回 409。 minLength: 1;maxLength: 256

application/json

不接受额外字段。

字段类型说明
namespacestring必填 / 必有;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9.-]{0,63};praxis 只读。 pattern: "^[a-zA-Z0-9][a-zA-Z0-9.-]{0,63}$"
namestring必填 / 必有;名称,存储前转为小写,格式 [a-z0-9][a-z0-9.-]{0,63}。 pattern: "^[a-zA-Z0-9][a-zA-Z0-9.-]{0,63}$"
descriptionstring可选;说明,最多 1000 个字符。 maxLength: 1000
draftstring可选;可编辑源码;脚本为 TypeScript,工作流为 YAML。创建时省略为空字符串。
labelsobject可选;最多 50 个标签;键为 1–40 个字符,值最多 500 个字符。

示例

curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/scripts" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "namespace": "docs-samples",
  "name": "sample-scripts",
  "draft": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.scripts.create({
  "body": {
    "namespace": "docs-samples",
    "name": "sample-scripts",
    "draft": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
Idempotent-ReplayedbooleanPresent and true when replaying the first response for this key.

application/json

字段类型说明
draftobject必填 / 必有;脚本或工作流的可编辑草稿;发布版本时以草稿或某次运行的源码为准。 不接受额外字段。
draft.sourcestring必填 / 必有;草稿源码:脚本为 TypeScript,工作流为 YAML。
draft.revisionstring必填 / 必有;草稿修订标识(ETag),发布时作为 expected_draft_revision,更新草稿时作为 If-Match;与当前不一致返回 412。
draft.updated_atstring必填 / 必有;草稿最近一次修改的时间(RFC 3339 UTC)。
draft.updated_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
draft.updated_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
draft.updated_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
idstring必填 / 必有;编排 ID,脚本前缀 scr_,工作流前缀 wf_;日常使用 namespace 与 name。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
namespacestring必填 / 必有;命名空间,引用形如 namespace/name@版本。
namestring必填 / 必有;名字,与 namespace 一起在租户内唯一,脚本与工作流共用命名空间,重名返回 409 NAME_TAKEN。
descriptionstring必填 / 必有;说明文字,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
latest_versionnull / object必填 / 必有;latest 标签指向的已发布版本 {version, published_at};尚未发布为 null。
latest_version(分支2).versionstring必填 / 必有;最新发布版本的版本号(semver)。
latest_version(分支2).published_atstring必填 / 必有;该版本的发布时间(RFC 3339 UTC)。
dist_tagsobject必填 / 必有;标签到精确版本号的映射,例如 latest 指向 1.2.0;用 ns/name@标签 运行时按此解析。
draft_changedboolean必填 / 必有;true 表示草稿内容(摘要)不同于 latest 版本,即有未发布的改动。
latest_runnull / object必填 / 必有;该编排最近一次运行的摘要;还没有运行为 null。
latest_run(分支2).idstring必填 / 必有;运行 ID(run_ 前缀),可用于 runs.retrieve。
latest_run(分支2).numbernull / number必填 / 必有;运行在该脚本或工作流内的递增序号。
latest_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
latest_run(分支2).created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
latest_run(分支2).current_waitnull / object必填 / 必有;当前未完成的等待点;没有等待为 null。
latest_run(分支2).current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
latest_run(分支2).current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
latest_run(分支2).current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
latest_run(分支2).current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
latest_run(分支2).current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
latest_run(分支2).current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
latest_run(分支2).current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
latest_run(分支2).current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
latest_run(分支2).current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
latest_run(分支2).current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
latest_run(分支2).current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
latest_run(分支2).current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
latest_run(分支2).current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
stats_7dobject必填 / 必有;近七天的运行统计:按运行结束日期累计,在运行结束时更新,读取时不扫描运行。 不接受额外字段。
stats_7d.runsnumber必填 / 必有;近七天内结束的运行总数(任意终态)。
stats_7d.failuresnumber必填 / 必有;其中以 faulted 结束的运行数。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不可复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "scr_00mv67lwvh08624c70ef824a0d8b14b0315c88452e",
  "owner": "tnt_3a9759864ccb4e00",
  "kind": "script",
  "namespace": "docs-samples",
  "name": "sample-scripts-1791867412840-b05e8a",
  "description": "",
  "labels": {},
  "latest_version": null,
  "dist_tags": {},
  "draft_changed": true,
  "latest_run": null,
  "stats_7d": {
    "runs": 0,
    "failures": 0
  },
  "archived_at": null,
  "created_at": "2026-10-13T04:57:19.277Z",
  "updated_at": "2026-10-13T04:57:19.277Z",
  "draft": {
    "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });",
    "revision": "draft_00mv67lwvh333793ba7d9e47cb89b5fd8b43fb4fa3",
    "updated_at": "2026-10-13T04:57:19.277Z",
    "updated_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    }
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
409IDEMPOTENCY_IN_FLIGHT:同一幂等键的请求仍在处理中。 NAME_TAKEN:名称已被同一租户占用。
422IDEMPOTENCY_KEY_MISMATCH:同一幂等键已用于不同请求内容。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

读取脚本

读取脚本详情及草稿源码;ETag 是草稿修订,可作为修改请求的 If-Match。

GET /automation/v1/scripts/{ns}/{name}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
SCRIPT_NAME创建脚本返回的 name
: "${SCRIPT_NAME:?Set SCRIPT_NAME}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/scripts/docs-samples/${SCRIPT_NAME}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.scripts.retrieve({
  "path": {
    "ns": "docs-samples",
    "name": env("SCRIPT_NAME")
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
ETagstringCurrent resource revision for conditional updates.

application/json

字段类型说明
draftobject必填 / 必有;脚本或工作流的可编辑草稿;发布版本时以草稿或某次运行的源码为准。 不接受额外字段。
draft.sourcestring必填 / 必有;草稿源码:脚本为 TypeScript,工作流为 YAML。
draft.revisionstring必填 / 必有;草稿修订标识(ETag),发布时作为 expected_draft_revision,更新草稿时作为 If-Match;与当前不一致返回 412。
draft.updated_atstring必填 / 必有;草稿最近一次修改的时间(RFC 3339 UTC)。
draft.updated_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
draft.updated_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
draft.updated_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
idstring必填 / 必有;编排 ID,脚本前缀 scr_,工作流前缀 wf_;日常使用 namespace 与 name。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
namespacestring必填 / 必有;命名空间,引用形如 namespace/name@版本。
namestring必填 / 必有;名字,与 namespace 一起在租户内唯一,脚本与工作流共用命名空间,重名返回 409 NAME_TAKEN。
descriptionstring必填 / 必有;说明文字,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
latest_versionnull / object必填 / 必有;latest 标签指向的已发布版本 {version, published_at};尚未发布为 null。
latest_version(分支2).versionstring必填 / 必有;最新发布版本的版本号(semver)。
latest_version(分支2).published_atstring必填 / 必有;该版本的发布时间(RFC 3339 UTC)。
dist_tagsobject必填 / 必有;标签到精确版本号的映射,例如 latest 指向 1.2.0;用 ns/name@标签 运行时按此解析。
draft_changedboolean必填 / 必有;true 表示草稿内容(摘要)不同于 latest 版本,即有未发布的改动。
latest_runnull / object必填 / 必有;该编排最近一次运行的摘要;还没有运行为 null。
latest_run(分支2).idstring必填 / 必有;运行 ID(run_ 前缀),可用于 runs.retrieve。
latest_run(分支2).numbernull / number必填 / 必有;运行在该脚本或工作流内的递增序号。
latest_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
latest_run(分支2).created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
latest_run(分支2).current_waitnull / object必填 / 必有;当前未完成的等待点;没有等待为 null。
latest_run(分支2).current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
latest_run(分支2).current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
latest_run(分支2).current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
latest_run(分支2).current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
latest_run(分支2).current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
latest_run(分支2).current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
latest_run(分支2).current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
latest_run(分支2).current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
latest_run(分支2).current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
latest_run(分支2).current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
latest_run(分支2).current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
latest_run(分支2).current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
latest_run(分支2).current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
stats_7dobject必填 / 必有;近七天的运行统计:按运行结束日期累计,在运行结束时更新,读取时不扫描运行。 不接受额外字段。
stats_7d.runsnumber必填 / 必有;近七天内结束的运行总数(任意终态)。
stats_7d.failuresnumber必填 / 必有;其中以 faulted 结束的运行数。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不可复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "scr_00mv67lwvh08624c70ef824a0d8b14b0315c88452e",
  "owner": "tnt_3a9759864ccb4e00",
  "kind": "script",
  "namespace": "docs-samples",
  "name": "sample-scripts-1791867412840-b05e8a",
  "description": "",
  "labels": {},
  "latest_version": null,
  "dist_tags": {},
  "draft_changed": true,
  "latest_run": null,
  "stats_7d": {
    "runs": 0,
    "failures": 0
  },
  "archived_at": null,
  "created_at": "2026-10-13T04:57:19.277Z",
  "updated_at": "2026-10-13T04:57:19.277Z",
  "draft": {
    "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });",
    "revision": "draft_00mv67lwvh333793ba7d9e47cb89b5fd8b43fb4fa3",
    "updated_at": "2026-10-13T04:57:19.277Z",
    "updated_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    }
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

更新脚本草稿

修改说明、标签或草稿,必须携带与当前草稿匹配的 If-Match;即使只改元数据也会生成新的草稿修订。

PATCH /automation/v1/scripts/{ns}/{name}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
header: If-Matchstring必填;当前资源的 ETag,可直接使用对象里的 draft.revision 或 etag 字段值:裸值、带双引号或弱校验写法 W/"…" 均接受(RFC 7232 弱比较);缺失返回 400,修订不匹配返回 412。

application/json

不接受额外字段。

字段类型说明
descriptionstring可选;说明,最多 1000 个字符。 maxLength: 1000
labelsobject可选;最多 50 个标签;键为 1–40 个字符,值最多 500 个字符。
draftstring可选;可编辑源码;脚本为 TypeScript,工作流为 YAML。创建时省略为空字符串。

示例

先设置以下环境变量,使用你自己的资源:

: "${SCRIPT_NAME:?Set SCRIPT_NAME}"
: "${ETAG:?Set ETAG}"
curl --fail-with-body -X PATCH "https://api.deepraxis.ai/automation/v1/scripts/docs-samples/${SCRIPT_NAME}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "If-Match: ${ETAG}" \
  -H "Content-Type: application/json" \
  --data '{
  "description": "Sample definition",
  "draft": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.scripts.update({
  "path": {
    "ns": "docs-samples",
    "name": env("SCRIPT_NAME")
  },
  "headers": {
    "If-Match": env("ETAG")
  },
  "body": {
    "description": "Sample definition",
    "draft": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
draftobject必填 / 必有;脚本或工作流的可编辑草稿;发布版本时以草稿或某次运行的源码为准。 不接受额外字段。
draft.sourcestring必填 / 必有;草稿源码:脚本为 TypeScript,工作流为 YAML。
draft.revisionstring必填 / 必有;草稿修订标识(ETag),发布时作为 expected_draft_revision,更新草稿时作为 If-Match;与当前不一致返回 412。
draft.updated_atstring必填 / 必有;草稿最近一次修改的时间(RFC 3339 UTC)。
draft.updated_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
draft.updated_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
draft.updated_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
idstring必填 / 必有;编排 ID,脚本前缀 scr_,工作流前缀 wf_;日常使用 namespace 与 name。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
namespacestring必填 / 必有;命名空间,引用形如 namespace/name@版本。
namestring必填 / 必有;名字,与 namespace 一起在租户内唯一,脚本与工作流共用命名空间,重名返回 409 NAME_TAKEN。
descriptionstring必填 / 必有;说明文字,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
latest_versionnull / object必填 / 必有;latest 标签指向的已发布版本 {version, published_at};尚未发布为 null。
latest_version(分支2).versionstring必填 / 必有;最新发布版本的版本号(semver)。
latest_version(分支2).published_atstring必填 / 必有;该版本的发布时间(RFC 3339 UTC)。
dist_tagsobject必填 / 必有;标签到精确版本号的映射,例如 latest 指向 1.2.0;用 ns/name@标签 运行时按此解析。
draft_changedboolean必填 / 必有;true 表示草稿内容(摘要)不同于 latest 版本,即有未发布的改动。
latest_runnull / object必填 / 必有;该编排最近一次运行的摘要;还没有运行为 null。
latest_run(分支2).idstring必填 / 必有;运行 ID(run_ 前缀),可用于 runs.retrieve。
latest_run(分支2).numbernull / number必填 / 必有;运行在该脚本或工作流内的递增序号。
latest_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
latest_run(分支2).created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
latest_run(分支2).current_waitnull / object必填 / 必有;当前未完成的等待点;没有等待为 null。
latest_run(分支2).current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
latest_run(分支2).current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
latest_run(分支2).current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
latest_run(分支2).current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
latest_run(分支2).current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
latest_run(分支2).current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
latest_run(分支2).current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
latest_run(分支2).current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
latest_run(分支2).current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
latest_run(分支2).current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
latest_run(分支2).current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
latest_run(分支2).current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
latest_run(分支2).current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
stats_7dobject必填 / 必有;近七天的运行统计:按运行结束日期累计,在运行结束时更新,读取时不扫描运行。 不接受额外字段。
stats_7d.runsnumber必填 / 必有;近七天内结束的运行总数(任意终态)。
stats_7d.failuresnumber必填 / 必有;其中以 faulted 结束的运行数。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不可复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "scr_00mv67lwvh08624c70ef824a0d8b14b0315c88452e",
  "owner": "tnt_3a9759864ccb4e00",
  "kind": "script",
  "namespace": "docs-samples",
  "name": "sample-scripts-1791867412840-b05e8a",
  "description": "Sample definition",
  "labels": {},
  "latest_version": null,
  "dist_tags": {},
  "draft_changed": true,
  "latest_run": null,
  "stats_7d": {
    "runs": 0,
    "failures": 0
  },
  "archived_at": null,
  "created_at": "2026-10-13T04:57:19.277Z",
  "updated_at": "2026-10-13T04:57:21.691Z",
  "draft": {
    "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });",
    "revision": "draft_00mv67lwvh333793ba7d9e47cb89b5fd8b43fb4fa3",
    "updated_at": "2026-10-13T04:57:19.277Z",
    "updated_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    }
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
409TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

归档脚本

归档后保留名称、版本和草稿;默认列表隐藏该条目,新的目标解析和运行请求拒绝已归档目标。

POST /automation/v1/scripts/{ns}/{name}/archive

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。

application/json

不接受额外字段。 object

示例

先设置以下环境变量,使用你自己的资源:

变量来源
SCRIPT_NAME创建脚本返回的 name
: "${SCRIPT_NAME:?Set SCRIPT_NAME}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/scripts/docs-samples/${SCRIPT_NAME}/archive" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.scripts.archive({
  "path": {
    "ns": "docs-samples",
    "name": env("SCRIPT_NAME")
  },
  "body": {}
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
idstring必填 / 必有;编排 ID,脚本前缀 scr_,工作流前缀 wf_;日常使用 namespace 与 name。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
namespacestring必填 / 必有;命名空间,引用形如 namespace/name@版本。
namestring必填 / 必有;名字,与 namespace 一起在租户内唯一,脚本与工作流共用命名空间,重名返回 409 NAME_TAKEN。
descriptionstring必填 / 必有;说明文字,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
latest_versionnull / object必填 / 必有;latest 标签指向的已发布版本 {version, published_at};尚未发布为 null。
latest_version(分支2).versionstring必填 / 必有;最新发布版本的版本号(semver)。
latest_version(分支2).published_atstring必填 / 必有;该版本的发布时间(RFC 3339 UTC)。
dist_tagsobject必填 / 必有;标签到精确版本号的映射,例如 latest 指向 1.2.0;用 ns/name@标签 运行时按此解析。
draft_changedboolean必填 / 必有;true 表示草稿内容(摘要)不同于 latest 版本,即有未发布的改动。
latest_runnull / object必填 / 必有;该编排最近一次运行的摘要;还没有运行为 null。
latest_run(分支2).idstring必填 / 必有;运行 ID(run_ 前缀),可用于 runs.retrieve。
latest_run(分支2).numbernull / number必填 / 必有;运行在该脚本或工作流内的递增序号。
latest_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
latest_run(分支2).created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
latest_run(分支2).current_waitnull / object必填 / 必有;当前未完成的等待点;没有等待为 null。
latest_run(分支2).current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
latest_run(分支2).current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
latest_run(分支2).current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
latest_run(分支2).current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
latest_run(分支2).current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
latest_run(分支2).current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
latest_run(分支2).current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
latest_run(分支2).current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
latest_run(分支2).current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
latest_run(分支2).current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
latest_run(分支2).current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
latest_run(分支2).current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
latest_run(分支2).current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
stats_7dobject必填 / 必有;近七天的运行统计:按运行结束日期累计,在运行结束时更新,读取时不扫描运行。 不接受额外字段。
stats_7d.runsnumber必填 / 必有;近七天内结束的运行总数(任意终态)。
stats_7d.failuresnumber必填 / 必有;其中以 faulted 结束的运行数。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不可复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "scr_00mv67lwvh08624c70ef824a0d8b14b0315c88452e",
  "owner": "tnt_3a9759864ccb4e00",
  "kind": "script",
  "namespace": "docs-samples",
  "name": "sample-scripts-1791867412840-b05e8a",
  "description": "Sample definition",
  "labels": {},
  "latest_version": {
    "version": "1.0.0",
    "published_at": "2026-10-13T04:57:22.398Z"
  },
  "dist_tags": {
    "latest": "1.0.0"
  },
  "draft_changed": false,
  "latest_run": null,
  "stats_7d": {
    "runs": 0,
    "failures": 0
  },
  "archived_at": "2026-10-13T04:57:27.639Z",
  "created_at": "2026-10-13T04:57:19.277Z",
  "updated_at": "2026-10-13T04:57:27.639Z"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

恢复脚本

恢复已归档定义,保留版本和标签。名称无需重新分配。

POST /automation/v1/scripts/{ns}/{name}/restore

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。

application/json

不接受额外字段。 object

示例

先设置以下环境变量,使用你自己的资源:

变量来源
SCRIPT_NAME创建脚本返回的 name
: "${SCRIPT_NAME:?Set SCRIPT_NAME}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/scripts/docs-samples/${SCRIPT_NAME}/restore" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.scripts.restore({
  "path": {
    "ns": "docs-samples",
    "name": env("SCRIPT_NAME")
  },
  "body": {}
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
idstring必填 / 必有;编排 ID,脚本前缀 scr_,工作流前缀 wf_;日常使用 namespace 与 name。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
namespacestring必填 / 必有;命名空间,引用形如 namespace/name@版本。
namestring必填 / 必有;名字,与 namespace 一起在租户内唯一,脚本与工作流共用命名空间,重名返回 409 NAME_TAKEN。
descriptionstring必填 / 必有;说明文字,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
latest_versionnull / object必填 / 必有;latest 标签指向的已发布版本 {version, published_at};尚未发布为 null。
latest_version(分支2).versionstring必填 / 必有;最新发布版本的版本号(semver)。
latest_version(分支2).published_atstring必填 / 必有;该版本的发布时间(RFC 3339 UTC)。
dist_tagsobject必填 / 必有;标签到精确版本号的映射,例如 latest 指向 1.2.0;用 ns/name@标签 运行时按此解析。
draft_changedboolean必填 / 必有;true 表示草稿内容(摘要)不同于 latest 版本,即有未发布的改动。
latest_runnull / object必填 / 必有;该编排最近一次运行的摘要;还没有运行为 null。
latest_run(分支2).idstring必填 / 必有;运行 ID(run_ 前缀),可用于 runs.retrieve。
latest_run(分支2).numbernull / number必填 / 必有;运行在该脚本或工作流内的递增序号。
latest_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
latest_run(分支2).created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
latest_run(分支2).current_waitnull / object必填 / 必有;当前未完成的等待点;没有等待为 null。
latest_run(分支2).current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
latest_run(分支2).current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
latest_run(分支2).current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
latest_run(分支2).current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
latest_run(分支2).current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
latest_run(分支2).current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
latest_run(分支2).current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
latest_run(分支2).current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
latest_run(分支2).current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
latest_run(分支2).current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
latest_run(分支2).current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
latest_run(分支2).current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
latest_run(分支2).current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
stats_7dobject必填 / 必有;近七天的运行统计:按运行结束日期累计,在运行结束时更新,读取时不扫描运行。 不接受额外字段。
stats_7d.runsnumber必填 / 必有;近七天内结束的运行总数(任意终态)。
stats_7d.failuresnumber必填 / 必有;其中以 faulted 结束的运行数。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不可复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "scr_00mv67lwvh08624c70ef824a0d8b14b0315c88452e",
  "owner": "tnt_3a9759864ccb4e00",
  "kind": "script",
  "namespace": "docs-samples",
  "name": "sample-scripts-1791867412840-b05e8a",
  "description": "Sample definition",
  "labels": {},
  "latest_version": {
    "version": "1.0.0",
    "published_at": "2026-10-13T04:57:22.398Z"
  },
  "dist_tags": {
    "latest": "1.0.0"
  },
  "draft_changed": false,
  "latest_run": null,
  "stats_7d": {
    "runs": 0,
    "failures": 0
  },
  "archived_at": null,
  "created_at": "2026-10-13T04:57:19.277Z",
  "updated_at": "2026-10-13T04:57:28.559Z"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

发布脚本版本

从草稿或临时运行源码发布版本,校验定义并锁定依赖。草稿须匹配 expected_draft_revision;临时运行由 from_run 与 expected_source_sha256 指定。版本相同且内容相同返回已有版本,内容不同返回 VERSION_EXISTS;预发布版本必须显式带 tag(不能是 latest,tag 只能含 URL 安全字符且不能是版本号或范围,违规返回 TAG_REQUIRED 或 TAG_INVALID,hint 给出完整规则),校验不通过返回 DEFINITION_INVALID。稳定版本仅高于已有最高稳定版本时自动移动 latest;工作流成为 latest 时同步定义中的定时触发器。 发布会去掉版本号的 +build 元数据。

POST /automation/v1/scripts/{ns}/{name}/versions

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
header: Idempotency-Keystring可选;可选;1–256 字符。24 小时内同一 key 重放首个响应并带 Idempotent-Replayed: true;同 key 不同请求体返回 422;处理中返回 409。 minLength: 1;maxLength: 256

application/json

字段类型说明
(分支1).versionstring必填 / 必有;规范的精确语义版本,例如 1.2.0 或 1.3.0-beta.1;不能是范围。
(分支1).expected_draft_revisionstring必填 / 必有;发布的草稿修订,必须匹配当前草稿;与 from_run 发布方式二选一。
(分支1).tagstring可选;发布标签。预发布版本(如 1.3.0-beta.1)必须带 tag 且不能是 latest;tag 只能由 URL 安全字符组成(字母、数字及 - _ . ! ~ * ' ( )),不含空格和 / ? #,首尾无空白;不能是版本号或版本范围(如 1.2.3、^1、1.x、*);beta、next、debug 等其余名称均可。违规返回 TAG_INVALID 或 TAG_REQUIRED,hint 给出完整规则。
(分支2).versionstring必填 / 必有;规范的精确语义版本,例如 1.2.0 或 1.3.0-beta.1;不能是范围。
(分支2).from_runstring必填 / 必有;提供源码快照的临时运行 ID;已发布目标的运行当前没有可用于此入口的快照。须同时给出 expected_source_sha256,不能同时给 expected_draft_revision。
(分支2).expected_source_sha256string必填 / 必有;运行源码的 SHA-256 摘要,必须与快照匹配。
(分支2).tagstring可选;发布标签。预发布版本(如 1.3.0-beta.1)必须带 tag 且不能是 latest;tag 只能由 URL 安全字符组成(字母、数字及 - _ . ! ~ * ' ( )),不含空格和 / ? #,首尾无空白;不能是版本号或版本范围(如 1.2.3、^1、1.x、*);beta、next、debug 等其余名称均可。违规返回 TAG_INVALID 或 TAG_REQUIRED,hint 给出完整规则。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
SCRIPT_NAME创建脚本返回的 name
DRAFT_REVISION当前 draft.revision
: "${SCRIPT_NAME:?Set SCRIPT_NAME}"
: "${DRAFT_REVISION:?Set DRAFT_REVISION}"
BODY=$(jq -n --arg DRAFT_REVISION "$DRAFT_REVISION" '{
  "version": "1.0.0",
  "expected_draft_revision": $DRAFT_REVISION
}')
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/scripts/docs-samples/${SCRIPT_NAME}/versions" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data "$BODY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.scripts.versions.publish({
  "path": {
    "ns": "docs-samples",
    "name": env("SCRIPT_NAME")
  },
  "body": {
    "version": "1.0.0",
    "expected_draft_revision": env("DRAFT_REVISION")
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
Idempotent-ReplayedbooleanPresent and true when replaying the first response for this key.

application/json

字段类型说明
idstring必填 / 必有;版本 ID,脚本前缀 scv_,工作流前缀 wfv_。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
versionstring必填 / 必有;版本号(semver,已去掉 +build 元数据)。
digeststring必填 / 必有;源码与契约的内容摘要。
sourcestring必填 / 必有;该版本的完整源码。版本列表默认不返回,需要时加 expand=source。
input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
input_schema.*(分支5)object递归 JSON 值。
input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
output_schemaobject必填 / 必有;脚本从返回类型推导,支持 Promise 解包、Record、交叉类型和 Date(date-time);推不出时为空 schema,并在 /validate 的 warnings 给出 warning。
output_schema.*(分支5)object递归 JSON 值。
output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
referencesobject[]必填 / 必有;该版本依赖的动作、平台 API、脚本与工作流。脚本和工作流依赖在发布时锁定到精确版本。
references[].kind"action" / "script" / "workflow" / "platform_api" / "run"必填 / 必有;依赖类型。action 为动作;platform_api 为平台 API 操作;script 为脚本;workflow 为工作流;run 为脚本中 invoke("ns/name") 调用的子运行目标(脚本或工作流,发布时解析)。
references[].namestring必填 / 必有;被依赖对象:动作为 ns/name,平台 API 为操作名,脚本与工作流为 ns/name。
references[].rangestring可选;引用时写的版本范围或标签(npm 规则);未写时为空。
references[].locked_versionstring可选;发布时锁定的精确版本;仅脚本与工作流依赖有,动作与平台 API 不锁定。
outlinenull / object[]必填 / 必有;工作流的步骤大纲(OutlineNode 数组),由解析器静态生成;脚本为 null。
outline(分支2)[].namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
outline(分支2)[].referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start;与运行时 Task.reference 一致。
outline(分支2)[].kind"run" / "call" / "wait" / "set" / "for" / "fork" / "try" / "switch" / "emit" / "raise" / "listen" / "do"必填 / 必有;工作流步骤类型。call 调用动作;run 运行子脚本或子工作流;wait 等待时长;set 设置变量;for 循环;fork 并行分支;try 带捕获的块;switch 条件分支;emit 发出事件;raise 抛出错误;listen 等待事件;do 顺序执行的步骤块。
outline(分支2)[].targetstring可选;步骤调用的目标:call 步骤为动作 ns/name,run 步骤为 ns/name@范围;其它类型没有。
outline(分支2)[].waitobject可选;等待步骤的摘要:时长(seconds 或 duration)或等待的事件类型(event)。 不接受额外字段。
outline(分支2)[].wait.untilstring可选;等待结束的绝对时刻,仅在可静态确定时给出;目前大纲不填充该字段。
outline(分支2)[].wait.secondsnumber可选;可静态换算的等待秒数;时长对象与可换算的 ISO 时长均投影到此字段。
outline(分支2)[].wait.eventstring可选;listen 步骤等待的事件类型。
outline(分支2)[].wait.durationstring可选;无法静态换算成秒的原始时长或运行时表达式;不与 seconds 强行换算。
outline(分支2)[].loopobject可选;for 步骤的循环信息 {each, in}。 不接受额外字段。
outline(分支2)[].loop.eachstring必填 / 必有;循环变量名;未指定时为 item。
outline(分支2)[].loop.instring必填 / 必有;被遍历的集合表达式原文。
outline(分支2)[].childrenobject[]可选;嵌套的子步骤(do、fork 分支、try 与 catch 内的步骤)。
outline(分支2)[].children[]object递归 JSON 值。
sdk_versionnull / string必填 / 必有;发布脚本所用的 SDK 版本;工作流为 null。
published_atstring必填 / 必有;发布时间(RFC 3339 UTC)。
published_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
published_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
published_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
deprecatednull / string必填 / 必有;弃用说明;未弃用为 null。弃用的版本仍可运行,但按范围或标签解析时优先选用未弃用的版本。
deprecated_atnull / string必填 / 必有;弃用时间(RFC 3339 UTC);未弃用为 null。
deprecated_bynull / object必填 / 必有;执行弃用的主体;未弃用为 null。
deprecated_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
deprecated_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。

实测响应

HTTP 200

{
  "id": "scv_00mv67lza679fc5498438040079f0c5684208c4915",
  "kind": "script",
  "version": "1.0.0",
  "digest": "7ae6678882a4ef2ea96e401c105d5c6ef512917cd72a9235289d2a3bf1f1b49d",
  "input_schema": {
    "type": "object",
    "properties": {
      "n": {
        "type": "number"
      }
    },
    "required": [
      "n"
    ]
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "answer": {
        "type": "number"
      }
    },
    "required": [
      "answer"
    ]
  },
  "references": [],
  "outline": null,
  "sdk_version": "0.1.0",
  "published_at": "2026-10-13T04:57:22.398Z",
  "published_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "deprecated": null,
  "deprecated_at": null,
  "deprecated_by": null,
  "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 TAG_REQUIRED:预发布版本必须显式指定发布标签(例如 beta,不能是 latest);响应 hint 列出完整规则。 TAG_INVALID:标签无效:预发布版本不能打 latest;tag 只能含 URL 安全字符(不含空格和 / ? #);不能是版本号或范围;latest 不能删除。响应 hint 列出完整规则。 DEFINITION_INVALID:源码未通过定义校验。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。 RUN_NOT_FOUND:运行不存在或当前租户不可见。
409IDEMPOTENCY_IN_FLIGHT:同一幂等键的请求仍在处理中。 TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。 VERSION_EXISTS:版本号已存在且源码内容不同。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
422IDEMPOTENCY_KEY_MISMATCH:同一幂等键已用于不同请求内容。 DEFINITION_IDENTITY_MISMATCH:源码声明或运行语言与发布目标不一致。 NO_MATCHING_VERSION:没有满足标签、版本或范围的已发布版本。 CYCLE_DETECTED:发布后依赖会形成环(A 依赖 B、B 又依赖 A);detail 给出环路径。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出脚本版本

按语义版本倒序分页列出不可变的 schema 和锁定依赖。默认不带源码;仅 expand=source 带完整源码,其它值返回 400。详情接口保持全文。

GET /automation/v1/scripts/{ns}/{name}/versions

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
query: limitinteger可选;每页条数,整数 1–100,默认 25。 minimum: 1;maximum: 100
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。
query: expand"source"可选;仅接受 source;默认不带源码,其它值返回 400。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
SCRIPT_NAME创建脚本返回的 name
: "${SCRIPT_NAME:?Set SCRIPT_NAME}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/scripts/docs-samples/${SCRIPT_NAME}/versions" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.scripts.versions.list({
  "path": {
    "ns": "docs-samples",
    "name": env("SCRIPT_NAME")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的脚本版本(默认不含源码,expand=source 才带),按 semver 降序排列。
data[].idstring必填 / 必有;版本 ID,脚本前缀 scv_,工作流前缀 wfv_。
data[].kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
data[].versionstring必填 / 必有;版本号(semver,已去掉 +build 元数据)。
data[].digeststring必填 / 必有;源码与契约的内容摘要。
data[].sourcestring可选;该版本的完整源码。版本列表默认不返回,需要时加 expand=source。
data[].input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
data[].input_schema.*(分支5)object递归 JSON 值。
data[].input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[].output_schemaobject必填 / 必有;脚本从返回类型推导,支持 Promise 解包、Record、交叉类型和 Date(date-time);推不出时为空 schema,并在 /validate 的 warnings 给出 warning。
data[].output_schema.*(分支5)object递归 JSON 值。
data[].output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[].referencesobject[]必填 / 必有;该版本依赖的动作、平台 API、脚本与工作流。脚本和工作流依赖在发布时锁定到精确版本。
data[].references[].kind"action" / "script" / "workflow" / "platform_api" / "run"必填 / 必有;依赖类型。action 为动作;platform_api 为平台 API 操作;script 为脚本;workflow 为工作流;run 为脚本中 invoke("ns/name") 调用的子运行目标(脚本或工作流,发布时解析)。
data[].references[].namestring必填 / 必有;被依赖对象:动作为 ns/name,平台 API 为操作名,脚本与工作流为 ns/name。
data[].references[].rangestring可选;引用时写的版本范围或标签(npm 规则);未写时为空。
data[].references[].locked_versionstring可选;发布时锁定的精确版本;仅脚本与工作流依赖有,动作与平台 API 不锁定。
data[].outlinenull / object[]必填 / 必有;工作流的步骤大纲(OutlineNode 数组),由解析器静态生成;脚本为 null。
data[].outline(分支2)[].namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
data[].outline(分支2)[].referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start;与运行时 Task.reference 一致。
data[].outline(分支2)[].kind"run" / "call" / "wait" / "set" / "for" / "fork" / "try" / "switch" / "emit" / "raise" / "listen" / "do"必填 / 必有;工作流步骤类型。call 调用动作;run 运行子脚本或子工作流;wait 等待时长;set 设置变量;for 循环;fork 并行分支;try 带捕获的块;switch 条件分支;emit 发出事件;raise 抛出错误;listen 等待事件;do 顺序执行的步骤块。
data[].outline(分支2)[].targetstring可选;步骤调用的目标:call 步骤为动作 ns/name,run 步骤为 ns/name@范围;其它类型没有。
data[].outline(分支2)[].waitobject可选;等待步骤的摘要:时长(seconds 或 duration)或等待的事件类型(event)。 不接受额外字段。
data[].outline(分支2)[].wait.untilstring可选;等待结束的绝对时刻,仅在可静态确定时给出;目前大纲不填充该字段。
data[].outline(分支2)[].wait.secondsnumber可选;可静态换算的等待秒数;时长对象与可换算的 ISO 时长均投影到此字段。
data[].outline(分支2)[].wait.eventstring可选;listen 步骤等待的事件类型。
data[].outline(分支2)[].wait.durationstring可选;无法静态换算成秒的原始时长或运行时表达式;不与 seconds 强行换算。
data[].outline(分支2)[].loopobject可选;for 步骤的循环信息 {each, in}。 不接受额外字段。
data[].outline(分支2)[].loop.eachstring必填 / 必有;循环变量名;未指定时为 item。
data[].outline(分支2)[].loop.instring必填 / 必有;被遍历的集合表达式原文。
data[].outline(分支2)[].childrenobject[]可选;嵌套的子步骤(do、fork 分支、try 与 catch 内的步骤)。
data[].outline(分支2)[].children[]object递归 JSON 值。
data[].sdk_versionnull / string必填 / 必有;发布脚本所用的 SDK 版本;工作流为 null。
data[].published_atstring必填 / 必有;发布时间(RFC 3339 UTC)。
data[].published_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
data[].published_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data[].published_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
data[].deprecatednull / string必填 / 必有;弃用说明;未弃用为 null。弃用的版本仍可运行,但按范围或标签解析时优先选用未弃用的版本。
data[].deprecated_atnull / string必填 / 必有;弃用时间(RFC 3339 UTC);未弃用为 null。
data[].deprecated_bynull / object必填 / 必有;执行弃用的主体;未弃用为 null。
data[].deprecated_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data[].deprecated_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [
    {
      "id": "scv_00mv67lza679fc5498438040079f0c5684208c4915",
      "kind": "script",
      "version": "1.0.0",
      "digest": "7ae6678882a4ef2ea96e401c105d5c6ef512917cd72a9235289d2a3bf1f1b49d",
      "input_schema": {
        "type": "object",
        "properties": {
          "n": {
            "type": "number"
          }
        },
        "required": [
          "n"
        ]
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "answer": {
            "type": "number"
          }
        },
        "required": [
          "answer"
        ]
      },
      "references": [],
      "outline": null,
      "sdk_version": "0.1.0",
      "published_at": "2026-10-13T04:57:22.398Z",
      "published_by": {
        "type": "api_key",
        "id": "key_3e00b8984967"
      },
      "deprecated": null,
      "deprecated_at": null,
      "deprecated_by": null
    }
  ],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

读取脚本版本

读取精确版本的源码、输入输出契约及弃用说明;版本缺失返回 VERSION_NOT_FOUND。 详情始终返回完整源码。 version 接受精确版本或 dist-tag;range 返回 400,hint 提示改用 /resolve。

GET /automation/v1/scripts/{ns}/{name}/versions/{version}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
path: versionstring必填;精确版本或 dist-tag;不接受 range(400,带 hint)。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
SCRIPT_NAME创建脚本返回的 name
: "${SCRIPT_NAME:?Set SCRIPT_NAME}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/scripts/docs-samples/${SCRIPT_NAME}/versions/1.0.0" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.scripts.versions.retrieve({
  "path": {
    "ns": "docs-samples",
    "name": env("SCRIPT_NAME"),
    "version": "1.0.0"
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
idstring必填 / 必有;版本 ID,脚本前缀 scv_,工作流前缀 wfv_。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
versionstring必填 / 必有;版本号(semver,已去掉 +build 元数据)。
digeststring必填 / 必有;源码与契约的内容摘要。
sourcestring必填 / 必有;该版本的完整源码。版本列表默认不返回,需要时加 expand=source。
input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
input_schema.*(分支5)object递归 JSON 值。
input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
output_schemaobject必填 / 必有;脚本从返回类型推导,支持 Promise 解包、Record、交叉类型和 Date(date-time);推不出时为空 schema,并在 /validate 的 warnings 给出 warning。
output_schema.*(分支5)object递归 JSON 值。
output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
referencesobject[]必填 / 必有;该版本依赖的动作、平台 API、脚本与工作流。脚本和工作流依赖在发布时锁定到精确版本。
references[].kind"action" / "script" / "workflow" / "platform_api" / "run"必填 / 必有;依赖类型。action 为动作;platform_api 为平台 API 操作;script 为脚本;workflow 为工作流;run 为脚本中 invoke("ns/name") 调用的子运行目标(脚本或工作流,发布时解析)。
references[].namestring必填 / 必有;被依赖对象:动作为 ns/name,平台 API 为操作名,脚本与工作流为 ns/name。
references[].rangestring可选;引用时写的版本范围或标签(npm 规则);未写时为空。
references[].locked_versionstring可选;发布时锁定的精确版本;仅脚本与工作流依赖有,动作与平台 API 不锁定。
outlinenull / object[]必填 / 必有;工作流的步骤大纲(OutlineNode 数组),由解析器静态生成;脚本为 null。
outline(分支2)[].namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
outline(分支2)[].referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start;与运行时 Task.reference 一致。
outline(分支2)[].kind"run" / "call" / "wait" / "set" / "for" / "fork" / "try" / "switch" / "emit" / "raise" / "listen" / "do"必填 / 必有;工作流步骤类型。call 调用动作;run 运行子脚本或子工作流;wait 等待时长;set 设置变量;for 循环;fork 并行分支;try 带捕获的块;switch 条件分支;emit 发出事件;raise 抛出错误;listen 等待事件;do 顺序执行的步骤块。
outline(分支2)[].targetstring可选;步骤调用的目标:call 步骤为动作 ns/name,run 步骤为 ns/name@范围;其它类型没有。
outline(分支2)[].waitobject可选;等待步骤的摘要:时长(seconds 或 duration)或等待的事件类型(event)。 不接受额外字段。
outline(分支2)[].wait.untilstring可选;等待结束的绝对时刻,仅在可静态确定时给出;目前大纲不填充该字段。
outline(分支2)[].wait.secondsnumber可选;可静态换算的等待秒数;时长对象与可换算的 ISO 时长均投影到此字段。
outline(分支2)[].wait.eventstring可选;listen 步骤等待的事件类型。
outline(分支2)[].wait.durationstring可选;无法静态换算成秒的原始时长或运行时表达式;不与 seconds 强行换算。
outline(分支2)[].loopobject可选;for 步骤的循环信息 {each, in}。 不接受额外字段。
outline(分支2)[].loop.eachstring必填 / 必有;循环变量名;未指定时为 item。
outline(分支2)[].loop.instring必填 / 必有;被遍历的集合表达式原文。
outline(分支2)[].childrenobject[]可选;嵌套的子步骤(do、fork 分支、try 与 catch 内的步骤)。
outline(分支2)[].children[]object递归 JSON 值。
sdk_versionnull / string必填 / 必有;发布脚本所用的 SDK 版本;工作流为 null。
published_atstring必填 / 必有;发布时间(RFC 3339 UTC)。
published_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
published_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
published_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
deprecatednull / string必填 / 必有;弃用说明;未弃用为 null。弃用的版本仍可运行,但按范围或标签解析时优先选用未弃用的版本。
deprecated_atnull / string必填 / 必有;弃用时间(RFC 3339 UTC);未弃用为 null。
deprecated_bynull / object必填 / 必有;执行弃用的主体;未弃用为 null。
deprecated_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
deprecated_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。

实测响应

HTTP 200

{
  "id": "scv_00mv67lza679fc5498438040079f0c5684208c4915",
  "kind": "script",
  "version": "1.0.0",
  "digest": "7ae6678882a4ef2ea96e401c105d5c6ef512917cd72a9235289d2a3bf1f1b49d",
  "input_schema": {
    "type": "object",
    "properties": {
      "n": {
        "type": "number"
      }
    },
    "required": [
      "n"
    ]
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "answer": {
        "type": "number"
      }
    },
    "required": [
      "answer"
    ]
  },
  "references": [],
  "outline": null,
  "sdk_version": "0.1.0",
  "published_at": "2026-10-13T04:57:22.398Z",
  "published_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "deprecated": null,
  "deprecated_at": null,
  "deprecated_by": null,
  "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。 VERSION_NOT_FOUND:指定版本或修订不存在。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

弃用脚本版本

记录版本弃用说明;message 为空字符串时取消弃用,版本源码不变。

POST /automation/v1/scripts/{ns}/{name}/versions/{version}/deprecate

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
path: versionstring必填;规范的精确语义版本,例如 1.2.0 或 1.3.0-beta.1;不能是范围。

application/json

不接受额外字段。

字段类型说明
messagestring必填 / 必有;弃用说明;空字符串取消弃用。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
SCRIPT_NAME创建脚本返回的 name
: "${SCRIPT_NAME:?Set SCRIPT_NAME}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/scripts/docs-samples/${SCRIPT_NAME}/versions/1.0.0/deprecate" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "message": ""
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.scripts.versions.deprecate({
  "path": {
    "ns": "docs-samples",
    "name": env("SCRIPT_NAME"),
    "version": "1.0.0"
  },
  "body": {
    "message": ""
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
idstring必填 / 必有;版本 ID,脚本前缀 scv_,工作流前缀 wfv_。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
versionstring必填 / 必有;版本号(semver,已去掉 +build 元数据)。
digeststring必填 / 必有;源码与契约的内容摘要。
sourcestring必填 / 必有;该版本的完整源码。版本列表默认不返回,需要时加 expand=source。
input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
input_schema.*(分支5)object递归 JSON 值。
input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
output_schemaobject必填 / 必有;脚本从返回类型推导,支持 Promise 解包、Record、交叉类型和 Date(date-time);推不出时为空 schema,并在 /validate 的 warnings 给出 warning。
output_schema.*(分支5)object递归 JSON 值。
output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
referencesobject[]必填 / 必有;该版本依赖的动作、平台 API、脚本与工作流。脚本和工作流依赖在发布时锁定到精确版本。
references[].kind"action" / "script" / "workflow" / "platform_api" / "run"必填 / 必有;依赖类型。action 为动作;platform_api 为平台 API 操作;script 为脚本;workflow 为工作流;run 为脚本中 invoke("ns/name") 调用的子运行目标(脚本或工作流,发布时解析)。
references[].namestring必填 / 必有;被依赖对象:动作为 ns/name,平台 API 为操作名,脚本与工作流为 ns/name。
references[].rangestring可选;引用时写的版本范围或标签(npm 规则);未写时为空。
references[].locked_versionstring可选;发布时锁定的精确版本;仅脚本与工作流依赖有,动作与平台 API 不锁定。
outlinenull / object[]必填 / 必有;工作流的步骤大纲(OutlineNode 数组),由解析器静态生成;脚本为 null。
outline(分支2)[].namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
outline(分支2)[].referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start;与运行时 Task.reference 一致。
outline(分支2)[].kind"run" / "call" / "wait" / "set" / "for" / "fork" / "try" / "switch" / "emit" / "raise" / "listen" / "do"必填 / 必有;工作流步骤类型。call 调用动作;run 运行子脚本或子工作流;wait 等待时长;set 设置变量;for 循环;fork 并行分支;try 带捕获的块;switch 条件分支;emit 发出事件;raise 抛出错误;listen 等待事件;do 顺序执行的步骤块。
outline(分支2)[].targetstring可选;步骤调用的目标:call 步骤为动作 ns/name,run 步骤为 ns/name@范围;其它类型没有。
outline(分支2)[].waitobject可选;等待步骤的摘要:时长(seconds 或 duration)或等待的事件类型(event)。 不接受额外字段。
outline(分支2)[].wait.untilstring可选;等待结束的绝对时刻,仅在可静态确定时给出;目前大纲不填充该字段。
outline(分支2)[].wait.secondsnumber可选;可静态换算的等待秒数;时长对象与可换算的 ISO 时长均投影到此字段。
outline(分支2)[].wait.eventstring可选;listen 步骤等待的事件类型。
outline(分支2)[].wait.durationstring可选;无法静态换算成秒的原始时长或运行时表达式;不与 seconds 强行换算。
outline(分支2)[].loopobject可选;for 步骤的循环信息 {each, in}。 不接受额外字段。
outline(分支2)[].loop.eachstring必填 / 必有;循环变量名;未指定时为 item。
outline(分支2)[].loop.instring必填 / 必有;被遍历的集合表达式原文。
outline(分支2)[].childrenobject[]可选;嵌套的子步骤(do、fork 分支、try 与 catch 内的步骤)。
outline(分支2)[].children[]object递归 JSON 值。
sdk_versionnull / string必填 / 必有;发布脚本所用的 SDK 版本;工作流为 null。
published_atstring必填 / 必有;发布时间(RFC 3339 UTC)。
published_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
published_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
published_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
deprecatednull / string必填 / 必有;弃用说明;未弃用为 null。弃用的版本仍可运行,但按范围或标签解析时优先选用未弃用的版本。
deprecated_atnull / string必填 / 必有;弃用时间(RFC 3339 UTC);未弃用为 null。
deprecated_bynull / object必填 / 必有;执行弃用的主体;未弃用为 null。
deprecated_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
deprecated_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。

实测响应

HTTP 200

{
  "id": "scv_00mv67lza679fc5498438040079f0c5684208c4915",
  "kind": "script",
  "version": "1.0.0",
  "digest": "7ae6678882a4ef2ea96e401c105d5c6ef512917cd72a9235289d2a3bf1f1b49d",
  "input_schema": {
    "type": "object",
    "properties": {
      "n": {
        "type": "number"
      }
    },
    "required": [
      "n"
    ]
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "answer": {
        "type": "number"
      }
    },
    "required": [
      "answer"
    ]
  },
  "references": [],
  "outline": null,
  "sdk_version": "0.1.0",
  "published_at": "2026-10-13T04:57:22.398Z",
  "published_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "deprecated": null,
  "deprecated_at": null,
  "deprecated_by": null,
  "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。 VERSION_NOT_FOUND:指定版本或修订不存在。
409TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出脚本标签

读取发布标签指向的精确版本。同时返回更新时间和更新者。

GET /automation/v1/scripts/{ns}/{name}/dist-tags

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
SCRIPT_NAME创建脚本返回的 name
: "${SCRIPT_NAME:?Set SCRIPT_NAME}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/scripts/docs-samples/${SCRIPT_NAME}/dist-tags" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.scripts.distTags.list({
  "path": {
    "ns": "docs-samples",
    "name": env("SCRIPT_NAME")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
.*.versionstring必填 / 必有;标签当前指向的精确版本号。
.*.updated_atstring必填 / 必有;标签最近一次移动的时间(RFC 3339 UTC)。
.*.updated_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
.*.updated_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
.*.updated_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。

实测响应

HTTP 200

{
  "latest": {
    "version": "1.0.0",
    "updated_at": "2026-10-13T04:57:22.398Z",
    "updated_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    }
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

设置脚本标签

将发布标签指向已有精确版本,标签不能是版本号或版本范围;移动 latest 可用于回滚,工作流会同步定时触发器。

PUT /automation/v1/scripts/{ns}/{name}/dist-tags/{tag}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
path: tagstring必填;发布标签。预发布版本(如 1.3.0-beta.1)必须带 tag 且不能是 latest;tag 只能由 URL 安全字符组成(字母、数字及 - _ . ! ~ * ' ( )),不含空格和 / ? #,首尾无空白;不能是版本号或版本范围(如 1.2.3、^1、1.x、*);beta、next、debug 等其余名称均可。违规返回 TAG_INVALID 或 TAG_REQUIRED,hint 给出完整规则。

application/json

不接受额外字段。

字段类型说明
versionstring必填 / 必有;规范的精确语义版本,例如 1.2.0 或 1.3.0-beta.1;不能是范围。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
SCRIPT_NAME创建脚本返回的 name
: "${SCRIPT_NAME:?Set SCRIPT_NAME}"
curl --fail-with-body -X PUT "https://api.deepraxis.ai/automation/v1/scripts/docs-samples/${SCRIPT_NAME}/dist-tags/sample" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "version": "1.0.0"
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.scripts.distTags.set({
  "path": {
    "ns": "docs-samples",
    "name": env("SCRIPT_NAME"),
    "tag": "sample"
  },
  "body": {
    "version": "1.0.0"
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
.*.versionstring必填 / 必有;标签当前指向的精确版本号。
.*.updated_atstring必填 / 必有;标签最近一次移动的时间(RFC 3339 UTC)。
.*.updated_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
.*.updated_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
.*.updated_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。

实测响应

HTTP 200

{
  "latest": {
    "version": "1.0.0",
    "updated_at": "2026-10-13T04:57:22.398Z",
    "updated_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    }
  },
  "sample": {
    "version": "1.0.0",
    "updated_at": "2026-10-13T04:57:26.232Z",
    "updated_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    }
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 TAG_INVALID:标签无效:预发布版本不能打 latest;tag 只能含 URL 安全字符(不含空格和 / ? #);不能是版本号或范围;latest 不能删除。响应 hint 列出完整规则。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。 VERSION_NOT_FOUND:指定版本或修订不存在。
409TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

删除脚本标签

删除发布标签但保留版本;latest 不可删除,标签不能是版本号或范围,不存在的合法标签可重复删除。

DELETE /automation/v1/scripts/{ns}/{name}/dist-tags/{tag}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
path: tagstring必填;发布标签。预发布版本(如 1.3.0-beta.1)必须带 tag 且不能是 latest;tag 只能由 URL 安全字符组成(字母、数字及 - _ . ! ~ * ' ( )),不含空格和 / ? #,首尾无空白;不能是版本号或版本范围(如 1.2.3、^1、1.x、*);beta、next、debug 等其余名称均可。违规返回 TAG_INVALID 或 TAG_REQUIRED,hint 给出完整规则。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
SCRIPT_NAME创建脚本返回的 name
: "${SCRIPT_NAME:?Set SCRIPT_NAME}"
curl --fail-with-body -X DELETE "https://api.deepraxis.ai/automation/v1/scripts/docs-samples/${SCRIPT_NAME}/dist-tags/sample" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.scripts.distTags.delete({
  "path": {
    "ns": "docs-samples",
    "name": env("SCRIPT_NAME"),
    "tag": "sample"
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
.*.versionstring必填 / 必有;标签当前指向的精确版本号。
.*.updated_atstring必填 / 必有;标签最近一次移动的时间(RFC 3339 UTC)。
.*.updated_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
.*.updated_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
.*.updated_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。

实测响应

HTTP 200

{
  "latest": {
    "version": "1.0.0",
    "updated_at": "2026-10-13T04:57:22.398Z",
    "updated_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    }
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 TAG_INVALID:标签无效:预发布版本不能打 latest;tag 只能含 URL 安全字符(不含空格和 / ? #);不能是版本号或范围;latest 不能删除。响应 hint 列出完整规则。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
409TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出工作流

列出可见工作流的摘要、最新版本、标签及近七天统计;默认排除已归档条目。

GET /automation/v1/workflows

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
query: limitinteger可选;每页条数,整数 1–100,默认 25。 minimum: 1;maximum: 100
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。
query: qstring可选;不区分大小写,按名称或说明的字面子串匹配;% 与 _ 无通配含义。
query: namespacestring[]可选;仅返回指定命名空间的定义,名称按小写匹配。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: scope"platform" / "own"[]可选;platform 仅平台定义,own 仅租户自建定义;省略返回两者。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: archivedboolean可选;true 仅已归档,false 仅未归档;默认 false。
query: labelsobject可选;按标签过滤,使用 labels[k]=v;同键逗号多值取任一,不同键同时满足。
query: created_at[gte]string可选;创建时间下界,包含边界;使用带时区的 ISO 8601 时间。 format: "date-time"
query: created_at[lte]string可选;创建时间上界,包含边界;使用带时区的 ISO 8601 时间。 format: "date-time"

示例

curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/workflows" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  --get \
  --data-urlencode "namespace=docs-samples" \
  --data-urlencode "limit=1"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.workflows.list({
  "query": {
    "namespace": [
      "docs-samples"
    ],
    "limit": 1
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的工作流摘要,按 created_at 倒序、id 倒序排列。
data[].idstring必填 / 必有;编排 ID,脚本前缀 scr_,工作流前缀 wf_;日常使用 namespace 与 name。
data[].kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
data[].namespacestring必填 / 必有;命名空间,引用形如 namespace/name@版本。
data[].namestring必填 / 必有;名字,与 namespace 一起在租户内唯一,脚本与工作流共用命名空间,重名返回 409 NAME_TAKEN。
data[].descriptionstring必填 / 必有;说明文字,最多 1000 字符。
data[].labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
data[].ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
data[].latest_versionnull / object必填 / 必有;latest 标签指向的已发布版本 {version, published_at};尚未发布为 null。
data[].latest_version(分支2).versionstring必填 / 必有;最新发布版本的版本号(semver)。
data[].latest_version(分支2).published_atstring必填 / 必有;该版本的发布时间(RFC 3339 UTC)。
data[].dist_tagsobject必填 / 必有;标签到精确版本号的映射,例如 latest 指向 1.2.0;用 ns/name@标签 运行时按此解析。
data[].draft_changedboolean必填 / 必有;true 表示草稿内容(摘要)不同于 latest 版本,即有未发布的改动。
data[].latest_runnull / object必填 / 必有;该编排最近一次运行的摘要;还没有运行为 null。
data[].latest_run(分支2).idstring必填 / 必有;运行 ID(run_ 前缀),可用于 runs.retrieve。
data[].latest_run(分支2).numbernull / number必填 / 必有;运行在该脚本或工作流内的递增序号。
data[].latest_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
data[].latest_run(分支2).created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
data[].latest_run(分支2).current_waitnull / object必填 / 必有;当前未完成的等待点;没有等待为 null。
data[].latest_run(分支2).current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
data[].latest_run(分支2).current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
data[].latest_run(分支2).current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
data[].latest_run(分支2).current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
data[].latest_run(分支2).current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
data[].latest_run(分支2).current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
data[].latest_run(分支2).current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
data[].latest_run(分支2).current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
data[].latest_run(分支2).current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
data[].latest_run(分支2).current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
data[].latest_run(分支2).current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
data[].latest_run(分支2).current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
data[].latest_run(分支2).current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
data[].stats_7dobject必填 / 必有;近七天的运行统计:按运行结束日期累计,在运行结束时更新,读取时不扫描运行。 不接受额外字段。
data[].stats_7d.runsnumber必填 / 必有;近七天内结束的运行总数(任意终态)。
data[].stats_7d.failuresnumber必填 / 必有;其中以 faulted 结束的运行数。
data[].archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不可复用。
data[].created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
data[].updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [
    {
      "id": "wf_00mv67m4jad0d5c2a3d1e04dc9ac4c18cff616eca7",
      "owner": "tnt_3a9759864ccb4e00",
      "kind": "workflow",
      "namespace": "docs-samples",
      "name": "sample-workflows-1791867412840-b05e8a",
      "description": "",
      "labels": {},
      "latest_version": null,
      "dist_tags": {},
      "draft_changed": true,
      "latest_run": null,
      "stats_7d": {
        "runs": 0,
        "failures": 0
      },
      "archived_at": null,
      "created_at": "2026-10-13T04:57:29.206Z",
      "updated_at": "2026-10-13T04:57:29.206Z"
    }
  ],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

创建工作流

创建工作流及可编辑草稿,不会发布或启动运行;脚本与工作流共用名称空间,同租户重名返回 NAME_TAKEN。 run.workflow 支持 ns/name@range 或 {namespace, name, version, input};run.script 使用相同引用形状(平台扩展)。 对象的 namespace、name、version 必填;version 支持精确版本、dist-tag 或范围,发布时锁定依赖。 对象 input 默认为 {},支持表达式;字符串引用继续使用任务级 with。run.await 默认 true,等待子运行输出; false 以 detach 创建子运行,任务立即输出 {run_id},父取消不级联。内联 script.code 返回 DEFINITION_INVALID, detail 提示「请先保存为脚本再引用」。raise.error 的 type URI、status、title、detail 保留到运行错误。

POST /automation/v1/workflows

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
header: Idempotency-Keystring可选;可选;1–256 字符。24 小时内同一 key 重放首个响应并带 Idempotent-Replayed: true;同 key 不同请求体返回 422;处理中返回 409。 minLength: 1;maxLength: 256

application/json

不接受额外字段。

字段类型说明
namespacestring必填 / 必有;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9.-]{0,63};praxis 只读。 pattern: "^[a-zA-Z0-9][a-zA-Z0-9.-]{0,63}$"
namestring必填 / 必有;名称,存储前转为小写,格式 [a-z0-9][a-z0-9.-]{0,63}。 pattern: "^[a-zA-Z0-9][a-zA-Z0-9.-]{0,63}$"
descriptionstring可选;说明,最多 1000 个字符。 maxLength: 1000
draftstring可选;可编辑源码;脚本为 TypeScript,工作流为 YAML。创建时省略为空字符串。
labelsobject可选;最多 50 个标签;键为 1–40 个字符,值最多 500 个字符。

示例

curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/workflows" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "namespace": "docs-samples",
  "name": "sample-workflows",
  "draft": "document:\n  dsl: '\''1.0.3'\''\n  namespace: docs-samples\n  name: sample-workflows\n  version: '\''1.0.0'\''\ndo:\n  - answer:\n      set:\n        answer: 42\n"
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.workflows.create({
  "body": {
    "namespace": "docs-samples",
    "name": "sample-workflows",
    "draft": "document:\n  dsl: '1.0.3'\n  namespace: docs-samples\n  name: sample-workflows\n  version: '1.0.0'\ndo:\n  - answer:\n      set:\n        answer: 42\n"
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
Idempotent-ReplayedbooleanPresent and true when replaying the first response for this key.

application/json

字段类型说明
draftobject必填 / 必有;脚本或工作流的可编辑草稿;发布版本时以草稿或某次运行的源码为准。 不接受额外字段。
draft.sourcestring必填 / 必有;草稿源码:脚本为 TypeScript,工作流为 YAML。
draft.revisionstring必填 / 必有;草稿修订标识(ETag),发布时作为 expected_draft_revision,更新草稿时作为 If-Match;与当前不一致返回 412。
draft.updated_atstring必填 / 必有;草稿最近一次修改的时间(RFC 3339 UTC)。
draft.updated_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
draft.updated_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
draft.updated_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
idstring必填 / 必有;编排 ID,脚本前缀 scr_,工作流前缀 wf_;日常使用 namespace 与 name。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
namespacestring必填 / 必有;命名空间,引用形如 namespace/name@版本。
namestring必填 / 必有;名字,与 namespace 一起在租户内唯一,脚本与工作流共用命名空间,重名返回 409 NAME_TAKEN。
descriptionstring必填 / 必有;说明文字,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
latest_versionnull / object必填 / 必有;latest 标签指向的已发布版本 {version, published_at};尚未发布为 null。
latest_version(分支2).versionstring必填 / 必有;最新发布版本的版本号(semver)。
latest_version(分支2).published_atstring必填 / 必有;该版本的发布时间(RFC 3339 UTC)。
dist_tagsobject必填 / 必有;标签到精确版本号的映射,例如 latest 指向 1.2.0;用 ns/name@标签 运行时按此解析。
draft_changedboolean必填 / 必有;true 表示草稿内容(摘要)不同于 latest 版本,即有未发布的改动。
latest_runnull / object必填 / 必有;该编排最近一次运行的摘要;还没有运行为 null。
latest_run(分支2).idstring必填 / 必有;运行 ID(run_ 前缀),可用于 runs.retrieve。
latest_run(分支2).numbernull / number必填 / 必有;运行在该脚本或工作流内的递增序号。
latest_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
latest_run(分支2).created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
latest_run(分支2).current_waitnull / object必填 / 必有;当前未完成的等待点;没有等待为 null。
latest_run(分支2).current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
latest_run(分支2).current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
latest_run(分支2).current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
latest_run(分支2).current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
latest_run(分支2).current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
latest_run(分支2).current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
latest_run(分支2).current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
latest_run(分支2).current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
latest_run(分支2).current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
latest_run(分支2).current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
latest_run(分支2).current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
latest_run(分支2).current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
latest_run(分支2).current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
stats_7dobject必填 / 必有;近七天的运行统计:按运行结束日期累计,在运行结束时更新,读取时不扫描运行。 不接受额外字段。
stats_7d.runsnumber必填 / 必有;近七天内结束的运行总数(任意终态)。
stats_7d.failuresnumber必填 / 必有;其中以 faulted 结束的运行数。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不可复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "wf_00mv67m4jad0d5c2a3d1e04dc9ac4c18cff616eca7",
  "owner": "tnt_3a9759864ccb4e00",
  "kind": "workflow",
  "namespace": "docs-samples",
  "name": "sample-workflows-1791867412840-b05e8a",
  "description": "",
  "labels": {},
  "latest_version": null,
  "dist_tags": {},
  "draft_changed": true,
  "latest_run": null,
  "stats_7d": {
    "runs": 0,
    "failures": 0
  },
  "archived_at": null,
  "created_at": "2026-10-13T04:57:29.206Z",
  "updated_at": "2026-10-13T04:57:29.206Z",
  "draft": {
    "source": "document:\n  dsl: '1.0.3'\n  namespace: docs-samples\n  name: sample-workflows-1791867412840-b05e8a\n  version: '1.0.0'\ndo:\n  - answer:\n      set:\n        answer: 42\n",
    "revision": "draft_00mv67m4ja0e38625d463646e3a526bb774bf453ee",
    "updated_at": "2026-10-13T04:57:29.206Z",
    "updated_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    }
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
409IDEMPOTENCY_IN_FLIGHT:同一幂等键的请求仍在处理中。 NAME_TAKEN:名称已被同一租户占用。
422IDEMPOTENCY_KEY_MISMATCH:同一幂等键已用于不同请求内容。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

读取工作流

读取工作流详情及草稿源码;ETag 是草稿修订,可作为修改请求的 If-Match。

GET /automation/v1/workflows/{ns}/{name}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
WORKFLOW_NAME创建工作流返回的 name
: "${WORKFLOW_NAME:?Set WORKFLOW_NAME}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/workflows/docs-samples/${WORKFLOW_NAME}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.workflows.retrieve({
  "path": {
    "ns": "docs-samples",
    "name": env("WORKFLOW_NAME")
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
ETagstringCurrent resource revision for conditional updates.

application/json

字段类型说明
draftobject必填 / 必有;脚本或工作流的可编辑草稿;发布版本时以草稿或某次运行的源码为准。 不接受额外字段。
draft.sourcestring必填 / 必有;草稿源码:脚本为 TypeScript,工作流为 YAML。
draft.revisionstring必填 / 必有;草稿修订标识(ETag),发布时作为 expected_draft_revision,更新草稿时作为 If-Match;与当前不一致返回 412。
draft.updated_atstring必填 / 必有;草稿最近一次修改的时间(RFC 3339 UTC)。
draft.updated_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
draft.updated_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
draft.updated_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
idstring必填 / 必有;编排 ID,脚本前缀 scr_,工作流前缀 wf_;日常使用 namespace 与 name。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
namespacestring必填 / 必有;命名空间,引用形如 namespace/name@版本。
namestring必填 / 必有;名字,与 namespace 一起在租户内唯一,脚本与工作流共用命名空间,重名返回 409 NAME_TAKEN。
descriptionstring必填 / 必有;说明文字,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
latest_versionnull / object必填 / 必有;latest 标签指向的已发布版本 {version, published_at};尚未发布为 null。
latest_version(分支2).versionstring必填 / 必有;最新发布版本的版本号(semver)。
latest_version(分支2).published_atstring必填 / 必有;该版本的发布时间(RFC 3339 UTC)。
dist_tagsobject必填 / 必有;标签到精确版本号的映射,例如 latest 指向 1.2.0;用 ns/name@标签 运行时按此解析。
draft_changedboolean必填 / 必有;true 表示草稿内容(摘要)不同于 latest 版本,即有未发布的改动。
latest_runnull / object必填 / 必有;该编排最近一次运行的摘要;还没有运行为 null。
latest_run(分支2).idstring必填 / 必有;运行 ID(run_ 前缀),可用于 runs.retrieve。
latest_run(分支2).numbernull / number必填 / 必有;运行在该脚本或工作流内的递增序号。
latest_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
latest_run(分支2).created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
latest_run(分支2).current_waitnull / object必填 / 必有;当前未完成的等待点;没有等待为 null。
latest_run(分支2).current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
latest_run(分支2).current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
latest_run(分支2).current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
latest_run(分支2).current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
latest_run(分支2).current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
latest_run(分支2).current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
latest_run(分支2).current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
latest_run(分支2).current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
latest_run(分支2).current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
latest_run(分支2).current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
latest_run(分支2).current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
latest_run(分支2).current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
latest_run(分支2).current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
stats_7dobject必填 / 必有;近七天的运行统计:按运行结束日期累计,在运行结束时更新,读取时不扫描运行。 不接受额外字段。
stats_7d.runsnumber必填 / 必有;近七天内结束的运行总数(任意终态)。
stats_7d.failuresnumber必填 / 必有;其中以 faulted 结束的运行数。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不可复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "wf_00mv67m4jad0d5c2a3d1e04dc9ac4c18cff616eca7",
  "owner": "tnt_3a9759864ccb4e00",
  "kind": "workflow",
  "namespace": "docs-samples",
  "name": "sample-workflows-1791867412840-b05e8a",
  "description": "",
  "labels": {},
  "latest_version": null,
  "dist_tags": {},
  "draft_changed": true,
  "latest_run": null,
  "stats_7d": {
    "runs": 0,
    "failures": 0
  },
  "archived_at": null,
  "created_at": "2026-10-13T04:57:29.206Z",
  "updated_at": "2026-10-13T04:57:29.206Z",
  "draft": {
    "source": "document:\n  dsl: '1.0.3'\n  namespace: docs-samples\n  name: sample-workflows-1791867412840-b05e8a\n  version: '1.0.0'\ndo:\n  - answer:\n      set:\n        answer: 42\n",
    "revision": "draft_00mv67m4ja0e38625d463646e3a526bb774bf453ee",
    "updated_at": "2026-10-13T04:57:29.206Z",
    "updated_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    }
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

更新工作流草稿

修改说明、标签或草稿,必须携带与当前草稿匹配的 If-Match;即使只改元数据也会生成新的草稿修订。

PATCH /automation/v1/workflows/{ns}/{name}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
header: If-Matchstring必填;当前资源的 ETag,可直接使用对象里的 draft.revision 或 etag 字段值:裸值、带双引号或弱校验写法 W/"…" 均接受(RFC 7232 弱比较);缺失返回 400,修订不匹配返回 412。

application/json

不接受额外字段。

字段类型说明
descriptionstring可选;说明,最多 1000 个字符。 maxLength: 1000
labelsobject可选;最多 50 个标签;键为 1–40 个字符,值最多 500 个字符。
draftstring可选;可编辑源码;脚本为 TypeScript,工作流为 YAML。创建时省略为空字符串。

示例

先设置以下环境变量,使用你自己的资源:

: "${WORKFLOW_NAME:?Set WORKFLOW_NAME}"
: "${ETAG:?Set ETAG}"
curl --fail-with-body -X PATCH "https://api.deepraxis.ai/automation/v1/workflows/docs-samples/${WORKFLOW_NAME}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "If-Match: ${ETAG}" \
  -H "Content-Type: application/json" \
  --data '{
  "description": "Sample definition",
  "draft": "document:\n  dsl: '\''1.0.3'\''\n  namespace: docs-samples\n  name: sample-workflows-1791867412840-b05e8a\n  version: '\''1.0.0'\''\ndo:\n  - answer:\n      set:\n        answer: 42\n"
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.workflows.update({
  "path": {
    "ns": "docs-samples",
    "name": env("WORKFLOW_NAME")
  },
  "headers": {
    "If-Match": env("ETAG")
  },
  "body": {
    "description": "Sample definition",
    "draft": "document:\n  dsl: '1.0.3'\n  namespace: docs-samples\n  name: sample-workflows-1791867412840-b05e8a\n  version: '1.0.0'\ndo:\n  - answer:\n      set:\n        answer: 42\n"
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
draftobject必填 / 必有;脚本或工作流的可编辑草稿;发布版本时以草稿或某次运行的源码为准。 不接受额外字段。
draft.sourcestring必填 / 必有;草稿源码:脚本为 TypeScript,工作流为 YAML。
draft.revisionstring必填 / 必有;草稿修订标识(ETag),发布时作为 expected_draft_revision,更新草稿时作为 If-Match;与当前不一致返回 412。
draft.updated_atstring必填 / 必有;草稿最近一次修改的时间(RFC 3339 UTC)。
draft.updated_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
draft.updated_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
draft.updated_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
idstring必填 / 必有;编排 ID,脚本前缀 scr_,工作流前缀 wf_;日常使用 namespace 与 name。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
namespacestring必填 / 必有;命名空间,引用形如 namespace/name@版本。
namestring必填 / 必有;名字,与 namespace 一起在租户内唯一,脚本与工作流共用命名空间,重名返回 409 NAME_TAKEN。
descriptionstring必填 / 必有;说明文字,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
latest_versionnull / object必填 / 必有;latest 标签指向的已发布版本 {version, published_at};尚未发布为 null。
latest_version(分支2).versionstring必填 / 必有;最新发布版本的版本号(semver)。
latest_version(分支2).published_atstring必填 / 必有;该版本的发布时间(RFC 3339 UTC)。
dist_tagsobject必填 / 必有;标签到精确版本号的映射,例如 latest 指向 1.2.0;用 ns/name@标签 运行时按此解析。
draft_changedboolean必填 / 必有;true 表示草稿内容(摘要)不同于 latest 版本,即有未发布的改动。
latest_runnull / object必填 / 必有;该编排最近一次运行的摘要;还没有运行为 null。
latest_run(分支2).idstring必填 / 必有;运行 ID(run_ 前缀),可用于 runs.retrieve。
latest_run(分支2).numbernull / number必填 / 必有;运行在该脚本或工作流内的递增序号。
latest_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
latest_run(分支2).created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
latest_run(分支2).current_waitnull / object必填 / 必有;当前未完成的等待点;没有等待为 null。
latest_run(分支2).current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
latest_run(分支2).current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
latest_run(分支2).current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
latest_run(分支2).current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
latest_run(分支2).current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
latest_run(分支2).current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
latest_run(分支2).current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
latest_run(分支2).current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
latest_run(分支2).current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
latest_run(分支2).current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
latest_run(分支2).current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
latest_run(分支2).current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
latest_run(分支2).current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
stats_7dobject必填 / 必有;近七天的运行统计:按运行结束日期累计,在运行结束时更新,读取时不扫描运行。 不接受额外字段。
stats_7d.runsnumber必填 / 必有;近七天内结束的运行总数(任意终态)。
stats_7d.failuresnumber必填 / 必有;其中以 faulted 结束的运行数。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不可复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "wf_00mv67m4jad0d5c2a3d1e04dc9ac4c18cff616eca7",
  "owner": "tnt_3a9759864ccb4e00",
  "kind": "workflow",
  "namespace": "docs-samples",
  "name": "sample-workflows-1791867412840-b05e8a",
  "description": "Sample definition",
  "labels": {},
  "latest_version": null,
  "dist_tags": {},
  "draft_changed": true,
  "latest_run": null,
  "stats_7d": {
    "runs": 0,
    "failures": 0
  },
  "archived_at": null,
  "created_at": "2026-10-13T04:57:29.206Z",
  "updated_at": "2026-10-13T04:57:31.570Z",
  "draft": {
    "source": "document:\n  dsl: '1.0.3'\n  namespace: docs-samples\n  name: sample-workflows-1791867412840-b05e8a\n  version: '1.0.0'\ndo:\n  - answer:\n      set:\n        answer: 42\n",
    "revision": "draft_00mv67m4ja0e38625d463646e3a526bb774bf453ee",
    "updated_at": "2026-10-13T04:57:29.206Z",
    "updated_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    }
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
409TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

归档工作流

归档后保留名称、版本和草稿;默认列表隐藏该条目,新的目标解析和运行请求拒绝已归档目标。

POST /automation/v1/workflows/{ns}/{name}/archive

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。

application/json

不接受额外字段。 object

示例

先设置以下环境变量,使用你自己的资源:

变量来源
WORKFLOW_NAME创建工作流返回的 name
: "${WORKFLOW_NAME:?Set WORKFLOW_NAME}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/workflows/docs-samples/${WORKFLOW_NAME}/archive" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.workflows.archive({
  "path": {
    "ns": "docs-samples",
    "name": env("WORKFLOW_NAME")
  },
  "body": {}
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
idstring必填 / 必有;编排 ID,脚本前缀 scr_,工作流前缀 wf_;日常使用 namespace 与 name。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
namespacestring必填 / 必有;命名空间,引用形如 namespace/name@版本。
namestring必填 / 必有;名字,与 namespace 一起在租户内唯一,脚本与工作流共用命名空间,重名返回 409 NAME_TAKEN。
descriptionstring必填 / 必有;说明文字,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
latest_versionnull / object必填 / 必有;latest 标签指向的已发布版本 {version, published_at};尚未发布为 null。
latest_version(分支2).versionstring必填 / 必有;最新发布版本的版本号(semver)。
latest_version(分支2).published_atstring必填 / 必有;该版本的发布时间(RFC 3339 UTC)。
dist_tagsobject必填 / 必有;标签到精确版本号的映射,例如 latest 指向 1.2.0;用 ns/name@标签 运行时按此解析。
draft_changedboolean必填 / 必有;true 表示草稿内容(摘要)不同于 latest 版本,即有未发布的改动。
latest_runnull / object必填 / 必有;该编排最近一次运行的摘要;还没有运行为 null。
latest_run(分支2).idstring必填 / 必有;运行 ID(run_ 前缀),可用于 runs.retrieve。
latest_run(分支2).numbernull / number必填 / 必有;运行在该脚本或工作流内的递增序号。
latest_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
latest_run(分支2).created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
latest_run(分支2).current_waitnull / object必填 / 必有;当前未完成的等待点;没有等待为 null。
latest_run(分支2).current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
latest_run(分支2).current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
latest_run(分支2).current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
latest_run(分支2).current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
latest_run(分支2).current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
latest_run(分支2).current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
latest_run(分支2).current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
latest_run(分支2).current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
latest_run(分支2).current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
latest_run(分支2).current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
latest_run(分支2).current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
latest_run(分支2).current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
latest_run(分支2).current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
stats_7dobject必填 / 必有;近七天的运行统计:按运行结束日期累计,在运行结束时更新,读取时不扫描运行。 不接受额外字段。
stats_7d.runsnumber必填 / 必有;近七天内结束的运行总数(任意终态)。
stats_7d.failuresnumber必填 / 必有;其中以 faulted 结束的运行数。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不可复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "wf_00mv67m4jad0d5c2a3d1e04dc9ac4c18cff616eca7",
  "owner": "tnt_3a9759864ccb4e00",
  "kind": "workflow",
  "namespace": "docs-samples",
  "name": "sample-workflows-1791867412840-b05e8a",
  "description": "Sample definition",
  "labels": {},
  "latest_version": {
    "version": "1.0.0",
    "published_at": "2026-10-13T04:57:32.297Z"
  },
  "dist_tags": {
    "latest": "1.0.0"
  },
  "draft_changed": false,
  "latest_run": null,
  "stats_7d": {
    "runs": 0,
    "failures": 0
  },
  "archived_at": "2026-10-13T04:57:37.671Z",
  "created_at": "2026-10-13T04:57:29.206Z",
  "updated_at": "2026-10-13T04:57:37.671Z"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

恢复工作流

恢复已归档定义,保留版本和标签。名称无需重新分配。

POST /automation/v1/workflows/{ns}/{name}/restore

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。

application/json

不接受额外字段。 object

示例

先设置以下环境变量,使用你自己的资源:

变量来源
WORKFLOW_NAME创建工作流返回的 name
: "${WORKFLOW_NAME:?Set WORKFLOW_NAME}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/workflows/docs-samples/${WORKFLOW_NAME}/restore" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.workflows.restore({
  "path": {
    "ns": "docs-samples",
    "name": env("WORKFLOW_NAME")
  },
  "body": {}
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
idstring必填 / 必有;编排 ID,脚本前缀 scr_,工作流前缀 wf_;日常使用 namespace 与 name。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
namespacestring必填 / 必有;命名空间,引用形如 namespace/name@版本。
namestring必填 / 必有;名字,与 namespace 一起在租户内唯一,脚本与工作流共用命名空间,重名返回 409 NAME_TAKEN。
descriptionstring必填 / 必有;说明文字,最多 1000 字符。
labelsobject必填 / 必有;用户自定义标签:字符串键值对,用于分类与列表过滤(labels[key]=value);键不能以 praxis. 开头。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
latest_versionnull / object必填 / 必有;latest 标签指向的已发布版本 {version, published_at};尚未发布为 null。
latest_version(分支2).versionstring必填 / 必有;最新发布版本的版本号(semver)。
latest_version(分支2).published_atstring必填 / 必有;该版本的发布时间(RFC 3339 UTC)。
dist_tagsobject必填 / 必有;标签到精确版本号的映射,例如 latest 指向 1.2.0;用 ns/name@标签 运行时按此解析。
draft_changedboolean必填 / 必有;true 表示草稿内容(摘要)不同于 latest 版本,即有未发布的改动。
latest_runnull / object必填 / 必有;该编排最近一次运行的摘要;还没有运行为 null。
latest_run(分支2).idstring必填 / 必有;运行 ID(run_ 前缀),可用于 runs.retrieve。
latest_run(分支2).numbernull / number必填 / 必有;运行在该脚本或工作流内的递增序号。
latest_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
latest_run(分支2).created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
latest_run(分支2).current_waitnull / object必填 / 必有;当前未完成的等待点;没有等待为 null。
latest_run(分支2).current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
latest_run(分支2).current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
latest_run(分支2).current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
latest_run(分支2).current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
latest_run(分支2).current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
latest_run(分支2).current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
latest_run(分支2).current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
latest_run(分支2).current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
latest_run(分支2).current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
latest_run(分支2).current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
latest_run(分支2).current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
latest_run(分支2).current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
latest_run(分支2).current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
stats_7dobject必填 / 必有;近七天的运行统计:按运行结束日期累计,在运行结束时更新,读取时不扫描运行。 不接受额外字段。
stats_7d.runsnumber必填 / 必有;近七天内结束的运行总数(任意终态)。
stats_7d.failuresnumber必填 / 必有;其中以 faulted 结束的运行数。
archived_atnull / string必填 / 必有;归档时间;未归档为 null。归档后名字保留,不可复用。
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。

实测响应

HTTP 200

{
  "id": "wf_00mv67m4jad0d5c2a3d1e04dc9ac4c18cff616eca7",
  "owner": "tnt_3a9759864ccb4e00",
  "kind": "workflow",
  "namespace": "docs-samples",
  "name": "sample-workflows-1791867412840-b05e8a",
  "description": "Sample definition",
  "labels": {},
  "latest_version": {
    "version": "1.0.0",
    "published_at": "2026-10-13T04:57:32.297Z"
  },
  "dist_tags": {
    "latest": "1.0.0"
  },
  "draft_changed": false,
  "latest_run": null,
  "stats_7d": {
    "runs": 0,
    "failures": 0
  },
  "archived_at": null,
  "created_at": "2026-10-13T04:57:29.206Z",
  "updated_at": "2026-10-13T04:57:38.354Z"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

发布工作流版本

从草稿或临时运行源码发布版本,校验定义并锁定依赖。草稿须匹配 expected_draft_revision;临时运行由 from_run 与 expected_source_sha256 指定。版本相同且内容相同返回已有版本,内容不同返回 VERSION_EXISTS;预发布版本必须显式带 tag(不能是 latest,tag 只能含 URL 安全字符且不能是版本号或范围,违规返回 TAG_REQUIRED 或 TAG_INVALID,hint 给出完整规则),校验不通过返回 DEFINITION_INVALID。稳定版本仅高于已有最高稳定版本时自动移动 latest;工作流成为 latest 时同步定义中的定时触发器。run.workflow/run.script 的字符串与对象引用使用相同版本解析和依赖锁定规则。 发布会去掉版本号的 +build 元数据。

POST /automation/v1/workflows/{ns}/{name}/versions

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
header: Idempotency-Keystring可选;可选;1–256 字符。24 小时内同一 key 重放首个响应并带 Idempotent-Replayed: true;同 key 不同请求体返回 422;处理中返回 409。 minLength: 1;maxLength: 256

application/json

字段类型说明
(分支1).versionstring必填 / 必有;规范的精确语义版本,例如 1.2.0 或 1.3.0-beta.1;不能是范围。
(分支1).expected_draft_revisionstring必填 / 必有;发布的草稿修订,必须匹配当前草稿;与 from_run 发布方式二选一。
(分支1).tagstring可选;发布标签。预发布版本(如 1.3.0-beta.1)必须带 tag 且不能是 latest;tag 只能由 URL 安全字符组成(字母、数字及 - _ . ! ~ * ' ( )),不含空格和 / ? #,首尾无空白;不能是版本号或版本范围(如 1.2.3、^1、1.x、*);beta、next、debug 等其余名称均可。违规返回 TAG_INVALID 或 TAG_REQUIRED,hint 给出完整规则。
(分支2).versionstring必填 / 必有;规范的精确语义版本,例如 1.2.0 或 1.3.0-beta.1;不能是范围。
(分支2).from_runstring必填 / 必有;提供源码快照的临时运行 ID;已发布目标的运行当前没有可用于此入口的快照。须同时给出 expected_source_sha256,不能同时给 expected_draft_revision。
(分支2).expected_source_sha256string必填 / 必有;运行源码的 SHA-256 摘要,必须与快照匹配。
(分支2).tagstring可选;发布标签。预发布版本(如 1.3.0-beta.1)必须带 tag 且不能是 latest;tag 只能由 URL 安全字符组成(字母、数字及 - _ . ! ~ * ' ( )),不含空格和 / ? #,首尾无空白;不能是版本号或版本范围(如 1.2.3、^1、1.x、*);beta、next、debug 等其余名称均可。违规返回 TAG_INVALID 或 TAG_REQUIRED,hint 给出完整规则。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
WORKFLOW_NAME创建工作流返回的 name
DRAFT_REVISION当前 draft.revision
: "${WORKFLOW_NAME:?Set WORKFLOW_NAME}"
: "${DRAFT_REVISION:?Set DRAFT_REVISION}"
BODY=$(jq -n --arg DRAFT_REVISION "$DRAFT_REVISION" '{
  "version": "1.0.0",
  "expected_draft_revision": $DRAFT_REVISION
}')
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/workflows/docs-samples/${WORKFLOW_NAME}/versions" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data "$BODY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.workflows.versions.publish({
  "path": {
    "ns": "docs-samples",
    "name": env("WORKFLOW_NAME")
  },
  "body": {
    "version": "1.0.0",
    "expected_draft_revision": env("DRAFT_REVISION")
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
Idempotent-ReplayedbooleanPresent and true when replaying the first response for this key.

application/json

字段类型说明
idstring必填 / 必有;版本 ID,脚本前缀 scv_,工作流前缀 wfv_。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
versionstring必填 / 必有;版本号(semver,已去掉 +build 元数据)。
digeststring必填 / 必有;源码与契约的内容摘要。
sourcestring必填 / 必有;该版本的完整源码。版本列表默认不返回,需要时加 expand=source。
input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
input_schema.*(分支5)object递归 JSON 值。
input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
output_schemaobject必填 / 必有;脚本从返回类型推导,支持 Promise 解包、Record、交叉类型和 Date(date-time);推不出时为空 schema,并在 /validate 的 warnings 给出 warning。
output_schema.*(分支5)object递归 JSON 值。
output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
referencesobject[]必填 / 必有;该版本依赖的动作、平台 API、脚本与工作流。脚本和工作流依赖在发布时锁定到精确版本。
references[].kind"action" / "script" / "workflow" / "platform_api" / "run"必填 / 必有;依赖类型。action 为动作;platform_api 为平台 API 操作;script 为脚本;workflow 为工作流;run 为脚本中 invoke("ns/name") 调用的子运行目标(脚本或工作流,发布时解析)。
references[].namestring必填 / 必有;被依赖对象:动作为 ns/name,平台 API 为操作名,脚本与工作流为 ns/name。
references[].rangestring可选;引用时写的版本范围或标签(npm 规则);未写时为空。
references[].locked_versionstring可选;发布时锁定的精确版本;仅脚本与工作流依赖有,动作与平台 API 不锁定。
outlinenull / object[]必填 / 必有;工作流的步骤大纲(OutlineNode 数组),由解析器静态生成;脚本为 null。
outline(分支2)[].namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
outline(分支2)[].referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start;与运行时 Task.reference 一致。
outline(分支2)[].kind"run" / "call" / "wait" / "set" / "for" / "fork" / "try" / "switch" / "emit" / "raise" / "listen" / "do"必填 / 必有;工作流步骤类型。call 调用动作;run 运行子脚本或子工作流;wait 等待时长;set 设置变量;for 循环;fork 并行分支;try 带捕获的块;switch 条件分支;emit 发出事件;raise 抛出错误;listen 等待事件;do 顺序执行的步骤块。
outline(分支2)[].targetstring可选;步骤调用的目标:call 步骤为动作 ns/name,run 步骤为 ns/name@范围;其它类型没有。
outline(分支2)[].waitobject可选;等待步骤的摘要:时长(seconds 或 duration)或等待的事件类型(event)。 不接受额外字段。
outline(分支2)[].wait.untilstring可选;等待结束的绝对时刻,仅在可静态确定时给出;目前大纲不填充该字段。
outline(分支2)[].wait.secondsnumber可选;可静态换算的等待秒数;时长对象与可换算的 ISO 时长均投影到此字段。
outline(分支2)[].wait.eventstring可选;listen 步骤等待的事件类型。
outline(分支2)[].wait.durationstring可选;无法静态换算成秒的原始时长或运行时表达式;不与 seconds 强行换算。
outline(分支2)[].loopobject可选;for 步骤的循环信息 {each, in}。 不接受额外字段。
outline(分支2)[].loop.eachstring必填 / 必有;循环变量名;未指定时为 item。
outline(分支2)[].loop.instring必填 / 必有;被遍历的集合表达式原文。
outline(分支2)[].childrenobject[]可选;嵌套的子步骤(do、fork 分支、try 与 catch 内的步骤)。
outline(分支2)[].children[]object递归 JSON 值。
sdk_versionnull / string必填 / 必有;发布脚本所用的 SDK 版本;工作流为 null。
published_atstring必填 / 必有;发布时间(RFC 3339 UTC)。
published_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
published_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
published_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
deprecatednull / string必填 / 必有;弃用说明;未弃用为 null。弃用的版本仍可运行,但按范围或标签解析时优先选用未弃用的版本。
deprecated_atnull / string必填 / 必有;弃用时间(RFC 3339 UTC);未弃用为 null。
deprecated_bynull / object必填 / 必有;执行弃用的主体;未弃用为 null。
deprecated_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
deprecated_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。

实测响应

HTTP 200

{
  "id": "wfv_00mv67m6x5409408c354944fa8a960d207eb33c297",
  "kind": "workflow",
  "version": "1.0.0",
  "digest": "ea7352d51087eca0113ee82230848ce1506fd97d27aad4c7b1911e5c4ef9b5fb",
  "input_schema": {},
  "output_schema": {},
  "references": [],
  "outline": [
    {
      "name": "answer",
      "reference": "/do/0/answer",
      "kind": "set"
    }
  ],
  "sdk_version": null,
  "published_at": "2026-10-13T04:57:32.297Z",
  "published_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "deprecated": null,
  "deprecated_at": null,
  "deprecated_by": null,
  "source": "document:\n  dsl: '1.0.3'\n  namespace: docs-samples\n  name: sample-workflows-1791867412840-b05e8a\n  version: '1.0.0'\ndo:\n  - answer:\n      set:\n        answer: 42\n"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 TAG_REQUIRED:预发布版本必须显式指定发布标签(例如 beta,不能是 latest);响应 hint 列出完整规则。 TAG_INVALID:标签无效:预发布版本不能打 latest;tag 只能含 URL 安全字符(不含空格和 / ? #);不能是版本号或范围;latest 不能删除。响应 hint 列出完整规则。 DEFINITION_INVALID:源码未通过定义校验。 INPUT_INVALID:输入不满足目标契约或业务校验。 SCHEDULE_INVALID:定时规则或时间边界无效。 TIMEZONE_INVALID:时区不是有效的 IANA 时区。 INTERVAL_TOO_SHORT:定时间隔短于一分钟。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。 RUN_NOT_FOUND:运行不存在或当前租户不可见。
409IDEMPOTENCY_IN_FLIGHT:同一幂等键的请求仍在处理中。 TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。 VERSION_EXISTS:版本号已存在且源码内容不同。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
422IDEMPOTENCY_KEY_MISMATCH:同一幂等键已用于不同请求内容。 DEFINITION_IDENTITY_MISMATCH:源码声明或运行语言与发布目标不一致。 NO_MATCHING_VERSION:没有满足标签、版本或范围的已发布版本。 CYCLE_DETECTED:发布后依赖会形成环(A 依赖 B、B 又依赖 A);detail 给出环路径。
429TRIGGER_LIMIT:租户已达到 100 个启用触发器的上限。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出工作流版本

按语义版本倒序分页列出不可变的 schema 和锁定依赖。默认不带源码;仅 expand=source 带完整源码,其它值返回 400。详情接口保持全文。

GET /automation/v1/workflows/{ns}/{name}/versions

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
query: limitinteger可选;每页条数,整数 1–100,默认 25。 minimum: 1;maximum: 100
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。
query: expand"source"可选;仅接受 source;默认不带源码,其它值返回 400。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
WORKFLOW_NAME创建工作流返回的 name
: "${WORKFLOW_NAME:?Set WORKFLOW_NAME}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/workflows/docs-samples/${WORKFLOW_NAME}/versions" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.workflows.versions.list({
  "path": {
    "ns": "docs-samples",
    "name": env("WORKFLOW_NAME")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的工作流版本(默认不含源码,expand=source 才带),按 semver 降序排列。
data[].idstring必填 / 必有;版本 ID,脚本前缀 scv_,工作流前缀 wfv_。
data[].kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
data[].versionstring必填 / 必有;版本号(semver,已去掉 +build 元数据)。
data[].digeststring必填 / 必有;源码与契约的内容摘要。
data[].sourcestring可选;该版本的完整源码。版本列表默认不返回,需要时加 expand=source。
data[].input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
data[].input_schema.*(分支5)object递归 JSON 值。
data[].input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[].output_schemaobject必填 / 必有;脚本从返回类型推导,支持 Promise 解包、Record、交叉类型和 Date(date-time);推不出时为空 schema,并在 /validate 的 warnings 给出 warning。
data[].output_schema.*(分支5)object递归 JSON 值。
data[].output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[].referencesobject[]必填 / 必有;该版本依赖的动作、平台 API、脚本与工作流。脚本和工作流依赖在发布时锁定到精确版本。
data[].references[].kind"action" / "script" / "workflow" / "platform_api" / "run"必填 / 必有;依赖类型。action 为动作;platform_api 为平台 API 操作;script 为脚本;workflow 为工作流;run 为脚本中 invoke("ns/name") 调用的子运行目标(脚本或工作流,发布时解析)。
data[].references[].namestring必填 / 必有;被依赖对象:动作为 ns/name,平台 API 为操作名,脚本与工作流为 ns/name。
data[].references[].rangestring可选;引用时写的版本范围或标签(npm 规则);未写时为空。
data[].references[].locked_versionstring可选;发布时锁定的精确版本;仅脚本与工作流依赖有,动作与平台 API 不锁定。
data[].outlinenull / object[]必填 / 必有;工作流的步骤大纲(OutlineNode 数组),由解析器静态生成;脚本为 null。
data[].outline(分支2)[].namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
data[].outline(分支2)[].referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start;与运行时 Task.reference 一致。
data[].outline(分支2)[].kind"run" / "call" / "wait" / "set" / "for" / "fork" / "try" / "switch" / "emit" / "raise" / "listen" / "do"必填 / 必有;工作流步骤类型。call 调用动作;run 运行子脚本或子工作流;wait 等待时长;set 设置变量;for 循环;fork 并行分支;try 带捕获的块;switch 条件分支;emit 发出事件;raise 抛出错误;listen 等待事件;do 顺序执行的步骤块。
data[].outline(分支2)[].targetstring可选;步骤调用的目标:call 步骤为动作 ns/name,run 步骤为 ns/name@范围;其它类型没有。
data[].outline(分支2)[].waitobject可选;等待步骤的摘要:时长(seconds 或 duration)或等待的事件类型(event)。 不接受额外字段。
data[].outline(分支2)[].wait.untilstring可选;等待结束的绝对时刻,仅在可静态确定时给出;目前大纲不填充该字段。
data[].outline(分支2)[].wait.secondsnumber可选;可静态换算的等待秒数;时长对象与可换算的 ISO 时长均投影到此字段。
data[].outline(分支2)[].wait.eventstring可选;listen 步骤等待的事件类型。
data[].outline(分支2)[].wait.durationstring可选;无法静态换算成秒的原始时长或运行时表达式;不与 seconds 强行换算。
data[].outline(分支2)[].loopobject可选;for 步骤的循环信息 {each, in}。 不接受额外字段。
data[].outline(分支2)[].loop.eachstring必填 / 必有;循环变量名;未指定时为 item。
data[].outline(分支2)[].loop.instring必填 / 必有;被遍历的集合表达式原文。
data[].outline(分支2)[].childrenobject[]可选;嵌套的子步骤(do、fork 分支、try 与 catch 内的步骤)。
data[].outline(分支2)[].children[]object递归 JSON 值。
data[].sdk_versionnull / string必填 / 必有;发布脚本所用的 SDK 版本;工作流为 null。
data[].published_atstring必填 / 必有;发布时间(RFC 3339 UTC)。
data[].published_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
data[].published_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data[].published_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
data[].deprecatednull / string必填 / 必有;弃用说明;未弃用为 null。弃用的版本仍可运行,但按范围或标签解析时优先选用未弃用的版本。
data[].deprecated_atnull / string必填 / 必有;弃用时间(RFC 3339 UTC);未弃用为 null。
data[].deprecated_bynull / object必填 / 必有;执行弃用的主体;未弃用为 null。
data[].deprecated_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data[].deprecated_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [
    {
      "id": "wfv_00mv67m6x5409408c354944fa8a960d207eb33c297",
      "kind": "workflow",
      "version": "1.0.0",
      "digest": "ea7352d51087eca0113ee82230848ce1506fd97d27aad4c7b1911e5c4ef9b5fb",
      "input_schema": {},
      "output_schema": {},
      "references": [],
      "outline": [
        {
          "name": "answer",
          "reference": "/do/0/answer",
          "kind": "set"
        }
      ],
      "sdk_version": null,
      "published_at": "2026-10-13T04:57:32.297Z",
      "published_by": {
        "type": "api_key",
        "id": "key_3e00b8984967"
      },
      "deprecated": null,
      "deprecated_at": null,
      "deprecated_by": null
    }
  ],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

读取工作流版本

读取精确版本的源码、输入输出契约及弃用说明;版本缺失返回 VERSION_NOT_FOUND。 详情始终返回完整源码。 version 接受精确版本或 dist-tag;range 返回 400,hint 提示改用 /resolve。

GET /automation/v1/workflows/{ns}/{name}/versions/{version}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
path: versionstring必填;精确版本或 dist-tag;不接受 range(400,带 hint)。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
WORKFLOW_NAME创建工作流返回的 name
: "${WORKFLOW_NAME:?Set WORKFLOW_NAME}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/workflows/docs-samples/${WORKFLOW_NAME}/versions/1.0.0" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.workflows.versions.retrieve({
  "path": {
    "ns": "docs-samples",
    "name": env("WORKFLOW_NAME"),
    "version": "1.0.0"
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
idstring必填 / 必有;版本 ID,脚本前缀 scv_,工作流前缀 wfv_。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
versionstring必填 / 必有;版本号(semver,已去掉 +build 元数据)。
digeststring必填 / 必有;源码与契约的内容摘要。
sourcestring必填 / 必有;该版本的完整源码。版本列表默认不返回,需要时加 expand=source。
input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
input_schema.*(分支5)object递归 JSON 值。
input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
output_schemaobject必填 / 必有;脚本从返回类型推导,支持 Promise 解包、Record、交叉类型和 Date(date-time);推不出时为空 schema,并在 /validate 的 warnings 给出 warning。
output_schema.*(分支5)object递归 JSON 值。
output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
referencesobject[]必填 / 必有;该版本依赖的动作、平台 API、脚本与工作流。脚本和工作流依赖在发布时锁定到精确版本。
references[].kind"action" / "script" / "workflow" / "platform_api" / "run"必填 / 必有;依赖类型。action 为动作;platform_api 为平台 API 操作;script 为脚本;workflow 为工作流;run 为脚本中 invoke("ns/name") 调用的子运行目标(脚本或工作流,发布时解析)。
references[].namestring必填 / 必有;被依赖对象:动作为 ns/name,平台 API 为操作名,脚本与工作流为 ns/name。
references[].rangestring可选;引用时写的版本范围或标签(npm 规则);未写时为空。
references[].locked_versionstring可选;发布时锁定的精确版本;仅脚本与工作流依赖有,动作与平台 API 不锁定。
outlinenull / object[]必填 / 必有;工作流的步骤大纲(OutlineNode 数组),由解析器静态生成;脚本为 null。
outline(分支2)[].namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
outline(分支2)[].referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start;与运行时 Task.reference 一致。
outline(分支2)[].kind"run" / "call" / "wait" / "set" / "for" / "fork" / "try" / "switch" / "emit" / "raise" / "listen" / "do"必填 / 必有;工作流步骤类型。call 调用动作;run 运行子脚本或子工作流;wait 等待时长;set 设置变量;for 循环;fork 并行分支;try 带捕获的块;switch 条件分支;emit 发出事件;raise 抛出错误;listen 等待事件;do 顺序执行的步骤块。
outline(分支2)[].targetstring可选;步骤调用的目标:call 步骤为动作 ns/name,run 步骤为 ns/name@范围;其它类型没有。
outline(分支2)[].waitobject可选;等待步骤的摘要:时长(seconds 或 duration)或等待的事件类型(event)。 不接受额外字段。
outline(分支2)[].wait.untilstring可选;等待结束的绝对时刻,仅在可静态确定时给出;目前大纲不填充该字段。
outline(分支2)[].wait.secondsnumber可选;可静态换算的等待秒数;时长对象与可换算的 ISO 时长均投影到此字段。
outline(分支2)[].wait.eventstring可选;listen 步骤等待的事件类型。
outline(分支2)[].wait.durationstring可选;无法静态换算成秒的原始时长或运行时表达式;不与 seconds 强行换算。
outline(分支2)[].loopobject可选;for 步骤的循环信息 {each, in}。 不接受额外字段。
outline(分支2)[].loop.eachstring必填 / 必有;循环变量名;未指定时为 item。
outline(分支2)[].loop.instring必填 / 必有;被遍历的集合表达式原文。
outline(分支2)[].childrenobject[]可选;嵌套的子步骤(do、fork 分支、try 与 catch 内的步骤)。
outline(分支2)[].children[]object递归 JSON 值。
sdk_versionnull / string必填 / 必有;发布脚本所用的 SDK 版本;工作流为 null。
published_atstring必填 / 必有;发布时间(RFC 3339 UTC)。
published_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
published_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
published_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
deprecatednull / string必填 / 必有;弃用说明;未弃用为 null。弃用的版本仍可运行,但按范围或标签解析时优先选用未弃用的版本。
deprecated_atnull / string必填 / 必有;弃用时间(RFC 3339 UTC);未弃用为 null。
deprecated_bynull / object必填 / 必有;执行弃用的主体;未弃用为 null。
deprecated_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
deprecated_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。

实测响应

HTTP 200

{
  "id": "wfv_00mv67m6x5409408c354944fa8a960d207eb33c297",
  "kind": "workflow",
  "version": "1.0.0",
  "digest": "ea7352d51087eca0113ee82230848ce1506fd97d27aad4c7b1911e5c4ef9b5fb",
  "input_schema": {},
  "output_schema": {},
  "references": [],
  "outline": [
    {
      "name": "answer",
      "reference": "/do/0/answer",
      "kind": "set"
    }
  ],
  "sdk_version": null,
  "published_at": "2026-10-13T04:57:32.297Z",
  "published_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "deprecated": null,
  "deprecated_at": null,
  "deprecated_by": null,
  "source": "document:\n  dsl: '1.0.3'\n  namespace: docs-samples\n  name: sample-workflows-1791867412840-b05e8a\n  version: '1.0.0'\ndo:\n  - answer:\n      set:\n        answer: 42\n"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。 VERSION_NOT_FOUND:指定版本或修订不存在。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

弃用工作流版本

记录版本弃用说明;message 为空字符串时取消弃用,版本源码不变。

POST /automation/v1/workflows/{ns}/{name}/versions/{version}/deprecate

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
path: versionstring必填;规范的精确语义版本,例如 1.2.0 或 1.3.0-beta.1;不能是范围。

application/json

不接受额外字段。

字段类型说明
messagestring必填 / 必有;弃用说明;空字符串取消弃用。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
WORKFLOW_NAME创建工作流返回的 name
: "${WORKFLOW_NAME:?Set WORKFLOW_NAME}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/workflows/docs-samples/${WORKFLOW_NAME}/versions/1.0.0/deprecate" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "message": ""
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.workflows.versions.deprecate({
  "path": {
    "ns": "docs-samples",
    "name": env("WORKFLOW_NAME"),
    "version": "1.0.0"
  },
  "body": {
    "message": ""
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
idstring必填 / 必有;版本 ID,脚本前缀 scv_,工作流前缀 wfv_。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
versionstring必填 / 必有;版本号(semver,已去掉 +build 元数据)。
digeststring必填 / 必有;源码与契约的内容摘要。
sourcestring必填 / 必有;该版本的完整源码。版本列表默认不返回,需要时加 expand=source。
input_schemaobject必填 / 必有;任意 JSON 对象(键为字符串,值为任意 JSON 值)。
input_schema.*(分支5)object递归 JSON 值。
input_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
output_schemaobject必填 / 必有;脚本从返回类型推导,支持 Promise 解包、Record、交叉类型和 Date(date-time);推不出时为空 schema,并在 /validate 的 warnings 给出 warning。
output_schema.*(分支5)object递归 JSON 值。
output_schema.*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
referencesobject[]必填 / 必有;该版本依赖的动作、平台 API、脚本与工作流。脚本和工作流依赖在发布时锁定到精确版本。
references[].kind"action" / "script" / "workflow" / "platform_api" / "run"必填 / 必有;依赖类型。action 为动作;platform_api 为平台 API 操作;script 为脚本;workflow 为工作流;run 为脚本中 invoke("ns/name") 调用的子运行目标(脚本或工作流,发布时解析)。
references[].namestring必填 / 必有;被依赖对象:动作为 ns/name,平台 API 为操作名,脚本与工作流为 ns/name。
references[].rangestring可选;引用时写的版本范围或标签(npm 规则);未写时为空。
references[].locked_versionstring可选;发布时锁定的精确版本;仅脚本与工作流依赖有,动作与平台 API 不锁定。
outlinenull / object[]必填 / 必有;工作流的步骤大纲(OutlineNode 数组),由解析器静态生成;脚本为 null。
outline(分支2)[].namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
outline(分支2)[].referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start;与运行时 Task.reference 一致。
outline(分支2)[].kind"run" / "call" / "wait" / "set" / "for" / "fork" / "try" / "switch" / "emit" / "raise" / "listen" / "do"必填 / 必有;工作流步骤类型。call 调用动作;run 运行子脚本或子工作流;wait 等待时长;set 设置变量;for 循环;fork 并行分支;try 带捕获的块;switch 条件分支;emit 发出事件;raise 抛出错误;listen 等待事件;do 顺序执行的步骤块。
outline(分支2)[].targetstring可选;步骤调用的目标:call 步骤为动作 ns/name,run 步骤为 ns/name@范围;其它类型没有。
outline(分支2)[].waitobject可选;等待步骤的摘要:时长(seconds 或 duration)或等待的事件类型(event)。 不接受额外字段。
outline(分支2)[].wait.untilstring可选;等待结束的绝对时刻,仅在可静态确定时给出;目前大纲不填充该字段。
outline(分支2)[].wait.secondsnumber可选;可静态换算的等待秒数;时长对象与可换算的 ISO 时长均投影到此字段。
outline(分支2)[].wait.eventstring可选;listen 步骤等待的事件类型。
outline(分支2)[].wait.durationstring可选;无法静态换算成秒的原始时长或运行时表达式;不与 seconds 强行换算。
outline(分支2)[].loopobject可选;for 步骤的循环信息 {each, in}。 不接受额外字段。
outline(分支2)[].loop.eachstring必填 / 必有;循环变量名;未指定时为 item。
outline(分支2)[].loop.instring必填 / 必有;被遍历的集合表达式原文。
outline(分支2)[].childrenobject[]可选;嵌套的子步骤(do、fork 分支、try 与 catch 内的步骤)。
outline(分支2)[].children[]object递归 JSON 值。
sdk_versionnull / string必填 / 必有;发布脚本所用的 SDK 版本;工作流为 null。
published_atstring必填 / 必有;发布时间(RFC 3339 UTC)。
published_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
published_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
published_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
deprecatednull / string必填 / 必有;弃用说明;未弃用为 null。弃用的版本仍可运行,但按范围或标签解析时优先选用未弃用的版本。
deprecated_atnull / string必填 / 必有;弃用时间(RFC 3339 UTC);未弃用为 null。
deprecated_bynull / object必填 / 必有;执行弃用的主体;未弃用为 null。
deprecated_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
deprecated_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。

实测响应

HTTP 200

{
  "id": "wfv_00mv67m6x5409408c354944fa8a960d207eb33c297",
  "kind": "workflow",
  "version": "1.0.0",
  "digest": "ea7352d51087eca0113ee82230848ce1506fd97d27aad4c7b1911e5c4ef9b5fb",
  "input_schema": {},
  "output_schema": {},
  "references": [],
  "outline": [
    {
      "name": "answer",
      "reference": "/do/0/answer",
      "kind": "set"
    }
  ],
  "sdk_version": null,
  "published_at": "2026-10-13T04:57:32.297Z",
  "published_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "deprecated": null,
  "deprecated_at": null,
  "deprecated_by": null,
  "source": "document:\n  dsl: '1.0.3'\n  namespace: docs-samples\n  name: sample-workflows-1791867412840-b05e8a\n  version: '1.0.0'\ndo:\n  - answer:\n      set:\n        answer: 42\n"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。 VERSION_NOT_FOUND:指定版本或修订不存在。
409TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出工作流标签

读取发布标签指向的精确版本。同时返回更新时间和更新者。

GET /automation/v1/workflows/{ns}/{name}/dist-tags

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
WORKFLOW_NAME创建工作流返回的 name
: "${WORKFLOW_NAME:?Set WORKFLOW_NAME}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/workflows/docs-samples/${WORKFLOW_NAME}/dist-tags" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.workflows.distTags.list({
  "path": {
    "ns": "docs-samples",
    "name": env("WORKFLOW_NAME")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
.*.versionstring必填 / 必有;标签当前指向的精确版本号。
.*.updated_atstring必填 / 必有;标签最近一次移动的时间(RFC 3339 UTC)。
.*.updated_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
.*.updated_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
.*.updated_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。

实测响应

HTTP 200

{
  "latest": {
    "version": "1.0.0",
    "updated_at": "2026-10-13T04:57:32.297Z",
    "updated_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    }
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

设置工作流标签

将发布标签指向已有精确版本,标签不能是版本号或版本范围;移动 latest 可用于回滚,工作流会同步定时触发器。

PUT /automation/v1/workflows/{ns}/{name}/dist-tags/{tag}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
path: tagstring必填;发布标签。预发布版本(如 1.3.0-beta.1)必须带 tag 且不能是 latest;tag 只能由 URL 安全字符组成(字母、数字及 - _ . ! ~ * ' ( )),不含空格和 / ? #,首尾无空白;不能是版本号或版本范围(如 1.2.3、^1、1.x、*);beta、next、debug 等其余名称均可。违规返回 TAG_INVALID 或 TAG_REQUIRED,hint 给出完整规则。

application/json

不接受额外字段。

字段类型说明
versionstring必填 / 必有;规范的精确语义版本,例如 1.2.0 或 1.3.0-beta.1;不能是范围。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
WORKFLOW_NAME创建工作流返回的 name
: "${WORKFLOW_NAME:?Set WORKFLOW_NAME}"
curl --fail-with-body -X PUT "https://api.deepraxis.ai/automation/v1/workflows/docs-samples/${WORKFLOW_NAME}/dist-tags/sample" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "version": "1.0.0"
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.workflows.distTags.set({
  "path": {
    "ns": "docs-samples",
    "name": env("WORKFLOW_NAME"),
    "tag": "sample"
  },
  "body": {
    "version": "1.0.0"
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
.*.versionstring必填 / 必有;标签当前指向的精确版本号。
.*.updated_atstring必填 / 必有;标签最近一次移动的时间(RFC 3339 UTC)。
.*.updated_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
.*.updated_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
.*.updated_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。

实测响应

HTTP 200

{
  "latest": {
    "version": "1.0.0",
    "updated_at": "2026-10-13T04:57:32.297Z",
    "updated_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    }
  },
  "sample": {
    "version": "1.0.0",
    "updated_at": "2026-10-13T04:57:36.329Z",
    "updated_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    }
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 TAG_INVALID:标签无效:预发布版本不能打 latest;tag 只能含 URL 安全字符(不含空格和 / ? #);不能是版本号或范围;latest 不能删除。响应 hint 列出完整规则。 INPUT_INVALID:输入不满足目标契约或业务校验。 SCHEDULE_INVALID:定时规则或时间边界无效。 TIMEZONE_INVALID:时区不是有效的 IANA 时区。 INTERVAL_TOO_SHORT:定时间隔短于一分钟。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。 VERSION_NOT_FOUND:指定版本或修订不存在。
409TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
429TRIGGER_LIMIT:租户已达到 100 个启用触发器的上限。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

删除工作流标签

删除发布标签但保留版本;latest 不可删除,标签不能是版本号或范围,不存在的合法标签可重复删除。

DELETE /automation/v1/workflows/{ns}/{name}/dist-tags/{tag}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: nsstring必填;命名空间,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63};praxis 只读。
path: namestring必填;名称,存储前转为小写,格式 [a-z0-9][a-z0-9._-]{0,63}。
path: tagstring必填;发布标签。预发布版本(如 1.3.0-beta.1)必须带 tag 且不能是 latest;tag 只能由 URL 安全字符组成(字母、数字及 - _ . ! ~ * ' ( )),不含空格和 / ? #,首尾无空白;不能是版本号或版本范围(如 1.2.3、^1、1.x、*);beta、next、debug 等其余名称均可。违规返回 TAG_INVALID 或 TAG_REQUIRED,hint 给出完整规则。

示例

先设置以下环境变量,使用你自己的资源:

变量来源
WORKFLOW_NAME创建工作流返回的 name
: "${WORKFLOW_NAME:?Set WORKFLOW_NAME}"
curl --fail-with-body -X DELETE "https://api.deepraxis.ai/automation/v1/workflows/docs-samples/${WORKFLOW_NAME}/dist-tags/sample" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.workflows.distTags.delete({
  "path": {
    "ns": "docs-samples",
    "name": env("WORKFLOW_NAME"),
    "tag": "sample"
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
.*.versionstring必填 / 必有;标签当前指向的精确版本号。
.*.updated_atstring必填 / 必有;标签最近一次移动的时间(RFC 3339 UTC)。
.*.updated_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
.*.updated_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
.*.updated_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。

实测响应

HTTP 200

{
  "latest": {
    "version": "1.0.0",
    "updated_at": "2026-10-13T04:57:32.297Z",
    "updated_by": {
      "type": "api_key",
      "id": "key_3e00b8984967"
    }
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 TAG_INVALID:标签无效:预发布版本不能打 latest;tag 只能含 URL 安全字符(不含空格和 / ? #);不能是版本号或范围;latest 不能删除。响应 hint 列出完整规则。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
409TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

校验定义

校验源码并返回诊断及输入输出契约。支持动作、脚本和工作流;结果含 valid 及引用,不会保存定义,源码不合法通过 valid=false 返回。 脚本/动作输出 schema 支持返回类型推断:Promise 解包、Record、交叉类型、Date;推不出时使用空 schema 并给 warning(warnings)。源码诊断使用 /source 或 /implementation/source,line/column 从 1 起。kind=action 与创建动作使用同一套准入检查(禁止导入外部模块、平台操作必须写成 call(praxis/., 输入) 直接调用、不能调用 agent 或 automation 接口),校验通过的动作源码创建时不会再被拒绝。

POST /automation/v1/validate

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

application/json

不接受额外字段。

字段类型说明
kind"action" / "script" / "workflow"必填 / 必有;源码类型:action、script 或 workflow。
sourcestring必填 / 必有;待校验的源码;action 和 script 使用 TypeScript,workflow 使用 YAML。

示例

curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/validate" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "kind": "script",
  "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.validate.create({
  "body": {
    "kind": "script",
    "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });"
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
validboolean必填 / 必有;源码是否通过校验:true 可发布或运行,false 见 errors。
errorsobject[]必填 / 必有;校验错误列表,每项含 pointer 与中文 detail;为空数组时 valid 为 true。
errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
input_schemanull / object必填 / 必有;从源码推导出的输入 JSON Schema;无法解析源码时为 null。
input_schema(分支2).*(分支5)object递归 JSON 值。
input_schema(分支2).*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
output_schemanull / object必填 / 必有;脚本从返回类型推导,支持 Promise 解包、Record、交叉类型和 Date(date-time);推不出时为空 schema,并在 /validate 的 warnings 给出 warning。
output_schema(分支2).*(分支5)object递归 JSON 值。
output_schema(分支2).*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
referencesobject[]必填 / 必有;源码依赖的动作、平台 API、脚本与工作流。
references[].kind"action" / "script" / "workflow" / "platform_api" / "run"必填 / 必有;依赖类型。action 为动作;platform_api 为平台 API 操作;script 为脚本;workflow 为工作流;run 为脚本中 invoke("ns/name") 调用的子运行目标(脚本或工作流,发布时解析)。
references[].namestring必填 / 必有;被依赖对象:动作为 ns/name,平台 API 为操作名,脚本与工作流为 ns/name。
references[].rangestring可选;引用时写的版本范围或标签(npm 规则);未写时为空。
references[].locked_versionstring可选;发布时锁定的精确版本;仅脚本与工作流依赖有,动作与平台 API 不锁定。
outlinenull / object[]必填 / 必有;工作流步骤大纲;脚本和动作为 null。
outline(分支2)[].namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
outline(分支2)[].referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start;与运行时 Task.reference 一致。
outline(分支2)[].kind"run" / "call" / "wait" / "set" / "for" / "fork" / "try" / "switch" / "emit" / "raise" / "listen" / "do"必填 / 必有;工作流步骤类型。call 调用动作;run 运行子脚本或子工作流;wait 等待时长;set 设置变量;for 循环;fork 并行分支;try 带捕获的块;switch 条件分支;emit 发出事件;raise 抛出错误;listen 等待事件;do 顺序执行的步骤块。
outline(分支2)[].targetstring可选;步骤调用的目标:call 步骤为动作 ns/name,run 步骤为 ns/name@范围;其它类型没有。
outline(分支2)[].waitobject可选;等待步骤的摘要:时长(seconds 或 duration)或等待的事件类型(event)。 不接受额外字段。
outline(分支2)[].wait.untilstring可选;等待结束的绝对时刻,仅在可静态确定时给出;目前大纲不填充该字段。
outline(分支2)[].wait.secondsnumber可选;可静态换算的等待秒数;时长对象与可换算的 ISO 时长均投影到此字段。
outline(分支2)[].wait.eventstring可选;listen 步骤等待的事件类型。
outline(分支2)[].wait.durationstring可选;无法静态换算成秒的原始时长或运行时表达式;不与 seconds 强行换算。
outline(分支2)[].loopobject可选;for 步骤的循环信息 {each, in}。 不接受额外字段。
outline(分支2)[].loop.eachstring必填 / 必有;循环变量名;未指定时为 item。
outline(分支2)[].loop.instring必填 / 必有;被遍历的集合表达式原文。
outline(分支2)[].childrenobject[]可选;嵌套的子步骤(do、fork 分支、try 与 catch 内的步骤)。
outline(分支2)[].children[]object递归 JSON 值。
warningsobject[]可选;脚本/动作静态分析的非阻断诊断;无法推导类型时使用空 schema 并给 warning。工作流分析可省略。
warnings[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
warnings[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
warnings[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
warnings[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
warnings[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
platform_apisstring[]可选;脚本/动作引用的平台 API 集合(字符串数组);工作流分析可省略。

实测响应

HTTP 200

{
  "valid": true,
  "errors": [],
  "warnings": [],
  "input_schema": {
    "type": "object",
    "properties": {
      "n": {
        "type": "number"
      }
    },
    "required": [
      "n"
    ]
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "answer": {
        "type": "number"
      }
    },
    "required": [
      "answer"
    ]
  },
  "references": [],
  "outline": null,
  "platform_apis": []
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

解析运行目标

将 ns/name@tag、精确版本或版本范围解析为可运行的精确版本;省略 @ 时使用 latest,归档目标拒绝解析,无匹配返回 NO_MATCHING_VERSION。

GET /automation/v1/resolve

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
query: targetstring必填;ns/name@tag、ns/name@version 或 ns/name@range;省略 @ 时使用 latest。

示例

先设置以下环境变量,使用你自己的资源:

: "${TARGET:?Set TARGET}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/resolve" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  --get \
  --data-urlencode "target=${TARGET}"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.resolve.retrieve({
  "query": {
    "target": env("TARGET")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
namespacestring必填 / 必有;编排命名空间。
namestring必填 / 必有;编排名字。
versionstring必填 / 必有;target 解析到的精确版本号。
version_idstring必填 / 必有;该版本的 ID(scv_ 或 wfv_ 前缀)。
deprecatednull / string必填 / 必有;解析到的版本被弃用时的弃用说明;未弃用为 null。

实测响应

HTTP 200

{
  "kind": "script",
  "namespace": "docs-samples",
  "name": "sample-scripts-1791867412840-b05e8a",
  "version": "1.0.0",
  "version_id": "scv_00mv67lza679fc5498438040079f0c5684208c4915",
  "deprecated": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。
409TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。
422NO_MATCHING_VERSION:没有满足标签、版本或范围的已发布版本。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

搜索自动化定义

按名称搜索可见目标,按名称升序分页;默认排除归档目标,可筛选已发布的脚本和工作流。

GET /automation/v1/targets

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
query: qstring可选;不区分大小写,按 ns/name 或说明的字面子串匹配。
query: kind"action" / "script" / "workflow"[]可选;action、script 或 workflow;省略返回全部。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: limitinteger可选;每页条数,整数 1–100,默认 25。 minimum: 1;maximum: 100
query: labelsobject可选;按标签过滤,使用 labels[k]=v;同键逗号多值取任一,不同键同时满足。
query: created_at[gte]string可选;创建时间下界,包含边界;使用带时区的 ISO 8601 时间。 format: "date-time"
query: created_at[lte]string可选;创建时间上界,包含边界;使用带时区的 ISO 8601 时间。 format: "date-time"
query: cursorstring可选;上一页的 next_cursor;翻页时保留原筛选条件。
query: archivedboolean可选;默认 false,仅返回未归档目标;true 仅返回已归档目标。 default: false
query: publishedboolean可选;true 仅返回有已发布版本的编排;动作始终可用。

示例

curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/targets" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  --get \
  --data-urlencode "q=sample-" \
  --data-urlencode "limit=1"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.targets.list({
  "query": {
    "q": "sample-",
    "limit": 1
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的目标搜索结果(动作、脚本、工作流),按相关度和创建时间排列。
data[].kind"action" / "script" / "workflow"必填 / 必有;目标类型。action 为动作;script 为脚本;workflow 为工作流。
data[].namespacestring必填 / 必有;目标命名空间。
data[].namestring必填 / 必有;目标名字。
data[].descriptionstring必填 / 必有;目标的说明文字。
data[].latest_versionnull / string必填 / 必有;latest 标签指向的版本号;动作或尚未发布时为 null。
data[].archivedboolean必填 / 必有;true 表示目标已归档,不能再被运行。
next_cursorstring / null必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [
    {
      "kind": "action",
      "namespace": "docs-samples",
      "name": "sample-action-1791867412840-b05e8a",
      "description": "",
      "latest_version": null,
      "archived": false
    }
  ],
  "next_cursor": "WyJbXCJ0YXJnZXRzXCIsXCJ0bnRfM2E5NzU5ODY0Y2NiNGUwMFwiLHtcInFcIjpcInNhbXBsZS1cIn1dIiwiZG9jcy1zYW1wbGVzL3NhbXBsZS1hY3Rpb24tMTc5MTg2NzQxMjg0MC1iMDVlOGEiLCJmdW5jdGlvbjphY3RfMDBtdjY3bG96NGZlNGYyN2JkZjg5MzQ2Yzg4NWIzYTI4YjIwMzhjMDkxIl0="
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

创建运行

target 与 source 二选一;source 还须提供 language,输入与源码先校验再创建运行。wait 为 0–60 秒(默认 0),返回时已到终态为 200,否则 202;Idempotency-Key 在租户、方法、路径内保留 24 小时,请求指纹不含 wait。重放返回当前运行并带 Idempotent-Replayed: true,同键不同内容返回 422,处理中返回 409。新建非确定性运行 ID 为 run_ + 10 位 base36 毫秒时间前缀 + 64 位十六进制 DO ID,共 78 字符;旧随机 ID 为 46 字符,历史与确定性 ID 仍有效。同毫秒内不保证顺序。

POST /automation/v1/runs

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
header: Idempotency-Keystring可选;1–256 字符;租户、方法、路径内去重 24 小时,请求指纹不含 wait。

application/json

字段类型说明
(分支1).targetstring必填 / 必有;脚本或工作流引用 ns/name@tag、ns/name@version 或 ns/name@range,省略 @ 时使用 latest;与 source 互斥。
(分支1).inputnull / string / number / boolean / object / null / string / number / boolean / object / JSON[][]可选;传给运行的 JSON 输入,缺省为 {};必须符合目标输入契约,最多 1 MiB。
(分支1).input(分支5).*(分支5)object递归 JSON 值。
(分支1).input(分支5).*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支1).input(分支6)[](分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支1).input(分支6)[](分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支1).waitnumber可选;等待终态的秒数,0–60,默认 0;不计入幂等请求指纹。 minimum: 0;maximum: 60
(分支1).labelsobject可选;最多 50 个标签;键为 1–40 个字符,值最多 500 个字符。
(分支1).deadline_secondsinteger可选;正整数秒,最多 604800;脚本默认且最多 300 秒,工作流默认 86400 秒、最多 7 天。 minimum: 1
(分支2).sourcestring必填 / 必有;源码;创建临时运行时与 target 互斥,且必须同时提供 language,最多 1 MiB。
(分支2).language"ts" / "yaml"必填 / 必有;源码语言:ts 表示脚本,yaml 表示工作流。
(分支2).inputnull / string / number / boolean / object / null / string / number / boolean / object / JSON[][]可选;传给运行的 JSON 输入,缺省为 {};必须符合目标输入契约,最多 1 MiB。
(分支2).input(分支5).*(分支5)object递归 JSON 值。
(分支2).input(分支5).*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支2).input(分支6)[](分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支2).input(分支6)[](分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支2).waitnumber可选;等待终态的秒数,0–60,默认 0;不计入幂等请求指纹。 minimum: 0;maximum: 60
(分支2).labelsobject可选;最多 50 个标签;键为 1–40 个字符,值最多 500 个字符。
(分支2).deadline_secondsinteger可选;正整数秒,最多 604800;脚本默认且最多 300 秒,工作流默认 86400 秒、最多 7 天。 minimum: 1

示例

curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/runs" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });",
  "language": "ts",
  "input": {
    "n": 41
  },
  "wait": 60,
  "labels": {
    "namespace": "docs-samples",
    "name": "sample-run"
  }
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.runs.create({
  "body": {
    "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });",
    "language": "ts",
    "input": {
      "n": 41
    },
    "wait": 60,
    "labels": {
      "namespace": "docs-samples",
      "name": "sample-run"
    }
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
Idempotent-Replayedbooleantrue when returning a replayed run.

application/json

字段类型说明
idstring必填 / 必有;不透明运行 ID。新建非确定性 ID 为 run_ + 10 位 base36 毫秒时间前缀 + 64 位 hex DO ID,共 78 字符;旧随机 ID 为 46 字符,历史及确定性 ID 仍有效。同毫秒内不保证创建顺序。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
numbernull / number必填 / 必有;运行在其脚本或工作流内的递增序号;临时运行为 null。
definitionnull / object必填 / 必有;运行所属的脚本或工作流 {namespace, name};临时运行(直接传 source)为 null。
definition(分支2).namespacestring必填 / 必有;脚本或工作流的命名空间。
definition(分支2).namestring必填 / 必有;脚本或工作流的名字。
targetnull / string必填 / 必有;创建时 target 参数的原文(如 acme/report@latest);临时运行为 null。
resolved_versionnull / string必填 / 必有;target 解析到的精确版本号;临时运行为 null。
source_digestnull / string必填 / 必有;临时运行的源码摘要,可用于读取源码;由已发布定义启动的运行为 null。
language"ts" / "yaml"必填 / 必有;源码语言。ts 表示 TypeScript 脚本;yaml 表示工作流 YAML。
status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败,error 给出原因;completed 成功完成,output 为结果。后三种是终态。
progressnull / object必填 / 必有;运行报告的最新进度 {label, current, total, updated_at};未报告为 null。
progress(分支2).labelstring必填 / 必有;进度说明文字,例如当前阶段。
progress(分支2).currentnull / number必填 / 必有;已完成的数量;未报告为 null。
progress(分支2).totalnull / number必填 / 必有;总量;未知为 null。
progress(分支2).updated_atstring必填 / 必有;进度最近一次更新的时间(RFC 3339 UTC)。
current_waitnull / object必填 / 必有;运行当前未完成的等待点;不在等待为 null。
current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
countersobject必填 / 必有;运行的累计计数。 不接受额外字段。
counters.callsnumber必填 / 必有;脚本发出的调用总数。
counters.action_callsnumber必填 / 必有;其中调用动作的次数。
counters.child_runsnumber必填 / 必有;启动的子运行数。
counters.tasks_completednumber必填 / 必有;工作流已完成的步骤数。
counters.tasks_totalnull / number必填 / 必有;工作流顶层步骤总数;脚本运行为 null。
inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
errornull / object必填 / 必有;运行失败(faulted)时的错误详情;未失败为 null。
error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
error(分支2).titlestring必填 / 必有;错误的简短标题。
error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
initiatorobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
initiator.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
initiator.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
channel"run" / "console" / "api" / "internal" / "trigger"必填 / 必有;请求进入平台的渠道。console 为控制台(经 BFF);api 为公开 API 调用;internal 为平台内部服务调用;run 为由另一个运行创建的子运行;trigger 为触发器启动。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
parentnull / object必填 / 必有;派生本运行的父运行 {id, number, definition};根运行为 null。
parent(分支2).idstring必填 / 必有;父运行 ID(run_ 前缀)。
parent(分支2).numbernull / number必填 / 必有;父运行在其定义内的序号;父运行是临时运行时为 null。
parent(分支2).definitionnull / object必填 / 必有;父运行所属的脚本或工作流 {namespace, name};临时运行为 null。
parent(分支2).definition(分支2).namespacestring必填 / 必有;父运行所属定义的命名空间。
parent(分支2).definition(分支2).namestring必填 / 必有;父运行所属定义的名字。
parent_run_idstring / null必填 / 必有;派生出本运行的父运行 id;根运行为 null
root_run_idstring必填 / 必有;运行树根运行的 ID;根运行自身指向自己。
depthnumber必填 / 必有;运行树中的深度:根运行为 0,每一层子运行加 1,最大 10。
attachnull / "wait" / "detach"必填 / 必有;子运行与父运行的关系。wait 表示父运行等待子运行结束,且子运行的截止时间不晚于父运行;detach 表示父运行不等待,也不会因父运行取消而被取消;根运行为 null。
deadline_atstring必填 / 必有;运行的截止时间(RFC 3339 UTC):创建时间加 deadline_seconds(脚本默认且最多 300 秒,工作流默认 86400 秒、最多 604800 秒),等待型子运行不晚于父运行截止前 1 秒。
created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
started_atnull / string必填 / 必有;开始执行的时间(RFC 3339 UTC);仍在排队为 null。
ended_atnull / string必填 / 必有;进入终态的时间(RFC 3339 UTC);尚未结束为 null。
updated_atstring必填 / 必有;运行记录最近一次更新的时间(RFC 3339 UTC)。
heartbeat_atnull / string必填 / 必有;执行器最近一次存活信号的时间(RFC 3339 UTC);尚未开始为 null。
cancel_requested_atnull / string必填 / 必有;收到取消请求的时间(RFC 3339 UTC);未取消为 null。
cancelled_bynull / object必填 / 必有;请求取消的主体;未取消或非人为取消为 null。
cancelled_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
cancelled_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
cancel_reasonnull / "user" / "parent_cancelled" / "deadline" / "executor_lost"必填 / 必有;取消原因。user 为用户取消;parent_cancelled 为父运行被取消而级联取消;deadline 为超过截止时间;executor_lost 为执行器丢失;未取消为 null。
suspend_requested_atnull / string必填 / 必有;请求暂停工作流的时间(RFC 3339 UTC);未暂停为 null。
suspended_bynull / object必填 / 必有;请求暂停的主体;未暂停为 null。
suspended_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
suspended_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
queued_msnull / number必填 / 必有;从创建到开始执行的排队毫秒数;尚未开始为 null。
run_msnull / number必填 / 必有;实际执行毫秒数,不含等待点上的等待时间;结束后固定。
wait_msnull / number必填 / 必有;在等待点上累计等待的毫秒数;尚无等待为 null。
usageobject / null必填 / 必有;仅单个运行详情(含 expand)返回;列表为 null。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
usage(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
usage(分支1).coststring必填 / 必有;仅本运行自身的已评级实扣(不含子运行),美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
usage(分支1).pending_eventsinteger必填 / 必有;本运行自身尚未评级的用量事件数,金额稍后才计入。 minimum: 0
usage(分支1).by_serviceobject[]必填 / 必有;本运行按服务拆分的实扣,每项为 service 与 cost(6 位小数美元字符串);没有用量时为空数组。
usage(分支1).by_service[].servicestring必填 / 必有;产生用量的服务名,例如 router 或 search。
usage(分支1).by_service[].coststring必填 / 必有;该服务已评级实扣的美元十进制字符串,精确到 6 位小数。 pattern: "^[0-9]+\.[0-9]{6}$"
usage(分支1).tree_coststring / null必填 / 必有;仅根运行返回整棵运行树的已评级实扣(含自身),6 位小数美元字符串;子运行为 null。
rerun_ofnull / string必填 / 必有;重跑来源:本运行是对哪个运行(run_ ID)的重跑;否则为 null。
labelsobject必填 / 必有;用户标签与系统标签;触发器运行支持 64 个用户标签,系统标签不占用名额。
triggerobject / null必填 / 必有;启动本运行的触发器 {id, name};不是触发器启动时为 null。
trigger(分支1).idstring必填 / 必有;启动本运行的触发器 ID(trg_ 前缀)。
trigger(分支1).namestring必填 / 必有;启动本运行的触发器名称。
cancel_messagestring / null必填 / 必有;用户提供的取消备注(1–500 字符);未提供时为 null,cancel_reason 枚举不变。
input_truncatedboolean可选;列表省略外置 input 时为 true,此时 input 为 null;内联值不变,运行详情返回完整值。
output_truncatedboolean可选;列表省略外置 output 时为 true,此时 output 为 null;内联值不变,运行详情返回完整值。

HTTP 202

Run accepted; still pending or executing when wait expires.

响应头类型说明
Idempotent-Replayedbooleantrue when returning a replayed run.

application/json

字段类型说明
idstring必填 / 必有;不透明运行 ID。新建非确定性 ID 为 run_ + 10 位 base36 毫秒时间前缀 + 64 位 hex DO ID,共 78 字符;旧随机 ID 为 46 字符,历史及确定性 ID 仍有效。同毫秒内不保证创建顺序。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
numbernull / number必填 / 必有;运行在其脚本或工作流内的递增序号;临时运行为 null。
definitionnull / object必填 / 必有;运行所属的脚本或工作流 {namespace, name};临时运行(直接传 source)为 null。
definition(分支2).namespacestring必填 / 必有;脚本或工作流的命名空间。
definition(分支2).namestring必填 / 必有;脚本或工作流的名字。
targetnull / string必填 / 必有;创建时 target 参数的原文(如 acme/report@latest);临时运行为 null。
resolved_versionnull / string必填 / 必有;target 解析到的精确版本号;临时运行为 null。
source_digestnull / string必填 / 必有;临时运行的源码摘要,可用于读取源码;由已发布定义启动的运行为 null。
language"ts" / "yaml"必填 / 必有;源码语言。ts 表示 TypeScript 脚本;yaml 表示工作流 YAML。
status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败,error 给出原因;completed 成功完成,output 为结果。后三种是终态。
progressnull / object必填 / 必有;运行报告的最新进度 {label, current, total, updated_at};未报告为 null。
progress(分支2).labelstring必填 / 必有;进度说明文字,例如当前阶段。
progress(分支2).currentnull / number必填 / 必有;已完成的数量;未报告为 null。
progress(分支2).totalnull / number必填 / 必有;总量;未知为 null。
progress(分支2).updated_atstring必填 / 必有;进度最近一次更新的时间(RFC 3339 UTC)。
current_waitnull / object必填 / 必有;运行当前未完成的等待点;不在等待为 null。
current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
countersobject必填 / 必有;运行的累计计数。 不接受额外字段。
counters.callsnumber必填 / 必有;脚本发出的调用总数。
counters.action_callsnumber必填 / 必有;其中调用动作的次数。
counters.child_runsnumber必填 / 必有;启动的子运行数。
counters.tasks_completednumber必填 / 必有;工作流已完成的步骤数。
counters.tasks_totalnull / number必填 / 必有;工作流顶层步骤总数;脚本运行为 null。
inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
errornull / object必填 / 必有;运行失败(faulted)时的错误详情;未失败为 null。
error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
error(分支2).titlestring必填 / 必有;错误的简短标题。
error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
initiatorobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
initiator.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
initiator.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
channel"run" / "console" / "api" / "internal" / "trigger"必填 / 必有;请求进入平台的渠道。console 为控制台(经 BFF);api 为公开 API 调用;internal 为平台内部服务调用;run 为由另一个运行创建的子运行;trigger 为触发器启动。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
parentnull / object必填 / 必有;派生本运行的父运行 {id, number, definition};根运行为 null。
parent(分支2).idstring必填 / 必有;父运行 ID(run_ 前缀)。
parent(分支2).numbernull / number必填 / 必有;父运行在其定义内的序号;父运行是临时运行时为 null。
parent(分支2).definitionnull / object必填 / 必有;父运行所属的脚本或工作流 {namespace, name};临时运行为 null。
parent(分支2).definition(分支2).namespacestring必填 / 必有;父运行所属定义的命名空间。
parent(分支2).definition(分支2).namestring必填 / 必有;父运行所属定义的名字。
parent_run_idstring / null必填 / 必有;派生出本运行的父运行 id;根运行为 null
root_run_idstring必填 / 必有;运行树根运行的 ID;根运行自身指向自己。
depthnumber必填 / 必有;运行树中的深度:根运行为 0,每一层子运行加 1,最大 10。
attachnull / "wait" / "detach"必填 / 必有;子运行与父运行的关系。wait 表示父运行等待子运行结束,且子运行的截止时间不晚于父运行;detach 表示父运行不等待,也不会因父运行取消而被取消;根运行为 null。
deadline_atstring必填 / 必有;运行的截止时间(RFC 3339 UTC):创建时间加 deadline_seconds(脚本默认且最多 300 秒,工作流默认 86400 秒、最多 604800 秒),等待型子运行不晚于父运行截止前 1 秒。
created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
started_atnull / string必填 / 必有;开始执行的时间(RFC 3339 UTC);仍在排队为 null。
ended_atnull / string必填 / 必有;进入终态的时间(RFC 3339 UTC);尚未结束为 null。
updated_atstring必填 / 必有;运行记录最近一次更新的时间(RFC 3339 UTC)。
heartbeat_atnull / string必填 / 必有;执行器最近一次存活信号的时间(RFC 3339 UTC);尚未开始为 null。
cancel_requested_atnull / string必填 / 必有;收到取消请求的时间(RFC 3339 UTC);未取消为 null。
cancelled_bynull / object必填 / 必有;请求取消的主体;未取消或非人为取消为 null。
cancelled_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
cancelled_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
cancel_reasonnull / "user" / "parent_cancelled" / "deadline" / "executor_lost"必填 / 必有;取消原因。user 为用户取消;parent_cancelled 为父运行被取消而级联取消;deadline 为超过截止时间;executor_lost 为执行器丢失;未取消为 null。
suspend_requested_atnull / string必填 / 必有;请求暂停工作流的时间(RFC 3339 UTC);未暂停为 null。
suspended_bynull / object必填 / 必有;请求暂停的主体;未暂停为 null。
suspended_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
suspended_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
queued_msnull / number必填 / 必有;从创建到开始执行的排队毫秒数;尚未开始为 null。
run_msnull / number必填 / 必有;实际执行毫秒数,不含等待点上的等待时间;结束后固定。
wait_msnull / number必填 / 必有;在等待点上累计等待的毫秒数;尚无等待为 null。
usageobject / null必填 / 必有;仅单个运行详情(含 expand)返回;列表为 null。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
usage(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
usage(分支1).coststring必填 / 必有;仅本运行自身的已评级实扣(不含子运行),美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
usage(分支1).pending_eventsinteger必填 / 必有;本运行自身尚未评级的用量事件数,金额稍后才计入。 minimum: 0
usage(分支1).by_serviceobject[]必填 / 必有;本运行按服务拆分的实扣,每项为 service 与 cost(6 位小数美元字符串);没有用量时为空数组。
usage(分支1).by_service[].servicestring必填 / 必有;产生用量的服务名,例如 router 或 search。
usage(分支1).by_service[].coststring必填 / 必有;该服务已评级实扣的美元十进制字符串,精确到 6 位小数。 pattern: "^[0-9]+\.[0-9]{6}$"
usage(分支1).tree_coststring / null必填 / 必有;仅根运行返回整棵运行树的已评级实扣(含自身),6 位小数美元字符串;子运行为 null。
rerun_ofnull / string必填 / 必有;重跑来源:本运行是对哪个运行(run_ ID)的重跑;否则为 null。
labelsobject必填 / 必有;用户标签与系统标签;触发器运行支持 64 个用户标签,系统标签不占用名额。
triggerobject / null必填 / 必有;启动本运行的触发器 {id, name};不是触发器启动时为 null。
trigger(分支1).idstring必填 / 必有;启动本运行的触发器 ID(trg_ 前缀)。
trigger(分支1).namestring必填 / 必有;启动本运行的触发器名称。
cancel_messagestring / null必填 / 必有;用户提供的取消备注(1–500 字符);未提供时为 null,cancel_reason 枚举不变。
input_truncatedboolean可选;列表省略外置 input 时为 true,此时 input 为 null;内联值不变,运行详情返回完整值。
output_truncatedboolean可选;列表省略外置 output 时为 true,此时 output 为 null;内联值不变,运行详情返回完整值。

实测响应

HTTP 200

{
  "id": "run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1",
  "kind": "script",
  "number": null,
  "definition": null,
  "target": null,
  "resolved_version": null,
  "source_digest": "7ae6678882a4ef2ea96e401c105d5c6ef512917cd72a9235289d2a3bf1f1b49d",
  "language": "ts",
  "status": "completed",
  "progress": null,
  "current_wait": null,
  "counters": {
    "calls": 0,
    "action_calls": 0,
    "child_runs": 0,
    "tasks_completed": 0,
    "tasks_total": null
  },
  "input": {
    "n": 41
  },
  "output": {
    "answer": 42
  },
  "error": null,
  "initiator": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "channel": "api",
  "owner": "tnt_3a9759864ccb4e00",
  "trigger": null,
  "parent": null,
  "parent_run_id": null,
  "root_run_id": "run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1",
  "depth": 0,
  "attach": null,
  "deadline_at": "2026-10-13T05:02:40.954Z",
  "created_at": "2026-10-13T04:57:40.954Z",
  "started_at": "2026-10-13T04:57:42.283Z",
  "ended_at": "2026-10-13T04:57:42.367Z",
  "updated_at": "2026-10-13T04:57:42.367Z",
  "heartbeat_at": "2026-10-13T04:57:42.283Z",
  "cancel_requested_at": null,
  "cancelled_by": null,
  "cancel_reason": null,
  "cancel_message": null,
  "suspend_requested_at": null,
  "suspended_by": null,
  "queued_ms": 1329,
  "run_ms": 84,
  "wait_ms": null,
  "usage": null,
  "rerun_of": null,
  "labels": {
    "namespace": "docs-samples",
    "name": "sample-run-1791867412840-b05e8a"
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 DEFINITION_INVALID:源码未通过定义校验。 INPUT_INVALID:输入不满足目标契约或业务校验。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。 VERSION_NOT_FOUND:指定版本或修订不存在。 RUN_NOT_FOUND:运行不存在或当前租户不可见。
409TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。 IDEMPOTENCY_IN_FLIGHT:同一幂等键的请求仍在处理中。
413PAYLOAD_TOO_LARGE:请求内容超过本操作允许的大小。
422NO_MATCHING_VERSION:没有满足标签、版本或范围的已发布版本。 IDEMPOTENCY_KEY_MISMATCH:同一幂等键已用于不同请求内容。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出运行

按创建时间倒序筛选租户内运行。支持状态多选、目标、来源、labels[k] 和创建时间下界筛选。q 以 run_ 开头时精确匹配运行 ID,否则按编排名称前缀匹配。大 input/output 在列表中为 null,对应 input_truncated/output_truncated 为 true;详情返回全文。

GET /automation/v1/runs

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
query: limitinteger可选;每页条数,整数 1–100,默认 50。 minimum: 1;maximum: 100
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。
query: kind"script" / "workflow"[]可选;script 或 workflow;省略返回两者。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: definitionstring[]可选;精确编排名,格式 ns/name。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: versionstring[]可选;规范的精确语义版本,例如 1.2.0 或 1.3.0-beta.1;不能是范围。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: status"pending" / "running" / "waiting" / "suspended" / "cancelled" / "faulted" / "completed"[]可选;逗号分隔的状态,可选 pending、running、waiting、suspended、cancelled、faulted、completed;省略不过滤。 多个值以逗号分隔,匹配任一值。
query: channel"console" / "api" / "internal" / "run" / "trigger"[]可选;来源渠道:run 仅子运行;console、api、internal、trigger 为根运行。多个值以逗号分隔,匹配任一值。 minItems: 1
query: initiator_type"user" / "api_key" / "agent" / "trigger"[]可选;根发起方类型:user、api_key、agent 或 trigger,子运行继承根发起方。run 返回 INPUT_INVALID;按来源筛选用 channel=run 或 parent_run_id。多个值以逗号分隔,匹配任一值。 minItems: 1
query: initiator"me"可选;仅支持 me,匹配当前凭证的主体类型和 ID,包含由我的运行派生出的子运行;省略不限制。
query: adhocboolean可选;true 仅临时运行,false 仅已发布定义的运行;省略返回两者。
query: language"ts" / "yaml"[]可选;源码语言:ts 或 yaml。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: parent_run_idstring[]可选;按直接父运行 ID 精确匹配;用它列出某个运行的子运行(由工作流 run 步骤或脚本 invoke() 启动),每项含 ID、目标、状态与耗时。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: root_run_idstring[]可选;按根运行 ID 精确匹配,读取同一运行树。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: qstring可选;run_ 开头时精确匹配运行 ID,否则按编排名称前缀匹配;% 与 _ 作为普通字符。
query: labelsobject可选;按标签过滤,使用 labels[k]=v;同键逗号多值取任一,不同键同时满足。
query: created_at[gte]string可选;创建时间下界,包含边界;使用带时区的 ISO 8601 时间。 format: "date-time"
query: created_at[lte]string可选;创建时间上界,包含边界;使用带时区的 ISO 8601 时间。 format: "date-time"

示例

curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/runs" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  --get \
  --data-urlencode "labels[name]=sample-run-1791867412840-b05e8a" \
  --data-urlencode "limit=1"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.runs.list({
  "query": {
    "labels": {
      "name": "sample-run-1791867412840-b05e8a"
    },
    "limit": 1
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的运行摘要,按 created_at 倒序、id 倒序排列。
data[].idstring必填 / 必有;不透明运行 ID。新建非确定性 ID 为 run_ + 10 位 base36 毫秒时间前缀 + 64 位 hex DO ID,共 78 字符;旧随机 ID 为 46 字符,历史及确定性 ID 仍有效。同毫秒内不保证创建顺序。
data[].kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
data[].numbernull / number必填 / 必有;运行在其脚本或工作流内的递增序号;临时运行为 null。
data[].definitionnull / object必填 / 必有;运行所属的脚本或工作流 {namespace, name};临时运行(直接传 source)为 null。
data[].definition(分支2).namespacestring必填 / 必有;脚本或工作流的命名空间。
data[].definition(分支2).namestring必填 / 必有;脚本或工作流的名字。
data[].targetnull / string必填 / 必有;创建时 target 参数的原文(如 acme/report@latest);临时运行为 null。
data[].resolved_versionnull / string必填 / 必有;target 解析到的精确版本号;临时运行为 null。
data[].source_digestnull / string必填 / 必有;临时运行的源码摘要,可用于读取源码;由已发布定义启动的运行为 null。
data[].language"ts" / "yaml"必填 / 必有;源码语言。ts 表示 TypeScript 脚本;yaml 表示工作流 YAML。
data[].status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败,error 给出原因;completed 成功完成,output 为结果。后三种是终态。
data[].progressnull / object必填 / 必有;运行报告的最新进度 {label, current, total, updated_at};未报告为 null。
data[].progress(分支2).labelstring必填 / 必有;进度说明文字,例如当前阶段。
data[].progress(分支2).currentnull / number必填 / 必有;已完成的数量;未报告为 null。
data[].progress(分支2).totalnull / number必填 / 必有;总量;未知为 null。
data[].progress(分支2).updated_atstring必填 / 必有;进度最近一次更新的时间(RFC 3339 UTC)。
data[].current_waitnull / object必填 / 必有;运行当前未完成的等待点;不在等待为 null。
data[].current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
data[].current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
data[].current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
data[].current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
data[].current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
data[].current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
data[].current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
data[].current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
data[].current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
data[].current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
data[].current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
data[].current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
data[].current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
data[].countersobject必填 / 必有;运行的累计计数。 不接受额外字段。
data[].counters.callsnumber必填 / 必有;脚本发出的调用总数。
data[].counters.action_callsnumber必填 / 必有;其中调用动作的次数。
data[].counters.child_runsnumber必填 / 必有;启动的子运行数。
data[].counters.tasks_completednumber必填 / 必有;工作流已完成的步骤数。
data[].counters.tasks_totalnull / number必填 / 必有;工作流顶层步骤总数;脚本运行为 null。
data[].inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
data[].input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
data[].input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[].outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
data[].output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
data[].output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[].errornull / object必填 / 必有;运行失败(faulted)时的错误详情;未失败为 null。
data[].error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
data[].error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
data[].error(分支2).titlestring必填 / 必有;错误的简短标题。
data[].error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
data[].error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
data[].error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
data[].error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
data[].error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
data[].error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
data[].error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
data[].error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
data[].error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
data[].error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
data[].error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
data[].error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
data[].error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
data[].error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
data[].error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
data[].error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
data[].initiatorobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
data[].initiator.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data[].initiator.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
data[].channel"run" / "console" / "api" / "internal" / "trigger"必填 / 必有;请求进入平台的渠道。console 为控制台(经 BFF);api 为公开 API 调用;internal 为平台内部服务调用;run 为由另一个运行创建的子运行;trigger 为触发器启动。
data[].ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
data[].parentnull / object必填 / 必有;派生本运行的父运行 {id, number, definition};根运行为 null。
data[].parent(分支2).idstring必填 / 必有;父运行 ID(run_ 前缀)。
data[].parent(分支2).numbernull / number必填 / 必有;父运行在其定义内的序号;父运行是临时运行时为 null。
data[].parent(分支2).definitionnull / object必填 / 必有;父运行所属的脚本或工作流 {namespace, name};临时运行为 null。
data[].parent(分支2).definition(分支2).namespacestring必填 / 必有;父运行所属定义的命名空间。
data[].parent(分支2).definition(分支2).namestring必填 / 必有;父运行所属定义的名字。
data[].parent_run_idstring / null必填 / 必有;派生出本运行的父运行 id;根运行为 null
data[].root_run_idstring必填 / 必有;运行树根运行的 ID;根运行自身指向自己。
data[].depthnumber必填 / 必有;运行树中的深度:根运行为 0,每一层子运行加 1,最大 10。
data[].attachnull / "wait" / "detach"必填 / 必有;子运行与父运行的关系。wait 表示父运行等待子运行结束,且子运行的截止时间不晚于父运行;detach 表示父运行不等待,也不会因父运行取消而被取消;根运行为 null。
data[].deadline_atstring必填 / 必有;运行的截止时间(RFC 3339 UTC):创建时间加 deadline_seconds(脚本默认且最多 300 秒,工作流默认 86400 秒、最多 604800 秒),等待型子运行不晚于父运行截止前 1 秒。
data[].created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
data[].started_atnull / string必填 / 必有;开始执行的时间(RFC 3339 UTC);仍在排队为 null。
data[].ended_atnull / string必填 / 必有;进入终态的时间(RFC 3339 UTC);尚未结束为 null。
data[].updated_atstring必填 / 必有;运行记录最近一次更新的时间(RFC 3339 UTC)。
data[].heartbeat_atnull / string必填 / 必有;执行器最近一次存活信号的时间(RFC 3339 UTC);尚未开始为 null。
data[].cancel_requested_atnull / string必填 / 必有;收到取消请求的时间(RFC 3339 UTC);未取消为 null。
data[].cancelled_bynull / object必填 / 必有;请求取消的主体;未取消或非人为取消为 null。
data[].cancelled_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data[].cancelled_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
data[].cancel_reasonnull / "user" / "parent_cancelled" / "deadline" / "executor_lost"必填 / 必有;取消原因。user 为用户取消;parent_cancelled 为父运行被取消而级联取消;deadline 为超过截止时间;executor_lost 为执行器丢失;未取消为 null。
data[].suspend_requested_atnull / string必填 / 必有;请求暂停工作流的时间(RFC 3339 UTC);未暂停为 null。
data[].suspended_bynull / object必填 / 必有;请求暂停的主体;未暂停为 null。
data[].suspended_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data[].suspended_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
data[].queued_msnull / number必填 / 必有;从创建到开始执行的排队毫秒数;尚未开始为 null。
data[].run_msnull / number必填 / 必有;实际执行毫秒数,不含等待点上的等待时间;结束后固定。
data[].wait_msnull / number必填 / 必有;在等待点上累计等待的毫秒数;尚无等待为 null。
data[].usageobject / null必填 / 必有;仅单个运行详情(含 expand)返回;列表为 null。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
data[].usage(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
data[].usage(分支1).coststring必填 / 必有;仅本运行自身的已评级实扣(不含子运行),美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
data[].usage(分支1).pending_eventsinteger必填 / 必有;本运行自身尚未评级的用量事件数,金额稍后才计入。 minimum: 0
data[].usage(分支1).by_serviceobject[]必填 / 必有;本运行按服务拆分的实扣,每项为 service 与 cost(6 位小数美元字符串);没有用量时为空数组。
data[].usage(分支1).by_service[].servicestring必填 / 必有;产生用量的服务名,例如 router 或 search。
data[].usage(分支1).by_service[].coststring必填 / 必有;该服务已评级实扣的美元十进制字符串,精确到 6 位小数。 pattern: "^[0-9]+\.[0-9]{6}$"
data[].usage(分支1).tree_coststring / null必填 / 必有;仅根运行返回整棵运行树的已评级实扣(含自身),6 位小数美元字符串;子运行为 null。
data[].rerun_ofnull / string必填 / 必有;重跑来源:本运行是对哪个运行(run_ ID)的重跑;否则为 null。
data[].labelsobject必填 / 必有;用户标签与系统标签;触发器运行支持 64 个用户标签,系统标签不占用名额。
data[].triggerobject / null必填 / 必有;启动本运行的触发器 {id, name};不是触发器启动时为 null。
data[].trigger(分支1).idstring必填 / 必有;启动本运行的触发器 ID(trg_ 前缀)。
data[].trigger(分支1).namestring必填 / 必有;启动本运行的触发器名称。
data[].cancel_messagestring / null必填 / 必有;用户提供的取消备注(1–500 字符);未提供时为 null,cancel_reason 枚举不变。
data[].input_truncatedboolean可选;列表省略外置 input 时为 true,此时 input 为 null;内联值不变,运行详情返回完整值。
data[].output_truncatedboolean可选;列表省略外置 output 时为 true,此时 output 为 null;内联值不变,运行详情返回完整值。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [
    {
      "id": "run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1",
      "kind": "script",
      "number": null,
      "definition": null,
      "target": null,
      "resolved_version": null,
      "source_digest": "7ae6678882a4ef2ea96e401c105d5c6ef512917cd72a9235289d2a3bf1f1b49d",
      "language": "ts",
      "status": "completed",
      "progress": null,
      "current_wait": null,
      "counters": {
        "calls": 0,
        "action_calls": 0,
        "child_runs": 0,
        "tasks_completed": 0,
        "tasks_total": null
      },
      "input": {
        "n": 41
      },
      "output": {
        "answer": 42
      },
      "error": null,
      "initiator": {
        "type": "api_key",
        "id": "key_3e00b8984967"
      },
      "channel": "api",
      "owner": "tnt_3a9759864ccb4e00",
      "trigger": null,
      "parent": null,
      "parent_run_id": null,
      "root_run_id": "run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1",
      "depth": 0,
      "attach": null,
      "deadline_at": "2026-10-13T05:02:40.954Z",
      "created_at": "2026-10-13T04:57:40.954Z",
      "started_at": "2026-10-13T04:57:42.283Z",
      "ended_at": "2026-10-13T04:57:42.367Z",
      "updated_at": "2026-10-13T04:57:42.367Z",
      "heartbeat_at": "2026-10-13T04:57:42.283Z",
      "cancel_requested_at": null,
      "cancelled_by": null,
      "cancel_reason": null,
      "cancel_message": null,
      "suspend_requested_at": null,
      "suspended_by": null,
      "queued_ms": 1329,
      "run_ms": 84,
      "wait_ms": null,
      "usage": null,
      "rerun_of": null,
      "labels": {
        "namespace": "docs-samples",
        "name": "sample-run-1791867412840-b05e8a"
      }
    }
  ],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 INPUT_INVALID:输入不满足目标契约或业务校验。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

读取运行

读取运行详情,可用 expand 一次带回调用、步骤、步骤聚合、日志或源码;传 wait(秒,0–60)可挂起请求直到运行到达终态或超时,不必轮询;展开页最多 200 条,后续通过各账本端点的游标读取。 工作流 raise 错误保留完整 type URI、status、title、detail;只有平台内部异常归为 runtime。

GET /automation/v1/runs/{id}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;运行 ID(run_)。
query: expand"calls" / "tasks" / "task_groups" / "logs" / "source"[]可选;逗号分隔且不能重复:calls、tasks、task_groups、logs、source,这是全部合法取值(output 不是展开项,运行输出在 output 字段里);省略不展开,展开页最多 200 条。无效取值返回 INVALID_PARAMS 并列出合法取值。 minItems: 1
query: waitinteger可选;等待运行到达终态的秒数,0–60 的整数,默认 0(立即返回)。超时后运行仍未结束则返回当前运行(状态码仍为 200),请检查 status;超过 60 或不是整数返回 INVALID_PARAMS。含义与 runs.create 的 wait 相同。 minimum: 0;maximum: 60

示例

先设置以下环境变量,使用你自己的资源:

: "${RUN_ID:?Set RUN_ID}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.runs.retrieve({
  "path": {
    "id": env("RUN_ID")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
idstring必填 / 必有;不透明运行 ID。新建非确定性 ID 为 run_ + 10 位 base36 毫秒时间前缀 + 64 位 hex DO ID,共 78 字符;旧随机 ID 为 46 字符,历史及确定性 ID 仍有效。同毫秒内不保证创建顺序。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
numbernull / number必填 / 必有;运行在其脚本或工作流内的递增序号;临时运行为 null。
definitionnull / object必填 / 必有;运行所属的脚本或工作流 {namespace, name};临时运行(直接传 source)为 null。
definition(分支2).namespacestring必填 / 必有;脚本或工作流的命名空间。
definition(分支2).namestring必填 / 必有;脚本或工作流的名字。
targetnull / string必填 / 必有;创建时 target 参数的原文(如 acme/report@latest);临时运行为 null。
resolved_versionnull / string必填 / 必有;target 解析到的精确版本号;临时运行为 null。
source_digestnull / string必填 / 必有;临时运行的源码摘要,可用于读取源码;由已发布定义启动的运行为 null。
language"ts" / "yaml"必填 / 必有;源码语言。ts 表示 TypeScript 脚本;yaml 表示工作流 YAML。
status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败,error 给出原因;completed 成功完成,output 为结果。后三种是终态。
progressnull / object必填 / 必有;运行报告的最新进度 {label, current, total, updated_at};未报告为 null。
progress(分支2).labelstring必填 / 必有;进度说明文字,例如当前阶段。
progress(分支2).currentnull / number必填 / 必有;已完成的数量;未报告为 null。
progress(分支2).totalnull / number必填 / 必有;总量;未知为 null。
progress(分支2).updated_atstring必填 / 必有;进度最近一次更新的时间(RFC 3339 UTC)。
current_waitnull / object必填 / 必有;运行当前未完成的等待点;不在等待为 null。
current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
countersobject必填 / 必有;运行的累计计数。 不接受额外字段。
counters.callsnumber必填 / 必有;脚本发出的调用总数。
counters.action_callsnumber必填 / 必有;其中调用动作的次数。
counters.child_runsnumber必填 / 必有;启动的子运行数。
counters.tasks_completednumber必填 / 必有;工作流已完成的步骤数。
counters.tasks_totalnull / number必填 / 必有;工作流顶层步骤总数;脚本运行为 null。
inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
errornull / object必填 / 必有;运行失败(faulted)时的错误详情;未失败为 null。
error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
error(分支2).titlestring必填 / 必有;错误的简短标题。
error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
initiatorobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
initiator.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
initiator.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
channel"run" / "console" / "api" / "internal" / "trigger"必填 / 必有;请求进入平台的渠道。console 为控制台(经 BFF);api 为公开 API 调用;internal 为平台内部服务调用;run 为由另一个运行创建的子运行;trigger 为触发器启动。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
parentnull / object必填 / 必有;派生本运行的父运行 {id, number, definition};根运行为 null。
parent(分支2).idstring必填 / 必有;父运行 ID(run_ 前缀)。
parent(分支2).numbernull / number必填 / 必有;父运行在其定义内的序号;父运行是临时运行时为 null。
parent(分支2).definitionnull / object必填 / 必有;父运行所属的脚本或工作流 {namespace, name};临时运行为 null。
parent(分支2).definition(分支2).namespacestring必填 / 必有;父运行所属定义的命名空间。
parent(分支2).definition(分支2).namestring必填 / 必有;父运行所属定义的名字。
parent_run_idstring / null必填 / 必有;派生出本运行的父运行 id;根运行为 null
root_run_idstring必填 / 必有;运行树根运行的 ID;根运行自身指向自己。
depthnumber必填 / 必有;运行树中的深度:根运行为 0,每一层子运行加 1,最大 10。
attachnull / "wait" / "detach"必填 / 必有;子运行与父运行的关系。wait 表示父运行等待子运行结束,且子运行的截止时间不晚于父运行;detach 表示父运行不等待,也不会因父运行取消而被取消;根运行为 null。
deadline_atstring必填 / 必有;运行的截止时间(RFC 3339 UTC):创建时间加 deadline_seconds(脚本默认且最多 300 秒,工作流默认 86400 秒、最多 604800 秒),等待型子运行不晚于父运行截止前 1 秒。
created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
started_atnull / string必填 / 必有;开始执行的时间(RFC 3339 UTC);仍在排队为 null。
ended_atnull / string必填 / 必有;进入终态的时间(RFC 3339 UTC);尚未结束为 null。
updated_atstring必填 / 必有;运行记录最近一次更新的时间(RFC 3339 UTC)。
heartbeat_atnull / string必填 / 必有;执行器最近一次存活信号的时间(RFC 3339 UTC);尚未开始为 null。
cancel_requested_atnull / string必填 / 必有;收到取消请求的时间(RFC 3339 UTC);未取消为 null。
cancelled_bynull / object必填 / 必有;请求取消的主体;未取消或非人为取消为 null。
cancelled_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
cancelled_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
cancel_reasonnull / "user" / "parent_cancelled" / "deadline" / "executor_lost"必填 / 必有;取消原因。user 为用户取消;parent_cancelled 为父运行被取消而级联取消;deadline 为超过截止时间;executor_lost 为执行器丢失;未取消为 null。
suspend_requested_atnull / string必填 / 必有;请求暂停工作流的时间(RFC 3339 UTC);未暂停为 null。
suspended_bynull / object必填 / 必有;请求暂停的主体;未暂停为 null。
suspended_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
suspended_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
queued_msnull / number必填 / 必有;从创建到开始执行的排队毫秒数;尚未开始为 null。
run_msnull / number必填 / 必有;实际执行毫秒数,不含等待点上的等待时间;结束后固定。
wait_msnull / number必填 / 必有;在等待点上累计等待的毫秒数;尚无等待为 null。
usageobject / null必填 / 必有;仅单个运行详情(含 expand)返回;列表为 null。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
usage(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
usage(分支1).coststring必填 / 必有;仅本运行自身的已评级实扣(不含子运行),美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
usage(分支1).pending_eventsinteger必填 / 必有;本运行自身尚未评级的用量事件数,金额稍后才计入。 minimum: 0
usage(分支1).by_serviceobject[]必填 / 必有;本运行按服务拆分的实扣,每项为 service 与 cost(6 位小数美元字符串);没有用量时为空数组。
usage(分支1).by_service[].servicestring必填 / 必有;产生用量的服务名,例如 router 或 search。
usage(分支1).by_service[].coststring必填 / 必有;该服务已评级实扣的美元十进制字符串,精确到 6 位小数。 pattern: "^[0-9]+\.[0-9]{6}$"
usage(分支1).tree_coststring / null必填 / 必有;仅根运行返回整棵运行树的已评级实扣(含自身),6 位小数美元字符串;子运行为 null。
rerun_ofnull / string必填 / 必有;重跑来源:本运行是对哪个运行(run_ ID)的重跑;否则为 null。
labelsobject必填 / 必有;用户标签与系统标签;触发器运行支持 64 个用户标签,系统标签不占用名额。
triggerobject / null必填 / 必有;启动本运行的触发器 {id, name};不是触发器启动时为 null。
trigger(分支1).idstring必填 / 必有;启动本运行的触发器 ID(trg_ 前缀)。
trigger(分支1).namestring必填 / 必有;启动本运行的触发器名称。
callsobject可选;expand=calls 时返回的调用记录分页:{data, next_cursor}。 不接受额外字段。
calls.dataobject[]必填 / 必有;本页的调用记录(Call)。 maxItems: 200
calls.data[].idstring必填 / 必有;调用 ID,前缀 call_。
calls.data[].run_idstring必填 / 必有;发出该调用的脚本运行 ID(run_ 前缀)。
calls.data[].seqnumber必填 / 必有;调用在该运行中的序号,随调用顺序递增;与 run_id 一起定位这次调用。
calls.data[].targetobject必填 / 必有;被调用的目标 {kind, name, revision?, version?}。 不接受额外字段。
calls.data[].target.kind"action" / "script" / "workflow" / "platform_api"必填 / 必有;目标类型。action 为动作;platform_api 为平台 API 操作;script 为脚本;workflow 为工作流。
calls.data[].target.namestring必填 / 必有;目标名称:动作为 ns/name,平台 API 为操作名,脚本与工作流为 ns/name。
calls.data[].target.revisionstring可选;实际执行的动作修订 ID(actr_ 前缀);仅动作调用有。
calls.data[].target.versionstring可选;实际运行的精确版本号;仅脚本与工作流调用有。
calls.data[].args_previewstring必填 / 必有;调用参数的单行预览,由服务端截断;超过 32 KB 的原文存放在对象存储而不内联。
calls.data[].result_previewnull / string必填 / 必有;返回值的单行预览,由服务端截断;调用结束前为 null。
calls.data[].status"running" / "completed" / "faulted" / "cancelled"必填 / 必有;调用状态。running 执行中;completed 已正常返回;faulted 失败,error 给出原因;cancelled 因运行被取消而中止。
calls.data[].started_atstring必填 / 必有;调用开始的时间(RFC 3339 UTC)。
calls.data[].ended_atnull / string必填 / 必有;调用结束的时间(RFC 3339 UTC);仍在执行为 null。
calls.data[].duration_msnull / number必填 / 必有;从开始到结束的毫秒数;未结束为 null。
calls.data[].errornull / object必填 / 必有;调用失败时的错误详情;成功或仍在执行为 null。
calls.data[].error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
calls.data[].error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
calls.data[].error(分支2).titlestring必填 / 必有;错误的简短标题。
calls.data[].error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
calls.data[].error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
calls.data[].error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
calls.data[].error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
calls.data[].error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
calls.data[].error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
calls.data[].error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
calls.data[].error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
calls.data[].error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
calls.data[].error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
calls.data[].error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
calls.data[].error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
calls.data[].error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
calls.data[].error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
calls.data[].error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
calls.data[].error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
calls.data[].child_run_idnull / string必填 / 必有;目标是脚本或工作流时,由本次调用启动的子运行 ID;动作与平台 API 调用为 null。
calls.data[].invocation_keystring必填 / 必有;标识这一次逻辑调用的键,随调用发往下游,使至少一次语义下的重试可被去重。
calls.data[].request_idstring / null必填 / 必有;下游响应的 X-Request-Id;尚未收到响应或响应未提供该头时为 null。
calls.next_cursornull / string必填 / 必有;下一页游标;没有更多为 null。
tasksobject可选;expand=tasks 时返回的工作流步骤分页:{data, next_cursor}。 不接受额外字段。
tasks.dataobject[]必填 / 必有;本页的步骤(Task)。 maxItems: 200
tasks.data[].idstring必填 / 必有;步骤执行记录的标识,按不透明字符串处理。
tasks.data[].run_idstring必填 / 必有;所属运行 ID。
tasks.data[].referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start。
tasks.data[].namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
tasks.data[].kind"run" / "call" / "wait" / "set" / "for" / "fork" / "try" / "switch" / "emit" / "raise" / "listen" / "do"必填 / 必有;工作流步骤类型。call 调用动作;run 运行子脚本或子工作流;wait 等待时长;set 设置变量;for 循环;fork 并行分支;try 带捕获的块;switch 条件分支;emit 发出事件;raise 抛出错误;listen 等待事件;do 顺序执行的步骤块。
tasks.data[].iterationnumber[]必填 / 必有;外层 for 循环的当前迭代下标,由外到内;不在循环中为空数组。
tasks.data[].attemptnumber必填 / 必有;第几次尝试;步骤因重试而重新执行时递增。
tasks.data[].status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;步骤状态,取值与运行状态相同。pending 尚未开始;running 执行中;waiting 在等待事件、定时器或子运行;suspended 因运行被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
tasks.data[].skippedboolean必填 / 必有;true 表示该步骤被跳过而没有实际执行。
tasks.data[].started_atnull / string必填 / 必有;步骤开始的时间(RFC 3339 UTC);未开始为 null。
tasks.data[].ended_atnull / string必填 / 必有;步骤结束的时间(RFC 3339 UTC);未结束为 null。
tasks.data[].duration_msnull / number必填 / 必有;执行耗时毫秒数;未结束为 null。
tasks.data[].inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
tasks.data[].input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
tasks.data[].input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
tasks.data[].input_truncatedboolean必填 / 必有;true 表示 input 超过 32 KB 已被截断。
tasks.data[].outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
tasks.data[].output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
tasks.data[].output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
tasks.data[].output_truncatedboolean必填 / 必有;输出超过内联限制而被省略时为 true。
tasks.data[].errornull / object必填 / 必有;步骤失败时的错误详情;未失败为 null。
tasks.data[].error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
tasks.data[].error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
tasks.data[].error(分支2).titlestring必填 / 必有;错误的简短标题。
tasks.data[].error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
tasks.data[].error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
tasks.data[].error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
tasks.data[].error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
tasks.data[].error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
tasks.data[].error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
tasks.data[].error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
tasks.data[].error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
tasks.data[].error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
tasks.data[].error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
tasks.data[].error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
tasks.data[].error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
tasks.data[].error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
tasks.data[].error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
tasks.data[].error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
tasks.data[].error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
tasks.data[].actionnull / object必填 / 必有;call 步骤执行的动作 {name, revision};其它步骤为 null。
tasks.data[].action(分支2).namestring必填 / 必有;动作全名 ns/name。
tasks.data[].action(分支2).revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
tasks.data[].child_runnull / object必填 / 必有;run 步骤启动的子运行摘要 {id, number, status, resolved_version};其它步骤为 null。
tasks.data[].child_run(分支2).idstring必填 / 必有;子运行 ID(run_ 前缀),创建后即可读取。
tasks.data[].child_run(分支2).numbernull / number必填 / 必有;子运行在其定义内的序号;临时运行为 null。
tasks.data[].child_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;子运行的状态。pending 尚未开始;running 执行中;waiting 在等待;suspended 已暂停;cancelled 已取消;faulted 失败;completed 成功完成。等待型子运行在结束时补全终态,detach 的子运行只记录启动时的状态。
tasks.data[].child_run(分支2).resolved_versionnull / string必填 / 必有;子运行解析到的精确版本号;临时运行为 null。
tasks.next_cursornull / string必填 / 必有;下一页游标;没有更多为 null。
task_groupsobject可选;expand=task_groups 时返回、按 reference 聚合的步骤分页 {data, next_cursor}(循环的多次迭代合并为一行);脚本运行为空页。 不接受额外字段。
task_groups.dataobject[]必填 / 必有;本页的聚合行(TaskGroup)。 maxItems: 200
task_groups.data[].referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start。
task_groups.data[].namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
task_groups.data[].countnumber必填 / 必有;该 reference 下合并的执行记录条数(循环的迭代数)。
task_groups.data[].status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;步骤状态,取值与运行状态相同。pending 尚未开始;running 执行中;waiting 在等待事件、定时器或子运行;suspended 因运行被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
task_groups.data[].duration_msnull / number必填 / 必有;执行耗时毫秒数;未结束为 null。
task_groups.next_cursornull / string必填 / 必有;下一页游标;没有更多为 null。
logsobject可选;expand=logs 时返回的日志分页:{data, next_cursor}。 不接受额外字段。
logs.dataobject[]必填 / 必有;本页的日志行(LogLine)。 maxItems: 200
logs.data[].cursorstring必填 / 必有;该行的游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
logs.data[].tsstring必填 / 必有;日志产生的时间(RFC 3339 UTC)。
logs.data[].level"debug" / "info" / "warn" / "error"必填 / 必有;日志级别。debug 调试信息;info 一般信息;warn 警告;error 错误。
logs.data[].messagestring必填 / 必有;日志文本。
logs.next_cursornull / string必填 / 必有;下一页游标;没有更多为 null。
sourceobject可选;临时运行的源码快照 {language, source, sha256}。 不接受额外字段。
source.language"ts" / "yaml"必填 / 必有;源码语言。ts 表示 TypeScript 脚本;yaml 表示工作流 YAML。
source.sourcestring必填 / 必有;运行时使用的完整源码(ts 或 yaml)。
source.sha256string必填 / 必有;源码的 SHA-256 摘要,可作为发布时的 expected_source_sha256。
cancel_messagestring / null必填 / 必有;用户提供的取消备注(1–500 字符);未提供时为 null,cancel_reason 枚举不变。
input_truncatedboolean可选;列表省略外置 input 时为 true,此时 input 为 null;内联值不变,运行详情返回完整值。
output_truncatedboolean可选;列表省略外置 output 时为 true,此时 output 为 null;内联值不变,运行详情返回完整值。

实测响应

HTTP 200

{
  "id": "run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1",
  "kind": "script",
  "number": null,
  "definition": null,
  "target": null,
  "resolved_version": null,
  "source_digest": "7ae6678882a4ef2ea96e401c105d5c6ef512917cd72a9235289d2a3bf1f1b49d",
  "language": "ts",
  "status": "completed",
  "progress": null,
  "current_wait": null,
  "counters": {
    "calls": 0,
    "action_calls": 0,
    "child_runs": 0,
    "tasks_completed": 0,
    "tasks_total": null
  },
  "input": {
    "n": 41
  },
  "output": {
    "answer": 42
  },
  "error": null,
  "initiator": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "channel": "api",
  "owner": "tnt_3a9759864ccb4e00",
  "trigger": null,
  "parent": null,
  "parent_run_id": null,
  "root_run_id": "run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1",
  "depth": 0,
  "attach": null,
  "deadline_at": "2026-10-13T05:02:40.954Z",
  "created_at": "2026-10-13T04:57:40.954Z",
  "started_at": "2026-10-13T04:57:42.283Z",
  "ended_at": "2026-10-13T04:57:42.367Z",
  "updated_at": "2026-10-13T04:57:42.367Z",
  "heartbeat_at": "2026-10-13T04:57:42.283Z",
  "cancel_requested_at": null,
  "cancelled_by": null,
  "cancel_reason": null,
  "cancel_message": null,
  "suspend_requested_at": null,
  "suspended_by": null,
  "queued_ms": 1329,
  "run_ms": 84,
  "wait_ms": null,
  "usage": {
    "currency": "USD",
    "cost": "0.000000",
    "pending_events": 0,
    "by_service": [],
    "tree_cost": "0.000000"
  },
  "rerun_of": null,
  "labels": {
    "namespace": "docs-samples",
    "name": "sample-run-1791867412840-b05e8a"
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404RUN_NOT_FOUND:运行不存在或当前租户不可见。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

取消运行

请求取消运行。返回 202:工作流直接终止,脚本先请求中止并在宽限期后强制结束;已终态运行返回 409 RUN_INVALID_STATE。取消传播到附着子运行,不影响 detach 子运行;可选 reason 为 1–500 字符,保存为 Run.cancel_message;用户取消的 cancel_reason 仍为 user。

POST /automation/v1/runs/{id}/cancel

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;运行 ID(run_)。

application/json

不接受额外字段。

字段类型说明
reasonstring可选;可选取消备注,1–500 字符;保存为 Run.cancel_message,cancel_reason 仍为 user。 minLength: 1;maxLength: 500

示例

先设置以下环境变量,使用你自己的资源:

: "${RUN_ID:?Set RUN_ID}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}/cancel" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "reason": "Sample completed"
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.runs.cancel({
  "path": {
    "id": env("RUN_ID")
  },
  "body": {
    "reason": "Sample completed"
  }
});
console.log(result);

响应

HTTP 202

Cancellation accepted; updated Run.

application/json

字段类型说明
idstring必填 / 必有;不透明运行 ID。新建非确定性 ID 为 run_ + 10 位 base36 毫秒时间前缀 + 64 位 hex DO ID,共 78 字符;旧随机 ID 为 46 字符,历史及确定性 ID 仍有效。同毫秒内不保证创建顺序。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
numbernull / number必填 / 必有;运行在其脚本或工作流内的递增序号;临时运行为 null。
definitionnull / object必填 / 必有;运行所属的脚本或工作流 {namespace, name};临时运行(直接传 source)为 null。
definition(分支2).namespacestring必填 / 必有;脚本或工作流的命名空间。
definition(分支2).namestring必填 / 必有;脚本或工作流的名字。
targetnull / string必填 / 必有;创建时 target 参数的原文(如 acme/report@latest);临时运行为 null。
resolved_versionnull / string必填 / 必有;target 解析到的精确版本号;临时运行为 null。
source_digestnull / string必填 / 必有;临时运行的源码摘要,可用于读取源码;由已发布定义启动的运行为 null。
language"ts" / "yaml"必填 / 必有;源码语言。ts 表示 TypeScript 脚本;yaml 表示工作流 YAML。
status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败,error 给出原因;completed 成功完成,output 为结果。后三种是终态。
progressnull / object必填 / 必有;运行报告的最新进度 {label, current, total, updated_at};未报告为 null。
progress(分支2).labelstring必填 / 必有;进度说明文字,例如当前阶段。
progress(分支2).currentnull / number必填 / 必有;已完成的数量;未报告为 null。
progress(分支2).totalnull / number必填 / 必有;总量;未知为 null。
progress(分支2).updated_atstring必填 / 必有;进度最近一次更新的时间(RFC 3339 UTC)。
current_waitnull / object必填 / 必有;运行当前未完成的等待点;不在等待为 null。
current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
countersobject必填 / 必有;运行的累计计数。 不接受额外字段。
counters.callsnumber必填 / 必有;脚本发出的调用总数。
counters.action_callsnumber必填 / 必有;其中调用动作的次数。
counters.child_runsnumber必填 / 必有;启动的子运行数。
counters.tasks_completednumber必填 / 必有;工作流已完成的步骤数。
counters.tasks_totalnull / number必填 / 必有;工作流顶层步骤总数;脚本运行为 null。
inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
errornull / object必填 / 必有;运行失败(faulted)时的错误详情;未失败为 null。
error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
error(分支2).titlestring必填 / 必有;错误的简短标题。
error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
initiatorobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
initiator.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
initiator.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
channel"run" / "console" / "api" / "internal" / "trigger"必填 / 必有;请求进入平台的渠道。console 为控制台(经 BFF);api 为公开 API 调用;internal 为平台内部服务调用;run 为由另一个运行创建的子运行;trigger 为触发器启动。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
parentnull / object必填 / 必有;派生本运行的父运行 {id, number, definition};根运行为 null。
parent(分支2).idstring必填 / 必有;父运行 ID(run_ 前缀)。
parent(分支2).numbernull / number必填 / 必有;父运行在其定义内的序号;父运行是临时运行时为 null。
parent(分支2).definitionnull / object必填 / 必有;父运行所属的脚本或工作流 {namespace, name};临时运行为 null。
parent(分支2).definition(分支2).namespacestring必填 / 必有;父运行所属定义的命名空间。
parent(分支2).definition(分支2).namestring必填 / 必有;父运行所属定义的名字。
parent_run_idstring / null必填 / 必有;派生出本运行的父运行 id;根运行为 null
root_run_idstring必填 / 必有;运行树根运行的 ID;根运行自身指向自己。
depthnumber必填 / 必有;运行树中的深度:根运行为 0,每一层子运行加 1,最大 10。
attachnull / "wait" / "detach"必填 / 必有;子运行与父运行的关系。wait 表示父运行等待子运行结束,且子运行的截止时间不晚于父运行;detach 表示父运行不等待,也不会因父运行取消而被取消;根运行为 null。
deadline_atstring必填 / 必有;运行的截止时间(RFC 3339 UTC):创建时间加 deadline_seconds(脚本默认且最多 300 秒,工作流默认 86400 秒、最多 604800 秒),等待型子运行不晚于父运行截止前 1 秒。
created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
started_atnull / string必填 / 必有;开始执行的时间(RFC 3339 UTC);仍在排队为 null。
ended_atnull / string必填 / 必有;进入终态的时间(RFC 3339 UTC);尚未结束为 null。
updated_atstring必填 / 必有;运行记录最近一次更新的时间(RFC 3339 UTC)。
heartbeat_atnull / string必填 / 必有;执行器最近一次存活信号的时间(RFC 3339 UTC);尚未开始为 null。
cancel_requested_atnull / string必填 / 必有;收到取消请求的时间(RFC 3339 UTC);未取消为 null。
cancelled_bynull / object必填 / 必有;请求取消的主体;未取消或非人为取消为 null。
cancelled_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
cancelled_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
cancel_reasonnull / "user" / "parent_cancelled" / "deadline" / "executor_lost"必填 / 必有;取消原因。user 为用户取消;parent_cancelled 为父运行被取消而级联取消;deadline 为超过截止时间;executor_lost 为执行器丢失;未取消为 null。
suspend_requested_atnull / string必填 / 必有;请求暂停工作流的时间(RFC 3339 UTC);未暂停为 null。
suspended_bynull / object必填 / 必有;请求暂停的主体;未暂停为 null。
suspended_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
suspended_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
queued_msnull / number必填 / 必有;从创建到开始执行的排队毫秒数;尚未开始为 null。
run_msnull / number必填 / 必有;实际执行毫秒数,不含等待点上的等待时间;结束后固定。
wait_msnull / number必填 / 必有;在等待点上累计等待的毫秒数;尚无等待为 null。
usageobject / null必填 / 必有;仅单个运行详情(含 expand)返回;列表为 null。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
usage(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
usage(分支1).coststring必填 / 必有;仅本运行自身的已评级实扣(不含子运行),美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
usage(分支1).pending_eventsinteger必填 / 必有;本运行自身尚未评级的用量事件数,金额稍后才计入。 minimum: 0
usage(分支1).by_serviceobject[]必填 / 必有;本运行按服务拆分的实扣,每项为 service 与 cost(6 位小数美元字符串);没有用量时为空数组。
usage(分支1).by_service[].servicestring必填 / 必有;产生用量的服务名,例如 router 或 search。
usage(分支1).by_service[].coststring必填 / 必有;该服务已评级实扣的美元十进制字符串,精确到 6 位小数。 pattern: "^[0-9]+\.[0-9]{6}$"
usage(分支1).tree_coststring / null必填 / 必有;仅根运行返回整棵运行树的已评级实扣(含自身),6 位小数美元字符串;子运行为 null。
rerun_ofnull / string必填 / 必有;重跑来源:本运行是对哪个运行(run_ ID)的重跑;否则为 null。
labelsobject必填 / 必有;用户标签与系统标签;触发器运行支持 64 个用户标签,系统标签不占用名额。
triggerobject / null必填 / 必有;启动本运行的触发器 {id, name};不是触发器启动时为 null。
trigger(分支1).idstring必填 / 必有;启动本运行的触发器 ID(trg_ 前缀)。
trigger(分支1).namestring必填 / 必有;启动本运行的触发器名称。
cancel_messagestring / null必填 / 必有;用户提供的取消备注(1–500 字符);未提供时为 null,cancel_reason 枚举不变。
input_truncatedboolean可选;列表省略外置 input 时为 true,此时 input 为 null;内联值不变,运行详情返回完整值。
output_truncatedboolean可选;列表省略外置 output 时为 true,此时 output 为 null;内联值不变,运行详情返回完整值。

实测响应

HTTP 202

{
  "id": "run_00mv67mwcj0f099fa839644b384742cdfbbbff67226e46f1eed8a36c5226f15a3cf730a221",
  "kind": "workflow",
  "number": null,
  "definition": null,
  "target": null,
  "resolved_version": null,
  "source_digest": "fa40016c6458f18ae4e5b418247cdccccfc4d5dfabe2bdec76f3103842ea15ad",
  "language": "yaml",
  "status": "cancelled",
  "progress": null,
  "current_wait": null,
  "counters": {
    "calls": 0,
    "action_calls": 0,
    "child_runs": 0,
    "tasks_completed": 0,
    "tasks_total": 1
  },
  "input": {},
  "output": null,
  "error": null,
  "initiator": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "channel": "api",
  "owner": "tnt_3a9759864ccb4e00",
  "trigger": null,
  "parent": null,
  "parent_run_id": null,
  "root_run_id": "run_00mv67mwcj0f099fa839644b384742cdfbbbff67226e46f1eed8a36c5226f15a3cf730a221",
  "depth": 0,
  "attach": null,
  "deadline_at": "2026-10-14T04:58:05.251Z",
  "created_at": "2026-10-13T04:58:05.251Z",
  "started_at": null,
  "ended_at": "2026-10-13T04:58:07.803Z",
  "updated_at": "2026-10-13T04:58:07.803Z",
  "heartbeat_at": null,
  "cancel_requested_at": "2026-10-13T04:58:07.754Z",
  "cancelled_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "cancel_reason": "user",
  "cancel_message": "Sample completed",
  "suspend_requested_at": null,
  "suspended_by": null,
  "queued_ms": 2552,
  "run_ms": 0,
  "wait_ms": null,
  "usage": null,
  "rerun_of": null,
  "labels": {
    "namespace": "docs-samples",
    "name": "sample-run-1791867412840-b05e8a"
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404RUN_NOT_FOUND:运行不存在或当前租户不可见。
409RUN_INVALID_STATE:当前状态不允许执行该动作。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

重新运行

用原精确版本或原临时源码创建新的根运行,保留标签并记录 rerun_of;可覆盖 input,未提供则沿用原输入。原目标已归档会拒绝重新运行,运行令牌不能使用此入口。

POST /automation/v1/runs/{id}/rerun

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;运行 ID(run_)。
header: Idempotency-Keystring可选;可选;1–256 字符。24 小时内同一 key 重放首个响应并带 Idempotent-Replayed: true;同 key 不同请求体返回 422;处理中返回 409。 minLength: 1;maxLength: 256

application/json

不接受额外字段。

字段类型说明
inputnull / string / number / boolean / object / null / string / number / boolean / object / JSON[][]可选;可选的新输入;省略沿用原运行输入,必须符合目标契约。
input(分支5).*(分支5)object递归 JSON 值。
input(分支5).*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[](分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[](分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。

示例

先设置以下环境变量,使用你自己的资源:

: "${RUN_ID:?Set RUN_ID}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}/rerun" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "input": {
    "n": 42
  }
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.runs.rerun({
  "path": {
    "id": env("RUN_ID")
  },
  "body": {
    "input": {
      "n": 42
    }
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
Idempotent-ReplayedbooleanPresent and true when replaying the first response for this key.

application/json

字段类型说明
idstring必填 / 必有;不透明运行 ID。新建非确定性 ID 为 run_ + 10 位 base36 毫秒时间前缀 + 64 位 hex DO ID,共 78 字符;旧随机 ID 为 46 字符,历史及确定性 ID 仍有效。同毫秒内不保证创建顺序。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
numbernull / number必填 / 必有;运行在其脚本或工作流内的递增序号;临时运行为 null。
definitionnull / object必填 / 必有;运行所属的脚本或工作流 {namespace, name};临时运行(直接传 source)为 null。
definition(分支2).namespacestring必填 / 必有;脚本或工作流的命名空间。
definition(分支2).namestring必填 / 必有;脚本或工作流的名字。
targetnull / string必填 / 必有;创建时 target 参数的原文(如 acme/report@latest);临时运行为 null。
resolved_versionnull / string必填 / 必有;target 解析到的精确版本号;临时运行为 null。
source_digestnull / string必填 / 必有;临时运行的源码摘要,可用于读取源码;由已发布定义启动的运行为 null。
language"ts" / "yaml"必填 / 必有;源码语言。ts 表示 TypeScript 脚本;yaml 表示工作流 YAML。
status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败,error 给出原因;completed 成功完成,output 为结果。后三种是终态。
progressnull / object必填 / 必有;运行报告的最新进度 {label, current, total, updated_at};未报告为 null。
progress(分支2).labelstring必填 / 必有;进度说明文字,例如当前阶段。
progress(分支2).currentnull / number必填 / 必有;已完成的数量;未报告为 null。
progress(分支2).totalnull / number必填 / 必有;总量;未知为 null。
progress(分支2).updated_atstring必填 / 必有;进度最近一次更新的时间(RFC 3339 UTC)。
current_waitnull / object必填 / 必有;运行当前未完成的等待点;不在等待为 null。
current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
countersobject必填 / 必有;运行的累计计数。 不接受额外字段。
counters.callsnumber必填 / 必有;脚本发出的调用总数。
counters.action_callsnumber必填 / 必有;其中调用动作的次数。
counters.child_runsnumber必填 / 必有;启动的子运行数。
counters.tasks_completednumber必填 / 必有;工作流已完成的步骤数。
counters.tasks_totalnull / number必填 / 必有;工作流顶层步骤总数;脚本运行为 null。
inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
errornull / object必填 / 必有;运行失败(faulted)时的错误详情;未失败为 null。
error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
error(分支2).titlestring必填 / 必有;错误的简短标题。
error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
initiatorobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
initiator.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
initiator.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
channel"run" / "console" / "api" / "internal" / "trigger"必填 / 必有;请求进入平台的渠道。console 为控制台(经 BFF);api 为公开 API 调用;internal 为平台内部服务调用;run 为由另一个运行创建的子运行;trigger 为触发器启动。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
parentnull / object必填 / 必有;派生本运行的父运行 {id, number, definition};根运行为 null。
parent(分支2).idstring必填 / 必有;父运行 ID(run_ 前缀)。
parent(分支2).numbernull / number必填 / 必有;父运行在其定义内的序号;父运行是临时运行时为 null。
parent(分支2).definitionnull / object必填 / 必有;父运行所属的脚本或工作流 {namespace, name};临时运行为 null。
parent(分支2).definition(分支2).namespacestring必填 / 必有;父运行所属定义的命名空间。
parent(分支2).definition(分支2).namestring必填 / 必有;父运行所属定义的名字。
parent_run_idstring / null必填 / 必有;派生出本运行的父运行 id;根运行为 null
root_run_idstring必填 / 必有;运行树根运行的 ID;根运行自身指向自己。
depthnumber必填 / 必有;运行树中的深度:根运行为 0,每一层子运行加 1,最大 10。
attachnull / "wait" / "detach"必填 / 必有;子运行与父运行的关系。wait 表示父运行等待子运行结束,且子运行的截止时间不晚于父运行;detach 表示父运行不等待,也不会因父运行取消而被取消;根运行为 null。
deadline_atstring必填 / 必有;运行的截止时间(RFC 3339 UTC):创建时间加 deadline_seconds(脚本默认且最多 300 秒,工作流默认 86400 秒、最多 604800 秒),等待型子运行不晚于父运行截止前 1 秒。
created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
started_atnull / string必填 / 必有;开始执行的时间(RFC 3339 UTC);仍在排队为 null。
ended_atnull / string必填 / 必有;进入终态的时间(RFC 3339 UTC);尚未结束为 null。
updated_atstring必填 / 必有;运行记录最近一次更新的时间(RFC 3339 UTC)。
heartbeat_atnull / string必填 / 必有;执行器最近一次存活信号的时间(RFC 3339 UTC);尚未开始为 null。
cancel_requested_atnull / string必填 / 必有;收到取消请求的时间(RFC 3339 UTC);未取消为 null。
cancelled_bynull / object必填 / 必有;请求取消的主体;未取消或非人为取消为 null。
cancelled_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
cancelled_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
cancel_reasonnull / "user" / "parent_cancelled" / "deadline" / "executor_lost"必填 / 必有;取消原因。user 为用户取消;parent_cancelled 为父运行被取消而级联取消;deadline 为超过截止时间;executor_lost 为执行器丢失;未取消为 null。
suspend_requested_atnull / string必填 / 必有;请求暂停工作流的时间(RFC 3339 UTC);未暂停为 null。
suspended_bynull / object必填 / 必有;请求暂停的主体;未暂停为 null。
suspended_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
suspended_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
queued_msnull / number必填 / 必有;从创建到开始执行的排队毫秒数;尚未开始为 null。
run_msnull / number必填 / 必有;实际执行毫秒数,不含等待点上的等待时间;结束后固定。
wait_msnull / number必填 / 必有;在等待点上累计等待的毫秒数;尚无等待为 null。
usageobject / null必填 / 必有;仅单个运行详情(含 expand)返回;列表为 null。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
usage(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
usage(分支1).coststring必填 / 必有;仅本运行自身的已评级实扣(不含子运行),美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
usage(分支1).pending_eventsinteger必填 / 必有;本运行自身尚未评级的用量事件数,金额稍后才计入。 minimum: 0
usage(分支1).by_serviceobject[]必填 / 必有;本运行按服务拆分的实扣,每项为 service 与 cost(6 位小数美元字符串);没有用量时为空数组。
usage(分支1).by_service[].servicestring必填 / 必有;产生用量的服务名,例如 router 或 search。
usage(分支1).by_service[].coststring必填 / 必有;该服务已评级实扣的美元十进制字符串,精确到 6 位小数。 pattern: "^[0-9]+\.[0-9]{6}$"
usage(分支1).tree_coststring / null必填 / 必有;仅根运行返回整棵运行树的已评级实扣(含自身),6 位小数美元字符串;子运行为 null。
rerun_ofnull / string必填 / 必有;重跑来源:本运行是对哪个运行(run_ ID)的重跑;否则为 null。
labelsobject必填 / 必有;用户标签与系统标签;触发器运行支持 64 个用户标签,系统标签不占用名额。
triggerobject / null必填 / 必有;启动本运行的触发器 {id, name};不是触发器启动时为 null。
trigger(分支1).idstring必填 / 必有;启动本运行的触发器 ID(trg_ 前缀)。
trigger(分支1).namestring必填 / 必有;启动本运行的触发器名称。
cancel_messagestring / null必填 / 必有;用户提供的取消备注(1–500 字符);未提供时为 null,cancel_reason 枚举不变。
input_truncatedboolean可选;列表省略外置 input 时为 true,此时 input 为 null;内联值不变,运行详情返回完整值。
output_truncatedboolean可选;列表省略外置 output 时为 true,此时 output 为 null;内联值不变,运行详情返回完整值。

实测响应

HTTP 200

{
  "id": "run_00mv67mj3s5141d7514d6e0c18cd71ba7e821b89faadad8897cc6bedb103209efe6de40b4d",
  "kind": "script",
  "number": null,
  "definition": null,
  "target": null,
  "resolved_version": null,
  "source_digest": "7ae6678882a4ef2ea96e401c105d5c6ef512917cd72a9235289d2a3bf1f1b49d",
  "language": "ts",
  "status": "running",
  "progress": null,
  "current_wait": null,
  "counters": {
    "calls": 0,
    "action_calls": 0,
    "child_runs": 0,
    "tasks_completed": 0,
    "tasks_total": null
  },
  "input": {
    "n": 42
  },
  "output": null,
  "error": null,
  "initiator": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "channel": "api",
  "owner": "tnt_3a9759864ccb4e00",
  "trigger": null,
  "parent": null,
  "parent_run_id": null,
  "root_run_id": "run_00mv67mj3s5141d7514d6e0c18cd71ba7e821b89faadad8897cc6bedb103209efe6de40b4d",
  "depth": 0,
  "attach": null,
  "deadline_at": "2026-10-13T05:02:48.088Z",
  "created_at": "2026-10-13T04:57:48.088Z",
  "started_at": "2026-10-13T04:57:49.075Z",
  "ended_at": null,
  "updated_at": "2026-10-13T04:57:49.075Z",
  "heartbeat_at": "2026-10-13T04:57:49.075Z",
  "cancel_requested_at": null,
  "cancelled_by": null,
  "cancel_reason": null,
  "cancel_message": null,
  "suspend_requested_at": null,
  "suspended_by": null,
  "queued_ms": 987,
  "run_ms": null,
  "wait_ms": null,
  "usage": null,
  "rerun_of": "run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1",
  "labels": {
    "namespace": "docs-samples",
    "name": "sample-run-1791867412840-b05e8a"
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 DEFINITION_INVALID:源码未通过定义校验。 INPUT_INVALID:输入不满足目标契约或业务校验。
403NAMESPACE_FORBIDDEN:命名空间只读或运行令牌不允许此调用。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。 VERSION_NOT_FOUND:指定版本或修订不存在。 RUN_NOT_FOUND:运行不存在或当前租户不可见。
409IDEMPOTENCY_IN_FLIGHT:同一幂等键的请求仍在处理中。 TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。
413PAYLOAD_TOO_LARGE:请求内容超过本操作允许的大小。
422IDEMPOTENCY_KEY_MISMATCH:同一幂等键已用于不同请求内容。 NO_MATCHING_VERSION:没有满足标签、版本或范围的已发布版本。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

暂停运行

仅可暂停正在运行或等待中的工作流;脚本返回 OPERATION_NOT_SUPPORTED,其他状态返回 RUN_INVALID_STATE。

POST /automation/v1/runs/{id}/suspend

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;运行 ID(run_)。

application/json

不接受额外字段。 object

示例

先设置以下环境变量,使用你自己的资源:

: "${RUN_ID:?Set RUN_ID}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}/suspend" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.runs.suspend({
  "path": {
    "id": env("RUN_ID")
  },
  "body": {}
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
idstring必填 / 必有;不透明运行 ID。新建非确定性 ID 为 run_ + 10 位 base36 毫秒时间前缀 + 64 位 hex DO ID,共 78 字符;旧随机 ID 为 46 字符,历史及确定性 ID 仍有效。同毫秒内不保证创建顺序。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
numbernull / number必填 / 必有;运行在其脚本或工作流内的递增序号;临时运行为 null。
definitionnull / object必填 / 必有;运行所属的脚本或工作流 {namespace, name};临时运行(直接传 source)为 null。
definition(分支2).namespacestring必填 / 必有;脚本或工作流的命名空间。
definition(分支2).namestring必填 / 必有;脚本或工作流的名字。
targetnull / string必填 / 必有;创建时 target 参数的原文(如 acme/report@latest);临时运行为 null。
resolved_versionnull / string必填 / 必有;target 解析到的精确版本号;临时运行为 null。
source_digestnull / string必填 / 必有;临时运行的源码摘要,可用于读取源码;由已发布定义启动的运行为 null。
language"ts" / "yaml"必填 / 必有;源码语言。ts 表示 TypeScript 脚本;yaml 表示工作流 YAML。
status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败,error 给出原因;completed 成功完成,output 为结果。后三种是终态。
progressnull / object必填 / 必有;运行报告的最新进度 {label, current, total, updated_at};未报告为 null。
progress(分支2).labelstring必填 / 必有;进度说明文字,例如当前阶段。
progress(分支2).currentnull / number必填 / 必有;已完成的数量;未报告为 null。
progress(分支2).totalnull / number必填 / 必有;总量;未知为 null。
progress(分支2).updated_atstring必填 / 必有;进度最近一次更新的时间(RFC 3339 UTC)。
current_waitnull / object必填 / 必有;运行当前未完成的等待点;不在等待为 null。
current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
countersobject必填 / 必有;运行的累计计数。 不接受额外字段。
counters.callsnumber必填 / 必有;脚本发出的调用总数。
counters.action_callsnumber必填 / 必有;其中调用动作的次数。
counters.child_runsnumber必填 / 必有;启动的子运行数。
counters.tasks_completednumber必填 / 必有;工作流已完成的步骤数。
counters.tasks_totalnull / number必填 / 必有;工作流顶层步骤总数;脚本运行为 null。
inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
errornull / object必填 / 必有;运行失败(faulted)时的错误详情;未失败为 null。
error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
error(分支2).titlestring必填 / 必有;错误的简短标题。
error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
initiatorobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
initiator.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
initiator.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
channel"run" / "console" / "api" / "internal" / "trigger"必填 / 必有;请求进入平台的渠道。console 为控制台(经 BFF);api 为公开 API 调用;internal 为平台内部服务调用;run 为由另一个运行创建的子运行;trigger 为触发器启动。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
parentnull / object必填 / 必有;派生本运行的父运行 {id, number, definition};根运行为 null。
parent(分支2).idstring必填 / 必有;父运行 ID(run_ 前缀)。
parent(分支2).numbernull / number必填 / 必有;父运行在其定义内的序号;父运行是临时运行时为 null。
parent(分支2).definitionnull / object必填 / 必有;父运行所属的脚本或工作流 {namespace, name};临时运行为 null。
parent(分支2).definition(分支2).namespacestring必填 / 必有;父运行所属定义的命名空间。
parent(分支2).definition(分支2).namestring必填 / 必有;父运行所属定义的名字。
parent_run_idstring / null必填 / 必有;派生出本运行的父运行 id;根运行为 null
root_run_idstring必填 / 必有;运行树根运行的 ID;根运行自身指向自己。
depthnumber必填 / 必有;运行树中的深度:根运行为 0,每一层子运行加 1,最大 10。
attachnull / "wait" / "detach"必填 / 必有;子运行与父运行的关系。wait 表示父运行等待子运行结束,且子运行的截止时间不晚于父运行;detach 表示父运行不等待,也不会因父运行取消而被取消;根运行为 null。
deadline_atstring必填 / 必有;运行的截止时间(RFC 3339 UTC):创建时间加 deadline_seconds(脚本默认且最多 300 秒,工作流默认 86400 秒、最多 604800 秒),等待型子运行不晚于父运行截止前 1 秒。
created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
started_atnull / string必填 / 必有;开始执行的时间(RFC 3339 UTC);仍在排队为 null。
ended_atnull / string必填 / 必有;进入终态的时间(RFC 3339 UTC);尚未结束为 null。
updated_atstring必填 / 必有;运行记录最近一次更新的时间(RFC 3339 UTC)。
heartbeat_atnull / string必填 / 必有;执行器最近一次存活信号的时间(RFC 3339 UTC);尚未开始为 null。
cancel_requested_atnull / string必填 / 必有;收到取消请求的时间(RFC 3339 UTC);未取消为 null。
cancelled_bynull / object必填 / 必有;请求取消的主体;未取消或非人为取消为 null。
cancelled_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
cancelled_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
cancel_reasonnull / "user" / "parent_cancelled" / "deadline" / "executor_lost"必填 / 必有;取消原因。user 为用户取消;parent_cancelled 为父运行被取消而级联取消;deadline 为超过截止时间;executor_lost 为执行器丢失;未取消为 null。
suspend_requested_atnull / string必填 / 必有;请求暂停工作流的时间(RFC 3339 UTC);未暂停为 null。
suspended_bynull / object必填 / 必有;请求暂停的主体;未暂停为 null。
suspended_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
suspended_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
queued_msnull / number必填 / 必有;从创建到开始执行的排队毫秒数;尚未开始为 null。
run_msnull / number必填 / 必有;实际执行毫秒数,不含等待点上的等待时间;结束后固定。
wait_msnull / number必填 / 必有;在等待点上累计等待的毫秒数;尚无等待为 null。
usageobject / null必填 / 必有;仅单个运行详情(含 expand)返回;列表为 null。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
usage(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
usage(分支1).coststring必填 / 必有;仅本运行自身的已评级实扣(不含子运行),美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
usage(分支1).pending_eventsinteger必填 / 必有;本运行自身尚未评级的用量事件数,金额稍后才计入。 minimum: 0
usage(分支1).by_serviceobject[]必填 / 必有;本运行按服务拆分的实扣,每项为 service 与 cost(6 位小数美元字符串);没有用量时为空数组。
usage(分支1).by_service[].servicestring必填 / 必有;产生用量的服务名,例如 router 或 search。
usage(分支1).by_service[].coststring必填 / 必有;该服务已评级实扣的美元十进制字符串,精确到 6 位小数。 pattern: "^[0-9]+\.[0-9]{6}$"
usage(分支1).tree_coststring / null必填 / 必有;仅根运行返回整棵运行树的已评级实扣(含自身),6 位小数美元字符串;子运行为 null。
rerun_ofnull / string必填 / 必有;重跑来源:本运行是对哪个运行(run_ ID)的重跑;否则为 null。
labelsobject必填 / 必有;用户标签与系统标签;触发器运行支持 64 个用户标签,系统标签不占用名额。
triggerobject / null必填 / 必有;启动本运行的触发器 {id, name};不是触发器启动时为 null。
trigger(分支1).idstring必填 / 必有;启动本运行的触发器 ID(trg_ 前缀)。
trigger(分支1).namestring必填 / 必有;启动本运行的触发器名称。
cancel_messagestring / null必填 / 必有;用户提供的取消备注(1–500 字符);未提供时为 null,cancel_reason 枚举不变。
input_truncatedboolean可选;列表省略外置 input 时为 true,此时 input 为 null;内联值不变,运行详情返回完整值。
output_truncatedboolean可选;列表省略外置 output 时为 true,此时 output 为 null;内联值不变,运行详情返回完整值。

实测响应

HTTP 200

{
  "id": "run_00mv67mkw52c7fa90cc9649b1053e66fd836b071f289acb667ff8ca853e65bc4608e9a45bd",
  "kind": "workflow",
  "number": null,
  "definition": null,
  "target": null,
  "resolved_version": null,
  "source_digest": "1f559f7323adda4865d889639a4d878eab97e1ce3e542c68ea4022af4cd0f7fa",
  "language": "yaml",
  "status": "suspended",
  "progress": null,
  "current_wait": {
    "id": "wait_wf-eebc9ef34869206fa1bcc1e2ae6375990a7ab34c5ad485ac98a4f189c4b37346",
    "run_id": "run_00mv67mkw52c7fa90cc9649b1053e66fd836b071f289acb667ff8ca853e65bc4608e9a45bd",
    "kind": "event",
    "state": "open",
    "task": {
      "reference": "/do/0/ready",
      "name": "ready"
    },
    "resume_at": null,
    "event_type": "ready",
    "child_run_id": null,
    "created_at": "2026-10-13T04:57:56.982Z",
    "expires_at": "2026-10-14T04:57:50.405Z",
    "resolved_at": null
  },
  "counters": {
    "calls": 0,
    "action_calls": 0,
    "child_runs": 0,
    "tasks_completed": 0,
    "tasks_total": 1
  },
  "input": {},
  "output": null,
  "error": null,
  "initiator": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "channel": "api",
  "owner": "tnt_3a9759864ccb4e00",
  "trigger": null,
  "parent": null,
  "parent_run_id": null,
  "root_run_id": "run_00mv67mkw52c7fa90cc9649b1053e66fd836b071f289acb667ff8ca853e65bc4608e9a45bd",
  "depth": 0,
  "attach": null,
  "deadline_at": "2026-10-14T04:57:50.405Z",
  "created_at": "2026-10-13T04:57:50.405Z",
  "started_at": "2026-10-13T04:57:56.933Z",
  "ended_at": null,
  "updated_at": "2026-10-13T04:57:58.173Z",
  "heartbeat_at": null,
  "cancel_requested_at": null,
  "cancelled_by": null,
  "cancel_reason": null,
  "cancel_message": null,
  "suspend_requested_at": "2026-10-13T04:57:58.173Z",
  "suspended_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "queued_ms": 6528,
  "run_ms": null,
  "wait_ms": null,
  "usage": null,
  "rerun_of": null,
  "labels": {
    "namespace": "docs-samples",
    "name": "sample-run-1791867412840-b05e8a"
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404RUN_NOT_FOUND:运行不存在或当前租户不可见。
409OPERATION_NOT_SUPPORTED:该资源类型不支持此操作。 RUN_INVALID_STATE:当前状态不允许执行该动作。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

恢复运行

仅恢复 suspended 状态的工作流,回到暂停前的运行或等待状态;并发名额不足时仍保持暂停,脚本不支持此操作。

POST /automation/v1/runs/{id}/resume

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;运行 ID(run_)。

application/json

不接受额外字段。 object

示例

先设置以下环境变量,使用你自己的资源:

: "${RUN_ID:?Set RUN_ID}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}/resume" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.runs.resume({
  "path": {
    "id": env("RUN_ID")
  },
  "body": {}
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
idstring必填 / 必有;不透明运行 ID。新建非确定性 ID 为 run_ + 10 位 base36 毫秒时间前缀 + 64 位 hex DO ID,共 78 字符;旧随机 ID 为 46 字符,历史及确定性 ID 仍有效。同毫秒内不保证创建顺序。
kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
numbernull / number必填 / 必有;运行在其脚本或工作流内的递增序号;临时运行为 null。
definitionnull / object必填 / 必有;运行所属的脚本或工作流 {namespace, name};临时运行(直接传 source)为 null。
definition(分支2).namespacestring必填 / 必有;脚本或工作流的命名空间。
definition(分支2).namestring必填 / 必有;脚本或工作流的名字。
targetnull / string必填 / 必有;创建时 target 参数的原文(如 acme/report@latest);临时运行为 null。
resolved_versionnull / string必填 / 必有;target 解析到的精确版本号;临时运行为 null。
source_digestnull / string必填 / 必有;临时运行的源码摘要,可用于读取源码;由已发布定义启动的运行为 null。
language"ts" / "yaml"必填 / 必有;源码语言。ts 表示 TypeScript 脚本;yaml 表示工作流 YAML。
status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败,error 给出原因;completed 成功完成,output 为结果。后三种是终态。
progressnull / object必填 / 必有;运行报告的最新进度 {label, current, total, updated_at};未报告为 null。
progress(分支2).labelstring必填 / 必有;进度说明文字,例如当前阶段。
progress(分支2).currentnull / number必填 / 必有;已完成的数量;未报告为 null。
progress(分支2).totalnull / number必填 / 必有;总量;未知为 null。
progress(分支2).updated_atstring必填 / 必有;进度最近一次更新的时间(RFC 3339 UTC)。
current_waitnull / object必填 / 必有;运行当前未完成的等待点;不在等待为 null。
current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
countersobject必填 / 必有;运行的累计计数。 不接受额外字段。
counters.callsnumber必填 / 必有;脚本发出的调用总数。
counters.action_callsnumber必填 / 必有;其中调用动作的次数。
counters.child_runsnumber必填 / 必有;启动的子运行数。
counters.tasks_completednumber必填 / 必有;工作流已完成的步骤数。
counters.tasks_totalnull / number必填 / 必有;工作流顶层步骤总数;脚本运行为 null。
inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
errornull / object必填 / 必有;运行失败(faulted)时的错误详情;未失败为 null。
error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
error(分支2).titlestring必填 / 必有;错误的简短标题。
error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
initiatorobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
initiator.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
initiator.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
channel"run" / "console" / "api" / "internal" / "trigger"必填 / 必有;请求进入平台的渠道。console 为控制台(经 BFF);api 为公开 API 调用;internal 为平台内部服务调用;run 为由另一个运行创建的子运行;trigger 为触发器启动。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
parentnull / object必填 / 必有;派生本运行的父运行 {id, number, definition};根运行为 null。
parent(分支2).idstring必填 / 必有;父运行 ID(run_ 前缀)。
parent(分支2).numbernull / number必填 / 必有;父运行在其定义内的序号;父运行是临时运行时为 null。
parent(分支2).definitionnull / object必填 / 必有;父运行所属的脚本或工作流 {namespace, name};临时运行为 null。
parent(分支2).definition(分支2).namespacestring必填 / 必有;父运行所属定义的命名空间。
parent(分支2).definition(分支2).namestring必填 / 必有;父运行所属定义的名字。
parent_run_idstring / null必填 / 必有;派生出本运行的父运行 id;根运行为 null
root_run_idstring必填 / 必有;运行树根运行的 ID;根运行自身指向自己。
depthnumber必填 / 必有;运行树中的深度:根运行为 0,每一层子运行加 1,最大 10。
attachnull / "wait" / "detach"必填 / 必有;子运行与父运行的关系。wait 表示父运行等待子运行结束,且子运行的截止时间不晚于父运行;detach 表示父运行不等待,也不会因父运行取消而被取消;根运行为 null。
deadline_atstring必填 / 必有;运行的截止时间(RFC 3339 UTC):创建时间加 deadline_seconds(脚本默认且最多 300 秒,工作流默认 86400 秒、最多 604800 秒),等待型子运行不晚于父运行截止前 1 秒。
created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
started_atnull / string必填 / 必有;开始执行的时间(RFC 3339 UTC);仍在排队为 null。
ended_atnull / string必填 / 必有;进入终态的时间(RFC 3339 UTC);尚未结束为 null。
updated_atstring必填 / 必有;运行记录最近一次更新的时间(RFC 3339 UTC)。
heartbeat_atnull / string必填 / 必有;执行器最近一次存活信号的时间(RFC 3339 UTC);尚未开始为 null。
cancel_requested_atnull / string必填 / 必有;收到取消请求的时间(RFC 3339 UTC);未取消为 null。
cancelled_bynull / object必填 / 必有;请求取消的主体;未取消或非人为取消为 null。
cancelled_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
cancelled_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
cancel_reasonnull / "user" / "parent_cancelled" / "deadline" / "executor_lost"必填 / 必有;取消原因。user 为用户取消;parent_cancelled 为父运行被取消而级联取消;deadline 为超过截止时间;executor_lost 为执行器丢失;未取消为 null。
suspend_requested_atnull / string必填 / 必有;请求暂停工作流的时间(RFC 3339 UTC);未暂停为 null。
suspended_bynull / object必填 / 必有;请求暂停的主体;未暂停为 null。
suspended_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
suspended_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
queued_msnull / number必填 / 必有;从创建到开始执行的排队毫秒数;尚未开始为 null。
run_msnull / number必填 / 必有;实际执行毫秒数,不含等待点上的等待时间;结束后固定。
wait_msnull / number必填 / 必有;在等待点上累计等待的毫秒数;尚无等待为 null。
usageobject / null必填 / 必有;仅单个运行详情(含 expand)返回;列表为 null。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
usage(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
usage(分支1).coststring必填 / 必有;仅本运行自身的已评级实扣(不含子运行),美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
usage(分支1).pending_eventsinteger必填 / 必有;本运行自身尚未评级的用量事件数,金额稍后才计入。 minimum: 0
usage(分支1).by_serviceobject[]必填 / 必有;本运行按服务拆分的实扣,每项为 service 与 cost(6 位小数美元字符串);没有用量时为空数组。
usage(分支1).by_service[].servicestring必填 / 必有;产生用量的服务名,例如 router 或 search。
usage(分支1).by_service[].coststring必填 / 必有;该服务已评级实扣的美元十进制字符串,精确到 6 位小数。 pattern: "^[0-9]+\.[0-9]{6}$"
usage(分支1).tree_coststring / null必填 / 必有;仅根运行返回整棵运行树的已评级实扣(含自身),6 位小数美元字符串;子运行为 null。
rerun_ofnull / string必填 / 必有;重跑来源:本运行是对哪个运行(run_ ID)的重跑;否则为 null。
labelsobject必填 / 必有;用户标签与系统标签;触发器运行支持 64 个用户标签,系统标签不占用名额。
triggerobject / null必填 / 必有;启动本运行的触发器 {id, name};不是触发器启动时为 null。
trigger(分支1).idstring必填 / 必有;启动本运行的触发器 ID(trg_ 前缀)。
trigger(分支1).namestring必填 / 必有;启动本运行的触发器名称。
cancel_messagestring / null必填 / 必有;用户提供的取消备注(1–500 字符);未提供时为 null,cancel_reason 枚举不变。
input_truncatedboolean可选;列表省略外置 input 时为 true,此时 input 为 null;内联值不变,运行详情返回完整值。
output_truncatedboolean可选;列表省略外置 output 时为 true,此时 output 为 null;内联值不变,运行详情返回完整值。

实测响应

HTTP 200

{
  "id": "run_00mv67mkw52c7fa90cc9649b1053e66fd836b071f289acb667ff8ca853e65bc4608e9a45bd",
  "kind": "workflow",
  "number": null,
  "definition": null,
  "target": null,
  "resolved_version": null,
  "source_digest": "1f559f7323adda4865d889639a4d878eab97e1ce3e542c68ea4022af4cd0f7fa",
  "language": "yaml",
  "status": "waiting",
  "progress": null,
  "current_wait": {
    "id": "wait_wf-eebc9ef34869206fa1bcc1e2ae6375990a7ab34c5ad485ac98a4f189c4b37346",
    "run_id": "run_00mv67mkw52c7fa90cc9649b1053e66fd836b071f289acb667ff8ca853e65bc4608e9a45bd",
    "kind": "event",
    "state": "open",
    "task": {
      "reference": "/do/0/ready",
      "name": "ready"
    },
    "resume_at": null,
    "event_type": "ready",
    "child_run_id": null,
    "created_at": "2026-10-13T04:57:56.982Z",
    "expires_at": "2026-10-14T04:57:50.405Z",
    "resolved_at": null
  },
  "counters": {
    "calls": 0,
    "action_calls": 0,
    "child_runs": 0,
    "tasks_completed": 0,
    "tasks_total": 1
  },
  "input": {},
  "output": null,
  "error": null,
  "initiator": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "channel": "api",
  "owner": "tnt_3a9759864ccb4e00",
  "trigger": null,
  "parent": null,
  "parent_run_id": null,
  "root_run_id": "run_00mv67mkw52c7fa90cc9649b1053e66fd836b071f289acb667ff8ca853e65bc4608e9a45bd",
  "depth": 0,
  "attach": null,
  "deadline_at": "2026-10-14T04:57:50.405Z",
  "created_at": "2026-10-13T04:57:50.405Z",
  "started_at": "2026-10-13T04:57:56.933Z",
  "ended_at": null,
  "updated_at": "2026-10-13T04:58:02.193Z",
  "heartbeat_at": null,
  "cancel_requested_at": null,
  "cancelled_by": null,
  "cancel_reason": null,
  "cancel_message": null,
  "suspend_requested_at": null,
  "suspended_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "queued_ms": 6528,
  "run_ms": null,
  "wait_ms": null,
  "usage": null,
  "rerun_of": null,
  "labels": {
    "namespace": "docs-samples",
    "name": "sample-run-1791867412840-b05e8a"
  }
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404RUN_NOT_FOUND:运行不存在或当前租户不可见。
409OPERATION_NOT_SUPPORTED:该资源类型不支持此操作。 RUN_INVALID_STATE:当前状态不允许执行该动作。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出等待点

按账本顺序列出运行的等待点。包括当前及历史的 event、timer 与 child 等待点。

GET /automation/v1/runs/{id}/waits

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;运行 ID(run_)。
query: limitinteger可选;每页条数,整数 1–100,默认 50。 minimum: 1;maximum: 100
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。

示例

先设置以下环境变量,使用你自己的资源:

: "${RUN_ID:?Set RUN_ID}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}/waits" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.runs.waits.list({
  "path": {
    "id": env("RUN_ID")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的等待点(当前与历史),按 created_at 倒序、id 倒序排列。
data[].idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
data[].run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
data[].kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
data[].state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
data[].tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
data[].task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
data[].task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
data[].resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
data[].event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
data[].child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
data[].created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
data[].expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
data[].resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [
    {
      "id": "wait_wf-eebc9ef34869206fa1bcc1e2ae6375990a7ab34c5ad485ac98a4f189c4b37346",
      "run_id": "run_00mv67mkw52c7fa90cc9649b1053e66fd836b071f289acb667ff8ca853e65bc4608e9a45bd",
      "kind": "event",
      "state": "open",
      "task": {
        "reference": "/do/0/ready",
        "name": "ready"
      },
      "resume_at": null,
      "event_type": "ready",
      "child_run_id": null,
      "created_at": "2026-10-13T04:57:56.982Z",
      "expires_at": "2026-10-14T04:57:50.405Z",
      "resolved_at": null
    }
  ],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404RUN_NOT_FOUND:运行不存在或当前租户不可见。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出运行调用

分页读取调用账本及执行结果。结果按账本顺序列出目标、参数与结果预览、状态和耗时。脚本运行读调用账本;工作流运行的动作调用记在步骤上,这里列出带动作的步骤(不含被跳过的),与 counters.action_calls 一致。

GET /automation/v1/runs/{id}/calls

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;运行 ID(run_)。
query: limitinteger可选;运行台账每页条数,整数 1–200,默认 50;其它集合上限为 100。 minimum: 1;maximum: 200
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。

示例

先设置以下环境变量,使用你自己的资源:

: "${RUN_ID:?Set RUN_ID}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}/calls" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.runs.calls.list({
  "path": {
    "id": env("RUN_ID")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的脚本调用记录,按 seq 顺序排列。
data[].idstring必填 / 必有;调用 ID,前缀 call_。
data[].run_idstring必填 / 必有;发出该调用的脚本运行 ID(run_ 前缀)。
data[].seqnumber必填 / 必有;调用在该运行中的序号,随调用顺序递增;与 run_id 一起定位这次调用。
data[].targetobject必填 / 必有;被调用的目标 {kind, name, revision?, version?}。 不接受额外字段。
data[].target.kind"action" / "script" / "workflow" / "platform_api"必填 / 必有;目标类型。action 为动作;platform_api 为平台 API 操作;script 为脚本;workflow 为工作流。
data[].target.namestring必填 / 必有;目标名称:动作为 ns/name,平台 API 为操作名,脚本与工作流为 ns/name。
data[].target.revisionstring可选;实际执行的动作修订 ID(actr_ 前缀);仅动作调用有。
data[].target.versionstring可选;实际运行的精确版本号;仅脚本与工作流调用有。
data[].args_previewstring必填 / 必有;调用参数的单行预览,由服务端截断;超过 32 KB 的原文存放在对象存储而不内联。
data[].result_previewnull / string必填 / 必有;返回值的单行预览,由服务端截断;调用结束前为 null。
data[].status"running" / "completed" / "faulted" / "cancelled"必填 / 必有;调用状态。running 执行中;completed 已正常返回;faulted 失败,error 给出原因;cancelled 因运行被取消而中止。
data[].started_atstring必填 / 必有;调用开始的时间(RFC 3339 UTC)。
data[].ended_atnull / string必填 / 必有;调用结束的时间(RFC 3339 UTC);仍在执行为 null。
data[].duration_msnull / number必填 / 必有;从开始到结束的毫秒数;未结束为 null。
data[].errornull / object必填 / 必有;调用失败时的错误详情;成功或仍在执行为 null。
data[].error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
data[].error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
data[].error(分支2).titlestring必填 / 必有;错误的简短标题。
data[].error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
data[].error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
data[].error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
data[].error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
data[].error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
data[].error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
data[].error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
data[].error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
data[].error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
data[].error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
data[].error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
data[].error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
data[].error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
data[].error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
data[].error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
data[].error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
data[].child_run_idnull / string必填 / 必有;目标是脚本或工作流时,由本次调用启动的子运行 ID;动作与平台 API 调用为 null。
data[].invocation_keystring必填 / 必有;标识这一次逻辑调用的键,随调用发往下游,使至少一次语义下的重试可被去重。
data[].request_idstring / null必填 / 必有;下游响应的 X-Request-Id;尚未收到响应或响应未提供该头时为 null。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404RUN_NOT_FOUND:运行不存在或当前租户不可见。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出运行产物

读取运行产物及其文件引用。按账本顺序返回类型、大小及所属步骤。

GET /automation/v1/runs/{id}/artifacts

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;运行 ID(run_)。
query: limitinteger可选;每页条数,整数 1–100,默认 50。 minimum: 1;maximum: 100
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。

示例

先设置以下环境变量,使用你自己的资源:

: "${RUN_ID:?Set RUN_ID}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}/artifacts" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.runs.artifacts.list({
  "path": {
    "id": env("RUN_ID")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的运行产物,按 created_at 倒序、id 倒序排列。
data[].idstring必填 / 必有;产物 ID,按不透明字符串处理。
data[].file_idstring必填 / 必有;产物在文件服务中的文件 ID,用文件接口下载内容。
data[].namestring必填 / 必有;产物文件名。
data[].content_typestring必填 / 必有;产物的 MIME 类型。
data[].size_in_bytesnumber必填 / 必有;产物大小,单位字节。
data[].tasknull / string必填 / 必有;产生该产物的工作流步骤的 JSON Pointer;不属于某个步骤为 null。
data[].created_atstring必填 / 必有;产物创建时间(RFC 3339 UTC)。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404RUN_NOT_FOUND:运行不存在或当前租户不可见。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

完成等待点

仅完成 event 等待点,payload 上限 32 KiB 且须满足等待条件;timer 与 child 不支持手动完成。相同 id 与相同 payload 重放返回 replayed=true,其他重复提交返回 WAIT_ALREADY_RESOLVED,超时返回 WAIT_EXPIRED。

POST /automation/v1/runs/{id}/waits/{wait_id}/complete

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;运行 ID(run_)。
path: wait_idstring必填;该运行下的等待点 ID(wait_)。

application/json

不接受额外字段。

字段类型说明
idstring可选;可选事件去重 ID;同一等待点重复提交相同 ID 和 payload 返回 replayed=true。
payloadnull / string / number / boolean / object / null / string / number / boolean / object / JSON[][]必填 / 必有;事件数据,JSON 编码最多 32 KiB;必须满足等待点的过滤条件。
payload(分支5).*(分支5)object递归 JSON 值。
payload(分支5).*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
payload(分支6)[](分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
payload(分支6)[](分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。

示例

先设置以下环境变量,使用你自己的资源:

: "${RUN_ID:?Set RUN_ID}"
: "${WAIT_ID:?Set WAIT_ID}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}/waits/${WAIT_ID}/complete" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "payload": {
    "answer": 42
  }
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.runs.waits.complete({
  "path": {
    "id": env("RUN_ID"),
    "wait_id": env("WAIT_ID")
  },
  "body": {
    "payload": {
      "answer": 42
    }
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
idstring必填 / 必有;等待点 ID,前缀 wait_。
run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件;timer 等待到点;child 等待子运行;本接口只对 event 有效。
state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;完成后的等待点状态。open 仍在等待;resolved 已被满足;expired 已到期;cancelled 已取消。成功提交的事件使其变为 resolved。
tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer。
task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC)。
replayedboolean必填 / 必有;true 表示这是对同一 id 且相同 payload 的重复提交,返回的是原结果而不是再次处理。

实测响应

HTTP 200

{
  "id": "wait_wf-eebc9ef34869206fa1bcc1e2ae6375990a7ab34c5ad485ac98a4f189c4b37346",
  "run_id": "run_00mv67mkw52c7fa90cc9649b1053e66fd836b071f289acb667ff8ca853e65bc4608e9a45bd",
  "kind": "event",
  "state": "resolved",
  "task": {
    "reference": "/do/0/ready",
    "name": "ready"
  },
  "resume_at": null,
  "event_type": "ready",
  "child_run_id": null,
  "created_at": "2026-10-13T04:57:56.982Z",
  "expires_at": "2026-10-14T04:57:50.405Z",
  "resolved_at": "2026-10-13T04:58:03.972Z",
  "replayed": false
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 INPUT_INVALID:输入不满足目标契约或业务校验。
404RUN_NOT_FOUND:运行不存在或当前租户不可见。 WAIT_NOT_FOUND:运行中不存在该等待点。
409OPERATION_NOT_SUPPORTED:该资源类型不支持此操作。 WAIT_ALREADY_RESOLVED:等待点已关闭,或重复事件与原提交不同。
410WAIT_EXPIRED:等待点已超过到期时间。
413PAYLOAD_TOO_LARGE:请求内容超过本操作允许的大小。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出运行步骤

分页读取步骤账本;include=planned 附带尚未执行的顶层步骤,group_by=reference 按步骤引用聚合次数、状态和耗时。

GET /automation/v1/runs/{id}/tasks

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;运行 ID(run_)。
query: limitinteger可选;运行台账每页条数,整数 1–200,默认 50;其它集合上限为 100。 minimum: 1;maximum: 200
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。
query: include"planned"可选;仅支持 planned,附带尚未执行的顶层步骤;省略只读已有步骤。
query: group_by"reference"可选;仅支持 reference,按步骤引用聚合循环执行;省略返回逐次步骤。

示例

先设置以下环境变量,使用你自己的资源:

: "${RUN_ID:?Set RUN_ID}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}/tasks" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.runs.tasks.list({
  "path": {
    "id": env("RUN_ID")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject / object[]必填 / 必有;本页的工作流步骤记录;group_by=reference 时为按 reference 聚合的 TaskGroup 行,按执行顺序排列。
data[](分支1).idstring必填 / 必有;步骤执行记录的标识,按不透明字符串处理。
data[](分支1).run_idstring必填 / 必有;所属运行 ID。
data[](分支1).referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start。
data[](分支1).namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
data[](分支1).kind"run" / "call" / "wait" / "set" / "for" / "fork" / "try" / "switch" / "emit" / "raise" / "listen" / "do"必填 / 必有;工作流步骤类型。call 调用动作;run 运行子脚本或子工作流;wait 等待时长;set 设置变量;for 循环;fork 并行分支;try 带捕获的块;switch 条件分支;emit 发出事件;raise 抛出错误;listen 等待事件;do 顺序执行的步骤块。
data[](分支1).iterationnumber[]必填 / 必有;外层 for 循环的当前迭代下标,由外到内;不在循环中为空数组。
data[](分支1).attemptnumber必填 / 必有;第几次尝试;步骤因重试而重新执行时递增。
data[](分支1).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;步骤状态,取值与运行状态相同。pending 尚未开始;running 执行中;waiting 在等待事件、定时器或子运行;suspended 因运行被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
data[](分支1).skippedboolean必填 / 必有;true 表示该步骤被跳过而没有实际执行。
data[](分支1).started_atnull / string必填 / 必有;步骤开始的时间(RFC 3339 UTC);未开始为 null。
data[](分支1).ended_atnull / string必填 / 必有;步骤结束的时间(RFC 3339 UTC);未结束为 null。
data[](分支1).duration_msnull / number必填 / 必有;执行耗时毫秒数;未结束为 null。
data[](分支1).inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
data[](分支1).input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
data[](分支1).input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[](分支1).input_truncatedboolean必填 / 必有;true 表示 input 超过 32 KB 已被截断。
data[](分支1).outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
data[](分支1).output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
data[](分支1).output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[](分支1).output_truncatedboolean必填 / 必有;输出超过内联限制而被省略时为 true。
data[](分支1).errornull / object必填 / 必有;步骤失败时的错误详情;未失败为 null。
data[](分支1).error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
data[](分支1).error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
data[](分支1).error(分支2).titlestring必填 / 必有;错误的简短标题。
data[](分支1).error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
data[](分支1).error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
data[](分支1).error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
data[](分支1).error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
data[](分支1).error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
data[](分支1).error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
data[](分支1).error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
data[](分支1).error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
data[](分支1).error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
data[](分支1).error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
data[](分支1).error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
data[](分支1).error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
data[](分支1).error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
data[](分支1).error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
data[](分支1).error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
data[](分支1).error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
data[](分支1).actionnull / object必填 / 必有;call 步骤执行的动作 {name, revision};其它步骤为 null。
data[](分支1).action(分支2).namestring必填 / 必有;动作全名 ns/name。
data[](分支1).action(分支2).revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
data[](分支1).child_runnull / object必填 / 必有;run 步骤启动的子运行摘要 {id, number, status, resolved_version};其它步骤为 null。
data[](分支1).child_run(分支2).idstring必填 / 必有;子运行 ID(run_ 前缀),创建后即可读取。
data[](分支1).child_run(分支2).numbernull / number必填 / 必有;子运行在其定义内的序号;临时运行为 null。
data[](分支1).child_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;子运行的状态。pending 尚未开始;running 执行中;waiting 在等待;suspended 已暂停;cancelled 已取消;faulted 失败;completed 成功完成。等待型子运行在结束时补全终态,detach 的子运行只记录启动时的状态。
data[](分支1).child_run(分支2).resolved_versionnull / string必填 / 必有;子运行解析到的精确版本号;临时运行为 null。
data[](分支2).referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start。
data[](分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
data[](分支2).countnumber必填 / 必有;该 reference 下合并的执行记录条数(循环的迭代数)。
data[](分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;步骤状态,取值与运行状态相同。pending 尚未开始;running 执行中;waiting 在等待事件、定时器或子运行;suspended 因运行被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
data[](分支2).duration_msnull / number必填 / 必有;执行耗时毫秒数;未结束为 null。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404RUN_NOT_FOUND:运行不存在或当前租户不可见。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

读取运行事件

读取 CloudEvents 账本或订阅实时事件流。默认返回 CloudEvents 账本页,Accept: text/event-stream 开启实时流,事件名为 ai.praxis.automation.run.status、ai.praxis.automation.run.progress、ai.praxis.automation.call.started、ai.praxis.automation.call.completed、ai.praxis.automation.task.started、ai.praxis.automation.task.completed、ai.praxis.automation.wait.created、ai.praxis.automation.wait.resolved。id 为续传游标,Last-Event-ID 优先于 cursor;每 20 秒发送 : ping,运行终态后以 event: end 收尾。

GET /automation/v1/runs/{id}/events

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;运行 ID(run_)。
query: limitinteger可选;每页条数,整数 1–100,默认 50。 minimum: 1;maximum: 100
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。
header: Accept"application/json" / "text/event-stream"可选;application/json(默认)读取账本页;text/event-stream 订阅实时流。
header: Last-Event-IDstring可选;SSE 续传游标,读取该事件之后的记录;优先于 cursor,仅用于实时流。

示例

先设置以下环境变量,使用你自己的资源:

: "${RUN_ID:?Set RUN_ID}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}/events" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Accept: text/event-stream"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
for await (const event of automation.runs.events({
  "path": {
    "id": env("RUN_ID")
  }
})) {
  console.log(event);
}

响应

HTTP 200

Success

application/json

字段类型说明
dataobject / object / object / object / object[]必填 / 必有;本页的账本事件(RunEvent),按事件顺序排列。
data[](分支1).type"ai.praxis.automation.run.status"必填 / 必有;事件类型:固定为 ai.praxis.automation.run.status,运行状态发生变化,data 为完整的运行。
data[](分支1).dataobject必填 / 必有;一次运行的完整状态:目标、状态、输入输出、错误、发起方、运行树位置和各类时间。 不接受额外字段。
data[](分支1).data.idstring必填 / 必有;不透明运行 ID。新建非确定性 ID 为 run_ + 10 位 base36 毫秒时间前缀 + 64 位 hex DO ID,共 78 字符;旧随机 ID 为 46 字符,历史及确定性 ID 仍有效。同毫秒内不保证创建顺序。
data[](分支1).data.kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
data[](分支1).data.numbernull / number必填 / 必有;运行在其脚本或工作流内的递增序号;临时运行为 null。
data[](分支1).data.definitionnull / object必填 / 必有;运行所属的脚本或工作流 {namespace, name};临时运行(直接传 source)为 null。
data[](分支1).data.definition(分支2).namespacestring必填 / 必有;脚本或工作流的命名空间。
data[](分支1).data.definition(分支2).namestring必填 / 必有;脚本或工作流的名字。
data[](分支1).data.targetnull / string必填 / 必有;创建时 target 参数的原文(如 acme/report@latest);临时运行为 null。
data[](分支1).data.resolved_versionnull / string必填 / 必有;target 解析到的精确版本号;临时运行为 null。
data[](分支1).data.source_digestnull / string必填 / 必有;临时运行的源码摘要,可用于读取源码;由已发布定义启动的运行为 null。
data[](分支1).data.language"ts" / "yaml"必填 / 必有;源码语言。ts 表示 TypeScript 脚本;yaml 表示工作流 YAML。
data[](分支1).data.status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败,error 给出原因;completed 成功完成,output 为结果。后三种是终态。
data[](分支1).data.progressnull / object必填 / 必有;运行报告的最新进度 {label, current, total, updated_at};未报告为 null。
data[](分支1).data.progress(分支2).labelstring必填 / 必有;进度说明文字,例如当前阶段。
data[](分支1).data.progress(分支2).currentnull / number必填 / 必有;已完成的数量;未报告为 null。
data[](分支1).data.progress(分支2).totalnull / number必填 / 必有;总量;未知为 null。
data[](分支1).data.progress(分支2).updated_atstring必填 / 必有;进度最近一次更新的时间(RFC 3339 UTC)。
data[](分支1).data.current_waitnull / object必填 / 必有;运行当前未完成的等待点;不在等待为 null。
data[](分支1).data.current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
data[](分支1).data.current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
data[](分支1).data.current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
data[](分支1).data.current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
data[](分支1).data.current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
data[](分支1).data.current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
data[](分支1).data.current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
data[](分支1).data.current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
data[](分支1).data.current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
data[](分支1).data.current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
data[](分支1).data.current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
data[](分支1).data.current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
data[](分支1).data.current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
data[](分支1).data.countersobject必填 / 必有;运行的累计计数。 不接受额外字段。
data[](分支1).data.counters.callsnumber必填 / 必有;脚本发出的调用总数。
data[](分支1).data.counters.action_callsnumber必填 / 必有;其中调用动作的次数。
data[](分支1).data.counters.child_runsnumber必填 / 必有;启动的子运行数。
data[](分支1).data.counters.tasks_completednumber必填 / 必有;工作流已完成的步骤数。
data[](分支1).data.counters.tasks_totalnull / number必填 / 必有;工作流顶层步骤总数;脚本运行为 null。
data[](分支1).data.inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
data[](分支1).data.input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
data[](分支1).data.input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[](分支1).data.outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
data[](分支1).data.output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
data[](分支1).data.output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[](分支1).data.errornull / object必填 / 必有;运行失败(faulted)时的错误详情;未失败为 null。
data[](分支1).data.error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
data[](分支1).data.error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
data[](分支1).data.error(分支2).titlestring必填 / 必有;错误的简短标题。
data[](分支1).data.error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
data[](分支1).data.error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
data[](分支1).data.error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
data[](分支1).data.error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
data[](分支1).data.error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
data[](分支1).data.error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
data[](分支1).data.error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
data[](分支1).data.error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
data[](分支1).data.error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
data[](分支1).data.error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
data[](分支1).data.error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
data[](分支1).data.error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
data[](分支1).data.error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
data[](分支1).data.error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
data[](分支1).data.error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
data[](分支1).data.error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
data[](分支1).data.initiatorobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
data[](分支1).data.initiator.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data[](分支1).data.initiator.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
data[](分支1).data.channel"run" / "console" / "api" / "internal" / "trigger"必填 / 必有;请求进入平台的渠道。console 为控制台(经 BFF);api 为公开 API 调用;internal 为平台内部服务调用;run 为由另一个运行创建的子运行;trigger 为触发器启动。
data[](分支1).data.ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
data[](分支1).data.parentnull / object必填 / 必有;派生本运行的父运行 {id, number, definition};根运行为 null。
data[](分支1).data.parent(分支2).idstring必填 / 必有;父运行 ID(run_ 前缀)。
data[](分支1).data.parent(分支2).numbernull / number必填 / 必有;父运行在其定义内的序号;父运行是临时运行时为 null。
data[](分支1).data.parent(分支2).definitionnull / object必填 / 必有;父运行所属的脚本或工作流 {namespace, name};临时运行为 null。
data[](分支1).data.parent(分支2).definition(分支2).namespacestring必填 / 必有;父运行所属定义的命名空间。
data[](分支1).data.parent(分支2).definition(分支2).namestring必填 / 必有;父运行所属定义的名字。
data[](分支1).data.parent_run_idstring / null必填 / 必有;派生出本运行的父运行 id;根运行为 null
data[](分支1).data.root_run_idstring必填 / 必有;运行树根运行的 ID;根运行自身指向自己。
data[](分支1).data.depthnumber必填 / 必有;运行树中的深度:根运行为 0,每一层子运行加 1,最大 10。
data[](分支1).data.attachnull / "wait" / "detach"必填 / 必有;子运行与父运行的关系。wait 表示父运行等待子运行结束,且子运行的截止时间不晚于父运行;detach 表示父运行不等待,也不会因父运行取消而被取消;根运行为 null。
data[](分支1).data.deadline_atstring必填 / 必有;运行的截止时间(RFC 3339 UTC):创建时间加 deadline_seconds(脚本默认且最多 300 秒,工作流默认 86400 秒、最多 604800 秒),等待型子运行不晚于父运行截止前 1 秒。
data[](分支1).data.created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
data[](分支1).data.started_atnull / string必填 / 必有;开始执行的时间(RFC 3339 UTC);仍在排队为 null。
data[](分支1).data.ended_atnull / string必填 / 必有;进入终态的时间(RFC 3339 UTC);尚未结束为 null。
data[](分支1).data.updated_atstring必填 / 必有;运行记录最近一次更新的时间(RFC 3339 UTC)。
data[](分支1).data.heartbeat_atnull / string必填 / 必有;执行器最近一次存活信号的时间(RFC 3339 UTC);尚未开始为 null。
data[](分支1).data.cancel_requested_atnull / string必填 / 必有;收到取消请求的时间(RFC 3339 UTC);未取消为 null。
data[](分支1).data.cancelled_bynull / object必填 / 必有;请求取消的主体;未取消或非人为取消为 null。
data[](分支1).data.cancelled_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data[](分支1).data.cancelled_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
data[](分支1).data.cancel_reasonnull / "user" / "parent_cancelled" / "deadline" / "executor_lost"必填 / 必有;取消原因。user 为用户取消;parent_cancelled 为父运行被取消而级联取消;deadline 为超过截止时间;executor_lost 为执行器丢失;未取消为 null。
data[](分支1).data.suspend_requested_atnull / string必填 / 必有;请求暂停工作流的时间(RFC 3339 UTC);未暂停为 null。
data[](分支1).data.suspended_bynull / object必填 / 必有;请求暂停的主体;未暂停为 null。
data[](分支1).data.suspended_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data[](分支1).data.suspended_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
data[](分支1).data.queued_msnull / number必填 / 必有;从创建到开始执行的排队毫秒数;尚未开始为 null。
data[](分支1).data.run_msnull / number必填 / 必有;实际执行毫秒数,不含等待点上的等待时间;结束后固定。
data[](分支1).data.wait_msnull / number必填 / 必有;在等待点上累计等待的毫秒数;尚无等待为 null。
data[](分支1).data.usageobject / null必填 / 必有;仅单个运行详情(含 expand)返回;列表为 null。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
data[](分支1).data.usage(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
data[](分支1).data.usage(分支1).coststring必填 / 必有;仅本运行自身的已评级实扣(不含子运行),美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
data[](分支1).data.usage(分支1).pending_eventsinteger必填 / 必有;本运行自身尚未评级的用量事件数,金额稍后才计入。 minimum: 0
data[](分支1).data.usage(分支1).by_serviceobject[]必填 / 必有;本运行按服务拆分的实扣,每项为 service 与 cost(6 位小数美元字符串);没有用量时为空数组。
data[](分支1).data.usage(分支1).by_service[].servicestring必填 / 必有;产生用量的服务名,例如 router 或 search。
data[](分支1).data.usage(分支1).by_service[].coststring必填 / 必有;该服务已评级实扣的美元十进制字符串,精确到 6 位小数。 pattern: "^[0-9]+\.[0-9]{6}$"
data[](分支1).data.usage(分支1).tree_coststring / null必填 / 必有;仅根运行返回整棵运行树的已评级实扣(含自身),6 位小数美元字符串;子运行为 null。
data[](分支1).data.rerun_ofnull / string必填 / 必有;重跑来源:本运行是对哪个运行(run_ ID)的重跑;否则为 null。
data[](分支1).data.labelsobject必填 / 必有;用户标签与系统标签;触发器运行支持 64 个用户标签,系统标签不占用名额。
data[](分支1).data.triggerobject / null必填 / 必有;启动本运行的触发器 {id, name};不是触发器启动时为 null。
data[](分支1).data.trigger(分支1).idstring必填 / 必有;启动本运行的触发器 ID(trg_ 前缀)。
data[](分支1).data.trigger(分支1).namestring必填 / 必有;启动本运行的触发器名称。
data[](分支1).data.cancel_messagestring / null必填 / 必有;用户提供的取消备注(1–500 字符);未提供时为 null,cancel_reason 枚举不变。
data[](分支1).data.input_truncatedboolean可选;列表省略外置 input 时为 true,此时 input 为 null;内联值不变,运行详情返回完整值。
data[](分支1).data.output_truncatedboolean可选;列表省略外置 output 时为 true,此时 output 为 null;内联值不变,运行详情返回完整值。
data[](分支1).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
data[](分支1).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
data[](分支1).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
data[](分支1).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
data[](分支1).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
data[](分支1).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
data[](分支2).type"ai.praxis.automation.run.progress"必填 / 必有;事件类型:固定为 ai.praxis.automation.run.progress,运行上报了新进度,data 为进度。
data[](分支2).dataobject必填 / 必有;运行报告的进度,包含说明、已完成量与总量。 不接受额外字段。
data[](分支2).data.labelstring必填 / 必有;进度说明文字,例如当前阶段。
data[](分支2).data.currentnull / number必填 / 必有;已完成的数量;未报告为 null。
data[](分支2).data.totalnull / number必填 / 必有;总量;未知为 null。
data[](分支2).data.updated_atstring必填 / 必有;进度最近一次更新的时间(RFC 3339 UTC)。
data[](分支2).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
data[](分支2).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
data[](分支2).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
data[](分支2).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
data[](分支2).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
data[](分支2).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
data[](分支3).type"ai.praxis.automation.call.started" / "ai.praxis.automation.call.completed"必填 / 必有;事件类型。ai.praxis.automation.call.started 调用开始;ai.praxis.automation.call.completed 调用结束(成功或失败);data 为调用记录。
data[](分支3).dataobject必填 / 必有;脚本运行中的一次调用记录(动作、平台 API、脚本或工作流),按 seq 顺序排列。 不接受额外字段。
data[](分支3).data.idstring必填 / 必有;调用 ID,前缀 call_。
data[](分支3).data.run_idstring必填 / 必有;发出该调用的脚本运行 ID(run_ 前缀)。
data[](分支3).data.seqnumber必填 / 必有;调用在该运行中的序号,随调用顺序递增;与 run_id 一起定位这次调用。
data[](分支3).data.targetobject必填 / 必有;被调用的目标 {kind, name, revision?, version?}。 不接受额外字段。
data[](分支3).data.target.kind"action" / "script" / "workflow" / "platform_api"必填 / 必有;目标类型。action 为动作;platform_api 为平台 API 操作;script 为脚本;workflow 为工作流。
data[](分支3).data.target.namestring必填 / 必有;目标名称:动作为 ns/name,平台 API 为操作名,脚本与工作流为 ns/name。
data[](分支3).data.target.revisionstring可选;实际执行的动作修订 ID(actr_ 前缀);仅动作调用有。
data[](分支3).data.target.versionstring可选;实际运行的精确版本号;仅脚本与工作流调用有。
data[](分支3).data.args_previewstring必填 / 必有;调用参数的单行预览,由服务端截断;超过 32 KB 的原文存放在对象存储而不内联。
data[](分支3).data.result_previewnull / string必填 / 必有;返回值的单行预览,由服务端截断;调用结束前为 null。
data[](分支3).data.status"running" / "completed" / "faulted" / "cancelled"必填 / 必有;调用状态。running 执行中;completed 已正常返回;faulted 失败,error 给出原因;cancelled 因运行被取消而中止。
data[](分支3).data.started_atstring必填 / 必有;调用开始的时间(RFC 3339 UTC)。
data[](分支3).data.ended_atnull / string必填 / 必有;调用结束的时间(RFC 3339 UTC);仍在执行为 null。
data[](分支3).data.duration_msnull / number必填 / 必有;从开始到结束的毫秒数;未结束为 null。
data[](分支3).data.errornull / object必填 / 必有;调用失败时的错误详情;成功或仍在执行为 null。
data[](分支3).data.error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
data[](分支3).data.error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
data[](分支3).data.error(分支2).titlestring必填 / 必有;错误的简短标题。
data[](分支3).data.error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
data[](分支3).data.error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
data[](分支3).data.error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
data[](分支3).data.error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
data[](分支3).data.error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
data[](分支3).data.error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
data[](分支3).data.error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
data[](分支3).data.error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
data[](分支3).data.error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
data[](分支3).data.error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
data[](分支3).data.error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
data[](分支3).data.error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
data[](分支3).data.error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
data[](分支3).data.error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
data[](分支3).data.error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
data[](分支3).data.error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
data[](分支3).data.child_run_idnull / string必填 / 必有;目标是脚本或工作流时,由本次调用启动的子运行 ID;动作与平台 API 调用为 null。
data[](分支3).data.invocation_keystring必填 / 必有;标识这一次逻辑调用的键,随调用发往下游,使至少一次语义下的重试可被去重。
data[](分支3).data.request_idstring / null必填 / 必有;下游响应的 X-Request-Id;尚未收到响应或响应未提供该头时为 null。
data[](分支3).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
data[](分支3).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
data[](分支3).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
data[](分支3).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
data[](分支3).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
data[](分支3).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
data[](分支4).type"ai.praxis.automation.task.started" / "ai.praxis.automation.task.completed"必填 / 必有;事件类型。ai.praxis.automation.task.started 步骤开始;ai.praxis.automation.task.completed 步骤结束;data 为步骤记录。
data[](分支4).dataobject必填 / 必有;工作流中一个步骤的一次执行记录。循环会让同一步骤产生多条记录(iteration 不同),重试会让 attempt 递增。 不接受额外字段。
data[](分支4).data.idstring必填 / 必有;步骤执行记录的标识,按不透明字符串处理。
data[](分支4).data.run_idstring必填 / 必有;所属运行 ID。
data[](分支4).data.referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start。
data[](分支4).data.namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
data[](分支4).data.kind"run" / "call" / "wait" / "set" / "for" / "fork" / "try" / "switch" / "emit" / "raise" / "listen" / "do"必填 / 必有;工作流步骤类型。call 调用动作;run 运行子脚本或子工作流;wait 等待时长;set 设置变量;for 循环;fork 并行分支;try 带捕获的块;switch 条件分支;emit 发出事件;raise 抛出错误;listen 等待事件;do 顺序执行的步骤块。
data[](分支4).data.iterationnumber[]必填 / 必有;外层 for 循环的当前迭代下标,由外到内;不在循环中为空数组。
data[](分支4).data.attemptnumber必填 / 必有;第几次尝试;步骤因重试而重新执行时递增。
data[](分支4).data.status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;步骤状态,取值与运行状态相同。pending 尚未开始;running 执行中;waiting 在等待事件、定时器或子运行;suspended 因运行被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
data[](分支4).data.skippedboolean必填 / 必有;true 表示该步骤被跳过而没有实际执行。
data[](分支4).data.started_atnull / string必填 / 必有;步骤开始的时间(RFC 3339 UTC);未开始为 null。
data[](分支4).data.ended_atnull / string必填 / 必有;步骤结束的时间(RFC 3339 UTC);未结束为 null。
data[](分支4).data.duration_msnull / number必填 / 必有;执行耗时毫秒数;未结束为 null。
data[](分支4).data.inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
data[](分支4).data.input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
data[](分支4).data.input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[](分支4).data.input_truncatedboolean必填 / 必有;true 表示 input 超过 32 KB 已被截断。
data[](分支4).data.outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
data[](分支4).data.output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
data[](分支4).data.output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[](分支4).data.output_truncatedboolean必填 / 必有;输出超过内联限制而被省略时为 true。
data[](分支4).data.errornull / object必填 / 必有;步骤失败时的错误详情;未失败为 null。
data[](分支4).data.error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
data[](分支4).data.error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
data[](分支4).data.error(分支2).titlestring必填 / 必有;错误的简短标题。
data[](分支4).data.error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
data[](分支4).data.error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
data[](分支4).data.error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
data[](分支4).data.error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
data[](分支4).data.error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
data[](分支4).data.error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
data[](分支4).data.error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
data[](分支4).data.error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
data[](分支4).data.error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
data[](分支4).data.error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
data[](分支4).data.error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
data[](分支4).data.error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
data[](分支4).data.error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
data[](分支4).data.error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
data[](分支4).data.error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
data[](分支4).data.error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
data[](分支4).data.actionnull / object必填 / 必有;call 步骤执行的动作 {name, revision};其它步骤为 null。
data[](分支4).data.action(分支2).namestring必填 / 必有;动作全名 ns/name。
data[](分支4).data.action(分支2).revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
data[](分支4).data.child_runnull / object必填 / 必有;run 步骤启动的子运行摘要 {id, number, status, resolved_version};其它步骤为 null。
data[](分支4).data.child_run(分支2).idstring必填 / 必有;子运行 ID(run_ 前缀),创建后即可读取。
data[](分支4).data.child_run(分支2).numbernull / number必填 / 必有;子运行在其定义内的序号;临时运行为 null。
data[](分支4).data.child_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;子运行的状态。pending 尚未开始;running 执行中;waiting 在等待;suspended 已暂停;cancelled 已取消;faulted 失败;completed 成功完成。等待型子运行在结束时补全终态,detach 的子运行只记录启动时的状态。
data[](分支4).data.child_run(分支2).resolved_versionnull / string必填 / 必有;子运行解析到的精确版本号;临时运行为 null。
data[](分支4).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
data[](分支4).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
data[](分支4).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
data[](分支4).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
data[](分支4).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
data[](分支4).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
data[](分支5).type"ai.praxis.automation.wait.created" / "ai.praxis.automation.wait.resolved"必填 / 必有;事件类型。ai.praxis.automation.wait.created 等待点创建;ai.praxis.automation.wait.resolved 等待点被满足、到期或取消;data 为等待点。
data[](分支5).dataobject必填 / 必有;运行上的一个等待点,工作流在它被满足、到期或取消之前不会继续。 不接受额外字段。
data[](分支5).data.idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
data[](分支5).data.run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
data[](分支5).data.kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
data[](分支5).data.state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
data[](分支5).data.tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
data[](分支5).data.task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
data[](分支5).data.task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
data[](分支5).data.resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
data[](分支5).data.event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
data[](分支5).data.child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
data[](分支5).data.created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
data[](分支5).data.expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
data[](分支5).data.resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
data[](分支5).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
data[](分支5).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
data[](分支5).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
data[](分支5).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
data[](分支5).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
data[](分支5).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

text/event-stream

字段类型说明
idstring可选;Resume cursor of this entry; send it back as Last-Event-ID, or as cursor on the JSON form, to continue after it. Absent on the end event.
event"ai.praxis.automation.run.status" / "ai.praxis.automation.run.progress" / "ai.praxis.automation.call.started" / "ai.praxis.automation.call.completed" / "ai.praxis.automation.task.started" / "ai.praxis.automation.task.completed" / "ai.praxis.automation.wait.created" / "ai.praxis.automation.wait.resolved" / "end"必填 / 必有;SSE event name: one of ai.praxis.automation.run.status, ai.praxis.automation.run.progress, ai.praxis.automation.call.started, ai.praxis.automation.call.completed, ai.praxis.automation.task.started, ai.praxis.automation.task.completed, ai.praxis.automation.wait.created, ai.praxis.automation.wait.resolved, naming the RunEvent type carried in data; end is sent once when the run has reached a terminal status and closes the stream.
dataobject / object / object / object / object / object必填 / 必有;Decoded JSON of one run event, whose shape is selected by its type; for the end event, an empty object.
data(分支1)(分支1).type"ai.praxis.automation.run.status"必填 / 必有;事件类型:固定为 ai.praxis.automation.run.status,运行状态发生变化,data 为完整的运行。
data(分支1)(分支1).dataobject必填 / 必有;一次运行的完整状态:目标、状态、输入输出、错误、发起方、运行树位置和各类时间。 不接受额外字段。
data(分支1)(分支1).data.idstring必填 / 必有;不透明运行 ID。新建非确定性 ID 为 run_ + 10 位 base36 毫秒时间前缀 + 64 位 hex DO ID,共 78 字符;旧随机 ID 为 46 字符,历史及确定性 ID 仍有效。同毫秒内不保证创建顺序。
data(分支1)(分支1).data.kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
data(分支1)(分支1).data.numbernull / number必填 / 必有;运行在其脚本或工作流内的递增序号;临时运行为 null。
data(分支1)(分支1).data.definitionnull / object必填 / 必有;运行所属的脚本或工作流 {namespace, name};临时运行(直接传 source)为 null。
data(分支1)(分支1).data.definition(分支2).namespacestring必填 / 必有;脚本或工作流的命名空间。
data(分支1)(分支1).data.definition(分支2).namestring必填 / 必有;脚本或工作流的名字。
data(分支1)(分支1).data.targetnull / string必填 / 必有;创建时 target 参数的原文(如 acme/report@latest);临时运行为 null。
data(分支1)(分支1).data.resolved_versionnull / string必填 / 必有;target 解析到的精确版本号;临时运行为 null。
data(分支1)(分支1).data.source_digestnull / string必填 / 必有;临时运行的源码摘要,可用于读取源码;由已发布定义启动的运行为 null。
data(分支1)(分支1).data.language"ts" / "yaml"必填 / 必有;源码语言。ts 表示 TypeScript 脚本;yaml 表示工作流 YAML。
data(分支1)(分支1).data.status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败,error 给出原因;completed 成功完成,output 为结果。后三种是终态。
data(分支1)(分支1).data.progressnull / object必填 / 必有;运行报告的最新进度 {label, current, total, updated_at};未报告为 null。
data(分支1)(分支1).data.progress(分支2).labelstring必填 / 必有;进度说明文字,例如当前阶段。
data(分支1)(分支1).data.progress(分支2).currentnull / number必填 / 必有;已完成的数量;未报告为 null。
data(分支1)(分支1).data.progress(分支2).totalnull / number必填 / 必有;总量;未知为 null。
data(分支1)(分支1).data.progress(分支2).updated_atstring必填 / 必有;进度最近一次更新的时间(RFC 3339 UTC)。
data(分支1)(分支1).data.current_waitnull / object必填 / 必有;运行当前未完成的等待点;不在等待为 null。
data(分支1)(分支1).data.current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
data(分支1)(分支1).data.current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
data(分支1)(分支1).data.current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
data(分支1)(分支1).data.current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
data(分支1)(分支1).data.current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
data(分支1)(分支1).data.current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
data(分支1)(分支1).data.current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
data(分支1)(分支1).data.current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
data(分支1)(分支1).data.current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
data(分支1)(分支1).data.current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
data(分支1)(分支1).data.current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
data(分支1)(分支1).data.current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
data(分支1)(分支1).data.current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
data(分支1)(分支1).data.countersobject必填 / 必有;运行的累计计数。 不接受额外字段。
data(分支1)(分支1).data.counters.callsnumber必填 / 必有;脚本发出的调用总数。
data(分支1)(分支1).data.counters.action_callsnumber必填 / 必有;其中调用动作的次数。
data(分支1)(分支1).data.counters.child_runsnumber必填 / 必有;启动的子运行数。
data(分支1)(分支1).data.counters.tasks_completednumber必填 / 必有;工作流已完成的步骤数。
data(分支1)(分支1).data.counters.tasks_totalnull / number必填 / 必有;工作流顶层步骤总数;脚本运行为 null。
data(分支1)(分支1).data.inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
data(分支1)(分支1).data.input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
data(分支1)(分支1).data.input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data(分支1)(分支1).data.outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
data(分支1)(分支1).data.output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
data(分支1)(分支1).data.output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data(分支1)(分支1).data.errornull / object必填 / 必有;运行失败(faulted)时的错误详情;未失败为 null。
data(分支1)(分支1).data.error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
data(分支1)(分支1).data.error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
data(分支1)(分支1).data.error(分支2).titlestring必填 / 必有;错误的简短标题。
data(分支1)(分支1).data.error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
data(分支1)(分支1).data.error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
data(分支1)(分支1).data.error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
data(分支1)(分支1).data.error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
data(分支1)(分支1).data.error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
data(分支1)(分支1).data.error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
data(分支1)(分支1).data.error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
data(分支1)(分支1).data.error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
data(分支1)(分支1).data.error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
data(分支1)(分支1).data.error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
data(分支1)(分支1).data.error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
data(分支1)(分支1).data.error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
data(分支1)(分支1).data.error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
data(分支1)(分支1).data.error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
data(分支1)(分支1).data.error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
data(分支1)(分支1).data.error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
data(分支1)(分支1).data.initiatorobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
data(分支1)(分支1).data.initiator.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data(分支1)(分支1).data.initiator.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
data(分支1)(分支1).data.channel"run" / "console" / "api" / "internal" / "trigger"必填 / 必有;请求进入平台的渠道。console 为控制台(经 BFF);api 为公开 API 调用;internal 为平台内部服务调用;run 为由另一个运行创建的子运行;trigger 为触发器启动。
data(分支1)(分支1).data.ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
data(分支1)(分支1).data.parentnull / object必填 / 必有;派生本运行的父运行 {id, number, definition};根运行为 null。
data(分支1)(分支1).data.parent(分支2).idstring必填 / 必有;父运行 ID(run_ 前缀)。
data(分支1)(分支1).data.parent(分支2).numbernull / number必填 / 必有;父运行在其定义内的序号;父运行是临时运行时为 null。
data(分支1)(分支1).data.parent(分支2).definitionnull / object必填 / 必有;父运行所属的脚本或工作流 {namespace, name};临时运行为 null。
data(分支1)(分支1).data.parent(分支2).definition(分支2).namespacestring必填 / 必有;父运行所属定义的命名空间。
data(分支1)(分支1).data.parent(分支2).definition(分支2).namestring必填 / 必有;父运行所属定义的名字。
data(分支1)(分支1).data.parent_run_idstring / null必填 / 必有;派生出本运行的父运行 id;根运行为 null
data(分支1)(分支1).data.root_run_idstring必填 / 必有;运行树根运行的 ID;根运行自身指向自己。
data(分支1)(分支1).data.depthnumber必填 / 必有;运行树中的深度:根运行为 0,每一层子运行加 1,最大 10。
data(分支1)(分支1).data.attachnull / "wait" / "detach"必填 / 必有;子运行与父运行的关系。wait 表示父运行等待子运行结束,且子运行的截止时间不晚于父运行;detach 表示父运行不等待,也不会因父运行取消而被取消;根运行为 null。
data(分支1)(分支1).data.deadline_atstring必填 / 必有;运行的截止时间(RFC 3339 UTC):创建时间加 deadline_seconds(脚本默认且最多 300 秒,工作流默认 86400 秒、最多 604800 秒),等待型子运行不晚于父运行截止前 1 秒。
data(分支1)(分支1).data.created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
data(分支1)(分支1).data.started_atnull / string必填 / 必有;开始执行的时间(RFC 3339 UTC);仍在排队为 null。
data(分支1)(分支1).data.ended_atnull / string必填 / 必有;进入终态的时间(RFC 3339 UTC);尚未结束为 null。
data(分支1)(分支1).data.updated_atstring必填 / 必有;运行记录最近一次更新的时间(RFC 3339 UTC)。
data(分支1)(分支1).data.heartbeat_atnull / string必填 / 必有;执行器最近一次存活信号的时间(RFC 3339 UTC);尚未开始为 null。
data(分支1)(分支1).data.cancel_requested_atnull / string必填 / 必有;收到取消请求的时间(RFC 3339 UTC);未取消为 null。
data(分支1)(分支1).data.cancelled_bynull / object必填 / 必有;请求取消的主体;未取消或非人为取消为 null。
data(分支1)(分支1).data.cancelled_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data(分支1)(分支1).data.cancelled_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
data(分支1)(分支1).data.cancel_reasonnull / "user" / "parent_cancelled" / "deadline" / "executor_lost"必填 / 必有;取消原因。user 为用户取消;parent_cancelled 为父运行被取消而级联取消;deadline 为超过截止时间;executor_lost 为执行器丢失;未取消为 null。
data(分支1)(分支1).data.suspend_requested_atnull / string必填 / 必有;请求暂停工作流的时间(RFC 3339 UTC);未暂停为 null。
data(分支1)(分支1).data.suspended_bynull / object必填 / 必有;请求暂停的主体;未暂停为 null。
data(分支1)(分支1).data.suspended_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data(分支1)(分支1).data.suspended_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
data(分支1)(分支1).data.queued_msnull / number必填 / 必有;从创建到开始执行的排队毫秒数;尚未开始为 null。
data(分支1)(分支1).data.run_msnull / number必填 / 必有;实际执行毫秒数,不含等待点上的等待时间;结束后固定。
data(分支1)(分支1).data.wait_msnull / number必填 / 必有;在等待点上累计等待的毫秒数;尚无等待为 null。
data(分支1)(分支1).data.usageobject / null必填 / 必有;仅单个运行详情(含 expand)返回;列表为 null。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
data(分支1)(分支1).data.usage(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
data(分支1)(分支1).data.usage(分支1).coststring必填 / 必有;仅本运行自身的已评级实扣(不含子运行),美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
data(分支1)(分支1).data.usage(分支1).pending_eventsinteger必填 / 必有;本运行自身尚未评级的用量事件数,金额稍后才计入。 minimum: 0
data(分支1)(分支1).data.usage(分支1).by_serviceobject[]必填 / 必有;本运行按服务拆分的实扣,每项为 service 与 cost(6 位小数美元字符串);没有用量时为空数组。
data(分支1)(分支1).data.usage(分支1).by_service[].servicestring必填 / 必有;产生用量的服务名,例如 router 或 search。
data(分支1)(分支1).data.usage(分支1).by_service[].coststring必填 / 必有;该服务已评级实扣的美元十进制字符串,精确到 6 位小数。 pattern: "^[0-9]+\.[0-9]{6}$"
data(分支1)(分支1).data.usage(分支1).tree_coststring / null必填 / 必有;仅根运行返回整棵运行树的已评级实扣(含自身),6 位小数美元字符串;子运行为 null。
data(分支1)(分支1).data.rerun_ofnull / string必填 / 必有;重跑来源:本运行是对哪个运行(run_ ID)的重跑;否则为 null。
data(分支1)(分支1).data.labelsobject必填 / 必有;用户标签与系统标签;触发器运行支持 64 个用户标签,系统标签不占用名额。
data(分支1)(分支1).data.triggerobject / null必填 / 必有;启动本运行的触发器 {id, name};不是触发器启动时为 null。
data(分支1)(分支1).data.trigger(分支1).idstring必填 / 必有;启动本运行的触发器 ID(trg_ 前缀)。
data(分支1)(分支1).data.trigger(分支1).namestring必填 / 必有;启动本运行的触发器名称。
data(分支1)(分支1).data.cancel_messagestring / null必填 / 必有;用户提供的取消备注(1–500 字符);未提供时为 null,cancel_reason 枚举不变。
data(分支1)(分支1).data.input_truncatedboolean可选;列表省略外置 input 时为 true,此时 input 为 null;内联值不变,运行详情返回完整值。
data(分支1)(分支1).data.output_truncatedboolean可选;列表省略外置 output 时为 true,此时 output 为 null;内联值不变,运行详情返回完整值。
data(分支1)(分支1).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
data(分支1)(分支1).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
data(分支1)(分支1).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
data(分支1)(分支1).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
data(分支1)(分支1).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
data(分支1)(分支1).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
data(分支1)(分支2).type"ai.praxis.automation.run.progress"必填 / 必有;事件类型:固定为 ai.praxis.automation.run.progress,运行上报了新进度,data 为进度。
data(分支1)(分支2).dataobject必填 / 必有;运行报告的进度,包含说明、已完成量与总量。 不接受额外字段。
data(分支1)(分支2).data.labelstring必填 / 必有;进度说明文字,例如当前阶段。
data(分支1)(分支2).data.currentnull / number必填 / 必有;已完成的数量;未报告为 null。
data(分支1)(分支2).data.totalnull / number必填 / 必有;总量;未知为 null。
data(分支1)(分支2).data.updated_atstring必填 / 必有;进度最近一次更新的时间(RFC 3339 UTC)。
data(分支1)(分支2).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
data(分支1)(分支2).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
data(分支1)(分支2).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
data(分支1)(分支2).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
data(分支1)(分支2).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
data(分支1)(分支2).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
data(分支1)(分支3).type"ai.praxis.automation.call.started" / "ai.praxis.automation.call.completed"必填 / 必有;事件类型。ai.praxis.automation.call.started 调用开始;ai.praxis.automation.call.completed 调用结束(成功或失败);data 为调用记录。
data(分支1)(分支3).dataobject必填 / 必有;脚本运行中的一次调用记录(动作、平台 API、脚本或工作流),按 seq 顺序排列。 不接受额外字段。
data(分支1)(分支3).data.idstring必填 / 必有;调用 ID,前缀 call_。
data(分支1)(分支3).data.run_idstring必填 / 必有;发出该调用的脚本运行 ID(run_ 前缀)。
data(分支1)(分支3).data.seqnumber必填 / 必有;调用在该运行中的序号,随调用顺序递增;与 run_id 一起定位这次调用。
data(分支1)(分支3).data.targetobject必填 / 必有;被调用的目标 {kind, name, revision?, version?}。 不接受额外字段。
data(分支1)(分支3).data.target.kind"action" / "script" / "workflow" / "platform_api"必填 / 必有;目标类型。action 为动作;platform_api 为平台 API 操作;script 为脚本;workflow 为工作流。
data(分支1)(分支3).data.target.namestring必填 / 必有;目标名称:动作为 ns/name,平台 API 为操作名,脚本与工作流为 ns/name。
data(分支1)(分支3).data.target.revisionstring可选;实际执行的动作修订 ID(actr_ 前缀);仅动作调用有。
data(分支1)(分支3).data.target.versionstring可选;实际运行的精确版本号;仅脚本与工作流调用有。
data(分支1)(分支3).data.args_previewstring必填 / 必有;调用参数的单行预览,由服务端截断;超过 32 KB 的原文存放在对象存储而不内联。
data(分支1)(分支3).data.result_previewnull / string必填 / 必有;返回值的单行预览,由服务端截断;调用结束前为 null。
data(分支1)(分支3).data.status"running" / "completed" / "faulted" / "cancelled"必填 / 必有;调用状态。running 执行中;completed 已正常返回;faulted 失败,error 给出原因;cancelled 因运行被取消而中止。
data(分支1)(分支3).data.started_atstring必填 / 必有;调用开始的时间(RFC 3339 UTC)。
data(分支1)(分支3).data.ended_atnull / string必填 / 必有;调用结束的时间(RFC 3339 UTC);仍在执行为 null。
data(分支1)(分支3).data.duration_msnull / number必填 / 必有;从开始到结束的毫秒数;未结束为 null。
data(分支1)(分支3).data.errornull / object必填 / 必有;调用失败时的错误详情;成功或仍在执行为 null。
data(分支1)(分支3).data.error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
data(分支1)(分支3).data.error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
data(分支1)(分支3).data.error(分支2).titlestring必填 / 必有;错误的简短标题。
data(分支1)(分支3).data.error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
data(分支1)(分支3).data.error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
data(分支1)(分支3).data.error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
data(分支1)(分支3).data.error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
data(分支1)(分支3).data.error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
data(分支1)(分支3).data.error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
data(分支1)(分支3).data.error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
data(分支1)(分支3).data.error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
data(分支1)(分支3).data.error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
data(分支1)(分支3).data.error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
data(分支1)(分支3).data.error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
data(分支1)(分支3).data.error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
data(分支1)(分支3).data.error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
data(分支1)(分支3).data.error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
data(分支1)(分支3).data.error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
data(分支1)(分支3).data.error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
data(分支1)(分支3).data.child_run_idnull / string必填 / 必有;目标是脚本或工作流时,由本次调用启动的子运行 ID;动作与平台 API 调用为 null。
data(分支1)(分支3).data.invocation_keystring必填 / 必有;标识这一次逻辑调用的键,随调用发往下游,使至少一次语义下的重试可被去重。
data(分支1)(分支3).data.request_idstring / null必填 / 必有;下游响应的 X-Request-Id;尚未收到响应或响应未提供该头时为 null。
data(分支1)(分支3).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
data(分支1)(分支3).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
data(分支1)(分支3).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
data(分支1)(分支3).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
data(分支1)(分支3).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
data(分支1)(分支3).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
data(分支1)(分支4).type"ai.praxis.automation.task.started" / "ai.praxis.automation.task.completed"必填 / 必有;事件类型。ai.praxis.automation.task.started 步骤开始;ai.praxis.automation.task.completed 步骤结束;data 为步骤记录。
data(分支1)(分支4).dataobject必填 / 必有;工作流中一个步骤的一次执行记录。循环会让同一步骤产生多条记录(iteration 不同),重试会让 attempt 递增。 不接受额外字段。
data(分支1)(分支4).data.idstring必填 / 必有;步骤执行记录的标识,按不透明字符串处理。
data(分支1)(分支4).data.run_idstring必填 / 必有;所属运行 ID。
data(分支1)(分支4).data.referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start。
data(分支1)(分支4).data.namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
data(分支1)(分支4).data.kind"run" / "call" / "wait" / "set" / "for" / "fork" / "try" / "switch" / "emit" / "raise" / "listen" / "do"必填 / 必有;工作流步骤类型。call 调用动作;run 运行子脚本或子工作流;wait 等待时长;set 设置变量;for 循环;fork 并行分支;try 带捕获的块;switch 条件分支;emit 发出事件;raise 抛出错误;listen 等待事件;do 顺序执行的步骤块。
data(分支1)(分支4).data.iterationnumber[]必填 / 必有;外层 for 循环的当前迭代下标,由外到内;不在循环中为空数组。
data(分支1)(分支4).data.attemptnumber必填 / 必有;第几次尝试;步骤因重试而重新执行时递增。
data(分支1)(分支4).data.status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;步骤状态,取值与运行状态相同。pending 尚未开始;running 执行中;waiting 在等待事件、定时器或子运行;suspended 因运行被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
data(分支1)(分支4).data.skippedboolean必填 / 必有;true 表示该步骤被跳过而没有实际执行。
data(分支1)(分支4).data.started_atnull / string必填 / 必有;步骤开始的时间(RFC 3339 UTC);未开始为 null。
data(分支1)(分支4).data.ended_atnull / string必填 / 必有;步骤结束的时间(RFC 3339 UTC);未结束为 null。
data(分支1)(分支4).data.duration_msnull / number必填 / 必有;执行耗时毫秒数;未结束为 null。
data(分支1)(分支4).data.inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
data(分支1)(分支4).data.input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
data(分支1)(分支4).data.input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data(分支1)(分支4).data.input_truncatedboolean必填 / 必有;true 表示 input 超过 32 KB 已被截断。
data(分支1)(分支4).data.outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
data(分支1)(分支4).data.output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
data(分支1)(分支4).data.output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data(分支1)(分支4).data.output_truncatedboolean必填 / 必有;输出超过内联限制而被省略时为 true。
data(分支1)(分支4).data.errornull / object必填 / 必有;步骤失败时的错误详情;未失败为 null。
data(分支1)(分支4).data.error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
data(分支1)(分支4).data.error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
data(分支1)(分支4).data.error(分支2).titlestring必填 / 必有;错误的简短标题。
data(分支1)(分支4).data.error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
data(分支1)(分支4).data.error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
data(分支1)(分支4).data.error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
data(分支1)(分支4).data.error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
data(分支1)(分支4).data.error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
data(分支1)(分支4).data.error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
data(分支1)(分支4).data.error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
data(分支1)(分支4).data.error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
data(分支1)(分支4).data.error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
data(分支1)(分支4).data.error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
data(分支1)(分支4).data.error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
data(分支1)(分支4).data.error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
data(分支1)(分支4).data.error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
data(分支1)(分支4).data.error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
data(分支1)(分支4).data.error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
data(分支1)(分支4).data.error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
data(分支1)(分支4).data.actionnull / object必填 / 必有;call 步骤执行的动作 {name, revision};其它步骤为 null。
data(分支1)(分支4).data.action(分支2).namestring必填 / 必有;动作全名 ns/name。
data(分支1)(分支4).data.action(分支2).revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
data(分支1)(分支4).data.child_runnull / object必填 / 必有;run 步骤启动的子运行摘要 {id, number, status, resolved_version};其它步骤为 null。
data(分支1)(分支4).data.child_run(分支2).idstring必填 / 必有;子运行 ID(run_ 前缀),创建后即可读取。
data(分支1)(分支4).data.child_run(分支2).numbernull / number必填 / 必有;子运行在其定义内的序号;临时运行为 null。
data(分支1)(分支4).data.child_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;子运行的状态。pending 尚未开始;running 执行中;waiting 在等待;suspended 已暂停;cancelled 已取消;faulted 失败;completed 成功完成。等待型子运行在结束时补全终态,detach 的子运行只记录启动时的状态。
data(分支1)(分支4).data.child_run(分支2).resolved_versionnull / string必填 / 必有;子运行解析到的精确版本号;临时运行为 null。
data(分支1)(分支4).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
data(分支1)(分支4).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
data(分支1)(分支4).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
data(分支1)(分支4).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
data(分支1)(分支4).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
data(分支1)(分支4).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
data(分支1)(分支5).type"ai.praxis.automation.wait.created" / "ai.praxis.automation.wait.resolved"必填 / 必有;事件类型。ai.praxis.automation.wait.created 等待点创建;ai.praxis.automation.wait.resolved 等待点被满足、到期或取消;data 为等待点。
data(分支1)(分支5).dataobject必填 / 必有;运行上的一个等待点,工作流在它被满足、到期或取消之前不会继续。 不接受额外字段。
data(分支1)(分支5).data.idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
data(分支1)(分支5).data.run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
data(分支1)(分支5).data.kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
data(分支1)(分支5).data.state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
data(分支1)(分支5).data.tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
data(分支1)(分支5).data.task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
data(分支1)(分支5).data.task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
data(分支1)(分支5).data.resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
data(分支1)(分支5).data.event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
data(分支1)(分支5).data.child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
data(分支1)(分支5).data.created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
data(分支1)(分支5).data.expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
data(分支1)(分支5).data.resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
data(分支1)(分支5).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
data(分支1)(分支5).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
data(分支1)(分支5).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
data(分支1)(分支5).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
data(分支1)(分支5).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
data(分支1)(分支5).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
(分支1).event"ai.praxis.automation.run.status" / "ai.praxis.automation.run.progress" / "ai.praxis.automation.call.started" / "ai.praxis.automation.call.completed" / "ai.praxis.automation.task.started" / "ai.praxis.automation.task.completed" / "ai.praxis.automation.wait.created" / "ai.praxis.automation.wait.resolved"可选;SSE event name: one of ai.praxis.automation.run.status, ai.praxis.automation.run.progress, ai.praxis.automation.call.started, ai.praxis.automation.call.completed, ai.praxis.automation.task.started, ai.praxis.automation.task.completed, ai.praxis.automation.wait.created, ai.praxis.automation.wait.resolved, naming the RunEvent type carried in data.
(分支1).dataobject / object / object / object / object可选;运行账本中的一条 CloudEvents 事件,载荷带完整投影,收到后不必回拉。type 决定 data 的类型:run.status 为运行,run.progress 为进度,call.* 为调用,task.* 为步骤,wait.* 为等待点。
(分支1).data(分支1).type"ai.praxis.automation.run.status"必填 / 必有;事件类型:固定为 ai.praxis.automation.run.status,运行状态发生变化,data 为完整的运行。
(分支1).data(分支1).dataobject必填 / 必有;一次运行的完整状态:目标、状态、输入输出、错误、发起方、运行树位置和各类时间。 不接受额外字段。
(分支1).data(分支1).data.idstring必填 / 必有;不透明运行 ID。新建非确定性 ID 为 run_ + 10 位 base36 毫秒时间前缀 + 64 位 hex DO ID,共 78 字符;旧随机 ID 为 46 字符,历史及确定性 ID 仍有效。同毫秒内不保证创建顺序。
(分支1).data(分支1).data.kind"script" / "workflow"必填 / 必有;编排类型。script 为 TypeScript 脚本,一次执行;workflow 为 YAML 工作流,由步骤组成,可等待事件、定时器或子运行并可暂停。
(分支1).data(分支1).data.numbernull / number必填 / 必有;运行在其脚本或工作流内的递增序号;临时运行为 null。
(分支1).data(分支1).data.definitionnull / object必填 / 必有;运行所属的脚本或工作流 {namespace, name};临时运行(直接传 source)为 null。
(分支1).data(分支1).data.definition(分支2).namespacestring必填 / 必有;脚本或工作流的命名空间。
(分支1).data(分支1).data.definition(分支2).namestring必填 / 必有;脚本或工作流的名字。
(分支1).data(分支1).data.targetnull / string必填 / 必有;创建时 target 参数的原文(如 acme/report@latest);临时运行为 null。
(分支1).data(分支1).data.resolved_versionnull / string必填 / 必有;target 解析到的精确版本号;临时运行为 null。
(分支1).data(分支1).data.source_digestnull / string必填 / 必有;临时运行的源码摘要,可用于读取源码;由已发布定义启动的运行为 null。
(分支1).data(分支1).data.language"ts" / "yaml"必填 / 必有;源码语言。ts 表示 TypeScript 脚本;yaml 表示工作流 YAML。
(分支1).data(分支1).data.status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;运行状态。pending 已创建尚未开始;running 执行中;waiting 工作流在等待事件、定时器或子运行;suspended 工作流被暂停;cancelled 已取消;faulted 失败,error 给出原因;completed 成功完成,output 为结果。后三种是终态。
(分支1).data(分支1).data.progressnull / object必填 / 必有;运行报告的最新进度 {label, current, total, updated_at};未报告为 null。
(分支1).data(分支1).data.progress(分支2).labelstring必填 / 必有;进度说明文字,例如当前阶段。
(分支1).data(分支1).data.progress(分支2).currentnull / number必填 / 必有;已完成的数量;未报告为 null。
(分支1).data(分支1).data.progress(分支2).totalnull / number必填 / 必有;总量;未知为 null。
(分支1).data(分支1).data.progress(分支2).updated_atstring必填 / 必有;进度最近一次更新的时间(RFC 3339 UTC)。
(分支1).data(分支1).data.current_waitnull / object必填 / 必有;运行当前未完成的等待点;不在等待为 null。
(分支1).data(分支1).data.current_wait(分支2).idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
(分支1).data(分支1).data.current_wait(分支2).run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
(分支1).data(分支1).data.current_wait(分支2).kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
(分支1).data(分支1).data.current_wait(分支2).state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
(分支1).data(分支1).data.current_wait(分支2).tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
(分支1).data(分支1).data.current_wait(分支2).task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
(分支1).data(分支1).data.current_wait(分支2).task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
(分支1).data(分支1).data.current_wait(分支2).resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
(分支1).data(分支1).data.current_wait(分支2).event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
(分支1).data(分支1).data.current_wait(分支2).child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
(分支1).data(分支1).data.current_wait(分支2).created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
(分支1).data(分支1).data.current_wait(分支2).expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
(分支1).data(分支1).data.current_wait(分支2).resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
(分支1).data(分支1).data.countersobject必填 / 必有;运行的累计计数。 不接受额外字段。
(分支1).data(分支1).data.counters.callsnumber必填 / 必有;脚本发出的调用总数。
(分支1).data(分支1).data.counters.action_callsnumber必填 / 必有;其中调用动作的次数。
(分支1).data(分支1).data.counters.child_runsnumber必填 / 必有;启动的子运行数。
(分支1).data(分支1).data.counters.tasks_completednumber必填 / 必有;工作流已完成的步骤数。
(分支1).data(分支1).data.counters.tasks_totalnull / number必填 / 必有;工作流顶层步骤总数;脚本运行为 null。
(分支1).data(分支1).data.inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
(分支1).data(分支1).data.input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支1).data(分支1).data.input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支1).data(分支1).data.outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
(分支1).data(分支1).data.output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支1).data(分支1).data.output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支1).data(分支1).data.errornull / object必填 / 必有;运行失败(faulted)时的错误详情;未失败为 null。
(分支1).data(分支1).data.error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
(分支1).data(分支1).data.error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
(分支1).data(分支1).data.error(分支2).titlestring必填 / 必有;错误的简短标题。
(分支1).data(分支1).data.error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
(分支1).data(分支1).data.error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
(分支1).data(分支1).data.error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
(分支1).data(分支1).data.error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
(分支1).data(分支1).data.error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
(分支1).data(分支1).data.error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
(分支1).data(分支1).data.error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
(分支1).data(分支1).data.error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
(分支1).data(分支1).data.error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
(分支1).data(分支1).data.error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
(分支1).data(分支1).data.error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
(分支1).data(分支1).data.error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
(分支1).data(分支1).data.error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
(分支1).data(分支1).data.error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
(分支1).data(分支1).data.error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
(分支1).data(分支1).data.error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
(分支1).data(分支1).data.initiatorobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
(分支1).data(分支1).data.initiator.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
(分支1).data(分支1).data.initiator.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
(分支1).data(分支1).data.channel"run" / "console" / "api" / "internal" / "trigger"必填 / 必有;请求进入平台的渠道。console 为控制台(经 BFF);api 为公开 API 调用;internal 为平台内部服务调用;run 为由另一个运行创建的子运行;trigger 为触发器启动。
(分支1).data(分支1).data.ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
(分支1).data(分支1).data.parentnull / object必填 / 必有;派生本运行的父运行 {id, number, definition};根运行为 null。
(分支1).data(分支1).data.parent(分支2).idstring必填 / 必有;父运行 ID(run_ 前缀)。
(分支1).data(分支1).data.parent(分支2).numbernull / number必填 / 必有;父运行在其定义内的序号;父运行是临时运行时为 null。
(分支1).data(分支1).data.parent(分支2).definitionnull / object必填 / 必有;父运行所属的脚本或工作流 {namespace, name};临时运行为 null。
(分支1).data(分支1).data.parent(分支2).definition(分支2).namespacestring必填 / 必有;父运行所属定义的命名空间。
(分支1).data(分支1).data.parent(分支2).definition(分支2).namestring必填 / 必有;父运行所属定义的名字。
(分支1).data(分支1).data.parent_run_idstring / null必填 / 必有;派生出本运行的父运行 id;根运行为 null
(分支1).data(分支1).data.root_run_idstring必填 / 必有;运行树根运行的 ID;根运行自身指向自己。
(分支1).data(分支1).data.depthnumber必填 / 必有;运行树中的深度:根运行为 0,每一层子运行加 1,最大 10。
(分支1).data(分支1).data.attachnull / "wait" / "detach"必填 / 必有;子运行与父运行的关系。wait 表示父运行等待子运行结束,且子运行的截止时间不晚于父运行;detach 表示父运行不等待,也不会因父运行取消而被取消;根运行为 null。
(分支1).data(分支1).data.deadline_atstring必填 / 必有;运行的截止时间(RFC 3339 UTC):创建时间加 deadline_seconds(脚本默认且最多 300 秒,工作流默认 86400 秒、最多 604800 秒),等待型子运行不晚于父运行截止前 1 秒。
(分支1).data(分支1).data.created_atstring必填 / 必有;运行创建时间(RFC 3339 UTC)。
(分支1).data(分支1).data.started_atnull / string必填 / 必有;开始执行的时间(RFC 3339 UTC);仍在排队为 null。
(分支1).data(分支1).data.ended_atnull / string必填 / 必有;进入终态的时间(RFC 3339 UTC);尚未结束为 null。
(分支1).data(分支1).data.updated_atstring必填 / 必有;运行记录最近一次更新的时间(RFC 3339 UTC)。
(分支1).data(分支1).data.heartbeat_atnull / string必填 / 必有;执行器最近一次存活信号的时间(RFC 3339 UTC);尚未开始为 null。
(分支1).data(分支1).data.cancel_requested_atnull / string必填 / 必有;收到取消请求的时间(RFC 3339 UTC);未取消为 null。
(分支1).data(分支1).data.cancelled_bynull / object必填 / 必有;请求取消的主体;未取消或非人为取消为 null。
(分支1).data(分支1).data.cancelled_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
(分支1).data(分支1).data.cancelled_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
(分支1).data(分支1).data.cancel_reasonnull / "user" / "parent_cancelled" / "deadline" / "executor_lost"必填 / 必有;取消原因。user 为用户取消;parent_cancelled 为父运行被取消而级联取消;deadline 为超过截止时间;executor_lost 为执行器丢失;未取消为 null。
(分支1).data(分支1).data.suspend_requested_atnull / string必填 / 必有;请求暂停工作流的时间(RFC 3339 UTC);未暂停为 null。
(分支1).data(分支1).data.suspended_bynull / object必填 / 必有;请求暂停的主体;未暂停为 null。
(分支1).data(分支1).data.suspended_by(分支2).type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
(分支1).data(分支1).data.suspended_by(分支2).idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
(分支1).data(分支1).data.queued_msnull / number必填 / 必有;从创建到开始执行的排队毫秒数;尚未开始为 null。
(分支1).data(分支1).data.run_msnull / number必填 / 必有;实际执行毫秒数,不含等待点上的等待时间;结束后固定。
(分支1).data(分支1).data.wait_msnull / number必填 / 必有;在等待点上累计等待的毫秒数;尚无等待为 null。
(分支1).data(分支1).data.usageobject / null必填 / 必有;仅单个运行详情(含 expand)返回;列表为 null。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
(分支1).data(分支1).data.usage(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
(分支1).data(分支1).data.usage(分支1).coststring必填 / 必有;仅本运行自身的已评级实扣(不含子运行),美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
(分支1).data(分支1).data.usage(分支1).pending_eventsinteger必填 / 必有;本运行自身尚未评级的用量事件数,金额稍后才计入。 minimum: 0
(分支1).data(分支1).data.usage(分支1).by_serviceobject[]必填 / 必有;本运行按服务拆分的实扣,每项为 service 与 cost(6 位小数美元字符串);没有用量时为空数组。
(分支1).data(分支1).data.usage(分支1).by_service[].servicestring必填 / 必有;产生用量的服务名,例如 router 或 search。
(分支1).data(分支1).data.usage(分支1).by_service[].coststring必填 / 必有;该服务已评级实扣的美元十进制字符串,精确到 6 位小数。 pattern: "^[0-9]+\.[0-9]{6}$"
(分支1).data(分支1).data.usage(分支1).tree_coststring / null必填 / 必有;仅根运行返回整棵运行树的已评级实扣(含自身),6 位小数美元字符串;子运行为 null。
(分支1).data(分支1).data.rerun_ofnull / string必填 / 必有;重跑来源:本运行是对哪个运行(run_ ID)的重跑;否则为 null。
(分支1).data(分支1).data.labelsobject必填 / 必有;用户标签与系统标签;触发器运行支持 64 个用户标签,系统标签不占用名额。
(分支1).data(分支1).data.triggerobject / null必填 / 必有;启动本运行的触发器 {id, name};不是触发器启动时为 null。
(分支1).data(分支1).data.trigger(分支1).idstring必填 / 必有;启动本运行的触发器 ID(trg_ 前缀)。
(分支1).data(分支1).data.trigger(分支1).namestring必填 / 必有;启动本运行的触发器名称。
(分支1).data(分支1).data.cancel_messagestring / null必填 / 必有;用户提供的取消备注(1–500 字符);未提供时为 null,cancel_reason 枚举不变。
(分支1).data(分支1).data.input_truncatedboolean可选;列表省略外置 input 时为 true,此时 input 为 null;内联值不变,运行详情返回完整值。
(分支1).data(分支1).data.output_truncatedboolean可选;列表省略外置 output 时为 true,此时 output 为 null;内联值不变,运行详情返回完整值。
(分支1).data(分支1).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
(分支1).data(分支1).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
(分支1).data(分支1).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
(分支1).data(分支1).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
(分支1).data(分支1).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
(分支1).data(分支1).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
(分支1).data(分支2).type"ai.praxis.automation.run.progress"必填 / 必有;事件类型:固定为 ai.praxis.automation.run.progress,运行上报了新进度,data 为进度。
(分支1).data(分支2).dataobject必填 / 必有;运行报告的进度,包含说明、已完成量与总量。 不接受额外字段。
(分支1).data(分支2).data.labelstring必填 / 必有;进度说明文字,例如当前阶段。
(分支1).data(分支2).data.currentnull / number必填 / 必有;已完成的数量;未报告为 null。
(分支1).data(分支2).data.totalnull / number必填 / 必有;总量;未知为 null。
(分支1).data(分支2).data.updated_atstring必填 / 必有;进度最近一次更新的时间(RFC 3339 UTC)。
(分支1).data(分支2).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
(分支1).data(分支2).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
(分支1).data(分支2).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
(分支1).data(分支2).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
(分支1).data(分支2).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
(分支1).data(分支2).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
(分支1).data(分支3).type"ai.praxis.automation.call.started" / "ai.praxis.automation.call.completed"必填 / 必有;事件类型。ai.praxis.automation.call.started 调用开始;ai.praxis.automation.call.completed 调用结束(成功或失败);data 为调用记录。
(分支1).data(分支3).dataobject必填 / 必有;脚本运行中的一次调用记录(动作、平台 API、脚本或工作流),按 seq 顺序排列。 不接受额外字段。
(分支1).data(分支3).data.idstring必填 / 必有;调用 ID,前缀 call_。
(分支1).data(分支3).data.run_idstring必填 / 必有;发出该调用的脚本运行 ID(run_ 前缀)。
(分支1).data(分支3).data.seqnumber必填 / 必有;调用在该运行中的序号,随调用顺序递增;与 run_id 一起定位这次调用。
(分支1).data(分支3).data.targetobject必填 / 必有;被调用的目标 {kind, name, revision?, version?}。 不接受额外字段。
(分支1).data(分支3).data.target.kind"action" / "script" / "workflow" / "platform_api"必填 / 必有;目标类型。action 为动作;platform_api 为平台 API 操作;script 为脚本;workflow 为工作流。
(分支1).data(分支3).data.target.namestring必填 / 必有;目标名称:动作为 ns/name,平台 API 为操作名,脚本与工作流为 ns/name。
(分支1).data(分支3).data.target.revisionstring可选;实际执行的动作修订 ID(actr_ 前缀);仅动作调用有。
(分支1).data(分支3).data.target.versionstring可选;实际运行的精确版本号;仅脚本与工作流调用有。
(分支1).data(分支3).data.args_previewstring必填 / 必有;调用参数的单行预览,由服务端截断;超过 32 KB 的原文存放在对象存储而不内联。
(分支1).data(分支3).data.result_previewnull / string必填 / 必有;返回值的单行预览,由服务端截断;调用结束前为 null。
(分支1).data(分支3).data.status"running" / "completed" / "faulted" / "cancelled"必填 / 必有;调用状态。running 执行中;completed 已正常返回;faulted 失败,error 给出原因;cancelled 因运行被取消而中止。
(分支1).data(分支3).data.started_atstring必填 / 必有;调用开始的时间(RFC 3339 UTC)。
(分支1).data(分支3).data.ended_atnull / string必填 / 必有;调用结束的时间(RFC 3339 UTC);仍在执行为 null。
(分支1).data(分支3).data.duration_msnull / number必填 / 必有;从开始到结束的毫秒数;未结束为 null。
(分支1).data(分支3).data.errornull / object必填 / 必有;调用失败时的错误详情;成功或仍在执行为 null。
(分支1).data(分支3).data.error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
(分支1).data(分支3).data.error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
(分支1).data(分支3).data.error(分支2).titlestring必填 / 必有;错误的简短标题。
(分支1).data(分支3).data.error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
(分支1).data(分支3).data.error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
(分支1).data(分支3).data.error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
(分支1).data(分支3).data.error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
(分支1).data(分支3).data.error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
(分支1).data(分支3).data.error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
(分支1).data(分支3).data.error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
(分支1).data(分支3).data.error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
(分支1).data(分支3).data.error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
(分支1).data(分支3).data.error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
(分支1).data(分支3).data.error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
(分支1).data(分支3).data.error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
(分支1).data(分支3).data.error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
(分支1).data(分支3).data.error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
(分支1).data(分支3).data.error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
(分支1).data(分支3).data.error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
(分支1).data(分支3).data.child_run_idnull / string必填 / 必有;目标是脚本或工作流时,由本次调用启动的子运行 ID;动作与平台 API 调用为 null。
(分支1).data(分支3).data.invocation_keystring必填 / 必有;标识这一次逻辑调用的键,随调用发往下游,使至少一次语义下的重试可被去重。
(分支1).data(分支3).data.request_idstring / null必填 / 必有;下游响应的 X-Request-Id;尚未收到响应或响应未提供该头时为 null。
(分支1).data(分支3).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
(分支1).data(分支3).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
(分支1).data(分支3).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
(分支1).data(分支3).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
(分支1).data(分支3).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
(分支1).data(分支3).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
(分支1).data(分支4).type"ai.praxis.automation.task.started" / "ai.praxis.automation.task.completed"必填 / 必有;事件类型。ai.praxis.automation.task.started 步骤开始;ai.praxis.automation.task.completed 步骤结束;data 为步骤记录。
(分支1).data(分支4).dataobject必填 / 必有;工作流中一个步骤的一次执行记录。循环会让同一步骤产生多条记录(iteration 不同),重试会让 attempt 递增。 不接受额外字段。
(分支1).data(分支4).data.idstring必填 / 必有;步骤执行记录的标识,按不透明字符串处理。
(分支1).data(分支4).data.run_idstring必填 / 必有;所属运行 ID。
(分支1).data(分支4).data.referencestring必填 / 必有;该步骤在工作流文档中的 JSON Pointer,例如 /do/0/start。
(分支1).data(分支4).data.namestring必填 / 必有;步骤名,即工作流 YAML 中该步骤的键。
(分支1).data(分支4).data.kind"run" / "call" / "wait" / "set" / "for" / "fork" / "try" / "switch" / "emit" / "raise" / "listen" / "do"必填 / 必有;工作流步骤类型。call 调用动作;run 运行子脚本或子工作流;wait 等待时长;set 设置变量;for 循环;fork 并行分支;try 带捕获的块;switch 条件分支;emit 发出事件;raise 抛出错误;listen 等待事件;do 顺序执行的步骤块。
(分支1).data(分支4).data.iterationnumber[]必填 / 必有;外层 for 循环的当前迭代下标,由外到内;不在循环中为空数组。
(分支1).data(分支4).data.attemptnumber必填 / 必有;第几次尝试;步骤因重试而重新执行时递增。
(分支1).data(分支4).data.status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;步骤状态,取值与运行状态相同。pending 尚未开始;running 执行中;waiting 在等待事件、定时器或子运行;suspended 因运行被暂停;cancelled 已取消;faulted 失败;completed 成功完成。
(分支1).data(分支4).data.skippedboolean必填 / 必有;true 表示该步骤被跳过而没有实际执行。
(分支1).data(分支4).data.started_atnull / string必填 / 必有;步骤开始的时间(RFC 3339 UTC);未开始为 null。
(分支1).data(分支4).data.ended_atnull / string必填 / 必有;步骤结束的时间(RFC 3339 UTC);未结束为 null。
(分支1).data(分支4).data.duration_msnull / number必填 / 必有;执行耗时毫秒数;未结束为 null。
(分支1).data(分支4).data.inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
(分支1).data(分支4).data.input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支1).data(分支4).data.input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支1).data(分支4).data.input_truncatedboolean必填 / 必有;true 表示 input 超过 32 KB 已被截断。
(分支1).data(分支4).data.outputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
(分支1).data(分支4).data.output(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支1).data(分支4).data.output(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支1).data(分支4).data.output_truncatedboolean必填 / 必有;输出超过内联限制而被省略时为 true。
(分支1).data(分支4).data.errornull / object必填 / 必有;步骤失败时的错误详情;未失败为 null。
(分支1).data(分支4).data.error(分支2).typestring必填 / 必有;平台错误类别,或工作流 raise 定义的完整 URI,原样保留。
(分支1).data(分支4).data.error(分支2).codenull / string必填 / 必有;稳定错误码,可按码分支处理;没有为 null。
(分支1).data(分支4).data.error(分支2).titlestring必填 / 必有;错误的简短标题。
(分支1).data(分支4).data.error(分支2).detailnull / string必填 / 必有;错误的详细说明;没有为 null。
(分支1).data(分支4).data.error(分支2).sourcenull / object必填 / 必有;错误发生的位置:工作流步骤或脚本调用;未知为 null。
(分支1).data(分支4).data.error(分支2).source(分支2).kind"call" / "task"必填 / 必有;位置类型。task 表示工作流步骤;call 表示脚本中的调用。
(分支1).data(分支4).data.error(分支2).source(分支2).referencestring可选;task 类型时:出错步骤的 JSON Pointer。
(分支1).data(分支4).data.error(分支2).source(分支2).seqnumber可选;call 类型时:出错调用的序号(与 Call.seq 对应)。
(分支1).data(分支4).data.error(分支2).source(分支2).actionobject可选;出错的动作 {name, revision};错误来自动作时才有。 不接受额外字段。
(分支1).data(分支4).data.error(分支2).source(分支2).action.namestring必填 / 必有;动作全名 ns/name。
(分支1).data(分支4).data.error(分支2).source(分支2).action.revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
(分支1).data(分支4).data.error(分支2).request_idstring / null可选;导致失败的下游响应 X-Request-Id;没有下游响应标识时为 null 或省略。
(分支1).data(分支4).data.error(分支2).errorsobject[]可选;逐字段校验错误;pointer 使用 RFC 6901 指向字段,detail 为中文修正说明。
(分支1).data(分支4).data.error(分支2).errors[].pointerstring必填 / 必有;RFC 6901 字段指针。TypeScript 源码诊断为 /source(脚本)或 /implementation/source(动作);行列另见 line/column,不拼在指针后。
(分支1).data(分支4).data.error(分支2).errors[].detailstring必填 / 必有;中文修正说明,指出该位置出了什么问题以及怎样改。
(分支1).data(分支4).data.error(分支2).errors[].hintstring可选;可选的补充提示,给出下一步可执行的动作(例如改用另一个接口)。
(分支1).data(分支4).data.error(分支2).errors[].lineinteger可选;行号,从 1 起;仅有源码位置时返回。 minimum: 1
(分支1).data(分支4).data.error(分支2).errors[].columninteger可选;列号,从 1 起;仅有源码位置时返回。 minimum: 1
(分支1).data(分支4).data.error(分支2).statusnumber可选;工作流 raise 声明的 HTTP 风格状态;可省略,平台错误可能不提供。
(分支1).data(分支4).data.actionnull / object必填 / 必有;call 步骤执行的动作 {name, revision};其它步骤为 null。
(分支1).data(分支4).data.action(分支2).namestring必填 / 必有;动作全名 ns/name。
(分支1).data(分支4).data.action(分支2).revisionstring必填 / 必有;执行的动作修订 ID(actr_ 前缀)。
(分支1).data(分支4).data.child_runnull / object必填 / 必有;run 步骤启动的子运行摘要 {id, number, status, resolved_version};其它步骤为 null。
(分支1).data(分支4).data.child_run(分支2).idstring必填 / 必有;子运行 ID(run_ 前缀),创建后即可读取。
(分支1).data(分支4).data.child_run(分支2).numbernull / number必填 / 必有;子运行在其定义内的序号;临时运行为 null。
(分支1).data(分支4).data.child_run(分支2).status"running" / "completed" / "faulted" / "cancelled" / "pending" / "waiting" / "suspended"必填 / 必有;子运行的状态。pending 尚未开始;running 执行中;waiting 在等待;suspended 已暂停;cancelled 已取消;faulted 失败;completed 成功完成。等待型子运行在结束时补全终态,detach 的子运行只记录启动时的状态。
(分支1).data(分支4).data.child_run(分支2).resolved_versionnull / string必填 / 必有;子运行解析到的精确版本号;临时运行为 null。
(分支1).data(分支4).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
(分支1).data(分支4).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
(分支1).data(分支4).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
(分支1).data(分支4).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
(分支1).data(分支4).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
(分支1).data(分支4).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
(分支1).data(分支5).type"ai.praxis.automation.wait.created" / "ai.praxis.automation.wait.resolved"必填 / 必有;事件类型。ai.praxis.automation.wait.created 等待点创建;ai.praxis.automation.wait.resolved 等待点被满足、到期或取消;data 为等待点。
(分支1).data(分支5).dataobject必填 / 必有;运行上的一个等待点,工作流在它被满足、到期或取消之前不会继续。 不接受额外字段。
(分支1).data(分支5).data.idstring必填 / 必有;等待点 ID,前缀 wait_;完成事件等待点时作为路径中的 wait_id。
(分支1).data(分支5).data.run_idstring必填 / 必有;所属运行 ID(run_ 前缀)。
(分支1).data(分支5).data.kind"event" / "timer" / "child"必填 / 必有;等待类型。event 等待外部事件,可通过 runs.completeWait 提交;timer 等待到达 resume_at;child 等待子运行结束。
(分支1).data(分支5).data.state"cancelled" / "open" / "resolved" / "expired"必填 / 必有;等待点状态。open 仍在等待;resolved 已被满足;expired 已超过 expires_at;cancelled 已被取消,不会再被满足。
(分支1).data(分支5).data.tasknull / object必填 / 必有;产生该等待的工作流步骤 {reference, name};没有对应步骤为 null。
(分支1).data(分支5).data.task(分支2).referencestring必填 / 必有;步骤的 JSON Pointer,例如 /do/2/wait_payment。
(分支1).data(分支5).data.task(分支2).namestring必填 / 必有;步骤名,即工作流 YAML 中的键。
(分支1).data(分支5).data.resume_atnull / string必填 / 必有;kind=timer 时恢复运行的时刻(RFC 3339 UTC);其它类型为 null。
(分支1).data(分支5).data.event_typenull / string必填 / 必有;kind=event 时等待的事件类型;其它类型为 null。
(分支1).data(分支5).data.child_run_idnull / string必填 / 必有;kind=child 时被等待的子运行 ID;其它类型为 null。
(分支1).data(分支5).data.created_atstring必填 / 必有;等待点创建时间(RFC 3339 UTC)。
(分支1).data(分支5).data.expires_atnull / string必填 / 必有;等待点到期时间(RFC 3339 UTC);没有期限为 null。
(分支1).data(分支5).data.resolved_atnull / string必填 / 必有;等待点被满足的时间(RFC 3339 UTC);尚未满足为 null。
(分支1).data(分支5).specversion"1.0"必填 / 必有;CloudEvents 规范版本,固定为 1.0。
(分支1).data(分支5).idstring必填 / 必有;事件 ID,在该运行的账本内唯一。
(分支1).data(分支5).sourcestring必填 / 必有;事件来源,形如 /automation/v1/runs/{id}。
(分支1).data(分支5).timestring必填 / 必有;事件发生的时间(RFC 3339 UTC)。
(分支1).data(分支5).cursorstring必填 / 必有;事件游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
(分支1).data(分支5).seqnumber必填 / 必有;事件在运行账本中的序号,严格递增。
(分支2).event"end"可选;SSE event name end: sent once when the run has reached a terminal status, and the stream then closes.
(分支2).dataobject可选;Always an empty object for the end event.

实测响应

HTTP 200

id: WyJydW5fMDBtdjY3bWRsbTVkNWQ3MDdjZDAzMTc0NGU4NDM3ZjY3ZjZhY2YwMmFmYWFiZDE4ZTc2YmY4ZGI5ZDY3NDMzM2RlNmYxZmIyZjE6ZXZlbnRzIiwxXQ==
event: ai.praxis.automation.run.status
data: {"type":"ai.praxis.automation.run.status","data":{"id":"run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1","kind":"script","number":null,"definition":null,"target":null,"resolved_version":null,"source_digest":"7ae6678882a4ef2ea96e401c105d5c6ef512917cd72a9235289d2a3bf1f1b49d","language":"ts","status":"pending","progress":null,"current_wait":null,"counters":{"calls":0,"action_calls":0,"child_runs":0,"tasks_completed":0,"tasks_total":null},"input":{"n":41},"output":null,"error":null,"initiator":{"type":"api_key","id":"key_3e00b8984967"},"channel":"api","owner":"tnt_3a9759864ccb4e00","trigger":null,"parent":null,"parent_run_id":null,"root_run_id":"run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1","depth":0,"attach":null,"deadline_at":"2026-10-13T05:02:40.954Z","created_at":"2026-10-13T04:57:40.954Z","started_at":null,"ended_at":null,"updated_at":"2026-10-13T04:57:40.954Z","heartbeat_at":null,"cancel_requested_at":null,"cancelled_by":null,"cancel_reason":null,"cancel_message":null,"suspend_requested_at":null,"suspended_by":null,"queued_ms":null,"run_ms":null,"wait_ms":null,"usage":null,"rerun_of":null,"labels":{"namespace":"docs-samples","name":"sample-run-1791867412840-b05e8a"}},"specversion":"1.0","id":"WyJydW5fMDBtdjY3bWRsbTVkNWQ3MDdjZDAzMTc0NGU4NDM3ZjY3ZjZhY2YwMmFmYWFiZDE4ZTc2YmY4ZGI5ZDY3NDMzM2RlNmYxZmIyZjE6ZXZlbnRzIiwxXQ==","cursor":"WyJydW5fMDBtdjY3bWRsbTVkNWQ3MDdjZDAzMTc0NGU4NDM3ZjY3ZjZhY2YwMmFmYWFiZDE4ZTc2YmY4ZGI5ZDY3NDMzM2RlNmYxZmIyZjE6ZXZlbnRzIiwxXQ==","seq":1,"source":"/automation/v1/runs/run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1","time":"2026-10-13T04:57:40.954Z"}

id: WyJydW5fMDBtdjY3bWRsbTVkNWQ3MDdjZDAzMTc0NGU4NDM3ZjY3ZjZhY2YwMmFmYWFiZDE4ZTc2YmY4ZGI5ZDY3NDMzM2RlNmYxZmIyZjE6ZXZlbnRzIiwyXQ==
event: ai.praxis.automation.run.status
data: {"type":"ai.praxis.automation.run.status","data":{"id":"run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1","kind":"script","number":null,"definition":null,"target":null,"resolved_version":null,"source_digest":"7ae6678882a4ef2ea96e401c105d5c6ef512917cd72a9235289d2a3bf1f1b49d","language":"ts","status":"running","progress":null,"current_wait":null,"counters":{"calls":0,"action_calls":0,"child_runs":0,"tasks_completed":0,"tasks_total":null},"input":{"n":41},"output":null,"error":null,"initiator":{"type":"api_key","id":"key_3e00b8984967"},"channel":"api","owner":"tnt_3a9759864ccb4e00","trigger":null,"parent":null,"parent_run_id":null,"root_run_id":"run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1","depth":0,"attach":null,"deadline_at":"2026-10-13T05:02:40.954Z","created_at":"2026-10-13T04:57:40.954Z","started_at":"2026-10-13T04:57:42.283Z","ended_at":null,"updated_at":"2026-10-13T04:57:42.283Z","heartbeat_at":"2026-10-13T04:57:42.283Z","cancel_requested_at":null,"cancelled_by":null,"cancel_reason":null,"cancel_message":null,"suspend_requested_at":null,"suspended_by":null,"queued_ms":1329,"run_ms":null,"wait_ms":null,"usage":null,"rerun_of":null,"labels":{"namespace":"docs-samples","name":"sample-run-1791867412840-b05e8a"}},"specversion":"1.0","id":"WyJydW5fMDBtdjY3bWRsbTVkNWQ3MDdjZDAzMTc0NGU4NDM3ZjY3ZjZhY2YwMmFmYWFiZDE4ZTc2YmY4ZGI5ZDY3NDMzM2RlNmYxZmIyZjE6ZXZlbnRzIiwyXQ==","cursor":"WyJydW5fMDBtdjY3bWRsbTVkNWQ3MDdjZDAzMTc0NGU4NDM3ZjY3ZjZhY2YwMmFmYWFiZDE4ZTc2YmY4ZGI5ZDY3NDMzM2RlNmYxZmIyZjE6ZXZlbnRzIiwyXQ==","seq":2,"source":"/automation/v1/runs/run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1","time":"2026-10-13T04:57:42.283Z"}

id: WyJydW5fMDBtdjY3bWRsbTVkNWQ3MDdjZDAzMTc0NGU4NDM3ZjY3ZjZhY2YwMmFmYWFiZDE4ZTc2YmY4ZGI5ZDY3NDMzM2RlNmYxZmIyZjE6ZXZlbnRzIiwzXQ==
event: ai.praxis.automation.run.status
data: {"type":"ai.praxis.automation.run.status","data":{"id":"run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1","kind":"script","number":null,"definition":null,"target":null,"resolved_version":null,"source_digest":"7ae6678882a4ef2ea96e401c105d5c6ef512917cd72a9235289d2a3bf1f1b49d","language":"ts","status":"completed","progress":null,"current_wait":null,"counters":{"calls":0,"action_calls":0,"child_runs":0,"tasks_completed":0,"tasks_total":null},"input":{"n":41},"output":{"answer":42},"error":null,"initiator":{"type":"api_key","id":"key_3e00b8984967"},"channel":"api","owner":"tnt_3a9759864ccb4e00","trigger":null,"parent":null,"parent_run_id":null,"root_run_id":"run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1","depth":0,"attach":null,"deadline_at":"2026-10-13T05:02:40.954Z","created_at":"2026-10-13T04:57:40.954Z","started_at":"2026-10-13T04:57:42.283Z","ended_at":"2026-10-13T04:57:42.367Z","updated_at":"2026-10-13T04:57:42.367Z","heartbeat_at":"2026-10-13T04:57:42.283Z","cancel_requested_at":null,"cancelled_by":null,"cancel_reason":null,"cancel_message":null,"suspend_requested_at":null,"suspended_by":null,"queued_ms":1329,"run_ms":84,"wait_ms":null,"usage":null,"rerun_of":null,"labels":{"namespace":"docs-samples","name":"sample-run-1791867412840-b05e8a"}},"specversion":"1.0","id":"WyJydW5fMDBtdjY3bWRsbTVkNWQ3MDdjZDAzMTc0NGU4NDM3ZjY3ZjZhY2YwMmFmYWFiZDE4ZTc2YmY4ZGI5ZDY3NDMzM2RlNmYxZmIyZjE6ZXZlbnRzIiwzXQ==","cursor":"WyJydW5fMDBtdjY3bWRsbTVkNWQ3MDdjZDAzMTc0NGU4NDM3ZjY3ZjZhY2YwMmFmYWFiZDE4ZTc2YmY4ZGI5ZDY3NDMzM2RlNmYxZmIyZjE6ZXZlbnRzIiwzXQ==","seq":3,"source":"/automation/v1/runs/run_00mv67mdlm5d5d707cd031744e8437f67f6acf02afaabd18e76bf8db9d674333de6f1fb2f1","time":"2026-10-13T04:57:42.367Z"}

event: end
data: {}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404RUN_NOT_FOUND:运行不存在或当前租户不可见。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

读取运行日志

默认返回保留期内的日志页,保留期为 30 天;Accept: text/event-stream 开启实时流,日志帧为 event: log。id 为续传游标,Last-Event-ID 优先于 cursor;每 20 秒发送 : ping,运行终态后以 event: end 收尾。

GET /automation/v1/runs/{id}/logs

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;运行 ID(run_)。
query: limitinteger可选;运行台账每页条数,整数 1–200,默认 50;其它集合上限为 100。 minimum: 1;maximum: 200
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。
header: Accept"application/json" / "text/event-stream"可选;application/json(默认)读取账本页;text/event-stream 订阅实时流。
header: Last-Event-IDstring可选;SSE 续传游标,读取该事件之后的记录;优先于 cursor,仅用于实时流。

示例

先设置以下环境变量,使用你自己的资源:

: "${RUN_ID:?Set RUN_ID}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}/logs" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Accept: text/event-stream"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
for await (const event of automation.runs.logs({
  "path": {
    "id": env("RUN_ID")
  }
})) {
  console.log(event);
}

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的日志行(LogLine),按时间顺序排列。
data[].cursorstring必填 / 必有;该行的游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
data[].tsstring必填 / 必有;日志产生的时间(RFC 3339 UTC)。
data[].level"debug" / "info" / "warn" / "error"必填 / 必有;日志级别。debug 调试信息;info 一般信息;warn 警告;error 错误。
data[].messagestring必填 / 必有;日志文本。
next_cursornull / string必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

text/event-stream

字段类型说明
idstring可选;Resume cursor of this entry; send it back as Last-Event-ID, or as cursor on the JSON form, to continue after it. Absent on the end event.
event"log" / "end"必填 / 必有;SSE event name: log carries one log line in data; end is sent once when the run has reached a terminal status and closes the stream.
dataobject / object必填 / 必有;Decoded JSON of one log line; for the end event, an empty object.
data(分支1).cursorstring必填 / 必有;该行的游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
data(分支1).tsstring必填 / 必有;日志产生的时间(RFC 3339 UTC)。
data(分支1).level"debug" / "info" / "warn" / "error"必填 / 必有;日志级别。debug 调试信息;info 一般信息;warn 警告;error 错误。
data(分支1).messagestring必填 / 必有;日志文本。
(分支1).event"log"可选;SSE event name: log, one log line is carried in data.
(分支1).dataobject可选;运行产生的一行日志,保留 30 天。 不接受额外字段。
(分支1).data.cursorstring必填 / 必有;该行的游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。
(分支1).data.tsstring必填 / 必有;日志产生的时间(RFC 3339 UTC)。
(分支1).data.level"debug" / "info" / "warn" / "error"必填 / 必有;日志级别。debug 调试信息;info 一般信息;warn 警告;error 错误。
(分支1).data.messagestring必填 / 必有;日志文本。
(分支2).event"end"可选;SSE event name end: sent once when the run has reached a terminal status, and the stream then closes.
(分支2).dataobject可选;Always an empty object for the end event.

实测响应

HTTP 200

event: end
data: {}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404RUN_NOT_FOUND:运行不存在或当前租户不可见。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

读取运行源码

读取运行实际使用的源码及摘要。结果包括语言与 SHA-256 摘要,适用于临时运行及已发布定义的运行。

GET /automation/v1/runs/{id}/source

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;运行 ID(run_)。

示例

先设置以下环境变量,使用你自己的资源:

: "${RUN_ID:?Set RUN_ID}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}/source" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.runs.retrieveSource({
  "path": {
    "id": env("RUN_ID")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
language"ts" / "yaml"必填 / 必有;源码语言。ts 表示 TypeScript 脚本;yaml 表示工作流 YAML。
sourcestring必填 / 必有;运行时使用的完整源码(ts 或 yaml)。
sha256string必填 / 必有;源码的 SHA-256 摘要,可作为发布时的 expected_source_sha256。

实测响应

HTTP 200

{
  "language": "ts",
  "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });",
  "sha256": "7ae6678882a4ef2ea96e401c105d5c6ef512917cd72a9235289d2a3bf1f1b49d"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404RUN_NOT_FOUND:运行不存在或当前租户不可见。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出触发器

分页列出租户触发器,可按目标、类型和状态筛选;ns/name 匹配该目标的所有标签或版本,ns/name@spec 精确匹配。

GET /automation/v1/triggers

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
query: limitinteger可选;每页条数,整数 1–100,默认 25。 minimum: 1;maximum: 100
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。
query: targetstring[]可选;ns/name 匹配该目标的所有版本或标签;ns/name@spec 精确匹配已存的引用。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: kind"schedule" / "webhook"[]可选;schedule 或 webhook;省略返回两者。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: state"enabled" / "paused" / "expired"[]可选;触发器状态:enabled、paused 或 expired;省略不过滤。 多个值以逗号分隔,匹配任一值。 minItems: 1
query: labelsobject可选;按标签过滤,使用 labels[k]=v;同键逗号多值取任一,不同键同时满足。
query: created_at[gte]string可选;创建时间下界,包含边界;使用带时区的 ISO 8601 时间。 format: "date-time"
query: created_at[lte]string可选;创建时间上界,包含边界;使用带时区的 ISO 8601 时间。 format: "date-time"

示例

先设置以下环境变量,使用你自己的资源:

: "${TARGET:?Set TARGET}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/triggers" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  --get \
  --data-urlencode "target=${TARGET}"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.triggers.list({
  "query": {
    "target": [
      env("TARGET")
    ]
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的触发器,按 created_at 倒序、id 倒序排列。
data[].namestring必填 / 必有;触发器名称,1–100 字符。 minLength: 1;maxLength: 100
data[].descriptionstring必填 / 必有;触发器说明,最多 1000 字符。 maxLength: 1000
data[].labelsobject必填 / 必有;触发器标签:字符串键值对,最多 64 个;键不能以保留前缀 praxis. 开头,违反返回 400 INPUT_INVALID。
data[].targetstring必填 / 必有;要运行的脚本或工作流引用,形如 ns/name@标签或版本;默认跟随 latest,写成 @1.2.0 则钉死版本。
data[].inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
data[].input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
data[].input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
data[].kind"schedule" / "webhook"必填 / 必有;触发器类型。schedule 按计划(cron、every 或 at)触发;webhook 由入站 HTTP 请求触发。
data[].scheduleobject / object / object / null必填 / 必有;定时规则,kind=schedule 时有值(cron、every 或 at 三选一);webhook 为 null。
data[].schedule(分支1)(分支1).cronstring必填 / 必有;Five fields; supports L, W, #. DST gaps skip the day and overlaps run once.
data[].schedule(分支1)(分支2).everystring / object必填 / 必有;时长:ISO 8601 字符串(如 PT5M),或 {days, hours, minutes, seconds, milliseconds} 对象;折算后必须是 60000 至 31622400000 毫秒(1 分钟至 366 天)的整数毫秒。
data[].schedule(分支1)(分支2).every(分支2).daysinteger可选;天数,非负整数。 minimum: 0
data[].schedule(分支1)(分支2).every(分支2).hoursinteger可选;小时数,非负整数。 minimum: 0
data[].schedule(分支1)(分支2).every(分支2).minutesinteger可选;分钟数,非负整数。 minimum: 0
data[].schedule(分支1)(分支2).every(分支2).secondsinteger可选;秒数,非负整数。 minimum: 0
data[].schedule(分支1)(分支2).every(分支2).millisecondsinteger可选;毫秒数,非负整数。 minimum: 0
data[].schedule(分支1)(分支3).atstring必填 / 必有;一次性触发的时刻(RFC 3339 UTC);不能早于当前时间,也不能晚于一年后。执行后触发器进入 expired。 format: "date-time"
data[].timezonestring必填 / 必有;IANA 时区名,定时规则按它解释;API 缺省为 UTC。 default: "UTC"
data[].start_atstring / null必填 / 必有;定时触发器的开始时间(RFC 3339 UTC);此前不触发。没有限制为 null。
data[].end_atstring / null必填 / 必有;定时触发器的结束时间(RFC 3339 UTC);超过后进入 expired。没有期限为 null。
data[].overlap"skip" / "allow"必填 / 必有;重叠策略:上一次运行未结束时又到点,skip(默认)跳过,allow 照常启动。 default: "skip"
data[].catchup_window_secondsinteger必填 / 必有;补跑窗口(秒),默认 300,仅定时触发器适用:到点时若已延迟超过该值(宕机、暂停期间),记为 missed 且不补跑。 default: 300;minimum: 0
data[].webhookobject / null必填 / 必有;webhook 设置,kind=webhook 时有值;schedule 触发器为 null。
data[].webhook(分支1).input_mode"body" / "envelope"必填 / 必有;webhook 触发时传给目标的输入形态。body(默认)只传请求体;envelope 传含 body、raw_body、raw_body_encoding、headers、webhook_id、received_at 的信封对象。
data[].webhook(分支1).url_hintstring必填 / 必有;webhook 地址的掩码提示,省略号代替私密 token,不能用于调用。新建触发器为公开完整 URL;历史记录可能为 /automation/v1/hooks/{id}/… 相对路径。
data[].idstring必填 / 必有;触发器 ID,前缀 trg_;用于 webhook 地址以及触发器的所有接口。
data[].ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
data[].state"enabled" / "paused" / "expired"必填 / 必有;触发器状态。enabled 启用,会按计划或请求触发;paused 已暂停,不触发;expired 已到期,一次性触发器执行完或超过 end_at 后进入,不再触发。
data[].source"api" / "definition"必填 / 必有;触发器来源。api 为通过 API 创建,可修改和删除;definition 为由工作流 YAML 的 schedule 生成,只能暂停或恢复,修改返回 409 TRIGGER_MANAGED。
data[].created_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
data[].created_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
data[].created_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
data[].created_by_user_idstring必填 / 必有;创建者的真实用户 ID,由网关转发;触发器启动的运行以该用户身份取令牌,用于审计与用量归属。
data[].next_fire_timesstring[]必填 / 必有;接下来最多 5 次的触发时间(RFC 3339 UTC);webhook、已暂停或已到期的触发器为空数组。 maxItems: 5
data[].last_firingobject / null必填 / 必有;最近一次触发记录;从未触发为 null。
data[].last_firing(分支1).idstring必填 / 必有;触发记录 ID;记录保留 30 天。
data[].last_firing(分支1).trigger_idstring必填 / 必有;所属触发器 ID(trg_ 前缀)。
data[].last_firing(分支1).scheduled_atstring必填 / 必有;计划触发的时间(RFC 3339 UTC);webhook 取请求到达时间。 format: "date-time"
data[].last_firing(分支1).fired_atstring必填 / 必有;实际触发的时间(RFC 3339 UTC)。 format: "date-time"
data[].last_firing(分支1).outcome"accepted" / "started" / "skipped_overlap" / "missed" / "failed" / "deduped"必填 / 必有;触发结果。accepted 已持久化等待处理;started 已创建运行;skipped_overlap 因上一次运行未结束而跳过;missed 到点时延迟超过补跑窗口,不补跑;failed 创建运行失败;deduped 与 24 小时内相同 webhook-id 的请求重复,已去重。
data[].last_firing(分支1).run_idstring / null必填 / 必有;本次触发创建的运行 ID(run_ 前缀);未创建运行为 null。
data[].last_firing(分支1).resolved_versionstring / null必填 / 必有;本次触发实际解析到的精确版本号;尚未解析或失败时为 null。
data[].last_firing(分支1).errorobject / null必填 / 必有;触发失败时的原因 {code, message};没有失败为 null。
data[].last_firing(分支1).error(分支1).codestring必填 / 必有;失败的错误码。
data[].last_firing(分支1).error(分支1).messagestring必填 / 必有;失败的说明文字。
data[].countsobject必填 / 必有;触发结果累计次数 {started, skipped, missed, failed}。 不接受额外字段。
data[].counts.startedinteger必填 / 必有;成功启动运行的次数。 minimum: 0
data[].counts.skippedinteger必填 / 必有;因重叠策略为 skip 且上一次运行未结束而跳过的次数。 minimum: 0
data[].counts.missedinteger必填 / 必有;因延迟超过补跑窗口而错过的次数。 minimum: 0
data[].counts.failedinteger必填 / 必有;创建运行失败的次数。 minimum: 0
data[].created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。 format: "date-time"
data[].updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。 format: "date-time"
data[].etagstring必填 / 必有;触发器当前修订标识,更新时作为 If-Match;不匹配返回 412。
data[].usage_30dobject / null可选;仅 GET /triggers/{id} 返回,列表省略。最近 30 天由此触发器启动的运行及子运行的归因实扣。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
data[].usage_30d(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
data[].usage_30d(分支1).coststring必填 / 必有;已评级实扣的美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
data[].usage_30d(分支1).pending_eventsinteger必填 / 必有;尚未评级的用量事件数,金额稍后才计入。 minimum: 0
next_cursorstring / null必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [
    {
      "id": "trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e",
      "owner": "tnt_3a9759864ccb4e00",
      "name": "sample-webhook-1791867412840-b05e8a",
      "description": "",
      "labels": {
        "namespace": "docs-samples"
      },
      "target": "docs-samples/sample-scripts-1791867412840-b05e8a@1.0.0",
      "input": {},
      "kind": "webhook",
      "schedule": null,
      "timezone": "UTC",
      "start_at": null,
      "end_at": null,
      "overlap": "skip",
      "catchup_window_seconds": 300,
      "webhook": {
        "input_mode": "body",
        "url_hint": "https://api-develop.deepraxis.ai/automation/v1/hooks/trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e/…"
      },
      "state": "paused",
      "source": "api",
      "created_by": {
        "type": "api_key",
        "id": "key_3e00b8984967"
      },
      "created_by_user_id": "usr_49d4fcb99517",
      "next_fire_times": [],
      "last_firing": null,
      "counts": {
        "started": 0,
        "skipped": 0,
        "missed": 0,
        "failed": 0
      },
      "created_at": "2026-10-13T04:58:09.974Z",
      "updated_at": "2026-10-13T04:58:12.519Z",
      "etag": "etag_00mv67n1yf40e7b8d39ce5459d9ce835bfb1083701"
    }
  ],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

创建触发器

为已发布脚本或工作流创建定时或 webhook 触发器,每租户最多 100 个启用中的触发器。目标只接受精确版本或标签,webhook_url 仅在创建 webhook 或轮换时返回,须妥善保存。

POST /automation/v1/triggers

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
header: Idempotency-Keystring可选;可选;1–256 字符。24 小时内同一 key 重放首个响应并带 Idempotent-Replayed: true;同 key 不同请求体返回 422;处理中返回 409。 minLength: 1;maxLength: 256

application/json

不接受额外字段。

字段类型说明
namestring必填 / 必有;触发器显示名,1–100 字符且不能全为空白;不要求唯一。 minLength: 1;maxLength: 100
descriptionstring可选;说明,最多 1000 个字符。 maxLength: 1000
labelsobject可选;最多 64 个用户标签,禁止 praxis. 前缀;内部标签不占用名额。键 1–40 字符、值最多 500 字符。
targetstring必填 / 必有;ns/name@tag 或 ns/name@version,省略 @ 时用 latest;触发器不接受版本范围。
inputnull / string / number / boolean / object / null / string / number / boolean / object / JSON[][]可选;定时触发的静态 JSON 输入,默认 {};创建与修改时校验目标契约。webhook 未显式提供时不在创建阶段校验回调输入。
input(分支5).*(分支5)object递归 JSON 值。
input(分支5).*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[](分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[](分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
kind"schedule" / "webhook"必填 / 必有;schedule 按计划触发,webhook 由 HTTP 回调触发;创建后不可更改。
scheduleobject / object / object可选;三选一:cron 为五段表达式(支持 L/W/#);every 为 ISO 8601 时长或时长对象,须为正整数毫秒且在 1 分钟至 366 天之间;at 为未来一年内的一次性 RFC 3339 时间。
schedule(分支1).cronstring必填 / 必有;Five fields; supports L, W, #. DST gaps skip the day and overlaps run once.
schedule(分支2).everystring / object必填 / 必有;时长:ISO 8601 字符串(如 PT5M),或 {days, hours, minutes, seconds, milliseconds} 对象;折算后必须是 60000 至 31622400000 毫秒(1 分钟至 366 天)的整数毫秒。
schedule(分支2).every(分支2).daysinteger可选;天数,非负整数。 minimum: 0
schedule(分支2).every(分支2).hoursinteger可选;小时数,非负整数。 minimum: 0
schedule(分支2).every(分支2).minutesinteger可选;分钟数,非负整数。 minimum: 0
schedule(分支2).every(分支2).secondsinteger可选;秒数,非负整数。 minimum: 0
schedule(分支2).every(分支2).millisecondsinteger可选;毫秒数,非负整数。 minimum: 0
schedule(分支3).atstring必填 / 必有;一次性触发时刻,需带 Z 或 ±HH:MM 时区;必须在请求时刻至一年后之间。调用时将示例替换为该范围内的未来时间。 pattern: "(Z|[+-]\d\d:\d\d)$";format: "date-time"
timezonestring可选;IANA 时区,默认 UTC;夏令时跳过不存在的时刻,重复时刻只触发一次。 default: "UTC"
start_atstring / null可选;可选开始时间,RFC 3339 且带时区;null 表示不设下界。
end_atstring / null可选;可选结束时间,RFC 3339 且带时区;不能早于 start_at,null 表示不设上界。
overlap"skip" / "allow"可选;skip(默认)在前次运行未结束时跳过,allow 允许并行触发。 default: "skip"
catchup_window_secondsinteger可选;非负整数秒,默认 300;仅对定时触发器生效;延迟超过窗口时记为 missed,不补跑,webhook 不受此窗口影响。 default: 300;minimum: 0
webhookobject可选;input_mode 为 body(默认)或 envelope;后者包含 body、raw_body、raw_body_encoding、白名单 headers、webhook_id、received_at,完整 URL 仅创建或轮换时返回。 不接受额外字段。
webhook.input_mode"body" / "envelope"必填 / 必有;webhook 触发时传给目标的输入形态。body(默认)只传请求体;envelope 传含 body、raw_body、raw_body_encoding、headers、webhook_id、received_at 的信封对象。 default: "body"

示例

先设置以下环境变量,使用你自己的资源:

: "${TARGET:?Set TARGET}"
BODY=$(jq -n --arg TARGET "$TARGET" '{
  "name": "sample-webhook",
  "target": $TARGET,
  "kind": "webhook",
  "labels": {
    "namespace": "docs-samples"
  },
  "webhook": {
    "input_mode": "body"
  }
}')
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/triggers" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data "$BODY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.triggers.create({
  "body": {
    "name": "sample-webhook",
    "target": env("TARGET"),
    "kind": "webhook",
    "labels": {
      "namespace": "docs-samples"
    },
    "webhook": {
      "input_mode": "body"
    }
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
ETagstringCurrent resource revision for conditional updates.
Idempotent-ReplayedbooleanPresent and true when replaying the first response for this key.

application/json

字段类型说明
namestring必填 / 必有;触发器名称,1–100 字符。 minLength: 1;maxLength: 100
descriptionstring必填 / 必有;触发器说明,最多 1000 字符。 maxLength: 1000
labelsobject必填 / 必有;触发器标签:字符串键值对,最多 64 个;键不能以保留前缀 praxis. 开头,违反返回 400 INPUT_INVALID。
targetstring必填 / 必有;要运行的脚本或工作流引用,形如 ns/name@标签或版本;默认跟随 latest,写成 @1.2.0 则钉死版本。
inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
kind"schedule" / "webhook"必填 / 必有;触发器类型。schedule 按计划(cron、every 或 at)触发;webhook 由入站 HTTP 请求触发。
scheduleobject / object / object / null必填 / 必有;定时规则,kind=schedule 时有值(cron、every 或 at 三选一);webhook 为 null。
schedule(分支1)(分支1).cronstring必填 / 必有;Five fields; supports L, W, #. DST gaps skip the day and overlaps run once.
schedule(分支1)(分支2).everystring / object必填 / 必有;时长:ISO 8601 字符串(如 PT5M),或 {days, hours, minutes, seconds, milliseconds} 对象;折算后必须是 60000 至 31622400000 毫秒(1 分钟至 366 天)的整数毫秒。
schedule(分支1)(分支2).every(分支2).daysinteger可选;天数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).hoursinteger可选;小时数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).minutesinteger可选;分钟数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).secondsinteger可选;秒数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).millisecondsinteger可选;毫秒数,非负整数。 minimum: 0
schedule(分支1)(分支3).atstring必填 / 必有;一次性触发的时刻(RFC 3339 UTC);不能早于当前时间,也不能晚于一年后。执行后触发器进入 expired。 format: "date-time"
timezonestring必填 / 必有;IANA 时区名,定时规则按它解释;API 缺省为 UTC。 default: "UTC"
start_atstring / null必填 / 必有;定时触发器的开始时间(RFC 3339 UTC);此前不触发。没有限制为 null。
end_atstring / null必填 / 必有;定时触发器的结束时间(RFC 3339 UTC);超过后进入 expired。没有期限为 null。
overlap"skip" / "allow"必填 / 必有;重叠策略:上一次运行未结束时又到点,skip(默认)跳过,allow 照常启动。 default: "skip"
catchup_window_secondsinteger必填 / 必有;补跑窗口(秒),默认 300,仅定时触发器适用:到点时若已延迟超过该值(宕机、暂停期间),记为 missed 且不补跑。 default: 300;minimum: 0
webhookobject / null必填 / 必有;webhook 设置,kind=webhook 时有值;schedule 触发器为 null。
webhook(分支1).input_mode"body" / "envelope"必填 / 必有;webhook 触发时传给目标的输入形态。body(默认)只传请求体;envelope 传含 body、raw_body、raw_body_encoding、headers、webhook_id、received_at 的信封对象。
webhook(分支1).url_hintstring必填 / 必有;webhook 地址的掩码提示,省略号代替私密 token,不能用于调用。新建触发器为公开完整 URL;历史记录可能为 /automation/v1/hooks/{id}/… 相对路径。
idstring必填 / 必有;触发器 ID,前缀 trg_;用于 webhook 地址以及触发器的所有接口。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
state"enabled" / "paused" / "expired"必填 / 必有;触发器状态。enabled 启用,会按计划或请求触发;paused 已暂停,不触发;expired 已到期,一次性触发器执行完或超过 end_at 后进入,不再触发。
source"api" / "definition"必填 / 必有;触发器来源。api 为通过 API 创建,可修改和删除;definition 为由工作流 YAML 的 schedule 生成,只能暂停或恢复,修改返回 409 TRIGGER_MANAGED。
created_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
created_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
created_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
created_by_user_idstring必填 / 必有;创建者的真实用户 ID,由网关转发;触发器启动的运行以该用户身份取令牌,用于审计与用量归属。
next_fire_timesstring[]必填 / 必有;接下来最多 5 次的触发时间(RFC 3339 UTC);webhook、已暂停或已到期的触发器为空数组。 maxItems: 5
last_firingobject / null必填 / 必有;最近一次触发记录;从未触发为 null。
last_firing(分支1).idstring必填 / 必有;触发记录 ID;记录保留 30 天。
last_firing(分支1).trigger_idstring必填 / 必有;所属触发器 ID(trg_ 前缀)。
last_firing(分支1).scheduled_atstring必填 / 必有;计划触发的时间(RFC 3339 UTC);webhook 取请求到达时间。 format: "date-time"
last_firing(分支1).fired_atstring必填 / 必有;实际触发的时间(RFC 3339 UTC)。 format: "date-time"
last_firing(分支1).outcome"accepted" / "started" / "skipped_overlap" / "missed" / "failed" / "deduped"必填 / 必有;触发结果。accepted 已持久化等待处理;started 已创建运行;skipped_overlap 因上一次运行未结束而跳过;missed 到点时延迟超过补跑窗口,不补跑;failed 创建运行失败;deduped 与 24 小时内相同 webhook-id 的请求重复,已去重。
last_firing(分支1).run_idstring / null必填 / 必有;本次触发创建的运行 ID(run_ 前缀);未创建运行为 null。
last_firing(分支1).resolved_versionstring / null必填 / 必有;本次触发实际解析到的精确版本号;尚未解析或失败时为 null。
last_firing(分支1).errorobject / null必填 / 必有;触发失败时的原因 {code, message};没有失败为 null。
last_firing(分支1).error(分支1).codestring必填 / 必有;失败的错误码。
last_firing(分支1).error(分支1).messagestring必填 / 必有;失败的说明文字。
countsobject必填 / 必有;触发结果累计次数 {started, skipped, missed, failed}。 不接受额外字段。
counts.startedinteger必填 / 必有;成功启动运行的次数。 minimum: 0
counts.skippedinteger必填 / 必有;因重叠策略为 skip 且上一次运行未结束而跳过的次数。 minimum: 0
counts.missedinteger必填 / 必有;因延迟超过补跑窗口而错过的次数。 minimum: 0
counts.failedinteger必填 / 必有;创建运行失败的次数。 minimum: 0
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。 format: "date-time"
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。 format: "date-time"
etagstring必填 / 必有;触发器当前修订标识,更新时作为 If-Match;不匹配返回 412。
usage_30dobject / null可选;创建响应中恒为 null;近 30 天用量只在 GET /triggers/{id} 返回。
usage_30d(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
usage_30d(分支1).coststring必填 / 必有;已评级实扣的美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
usage_30d(分支1).pending_eventsinteger必填 / 必有;尚未评级的用量事件数,金额稍后才计入。 minimum: 0
webhook_urlstring可选;Returned only on webhook creation or rotation. format: "uri"

实测响应

HTTP 200

{
  "id": "trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e",
  "owner": "tnt_3a9759864ccb4e00",
  "name": "sample-webhook-1791867412840-b05e8a",
  "description": "",
  "labels": {
    "namespace": "docs-samples"
  },
  "target": "docs-samples/sample-scripts-1791867412840-b05e8a@1.0.0",
  "input": {},
  "kind": "webhook",
  "schedule": null,
  "timezone": "UTC",
  "start_at": null,
  "end_at": null,
  "overlap": "skip",
  "catchup_window_seconds": 300,
  "webhook": {
    "input_mode": "body",
    "url_hint": "https://api-develop.deepraxis.ai/automation/v1/hooks/trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e/…"
  },
  "state": "enabled",
  "source": "api",
  "created_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "created_by_user_id": "usr_49d4fcb99517",
  "next_fire_times": [],
  "last_firing": null,
  "counts": {
    "started": 0,
    "skipped": 0,
    "missed": 0,
    "failed": 0
  },
  "created_at": "2026-10-13T04:58:09.974Z",
  "updated_at": "2026-10-13T04:58:09.974Z",
  "etag": "etag_00mv67mzzqc6ef5487c69f4857b65b91dab497104c",
  "webhook_url": "https://api-develop.deepraxis.ai/automation/v1/hooks/trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e/${WEBHOOK_TOKEN}"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 SCHEDULE_INVALID:定时规则或时间边界无效。 TIMEZONE_INVALID:时区不是有效的 IANA 时区。 INTERVAL_TOO_SHORT:定时间隔短于一分钟。 INPUT_INVALID:输入不满足目标契约或业务校验。
404TARGET_NOT_FOUND:编排目标不存在或类型不匹配。 VERSION_NOT_FOUND:指定版本或修订不存在。
409IDEMPOTENCY_IN_FLIGHT:同一幂等键的请求仍在处理中。 TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
422IDEMPOTENCY_KEY_MISMATCH:同一幂等键已用于不同请求内容。 NO_MATCHING_VERSION:没有满足标签、版本或范围的已发布版本。
429TRIGGER_LIMIT:租户已达到 100 个启用触发器的上限。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

读取触发器

读取规则、状态、未来触发时间与最近触发结果;ETag 可用于修改,完整 webhook URL 不会再次返回。

GET /automation/v1/triggers/{id}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;触发器 ID(trg_)。

示例

先设置以下环境变量,使用你自己的资源:

: "${TRIGGER_ID:?Set TRIGGER_ID}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/triggers/${TRIGGER_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.triggers.retrieve({
  "path": {
    "id": env("TRIGGER_ID")
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
ETagstringCurrent resource revision for conditional updates.

application/json

字段类型说明
namestring必填 / 必有;触发器名称,1–100 字符。 minLength: 1;maxLength: 100
descriptionstring必填 / 必有;触发器说明,最多 1000 字符。 maxLength: 1000
labelsobject必填 / 必有;触发器标签:字符串键值对,最多 64 个;键不能以保留前缀 praxis. 开头,违反返回 400 INPUT_INVALID。
targetstring必填 / 必有;要运行的脚本或工作流引用,形如 ns/name@标签或版本;默认跟随 latest,写成 @1.2.0 则钉死版本。
inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
kind"schedule" / "webhook"必填 / 必有;触发器类型。schedule 按计划(cron、every 或 at)触发;webhook 由入站 HTTP 请求触发。
scheduleobject / object / object / null必填 / 必有;定时规则,kind=schedule 时有值(cron、every 或 at 三选一);webhook 为 null。
schedule(分支1)(分支1).cronstring必填 / 必有;Five fields; supports L, W, #. DST gaps skip the day and overlaps run once.
schedule(分支1)(分支2).everystring / object必填 / 必有;时长:ISO 8601 字符串(如 PT5M),或 {days, hours, minutes, seconds, milliseconds} 对象;折算后必须是 60000 至 31622400000 毫秒(1 分钟至 366 天)的整数毫秒。
schedule(分支1)(分支2).every(分支2).daysinteger可选;天数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).hoursinteger可选;小时数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).minutesinteger可选;分钟数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).secondsinteger可选;秒数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).millisecondsinteger可选;毫秒数,非负整数。 minimum: 0
schedule(分支1)(分支3).atstring必填 / 必有;一次性触发的时刻(RFC 3339 UTC);不能早于当前时间,也不能晚于一年后。执行后触发器进入 expired。 format: "date-time"
timezonestring必填 / 必有;IANA 时区名,定时规则按它解释;API 缺省为 UTC。 default: "UTC"
start_atstring / null必填 / 必有;定时触发器的开始时间(RFC 3339 UTC);此前不触发。没有限制为 null。
end_atstring / null必填 / 必有;定时触发器的结束时间(RFC 3339 UTC);超过后进入 expired。没有期限为 null。
overlap"skip" / "allow"必填 / 必有;重叠策略:上一次运行未结束时又到点,skip(默认)跳过,allow 照常启动。 default: "skip"
catchup_window_secondsinteger必填 / 必有;补跑窗口(秒),默认 300,仅定时触发器适用:到点时若已延迟超过该值(宕机、暂停期间),记为 missed 且不补跑。 default: 300;minimum: 0
webhookobject / null必填 / 必有;webhook 设置,kind=webhook 时有值;schedule 触发器为 null。
webhook(分支1).input_mode"body" / "envelope"必填 / 必有;webhook 触发时传给目标的输入形态。body(默认)只传请求体;envelope 传含 body、raw_body、raw_body_encoding、headers、webhook_id、received_at 的信封对象。
webhook(分支1).url_hintstring必填 / 必有;webhook 地址的掩码提示,省略号代替私密 token,不能用于调用。新建触发器为公开完整 URL;历史记录可能为 /automation/v1/hooks/{id}/… 相对路径。
idstring必填 / 必有;触发器 ID,前缀 trg_;用于 webhook 地址以及触发器的所有接口。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
state"enabled" / "paused" / "expired"必填 / 必有;触发器状态。enabled 启用,会按计划或请求触发;paused 已暂停,不触发;expired 已到期,一次性触发器执行完或超过 end_at 后进入,不再触发。
source"api" / "definition"必填 / 必有;触发器来源。api 为通过 API 创建,可修改和删除;definition 为由工作流 YAML 的 schedule 生成,只能暂停或恢复,修改返回 409 TRIGGER_MANAGED。
created_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
created_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
created_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
created_by_user_idstring必填 / 必有;创建者的真实用户 ID,由网关转发;触发器启动的运行以该用户身份取令牌,用于审计与用量归属。
next_fire_timesstring[]必填 / 必有;接下来最多 5 次的触发时间(RFC 3339 UTC);webhook、已暂停或已到期的触发器为空数组。 maxItems: 5
last_firingobject / null必填 / 必有;最近一次触发记录;从未触发为 null。
last_firing(分支1).idstring必填 / 必有;触发记录 ID;记录保留 30 天。
last_firing(分支1).trigger_idstring必填 / 必有;所属触发器 ID(trg_ 前缀)。
last_firing(分支1).scheduled_atstring必填 / 必有;计划触发的时间(RFC 3339 UTC);webhook 取请求到达时间。 format: "date-time"
last_firing(分支1).fired_atstring必填 / 必有;实际触发的时间(RFC 3339 UTC)。 format: "date-time"
last_firing(分支1).outcome"accepted" / "started" / "skipped_overlap" / "missed" / "failed" / "deduped"必填 / 必有;触发结果。accepted 已持久化等待处理;started 已创建运行;skipped_overlap 因上一次运行未结束而跳过;missed 到点时延迟超过补跑窗口,不补跑;failed 创建运行失败;deduped 与 24 小时内相同 webhook-id 的请求重复,已去重。
last_firing(分支1).run_idstring / null必填 / 必有;本次触发创建的运行 ID(run_ 前缀);未创建运行为 null。
last_firing(分支1).resolved_versionstring / null必填 / 必有;本次触发实际解析到的精确版本号;尚未解析或失败时为 null。
last_firing(分支1).errorobject / null必填 / 必有;触发失败时的原因 {code, message};没有失败为 null。
last_firing(分支1).error(分支1).codestring必填 / 必有;失败的错误码。
last_firing(分支1).error(分支1).messagestring必填 / 必有;失败的说明文字。
countsobject必填 / 必有;触发结果累计次数 {started, skipped, missed, failed}。 不接受额外字段。
counts.startedinteger必填 / 必有;成功启动运行的次数。 minimum: 0
counts.skippedinteger必填 / 必有;因重叠策略为 skip 且上一次运行未结束而跳过的次数。 minimum: 0
counts.missedinteger必填 / 必有;因延迟超过补跑窗口而错过的次数。 minimum: 0
counts.failedinteger必填 / 必有;创建运行失败的次数。 minimum: 0
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。 format: "date-time"
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。 format: "date-time"
etagstring必填 / 必有;触发器当前修订标识,更新时作为 If-Match;不匹配返回 412。
usage_30dobject / null可选;仅 GET /triggers/{id} 返回,列表省略。最近 30 天由此触发器启动的运行及子运行的归因实扣。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
usage_30d(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
usage_30d(分支1).coststring必填 / 必有;已评级实扣的美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
usage_30d(分支1).pending_eventsinteger必填 / 必有;尚未评级的用量事件数,金额稍后才计入。 minimum: 0

实测响应

HTTP 200

{
  "id": "trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e",
  "owner": "tnt_3a9759864ccb4e00",
  "name": "sample-webhook-1791867412840-b05e8a",
  "description": "",
  "labels": {
    "namespace": "docs-samples"
  },
  "target": "docs-samples/sample-scripts-1791867412840-b05e8a@1.0.0",
  "input": {},
  "kind": "webhook",
  "schedule": null,
  "timezone": "UTC",
  "start_at": null,
  "end_at": null,
  "overlap": "skip",
  "catchup_window_seconds": 300,
  "webhook": {
    "input_mode": "body",
    "url_hint": "https://api-develop.deepraxis.ai/automation/v1/hooks/trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e/…"
  },
  "state": "paused",
  "source": "api",
  "created_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "created_by_user_id": "usr_49d4fcb99517",
  "next_fire_times": [],
  "last_firing": null,
  "counts": {
    "started": 0,
    "skipped": 0,
    "missed": 0,
    "failed": 0
  },
  "created_at": "2026-10-13T04:58:09.974Z",
  "updated_at": "2026-10-13T04:58:12.519Z",
  "etag": "etag_00mv67n1yf40e7b8d39ce5459d9ce835bfb1083701",
  "usage_30d": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TRIGGER_NOT_FOUND:触发器不存在或不可访问,回调鉴权失败也使用此错误。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

更新触发器

使用匹配当前 ETag 的 If-Match 修改配置,并重新校验目标输入与规则;kind 不可更改,由定义管理的触发器拒绝修改并返回 TRIGGER_MANAGED。

PATCH /automation/v1/triggers/{id}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;触发器 ID(trg_)。
header: If-Matchstring必填;当前资源的 ETag,可直接使用对象里的 draft.revision 或 etag 字段值:裸值、带双引号或弱校验写法 W/"…" 均接受(RFC 7232 弱比较);缺失返回 400,修订不匹配返回 412。

application/json

不接受额外字段。

字段类型说明
namestring可选;触发器显示名,1–100 字符且不能全为空白;不要求唯一。 minLength: 1;maxLength: 100
descriptionstring可选;说明,最多 1000 个字符。 maxLength: 1000
labelsobject可选;最多 64 个用户标签,禁止 praxis. 前缀;内部标签不占用名额。键 1–40 字符、值最多 500 字符。
targetstring可选;ns/name@tag 或 ns/name@version,省略 @ 时用 latest;触发器不接受版本范围。
inputnull / string / number / boolean / object / null / string / number / boolean / object / JSON[][]可选;定时触发的静态 JSON 输入,默认 {};创建与修改时校验目标契约。webhook 未显式提供时不在创建阶段校验回调输入。
input(分支5).*(分支5)object递归 JSON 值。
input(分支5).*(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[](分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[](分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
kind"schedule" / "webhook"可选;schedule 按计划触发,webhook 由 HTTP 回调触发;创建后不可更改。
scheduleobject / object / object可选;三选一:cron 为五段表达式(支持 L/W/#);every 为 ISO 8601 时长或时长对象,须为正整数毫秒且在 1 分钟至 366 天之间;at 为未来一年内的一次性 RFC 3339 时间。
schedule(分支1).cronstring必填 / 必有;Five fields; supports L, W, #. DST gaps skip the day and overlaps run once.
schedule(分支2).everystring / object必填 / 必有;时长:ISO 8601 字符串(如 PT5M),或 {days, hours, minutes, seconds, milliseconds} 对象;折算后必须是 60000 至 31622400000 毫秒(1 分钟至 366 天)的整数毫秒。
schedule(分支2).every(分支2).daysinteger可选;天数,非负整数。 minimum: 0
schedule(分支2).every(分支2).hoursinteger可选;小时数,非负整数。 minimum: 0
schedule(分支2).every(分支2).minutesinteger可选;分钟数,非负整数。 minimum: 0
schedule(分支2).every(分支2).secondsinteger可选;秒数,非负整数。 minimum: 0
schedule(分支2).every(分支2).millisecondsinteger可选;毫秒数,非负整数。 minimum: 0
schedule(分支3).atstring必填 / 必有;一次性触发时刻,需带 Z 或 ±HH:MM 时区;必须在请求时刻至一年后之间。调用时将示例替换为该范围内的未来时间。 pattern: "(Z|[+-]\d\d:\d\d)$";format: "date-time"
timezonestring可选;IANA 时区,默认 UTC;夏令时跳过不存在的时刻,重复时刻只触发一次。 default: "UTC"
start_atstring / null可选;可选开始时间,RFC 3339 且带时区;null 表示不设下界。
end_atstring / null可选;可选结束时间,RFC 3339 且带时区;不能早于 start_at,null 表示不设上界。
overlap"skip" / "allow"可选;skip(默认)在前次运行未结束时跳过,allow 允许并行触发。 default: "skip"
catchup_window_secondsinteger可选;非负整数秒,默认 300;仅对定时触发器生效;延迟超过窗口时记为 missed,不补跑,webhook 不受此窗口影响。 default: 300;minimum: 0
webhookobject可选;input_mode 为 body(默认)或 envelope;后者包含 body、raw_body、raw_body_encoding、白名单 headers、webhook_id、received_at,完整 URL 仅创建或轮换时返回。 不接受额外字段。
webhook.input_mode"body" / "envelope"必填 / 必有;webhook 触发时传给目标的输入形态。body(默认)只传请求体;envelope 传含 body、raw_body、raw_body_encoding、headers、webhook_id、received_at 的信封对象。 default: "body"

示例

先设置以下环境变量,使用你自己的资源:

: "${TRIGGER_ID:?Set TRIGGER_ID}"
: "${ETAG:?Set ETAG}"
curl --fail-with-body -X PATCH "https://api.deepraxis.ai/automation/v1/triggers/${TRIGGER_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "If-Match: ${ETAG}" \
  -H "Content-Type: application/json" \
  --data '{
  "description": "Sample webhook",
  "input": {
    "n": 41
  }
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.triggers.update({
  "path": {
    "id": env("TRIGGER_ID")
  },
  "headers": {
    "If-Match": env("ETAG")
  },
  "body": {
    "description": "Sample webhook",
    "input": {
      "n": 41
    }
  }
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
ETagstringCurrent resource revision for conditional updates.

application/json

字段类型说明
namestring必填 / 必有;触发器名称,1–100 字符。 minLength: 1;maxLength: 100
descriptionstring必填 / 必有;触发器说明,最多 1000 字符。 maxLength: 1000
labelsobject必填 / 必有;触发器标签:字符串键值对,最多 64 个;键不能以保留前缀 praxis. 开头,违反返回 400 INPUT_INVALID。
targetstring必填 / 必有;要运行的脚本或工作流引用,形如 ns/name@标签或版本;默认跟随 latest,写成 @1.2.0 则钉死版本。
inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
kind"schedule" / "webhook"必填 / 必有;触发器类型。schedule 按计划(cron、every 或 at)触发;webhook 由入站 HTTP 请求触发。
scheduleobject / object / object / null必填 / 必有;定时规则,kind=schedule 时有值(cron、every 或 at 三选一);webhook 为 null。
schedule(分支1)(分支1).cronstring必填 / 必有;Five fields; supports L, W, #. DST gaps skip the day and overlaps run once.
schedule(分支1)(分支2).everystring / object必填 / 必有;时长:ISO 8601 字符串(如 PT5M),或 {days, hours, minutes, seconds, milliseconds} 对象;折算后必须是 60000 至 31622400000 毫秒(1 分钟至 366 天)的整数毫秒。
schedule(分支1)(分支2).every(分支2).daysinteger可选;天数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).hoursinteger可选;小时数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).minutesinteger可选;分钟数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).secondsinteger可选;秒数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).millisecondsinteger可选;毫秒数,非负整数。 minimum: 0
schedule(分支1)(分支3).atstring必填 / 必有;一次性触发的时刻(RFC 3339 UTC);不能早于当前时间,也不能晚于一年后。执行后触发器进入 expired。 format: "date-time"
timezonestring必填 / 必有;IANA 时区名,定时规则按它解释;API 缺省为 UTC。 default: "UTC"
start_atstring / null必填 / 必有;定时触发器的开始时间(RFC 3339 UTC);此前不触发。没有限制为 null。
end_atstring / null必填 / 必有;定时触发器的结束时间(RFC 3339 UTC);超过后进入 expired。没有期限为 null。
overlap"skip" / "allow"必填 / 必有;重叠策略:上一次运行未结束时又到点,skip(默认)跳过,allow 照常启动。 default: "skip"
catchup_window_secondsinteger必填 / 必有;补跑窗口(秒),默认 300,仅定时触发器适用:到点时若已延迟超过该值(宕机、暂停期间),记为 missed 且不补跑。 default: 300;minimum: 0
webhookobject / null必填 / 必有;webhook 设置,kind=webhook 时有值;schedule 触发器为 null。
webhook(分支1).input_mode"body" / "envelope"必填 / 必有;webhook 触发时传给目标的输入形态。body(默认)只传请求体;envelope 传含 body、raw_body、raw_body_encoding、headers、webhook_id、received_at 的信封对象。
webhook(分支1).url_hintstring必填 / 必有;webhook 地址的掩码提示,省略号代替私密 token,不能用于调用。新建触发器为公开完整 URL;历史记录可能为 /automation/v1/hooks/{id}/… 相对路径。
idstring必填 / 必有;触发器 ID,前缀 trg_;用于 webhook 地址以及触发器的所有接口。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
state"enabled" / "paused" / "expired"必填 / 必有;触发器状态。enabled 启用,会按计划或请求触发;paused 已暂停,不触发;expired 已到期,一次性触发器执行完或超过 end_at 后进入,不再触发。
source"api" / "definition"必填 / 必有;触发器来源。api 为通过 API 创建,可修改和删除;definition 为由工作流 YAML 的 schedule 生成,只能暂停或恢复,修改返回 409 TRIGGER_MANAGED。
created_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
created_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
created_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
created_by_user_idstring必填 / 必有;创建者的真实用户 ID,由网关转发;触发器启动的运行以该用户身份取令牌,用于审计与用量归属。
next_fire_timesstring[]必填 / 必有;接下来最多 5 次的触发时间(RFC 3339 UTC);webhook、已暂停或已到期的触发器为空数组。 maxItems: 5
last_firingobject / null必填 / 必有;最近一次触发记录;从未触发为 null。
last_firing(分支1).idstring必填 / 必有;触发记录 ID;记录保留 30 天。
last_firing(分支1).trigger_idstring必填 / 必有;所属触发器 ID(trg_ 前缀)。
last_firing(分支1).scheduled_atstring必填 / 必有;计划触发的时间(RFC 3339 UTC);webhook 取请求到达时间。 format: "date-time"
last_firing(分支1).fired_atstring必填 / 必有;实际触发的时间(RFC 3339 UTC)。 format: "date-time"
last_firing(分支1).outcome"accepted" / "started" / "skipped_overlap" / "missed" / "failed" / "deduped"必填 / 必有;触发结果。accepted 已持久化等待处理;started 已创建运行;skipped_overlap 因上一次运行未结束而跳过;missed 到点时延迟超过补跑窗口,不补跑;failed 创建运行失败;deduped 与 24 小时内相同 webhook-id 的请求重复,已去重。
last_firing(分支1).run_idstring / null必填 / 必有;本次触发创建的运行 ID(run_ 前缀);未创建运行为 null。
last_firing(分支1).resolved_versionstring / null必填 / 必有;本次触发实际解析到的精确版本号;尚未解析或失败时为 null。
last_firing(分支1).errorobject / null必填 / 必有;触发失败时的原因 {code, message};没有失败为 null。
last_firing(分支1).error(分支1).codestring必填 / 必有;失败的错误码。
last_firing(分支1).error(分支1).messagestring必填 / 必有;失败的说明文字。
countsobject必填 / 必有;触发结果累计次数 {started, skipped, missed, failed}。 不接受额外字段。
counts.startedinteger必填 / 必有;成功启动运行的次数。 minimum: 0
counts.skippedinteger必填 / 必有;因重叠策略为 skip 且上一次运行未结束而跳过的次数。 minimum: 0
counts.missedinteger必填 / 必有;因延迟超过补跑窗口而错过的次数。 minimum: 0
counts.failedinteger必填 / 必有;创建运行失败的次数。 minimum: 0
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。 format: "date-time"
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。 format: "date-time"
etagstring必填 / 必有;触发器当前修订标识,更新时作为 If-Match;不匹配返回 412。
usage_30dobject / null可选;仅 GET /triggers/{id} 返回,列表省略。最近 30 天由此触发器启动的运行及子运行的归因实扣。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
usage_30d(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
usage_30d(分支1).coststring必填 / 必有;已评级实扣的美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
usage_30d(分支1).pending_eventsinteger必填 / 必有;尚未评级的用量事件数,金额稍后才计入。 minimum: 0

实测响应

HTTP 200

{
  "id": "trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e",
  "owner": "tnt_3a9759864ccb4e00",
  "name": "sample-webhook-1791867412840-b05e8a",
  "description": "Sample webhook",
  "labels": {
    "namespace": "docs-samples"
  },
  "target": "docs-samples/sample-scripts-1791867412840-b05e8a@1.0.0",
  "input": {
    "n": 41
  },
  "kind": "webhook",
  "schedule": null,
  "timezone": "UTC",
  "start_at": null,
  "end_at": null,
  "overlap": "skip",
  "catchup_window_seconds": 300,
  "webhook": {
    "input_mode": "body",
    "url_hint": "https://api-develop.deepraxis.ai/automation/v1/hooks/trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e/…"
  },
  "state": "paused",
  "source": "api",
  "created_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "created_by_user_id": "usr_49d4fcb99517",
  "next_fire_times": [],
  "last_firing": null,
  "counts": {
    "started": 0,
    "skipped": 0,
    "missed": 0,
    "failed": 0
  },
  "created_at": "2026-10-13T04:58:09.974Z",
  "updated_at": "2026-10-13T04:58:14.661Z",
  "etag": "etag_00mv67n3ib18c0371214b84064b86e9375320685fa"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 SCHEDULE_INVALID:定时规则或时间边界无效。 TIMEZONE_INVALID:时区不是有效的 IANA 时区。 INTERVAL_TOO_SHORT:定时间隔短于一分钟。 INPUT_INVALID:输入不满足目标契约或业务校验。
404TRIGGER_NOT_FOUND:触发器不存在或不可访问,回调鉴权失败也使用此错误。 TARGET_NOT_FOUND:编排目标不存在或类型不匹配。 VERSION_NOT_FOUND:指定版本或修订不存在。
409TRIGGER_MANAGED:触发器由定义管理,不能直接修改。 TARGET_ARCHIVED:目标已归档,不能用于本操作;动作执行错误的 detail 包含 ns/name。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
422NO_MATCHING_VERSION:没有满足标签、版本或范围的已发布版本。
429TRIGGER_LIMIT:租户已达到 100 个启用触发器的上限。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

删除触发器

删除触发器及其触发历史,返回 204;已经启动的运行不受影响。由定义管理的触发器返回 409 TRIGGER_MANAGED,需在工作流定义里删除 schedule 后重新发布。

DELETE /automation/v1/triggers/{id}

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;触发器 ID(trg_)。

示例

先设置以下环境变量,使用你自己的资源:

: "${TRIGGER_ID:?Set TRIGGER_ID}"
curl --fail-with-body -X DELETE "https://api.deepraxis.ai/automation/v1/triggers/${TRIGGER_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.triggers.delete({
  "path": {
    "id": env("TRIGGER_ID")
  }
});
console.log(result);

响应

HTTP 204

Deleted

实测响应

HTTP 204

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TRIGGER_NOT_FOUND:触发器不存在或不可访问,回调鉴权失败也使用此错误。
409TRIGGER_MANAGED:触发器由定义管理,不能直接修改。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

暂停触发器

暂停后停止新触发,不终止已经启动的运行;由定义管理的触发器也可以暂停。

POST /automation/v1/triggers/{id}/pause

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;触发器 ID(trg_)。

示例

先设置以下环境变量,使用你自己的资源:

: "${TRIGGER_ID:?Set TRIGGER_ID}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/triggers/${TRIGGER_ID}/pause" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.triggers.pause({
  "path": {
    "id": env("TRIGGER_ID")
  },
  "body": {}
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
namestring必填 / 必有;触发器名称,1–100 字符。 minLength: 1;maxLength: 100
descriptionstring必填 / 必有;触发器说明,最多 1000 字符。 maxLength: 1000
labelsobject必填 / 必有;触发器标签:字符串键值对,最多 64 个;键不能以保留前缀 praxis. 开头,违反返回 400 INPUT_INVALID。
targetstring必填 / 必有;要运行的脚本或工作流引用,形如 ns/name@标签或版本;默认跟随 latest,写成 @1.2.0 则钉死版本。
inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
kind"schedule" / "webhook"必填 / 必有;触发器类型。schedule 按计划(cron、every 或 at)触发;webhook 由入站 HTTP 请求触发。
scheduleobject / object / object / null必填 / 必有;定时规则,kind=schedule 时有值(cron、every 或 at 三选一);webhook 为 null。
schedule(分支1)(分支1).cronstring必填 / 必有;Five fields; supports L, W, #. DST gaps skip the day and overlaps run once.
schedule(分支1)(分支2).everystring / object必填 / 必有;时长:ISO 8601 字符串(如 PT5M),或 {days, hours, minutes, seconds, milliseconds} 对象;折算后必须是 60000 至 31622400000 毫秒(1 分钟至 366 天)的整数毫秒。
schedule(分支1)(分支2).every(分支2).daysinteger可选;天数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).hoursinteger可选;小时数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).minutesinteger可选;分钟数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).secondsinteger可选;秒数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).millisecondsinteger可选;毫秒数,非负整数。 minimum: 0
schedule(分支1)(分支3).atstring必填 / 必有;一次性触发的时刻(RFC 3339 UTC);不能早于当前时间,也不能晚于一年后。执行后触发器进入 expired。 format: "date-time"
timezonestring必填 / 必有;IANA 时区名,定时规则按它解释;API 缺省为 UTC。 default: "UTC"
start_atstring / null必填 / 必有;定时触发器的开始时间(RFC 3339 UTC);此前不触发。没有限制为 null。
end_atstring / null必填 / 必有;定时触发器的结束时间(RFC 3339 UTC);超过后进入 expired。没有期限为 null。
overlap"skip" / "allow"必填 / 必有;重叠策略:上一次运行未结束时又到点,skip(默认)跳过,allow 照常启动。 default: "skip"
catchup_window_secondsinteger必填 / 必有;补跑窗口(秒),默认 300,仅定时触发器适用:到点时若已延迟超过该值(宕机、暂停期间),记为 missed 且不补跑。 default: 300;minimum: 0
webhookobject / null必填 / 必有;webhook 设置,kind=webhook 时有值;schedule 触发器为 null。
webhook(分支1).input_mode"body" / "envelope"必填 / 必有;webhook 触发时传给目标的输入形态。body(默认)只传请求体;envelope 传含 body、raw_body、raw_body_encoding、headers、webhook_id、received_at 的信封对象。
webhook(分支1).url_hintstring必填 / 必有;webhook 地址的掩码提示,省略号代替私密 token,不能用于调用。新建触发器为公开完整 URL;历史记录可能为 /automation/v1/hooks/{id}/… 相对路径。
idstring必填 / 必有;触发器 ID,前缀 trg_;用于 webhook 地址以及触发器的所有接口。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
state"enabled" / "paused" / "expired"必填 / 必有;触发器状态。enabled 启用,会按计划或请求触发;paused 已暂停,不触发;expired 已到期,一次性触发器执行完或超过 end_at 后进入,不再触发。
source"api" / "definition"必填 / 必有;触发器来源。api 为通过 API 创建,可修改和删除;definition 为由工作流 YAML 的 schedule 生成,只能暂停或恢复,修改返回 409 TRIGGER_MANAGED。
created_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
created_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
created_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
created_by_user_idstring必填 / 必有;创建者的真实用户 ID,由网关转发;触发器启动的运行以该用户身份取令牌,用于审计与用量归属。
next_fire_timesstring[]必填 / 必有;接下来最多 5 次的触发时间(RFC 3339 UTC);webhook、已暂停或已到期的触发器为空数组。 maxItems: 5
last_firingobject / null必填 / 必有;最近一次触发记录;从未触发为 null。
last_firing(分支1).idstring必填 / 必有;触发记录 ID;记录保留 30 天。
last_firing(分支1).trigger_idstring必填 / 必有;所属触发器 ID(trg_ 前缀)。
last_firing(分支1).scheduled_atstring必填 / 必有;计划触发的时间(RFC 3339 UTC);webhook 取请求到达时间。 format: "date-time"
last_firing(分支1).fired_atstring必填 / 必有;实际触发的时间(RFC 3339 UTC)。 format: "date-time"
last_firing(分支1).outcome"accepted" / "started" / "skipped_overlap" / "missed" / "failed" / "deduped"必填 / 必有;触发结果。accepted 已持久化等待处理;started 已创建运行;skipped_overlap 因上一次运行未结束而跳过;missed 到点时延迟超过补跑窗口,不补跑;failed 创建运行失败;deduped 与 24 小时内相同 webhook-id 的请求重复,已去重。
last_firing(分支1).run_idstring / null必填 / 必有;本次触发创建的运行 ID(run_ 前缀);未创建运行为 null。
last_firing(分支1).resolved_versionstring / null必填 / 必有;本次触发实际解析到的精确版本号;尚未解析或失败时为 null。
last_firing(分支1).errorobject / null必填 / 必有;触发失败时的原因 {code, message};没有失败为 null。
last_firing(分支1).error(分支1).codestring必填 / 必有;失败的错误码。
last_firing(分支1).error(分支1).messagestring必填 / 必有;失败的说明文字。
countsobject必填 / 必有;触发结果累计次数 {started, skipped, missed, failed}。 不接受额外字段。
counts.startedinteger必填 / 必有;成功启动运行的次数。 minimum: 0
counts.skippedinteger必填 / 必有;因重叠策略为 skip 且上一次运行未结束而跳过的次数。 minimum: 0
counts.missedinteger必填 / 必有;因延迟超过补跑窗口而错过的次数。 minimum: 0
counts.failedinteger必填 / 必有;创建运行失败的次数。 minimum: 0
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。 format: "date-time"
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。 format: "date-time"
etagstring必填 / 必有;触发器当前修订标识,更新时作为 If-Match;不匹配返回 412。
usage_30dobject / null可选;仅 GET /triggers/{id} 返回,列表省略。最近 30 天由此触发器启动的运行及子运行的归因实扣。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
usage_30d(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
usage_30d(分支1).coststring必填 / 必有;已评级实扣的美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
usage_30d(分支1).pending_eventsinteger必填 / 必有;尚未评级的用量事件数,金额稍后才计入。 minimum: 0

实测响应

HTTP 200

{
  "id": "trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e",
  "owner": "tnt_3a9759864ccb4e00",
  "name": "sample-webhook-1791867412840-b05e8a",
  "description": "",
  "labels": {
    "namespace": "docs-samples"
  },
  "target": "docs-samples/sample-scripts-1791867412840-b05e8a@1.0.0",
  "input": {},
  "kind": "webhook",
  "schedule": null,
  "timezone": "UTC",
  "start_at": null,
  "end_at": null,
  "overlap": "skip",
  "catchup_window_seconds": 300,
  "webhook": {
    "input_mode": "body",
    "url_hint": "https://api-develop.deepraxis.ai/automation/v1/hooks/trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e/…"
  },
  "state": "paused",
  "source": "api",
  "created_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "created_by_user_id": "usr_49d4fcb99517",
  "next_fire_times": [],
  "last_firing": null,
  "counts": {
    "started": 0,
    "skipped": 0,
    "missed": 0,
    "failed": 0
  },
  "created_at": "2026-10-13T04:58:09.974Z",
  "updated_at": "2026-10-13T04:58:12.519Z",
  "etag": "etag_00mv67n1yf40e7b8d39ce5459d9ce835bfb1083701"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TRIGGER_NOT_FOUND:触发器不存在或不可访问,回调鉴权失败也使用此错误。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

恢复触发器

恢复触发并清空连续失败计数;已过结束时间或已执行完的一次性触发器保持 expired,启用配额已满时返回 TRIGGER_LIMIT。

POST /automation/v1/triggers/{id}/resume

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;触发器 ID(trg_)。

示例

先设置以下环境变量,使用你自己的资源:

: "${TRIGGER_ID:?Set TRIGGER_ID}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/triggers/${TRIGGER_ID}/resume" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.triggers.resume({
  "path": {
    "id": env("TRIGGER_ID")
  },
  "body": {}
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
namestring必填 / 必有;触发器名称,1–100 字符。 minLength: 1;maxLength: 100
descriptionstring必填 / 必有;触发器说明,最多 1000 字符。 maxLength: 1000
labelsobject必填 / 必有;触发器标签:字符串键值对,最多 64 个;键不能以保留前缀 praxis. 开头,违反返回 400 INPUT_INVALID。
targetstring必填 / 必有;要运行的脚本或工作流引用,形如 ns/name@标签或版本;默认跟随 latest,写成 @1.2.0 则钉死版本。
inputnull / string / number / boolean / object / JSON[]必填 / 必有;任意 JSON 值:null、布尔、数字、字符串、数组或对象。
input(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
input(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。
kind"schedule" / "webhook"必填 / 必有;触发器类型。schedule 按计划(cron、every 或 at)触发;webhook 由入站 HTTP 请求触发。
scheduleobject / object / object / null必填 / 必有;定时规则,kind=schedule 时有值(cron、every 或 at 三选一);webhook 为 null。
schedule(分支1)(分支1).cronstring必填 / 必有;Five fields; supports L, W, #. DST gaps skip the day and overlaps run once.
schedule(分支1)(分支2).everystring / object必填 / 必有;时长:ISO 8601 字符串(如 PT5M),或 {days, hours, minutes, seconds, milliseconds} 对象;折算后必须是 60000 至 31622400000 毫秒(1 分钟至 366 天)的整数毫秒。
schedule(分支1)(分支2).every(分支2).daysinteger可选;天数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).hoursinteger可选;小时数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).minutesinteger可选;分钟数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).secondsinteger可选;秒数,非负整数。 minimum: 0
schedule(分支1)(分支2).every(分支2).millisecondsinteger可选;毫秒数,非负整数。 minimum: 0
schedule(分支1)(分支3).atstring必填 / 必有;一次性触发的时刻(RFC 3339 UTC);不能早于当前时间,也不能晚于一年后。执行后触发器进入 expired。 format: "date-time"
timezonestring必填 / 必有;IANA 时区名,定时规则按它解释;API 缺省为 UTC。 default: "UTC"
start_atstring / null必填 / 必有;定时触发器的开始时间(RFC 3339 UTC);此前不触发。没有限制为 null。
end_atstring / null必填 / 必有;定时触发器的结束时间(RFC 3339 UTC);超过后进入 expired。没有期限为 null。
overlap"skip" / "allow"必填 / 必有;重叠策略:上一次运行未结束时又到点,skip(默认)跳过,allow 照常启动。 default: "skip"
catchup_window_secondsinteger必填 / 必有;补跑窗口(秒),默认 300,仅定时触发器适用:到点时若已延迟超过该值(宕机、暂停期间),记为 missed 且不补跑。 default: 300;minimum: 0
webhookobject / null必填 / 必有;webhook 设置,kind=webhook 时有值;schedule 触发器为 null。
webhook(分支1).input_mode"body" / "envelope"必填 / 必有;webhook 触发时传给目标的输入形态。body(默认)只传请求体;envelope 传含 body、raw_body、raw_body_encoding、headers、webhook_id、received_at 的信封对象。
webhook(分支1).url_hintstring必填 / 必有;webhook 地址的掩码提示,省略号代替私密 token,不能用于调用。新建触发器为公开完整 URL;历史记录可能为 /automation/v1/hooks/{id}/… 相对路径。
idstring必填 / 必有;触发器 ID,前缀 trg_;用于 webhook 地址以及触发器的所有接口。
ownerstring必填 / 必有;所属租户,由网关注入;按不透明字符串处理。
state"enabled" / "paused" / "expired"必填 / 必有;触发器状态。enabled 启用,会按计划或请求触发;paused 已暂停,不触发;expired 已到期,一次性触发器执行完或超过 end_at 后进入,不再触发。
source"api" / "definition"必填 / 必有;触发器来源。api 为通过 API 创建,可修改和删除;definition 为由工作流 YAML 的 schedule 生成,只能暂停或恢复,修改返回 409 TRIGGER_MANAGED。
created_byobject必填 / 必有;网关注入的主体 {type, id},表示谁发起或操作;本服务不解析名字,名字由控制台批量解析。 不接受额外字段。
created_by.type"user" / "api_key" / "agent" / "run" / "trigger"必填 / 必有;主体类型。user 为登录用户;api_key 为平台 API Key;agent 为智能体;run 为由运行本身(例如父运行)执行的操作;trigger 为触发器。
created_by.idstring必填 / 必有;主体标识,含义随 type 而定:用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID;按不透明字符串处理。
created_by_user_idstring必填 / 必有;创建者的真实用户 ID,由网关转发;触发器启动的运行以该用户身份取令牌,用于审计与用量归属。
next_fire_timesstring[]必填 / 必有;接下来最多 5 次的触发时间(RFC 3339 UTC);webhook、已暂停或已到期的触发器为空数组。 maxItems: 5
last_firingobject / null必填 / 必有;最近一次触发记录;从未触发为 null。
last_firing(分支1).idstring必填 / 必有;触发记录 ID;记录保留 30 天。
last_firing(分支1).trigger_idstring必填 / 必有;所属触发器 ID(trg_ 前缀)。
last_firing(分支1).scheduled_atstring必填 / 必有;计划触发的时间(RFC 3339 UTC);webhook 取请求到达时间。 format: "date-time"
last_firing(分支1).fired_atstring必填 / 必有;实际触发的时间(RFC 3339 UTC)。 format: "date-time"
last_firing(分支1).outcome"accepted" / "started" / "skipped_overlap" / "missed" / "failed" / "deduped"必填 / 必有;触发结果。accepted 已持久化等待处理;started 已创建运行;skipped_overlap 因上一次运行未结束而跳过;missed 到点时延迟超过补跑窗口,不补跑;failed 创建运行失败;deduped 与 24 小时内相同 webhook-id 的请求重复,已去重。
last_firing(分支1).run_idstring / null必填 / 必有;本次触发创建的运行 ID(run_ 前缀);未创建运行为 null。
last_firing(分支1).resolved_versionstring / null必填 / 必有;本次触发实际解析到的精确版本号;尚未解析或失败时为 null。
last_firing(分支1).errorobject / null必填 / 必有;触发失败时的原因 {code, message};没有失败为 null。
last_firing(分支1).error(分支1).codestring必填 / 必有;失败的错误码。
last_firing(分支1).error(分支1).messagestring必填 / 必有;失败的说明文字。
countsobject必填 / 必有;触发结果累计次数 {started, skipped, missed, failed}。 不接受额外字段。
counts.startedinteger必填 / 必有;成功启动运行的次数。 minimum: 0
counts.skippedinteger必填 / 必有;因重叠策略为 skip 且上一次运行未结束而跳过的次数。 minimum: 0
counts.missedinteger必填 / 必有;因延迟超过补跑窗口而错过的次数。 minimum: 0
counts.failedinteger必填 / 必有;创建运行失败的次数。 minimum: 0
created_atstring必填 / 必有;创建时间(RFC 3339 UTC)。 format: "date-time"
updated_atstring必填 / 必有;最近一次更新的时间(RFC 3339 UTC)。 format: "date-time"
etagstring必填 / 必有;触发器当前修订标识,更新时作为 If-Match;不匹配返回 412。
usage_30dobject / null可选;仅 GET /triggers/{id} 返回,列表省略。最近 30 天由此触发器启动的运行及子运行的归因实扣。运行本身不收费;这里是运行中调用模型、搜索等能力产生的实扣,按调用归因;未评级的用量稍后计入。汇总超时(1.5 秒)或失败时为 null,详情仍返回 200。
usage_30d(分支1).currency"USD"必填 / 必有;金额币种,固定为 USD。
usage_30d(分支1).coststring必填 / 必有;已评级实扣的美元十进制字符串,精确到 6 位小数;没有用量时为 0.000000。 pattern: "^[0-9]+\.[0-9]{6}$"
usage_30d(分支1).pending_eventsinteger必填 / 必有;尚未评级的用量事件数,金额稍后才计入。 minimum: 0

实测响应

HTTP 200

{
  "id": "trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e",
  "owner": "tnt_3a9759864ccb4e00",
  "name": "sample-webhook-1791867412840-b05e8a",
  "description": "Sample webhook",
  "labels": {
    "namespace": "docs-samples"
  },
  "target": "docs-samples/sample-scripts-1791867412840-b05e8a@1.0.0",
  "input": {
    "n": 41
  },
  "kind": "webhook",
  "schedule": null,
  "timezone": "UTC",
  "start_at": null,
  "end_at": null,
  "overlap": "skip",
  "catchup_window_seconds": 300,
  "webhook": {
    "input_mode": "body",
    "url_hint": "https://api-develop.deepraxis.ai/automation/v1/hooks/trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e/…"
  },
  "state": "enabled",
  "source": "api",
  "created_by": {
    "type": "api_key",
    "id": "key_3e00b8984967"
  },
  "created_by_user_id": "usr_49d4fcb99517",
  "next_fire_times": [],
  "last_firing": null,
  "counts": {
    "started": 0,
    "skipped": 0,
    "missed": 0,
    "failed": 0
  },
  "created_at": "2026-10-13T04:58:09.974Z",
  "updated_at": "2026-10-13T04:58:17.058Z",
  "etag": "etag_00mv67n5gidea13751125d4ad292fb95b07fac032e"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TRIGGER_NOT_FOUND:触发器不存在或不可访问,回调鉴权失败也使用此错误。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
429TRIGGER_LIMIT:租户已达到 100 个启用触发器的上限。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

立即触发

立即触发一次并返回 Firing,仍受当前状态、补跑窗口和 overlap 约束;启动失败记在触发结果的 error 中。

POST /automation/v1/triggers/{id}/fire

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;触发器 ID(trg_)。
header: Idempotency-Keystring可选;可选;1–256 字符。24 小时内同一 key 重放首个响应并带 Idempotent-Replayed: true;同 key 不同请求体返回 422;处理中返回 409。 minLength: 1;maxLength: 256

示例

先设置以下环境变量,使用你自己的资源:

: "${TRIGGER_ID:?Set TRIGGER_ID}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/triggers/${TRIGGER_ID}/fire" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.triggers.fire({
  "path": {
    "id": env("TRIGGER_ID")
  },
  "body": {}
});
console.log(result);

响应

HTTP 200

Success

响应头类型说明
Idempotent-ReplayedbooleanPresent and true when replaying the first response for this key.

application/json

字段类型说明
idstring必填 / 必有;触发记录 ID;记录保留 30 天。
trigger_idstring必填 / 必有;所属触发器 ID(trg_ 前缀)。
scheduled_atstring必填 / 必有;计划触发的时间(RFC 3339 UTC);webhook 取请求到达时间。 format: "date-time"
fired_atstring必填 / 必有;实际触发的时间(RFC 3339 UTC)。 format: "date-time"
outcome"accepted" / "started" / "skipped_overlap" / "missed" / "failed" / "deduped"必填 / 必有;触发结果。accepted 已持久化等待处理;started 已创建运行;skipped_overlap 因上一次运行未结束而跳过;missed 到点时延迟超过补跑窗口,不补跑;failed 创建运行失败;deduped 与 24 小时内相同 webhook-id 的请求重复,已去重。
run_idstring / null必填 / 必有;本次触发创建的运行 ID(run_ 前缀);未创建运行为 null。
resolved_versionstring / null必填 / 必有;本次触发实际解析到的精确版本号;尚未解析或失败时为 null。
errorobject / null必填 / 必有;触发失败时的原因 {code, message};没有失败为 null。
error(分支1).codestring必填 / 必有;失败的错误码。
error(分支1).messagestring必填 / 必有;失败的说明文字。

实测响应

HTTP 200

{
  "id": "frg_00mv67n833fec8a47a90904782ac1a8f1fef264379",
  "trigger_id": "trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e",
  "scheduled_at": "2026-10-13T04:58:20.215Z",
  "fired_at": "2026-10-13T04:58:20.215Z",
  "outcome": "started",
  "run_id": "run_00mv67n8ao7de994212f453fdfe7def756b57ec5cdeb562a1222f554c6f3d9f428ec25480e",
  "resolved_version": "1.0.0",
  "error": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TRIGGER_NOT_FOUND:触发器不存在或不可访问,回调鉴权失败也使用此错误。
409IDEMPOTENCY_IN_FLIGHT:同一幂等键的请求仍在处理中。 RUN_INVALID_STATE:当前状态不允许执行该动作。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
422IDEMPOTENCY_KEY_MISMATCH:同一幂等键已用于不同请求内容。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

轮换回调地址

仅适用于 webhook 触发器:立即作废旧 token,返回新的完整 webhook_url;之后的详情读取不会再次显示完整地址。

POST /automation/v1/triggers/{id}/rotate-webhook

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;触发器 ID(trg_)。

示例

先设置以下环境变量,使用你自己的资源:

: "${TRIGGER_ID:?Set TRIGGER_ID}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/triggers/${TRIGGER_ID}/rotate-webhook" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.triggers.rotateWebhook({
  "path": {
    "id": env("TRIGGER_ID")
  },
  "body": {}
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
webhook_urlstring必填 / 必有;新的完整 webhook 地址,含私密 token;只返回这一次,请妥善保存,丢失后需再次轮换。旧地址立即失效。 format: "uri"

实测响应

HTTP 200

{
  "webhook_url": "https://api-develop.deepraxis.ai/automation/v1/hooks/trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e/${WEBHOOK_TOKEN}"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TRIGGER_NOT_FOUND:触发器不存在或不可访问,回调鉴权失败也使用此错误。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

列出触发历史

按时间倒序读取最近 30 天的触发记录。结果包括实际版本、运行 ID 与失败原因。

GET /automation/v1/triggers/{id}/firings

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;触发器 ID(trg_)。
query: limitinteger可选;每页条数,整数 1–100,默认 25。 minimum: 1;maximum: 100
query: cursorstring可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。
query: outcome"accepted" / "started" / "skipped_overlap" / "missed" / "failed" / "deduped"[]可选;按结果筛选,多个值用逗号分隔(OR);与 run_id 同时提供时取交集。
query: run_idstring可选;仅返回关联此运行 ID 的记录。

示例

先设置以下环境变量,使用你自己的资源:

: "${TRIGGER_ID:?Set TRIGGER_ID}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/triggers/${TRIGGER_ID}/firings" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.triggers.firings.list({
  "path": {
    "id": env("TRIGGER_ID")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
dataobject[]必填 / 必有;本页的最近 30 天的触发记录,按 created_at 倒序、id 倒序排列。
data[].idstring必填 / 必有;触发记录 ID;记录保留 30 天。
data[].trigger_idstring必填 / 必有;所属触发器 ID(trg_ 前缀)。
data[].scheduled_atstring必填 / 必有;计划触发的时间(RFC 3339 UTC);webhook 取请求到达时间。 format: "date-time"
data[].fired_atstring必填 / 必有;实际触发的时间(RFC 3339 UTC)。 format: "date-time"
data[].outcome"accepted" / "started" / "skipped_overlap" / "missed" / "failed" / "deduped"必填 / 必有;触发结果。accepted 已持久化等待处理;started 已创建运行;skipped_overlap 因上一次运行未结束而跳过;missed 到点时延迟超过补跑窗口,不补跑;failed 创建运行失败;deduped 与 24 小时内相同 webhook-id 的请求重复,已去重。
data[].run_idstring / null必填 / 必有;本次触发创建的运行 ID(run_ 前缀);未创建运行为 null。
data[].resolved_versionstring / null必填 / 必有;本次触发实际解析到的精确版本号;尚未解析或失败时为 null。
data[].errorobject / null必填 / 必有;触发失败时的原因 {code, message};没有失败为 null。
data[].error(分支1).codestring必填 / 必有;失败的错误码。
data[].error(分支1).messagestring必填 / 必有;失败的说明文字。
next_cursorstring / null必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。

实测响应

HTTP 200

{
  "data": [
    {
      "id": "frg_00mv67n833fec8a47a90904782ac1a8f1fef264379",
      "trigger_id": "trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e",
      "scheduled_at": "2026-10-13T04:58:20.215Z",
      "fired_at": "2026-10-13T04:58:20.215Z",
      "outcome": "started",
      "run_id": "run_00mv67n8ao7de994212f453fdfe7def756b57ec5cdeb562a1222f554c6f3d9f428ec25480e",
      "resolved_version": "1.0.0",
      "error": null
    },
    {
      "id": "frg_00mv67n6in516077a64cfc4102a4da939476a3fa78",
      "trigger_id": "trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e",
      "scheduled_at": "2026-10-13T04:58:18.384Z",
      "fired_at": "2026-10-13T04:58:18.384Z",
      "outcome": "started",
      "run_id": "run_00mv67n6vvebb47a96bf4b54630d8a07786ec923a68d3b722c2f7ffca4e0a553053c4a5421",
      "resolved_version": "1.0.0",
      "error": null
    }
  ],
  "next_cursor": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TRIGGER_NOT_FOUND:触发器不存在或不可访问,回调鉴权失败也使用此错误。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

预览触发时间

校验规则与时区并预览未来触发时间。返回人读说明及最多五个未来时间,不会创建触发器或运行。

POST /automation/v1/triggers/preview

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
header: Accept-Languagestring可选;人读描述的语言,支持中文(默认)与英文,按语言权重选择。

application/json

不接受额外字段。

字段类型说明
scheduleobject / object / object必填 / 必有;三选一:cron 为五段表达式(支持 L/W/#);every 至少一分钟;at 为带时区的一次性时间。与创建使用相同校验:at 须在当前时间至一年后之间;every 须为正整数毫秒且不超过 366 天。
schedule(分支1).cronstring必填 / 必有;Five fields; supports L, W, #. DST gaps skip the day and overlaps run once.
schedule(分支2).everystring / object必填 / 必有;时长:ISO 8601 字符串(如 PT5M),或 {days, hours, minutes, seconds, milliseconds} 对象;折算后必须是 60000 至 31622400000 毫秒(1 分钟至 366 天)的整数毫秒。
schedule(分支2).every(分支2).daysinteger可选;天数,非负整数。 minimum: 0
schedule(分支2).every(分支2).hoursinteger可选;小时数,非负整数。 minimum: 0
schedule(分支2).every(分支2).minutesinteger可选;分钟数,非负整数。 minimum: 0
schedule(分支2).every(分支2).secondsinteger可选;秒数,非负整数。 minimum: 0
schedule(分支2).every(分支2).millisecondsinteger可选;毫秒数,非负整数。 minimum: 0
schedule(分支3).atstring必填 / 必有;一次性触发时刻,需带 Z 或 ±HH:MM 时区;必须在请求时刻至一年后之间。调用时将示例替换为该范围内的未来时间。 pattern: "(Z|[+-]\d\d:\d\d)$";format: "date-time"
timezonestring可选;IANA 时区,默认 UTC;夏令时跳过不存在的时刻,重复时刻只触发一次。

示例

curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/triggers/preview" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "schedule": {
    "cron": "0 9 * * *"
  },
  "timezone": "UTC"
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: env('PRAXIS_API_KEY'),
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.triggers.preview({
  "body": {
    "schedule": {
      "cron": "0 9 * * *"
    },
    "timezone": "UTC"
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
descriptionstring必填 / 必有;规则的人读描述;常见 cron 为自然语言,其余回显表达式。语言由 Accept-Language 决定,默认中文。
next_fire_timesstring[]必填 / 必有;按该规则和时区计算的接下来最多 5 次触发时间(RFC 3339 UTC)。 maxItems: 5

实测响应

HTTP 200

{
  "description": "每天 09:00 · UTC",
  "next_fire_times": [
    "2026-10-13T09:00:00.000Z",
    "2026-10-14T09:00:00.000Z",
    "2026-10-15T09:00:00.000Z",
    "2026-10-16T09:00:00.000Z",
    "2026-10-17T09:00:00.000Z"
  ]
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 SCHEDULE_INVALID:定时规则或时间边界无效。 TIMEZONE_INVALID:时区不是有效的 IANA 时区。 INTERVAL_TOO_SHORT:定时间隔短于一分钟。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

接收入站回调

无需 API Key,以 URL 中 token 鉴权;token 错误、触发器不存在、类型不符或不在时间窗口内均返回 404;触发器处于暂停状态(连续 5 次失败熔断或人工暂停)返回 409 TRIGGER_PAUSED,message 说明原因,hint 给出恢复办法 POST /automation/v1/triggers/{id}/resume。原始请求体上限 512 KiB;组装后的运行输入(含原文与解析后的副本)序列化后最多 1 MiB,超限同步返回 413,不创建触发记录;webhook-id 去重 24 小时。202 的 outcome=accepted 表示已受理,最终结果随后更新,重复请求为 deduped。JSON 解析失败时 body 为 null;其它 UTF-8 为原文,非 UTF-8 为 base64。envelope 包含 body、raw_body、raw_body_encoding、白名单 headers、webhook_id 和 received_at;raw_body 保留原始字节,raw_body_encoding 为 utf8 或 base64,可用于自行验签。

POST /automation/v1/hooks/{trigger_id}/{token}

鉴权

使用创建或轮换时返回的 webhook URL;路径中的 token 是凭据,无需 Bearer Key。

请求字段

参数类型说明
path: trigger_idstring必填;触发器 ID(trg_)。
path: tokenstring必填;创建或轮换时返回的私密 URL token;请勿公开。
header: webhook-idstring可选;可选去重标识,同一触发器内保留 24 小时。

application/json

任意 JSON 值:null、布尔、数字、字符串、数组或对象。

字段类型说明
(分支5).*null / string / number / boolean / object / JSON[]递归 JSON 值。
(分支6)[]null / string / number / boolean / object / JSON[]递归 JSON 值。

text/plain

string

application/octet-stream

string

示例

先设置以下环境变量,使用你自己的资源:

: "${TRIGGER_ID:?Set TRIGGER_ID}"
: "${WEBHOOK_TOKEN:?Set WEBHOOK_TOKEN}"
curl --fail-with-body -X POST "https://api.deepraxis.ai/automation/v1/hooks/${TRIGGER_ID}/${WEBHOOK_TOKEN}" \
  -H "Content-Type: application/json" \
  --data '{
  "n": 41
}'
import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';

function env(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
}
const automation = createAutomationClient({
  apiKey: '',
  baseUrl: 'https://api.deepraxis.ai',
  maxRetries: 0,
  timeoutMs: 90_000,
});
const result = await automation.hooks.send({
  "path": {
    "trigger_id": env("TRIGGER_ID"),
    "token": env("WEBHOOK_TOKEN")
  },
  "body": {
    "n": 41
  }
});
console.log(result);

响应

HTTP 202

Success

application/json

字段类型说明
idstring必填 / 必有;触发记录 ID;记录保留 30 天。
trigger_idstring必填 / 必有;所属触发器 ID(trg_ 前缀)。
scheduled_atstring必填 / 必有;计划触发的时间(RFC 3339 UTC);webhook 取请求到达时间。 format: "date-time"
fired_atstring必填 / 必有;实际触发的时间(RFC 3339 UTC)。 format: "date-time"
outcome"accepted" / "started" / "skipped_overlap" / "missed" / "failed" / "deduped"必填 / 必有;触发结果。accepted 已持久化等待处理;started 已创建运行;skipped_overlap 因上一次运行未结束而跳过;missed 到点时延迟超过补跑窗口,不补跑;failed 创建运行失败;deduped 与 24 小时内相同 webhook-id 的请求重复,已去重。
run_idstring / null必填 / 必有;本次触发创建的运行 ID(run_ 前缀);未创建运行为 null。
resolved_versionstring / null必填 / 必有;本次触发实际解析到的精确版本号;尚未解析或失败时为 null。
errorobject / null必填 / 必有;触发失败时的原因 {code, message};没有失败为 null。
error(分支1).codestring必填 / 必有;失败的错误码。
error(分支1).messagestring必填 / 必有;失败的说明文字。

实测响应

HTTP 202

{
  "id": "frg_00mv67n6in516077a64cfc4102a4da939476a3fa78",
  "trigger_id": "trg_00mv67mzzqa0d63b98d72446dd9d1331051a3e100e",
  "scheduled_at": "2026-10-13T04:58:18.384Z",
  "fired_at": "2026-10-13T04:58:18.384Z",
  "outcome": "accepted",
  "run_id": null,
  "resolved_version": null,
  "error": null
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404TRIGGER_NOT_FOUND:触发器不存在或不可访问,回调鉴权失败也使用此错误。
405METHOD_NOT_ALLOWED:仅支持 POST;其它方法无需鉴权即返回 405,Allow 为 POST。
409TRIGGER_PAUSED:触发器处于暂停状态:连续 5 次触发失败触发熔断自动暂停,或被人工暂停;响应 message 说明原因,hint 给出恢复办法:恢复该触发器(triggers.resume)。
412PRECONDITION_FAILED:修订、源码摘要或并发写入条件不匹配。
413PAYLOAD_TOO_LARGE:请求内容超过本操作允许的大小。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

组织 API

基础地址

加载中…

接入

加载中…

事实与边界

事实说明
组织由 Key 决定调用方的 API Key 解析出唯一的组织;路径里没有组织 ID,组织的任何有效 API Key 都可读本域
只覆盖资金账户扣费仅统计从资金账户以 USD 扣费的用量;Credits 不在统计内
字段名按 FOCUS 1.3BilledCost、ServiceName、ConsumedQuantity 等列名与 FOCUS 1.3 规范逐字一致
时间一律 UTC窗口边界与时间桶都是 UTC ISO 8601;桶对齐到整点或自然日
查询窗口上限 93 天查询费用 / 查询用量 / 用量事件一次最多查 93 天;更久的账用费用明细导出,它按天在服务端分页
分页是不透明游标列表带 has_more 与 next_page;把 next_page 原样放进 page 参数取下一页

金额都是美元十进制字符串(如 "0.001234"),不要用浮点数相加——对账请按字符串精确十进制求和。

这里只统计从资金账户以美元扣费的用量;Credits 余额不在这个域。鉴权方式见鉴权。

端点

方法路径说明支持
GET/v1/costs查询费用● 支持
GET/v1/usage查询用量● 支持
GET/v1/events列出用量事件● 支持
GET/v1/events/{id}查看单个用量事件● 支持
GET/v1/charges导出费用明细● 支持

与官方的差异

  • 聚合信封照 OpenAI organization usage/costs、分桶与 estimated 标记照 AWS GetCostAndUsage、列名按 FOCUS 1.3、明细导出照 Vercel charges 的 JSONL。只给原始事实:占比、环比、前 N 名等派生视图不在本域,请在调用方自行计算。

参数与字段的权威定义以本站 /meta/v1/openapi.yaml 公开的规范与 FOCUS 1.3 规范为准。

错误按 problem+json 格式返回,参见错误;额度与响应头参见限流。

查询费用

GET /organization/v1/costs● 支持

官方参考 ↗

请求参数

  • starting_atstring必填

    query: 窗口开始(含),UTC ISO 8601,如 2026-09-26T00:00:00Z

  • ending_atstring必填

    query: 窗口结束(不含),UTC ISO 8601;距 starting_at 最多 93 天(费用明细导出无此限制)

  • bucket_widthstring必填

    query: 时间桶宽度:1h(整点对齐)或 1d(自然日对齐),一律 UTC

    取值 1h1d
  • time_zonestring可选
    默认 "UTC"

    query: IANA time zone name (for example Asia/Shanghai) whose local hours or days form the buckets. Defaults to UTC. Offsets such as +08:00 are rejected. The window widens to whole local buckets; a day that crosses a daylight-saving change lasts 23 or 25 hours. starting_at and ending_at stay UTC instants.

  • group_byarray可选

    query: 分组列,可重复:ServiceName、ServiceCategory、ResourceId、ConsumedUnit;查询用量时 ConsumedUnit 恒被服务端拆出

  • pagestring可选

    query: 上一页响应里 next_page 给出的不透明游标,原样带回即可

返回

200 page

错误按 problem+json 格式返回,参见 错误码

响应

HTTP 200

Cost page

application/json

名称类型说明
objectstringObject type; always `page`.
dataarray<object>Cost buckets in time order, one per hour or day of the requested window.
data[].objectstringObject type; always `bucket`.
data[].starting_atstringStart of the bucket, UTC, inclusive.
data[].ending_atstringEnd of the bucket, UTC, exclusive.
data[].estimatedbooleanTrue when at least one contributing event is not settled yet, so the amounts can still change.
data[].resultsarray<object>Aggregates of the bucket, one entry per group requested with group_by.
has_morebooleanWhether more results exist beyond this page; request again with `page` set to `next_page` to read them.
next_pagestring | nullOpaque cursor for the next page; null on the last page. Pass it unchanged as `page`.

响应字段

字段说明
object固定 "page"
data[].object固定 "bucket"
data[].starting_at / data[].ending_at桶的起止时间(UTC,整点或自然日对齐)
data[].estimatedtrue 表示该桶含尚未结算的用量,金额之后可能变化
data[].results[].ServiceName产生用量的服务名(仅在请求 group_by 含 ServiceName 时出现)
data[].results[].ServiceCategoryFOCUS 服务类别(仅按请求出现)
data[].results[].ResourceId / data[].results[].ResourceName资源 ID 与显示名;ResourceName 随 ResourceId 附带,解析不到显示名时等于 ResourceId
data[].results[].BilledCost该桶该组的费用,美元十进制字符串
data[].results[].BillingCurrency固定 "USD"
has_more / next_page是否还有下一页;下一页的不透明游标(null 表示没有更多)

单条明细的逐计量项拆分见查看单个用量事件。

查询用量

GET /organization/v1/usage● 支持

官方参考 ↗

请求参数

  • starting_atstring必填

    query: 窗口开始(含),UTC ISO 8601,如 2026-09-26T00:00:00Z

  • ending_atstring必填

    query: 窗口结束(不含),UTC ISO 8601;距 starting_at 最多 93 天(费用明细导出无此限制)

  • bucket_widthstring必填

    query: 时间桶宽度:1h(整点对齐)或 1d(自然日对齐),一律 UTC

    取值 1h1d
  • time_zonestring可选
    默认 "UTC"

    query: IANA time zone name (for example Asia/Shanghai) whose local hours or days form the buckets. Defaults to UTC. Offsets such as +08:00 are rejected. The window widens to whole local buckets; a day that crosses a daylight-saving change lasts 23 or 25 hours. starting_at and ending_at stay UTC instants.

  • group_byarray可选

    query: 分组列,可重复:ServiceName、ServiceCategory、ResourceId、ConsumedUnit;查询用量时 ConsumedUnit 恒被服务端拆出

  • pagestring可选

    query: 上一页响应里 next_page 给出的不透明游标,原样带回即可

返回

200 page

错误按 problem+json 格式返回,参见 错误码

响应

HTTP 200

Usage page

application/json

名称类型说明
objectstringObject type; always `page`.
dataarray<object>Usage buckets in time order, one per hour or day of the requested window.
data[].objectstringObject type; always `bucket`.
data[].starting_atstringStart of the bucket, UTC, inclusive.
data[].ending_atstringEnd of the bucket, UTC, exclusive.
data[].estimatedbooleanTrue when at least one contributing event is not settled yet, so the amounts can still change.
data[].resultsarray<object>Aggregates of the bucket, one entry per group requested with group_by.
has_morebooleanWhether more results exist beyond this page; request again with `page` set to `next_page` to read them.
next_pagestring | nullOpaque cursor for the next page; null on the last page. Pass it unchanged as `page`.

响应字段

字段说明
object / data[].object固定 "page" / 固定 "bucket"
data[].starting_at / data[].ending_at / data[].estimated桶的起止(UTC)与待结算标记,与查询费用相同
data[].results[].ServiceName / ServiceCategory服务列(仅按请求出现)
data[].results[].ResourceId / data[].results[].ResourceName资源列;ResourceName 随 ResourceId 附带
data[].results[].ConsumedQuantity该桶该组的消耗数量,十进制字符串
data[].results[].ConsumedUnit计量单位;不同单位各成一行,永远不会相加
has_more / next_page游标分页,与查询费用相同

单条明细的逐计量项拆分见查看单个用量事件。

列出用量事件

GET /organization/v1/events● 支持

官方参考 ↗

请求参数

  • starting_atstring必填

    query: 窗口开始(含),UTC ISO 8601,如 2026-09-26T00:00:00Z

  • ending_atstring必填

    query: 窗口结束(不含),UTC ISO 8601;距 starting_at 最多 93 天(费用明细导出无此限制)

  • limitinteger可选

    query: 每页条数,1–100,默认 25

  • pagestring可选

    query: 上一页响应里 next_page 给出的不透明游标,原样带回即可

返回

200 page

错误按 problem+json 格式返回,参见 错误码

响应

HTTP 200

Event page

application/json

名称类型说明
objectstringObject type; always `page`.
dataarray<object>Usage events, newest first.
data[].objectstringObject type; always `usage.event`.
data[].idstringId of the usage event; pass it to getOrganizationEvent.
data[].occurred_atstringTime at which the usage happened, UTC.
data[].ServiceNamestringName of the platform service that produced the usage (the source service of the usage event).
data[].ServiceCategorystringCategory of the service; a service without a registered category reports its own name.
data[].ResourceIdstringId of the resource that the usage belongs to.
data[].ResourceNamestringDisplay name of the resource; falls back to ResourceId when no name is known.
data[].BilledCoststringAmount billed in USD as an exact decimal string; unsettled usage counts as 0 until it settles.
data[].BillingCurrencystringCurrency of BilledCost; always `USD`.
data[].ChargeClassstring | null`Correction` for an event that corrects an earlier charge (its BilledCost is negative); null for ordinary usage.
data[].request_idstring | nullX-Request-Id of the API call that produced the usage; null for usage that does not come from a request.
data[].settlementobjectHow the usage was charged: settlement state, any shortfall, and why nothing was charged.
data[].linesarray<object>Metering lines mapped from the billing measurements; the priced split (ListUnitPrice, PricingUnit, BilledCost) rides only GET /events/{id}.
has_morebooleanWhether more results exist beyond this page; request again with `page` set to `next_page` to read them.
next_pagestring | nullOpaque cursor for the next page; null on the last page. Pass it unchanged as `page`.

响应字段

字段说明
object固定 "page"
data[].object固定 "usage.event"
data[].id事件 id;查单条明细、对账都用它
data[].occurred_at事件发生时间(UTC)
data[].ServiceName / ServiceCategory / ResourceId / ResourceNameFOCUS 服务与资源列
data[].BilledCost / BillingCurrency事件费用(美元十进制字符串)与币种
data[].ChargeClass更正事件为 "Correction"(费用为负数),普通事件为 null
data[].request_id产生这次用量的那次 API 调用响应头 X-Request-Id 的值,可拿去调用日志里查同一次请求
data[].settlement.statussettled(已结算)/ unsettled(未结算)/ settled_with_shortfall(结算有缺口)/ no_asset(无计费资产,零费用)
data[].settlement.shortfall / data[].settlement.zero_reason结算缺口金额(十进制字符串或 null);零费用的原因(或 null)
has_more / next_page按发生时间倒序逐页;游标不透明,不重复、不遗漏

单条明细的逐计量项拆分见查看单个用量事件。

查看单个用量事件

GET /organization/v1/events/{id}● 支持

官方参考 ↗

请求参数

  • idstring必填

    path: 用量事件 id,来自用量事件列表的 data[].id

返回

200 usage.event

错误按 problem+json 格式返回,参见 错误码

响应

HTTP 200

The usage event

application/json

名称类型说明
objectstringObject type; always `usage.event`.
idstringId of the usage event; pass it to getOrganizationEvent.
occurred_atstringTime at which the usage happened, UTC.
ServiceNamestringName of the platform service that produced the usage (the source service of the usage event).
ServiceCategorystringCategory of the service; a service without a registered category reports its own name.
ResourceIdstringId of the resource that the usage belongs to.
ResourceNamestringDisplay name of the resource; falls back to ResourceId when no name is known.
BilledCoststringAmount billed in USD as an exact decimal string; unsettled usage counts as 0 until it settles.
BillingCurrencystringCurrency of BilledCost; always `USD`.
ChargeClassstring | null`Correction` for an event that corrects an earlier charge (its BilledCost is negative); null for ordinary usage.
request_idstring | nullX-Request-Id of the API call that produced the usage; null for usage that does not come from a request.
settlementobjectHow the usage was charged: settlement state, any shortfall, and why nothing was charged.
settlement.statusstringSettlement state of the event.
settlement.shortfallstring | nullUSD amount that could not be charged, as a decimal string, when status is settled_with_shortfall; null otherwise.
settlement.zero_reasonstring | nullWhy nothing was charged for the event: `byok` when the caller used its own provider key; null when a charge applies.
linesarray<object>Priced lines of the event; their BilledCost values add up to the event's BilledCost.
lines[].meterstringKey of the meter that measured the line.
lines[].display_namestringEnglish label of the meter; falls back to the meter key in list pages.
lines[].ConsumedQuantitystringQuantity consumed, an exact decimal string in ConsumedUnit.
lines[].ConsumedUnitstringUnit of ConsumedQuantity as reported by the metering line; quantities of different units are never added together.
lines[].ListUnitPricestring | nullList price in USD per PricingUnit as a decimal string; null when the line is not priced.
lines[].PricingUnitstring | nullUnit that ListUnitPrice applies to; null when the line is not priced.
lines[].BilledCoststringAmount billed for this line in USD as a decimal string.

响应字段

字段说明
object / id / occurred_at固定 "usage.event"、事件 id、发生时间(UTC)
ServiceName / ServiceCategory / ResourceId / ResourceName / BilledCost / BillingCurrency / ChargeClass / request_id / settlement与用量事件列表中同一事件完全相同的字段
lines[].meter / lines[].display_name计量项标识与其英文显示名
lines[].ConsumedQuantity / ConsumedUnit该计量项的消耗数量与单位
lines[].ListUnitPrice / PricingUnit官方单价与计价单位(未公布时为 null)
lines[].BilledCost该计量项的费用;各项之和等于事件的 BilledCost

单条明细的逐计量项拆分见查看单个用量事件。

导出费用明细

GET /organization/v1/charges● 支持

官方参考 ↗

请求参数

  • starting_atstring必填

    query: 窗口开始(含),UTC ISO 8601,如 2026-09-26T00:00:00Z

  • ending_atstring必填

    query: 窗口结束(不含),UTC ISO 8601;距 starting_at 最多 93 天(费用明细导出无此限制)

返回

200

错误按 problem+json 格式返回,参见 错误码

响应

HTTP 200

FOCUS 1.3 JSONL stream

application/x-ndjson

名称类型说明
ChargePeriodStartstringStart of the charge period (the event time), UTC.
ChargePeriodEndstringEnd of the charge period (the event time), UTC.
BilledCoststringAmount billed in USD as an exact decimal string; unsettled usage counts as 0 until it settles.
BillingCurrencystringCurrency of BilledCost; always `USD`.
ServiceNamestringName of the platform service that produced the usage (the source service of the usage event).
ServiceCategorystringCategory of the service; a service without a registered category reports its own name.
ResourceIdstringId of the resource that the usage belongs to.
ResourceNamestringDisplay name of the resource; falls back to ResourceId when no name is known.
ConsumedQuantitystringQuantity consumed, an exact decimal string in ConsumedUnit.
ConsumedUnitstringUnit of ConsumedQuantity as reported by the metering line; quantities of different units are never added together.
ChargeCategorystringKind of charge.
ChargeClassstring | null`Correction` for an event that corrects an earlier charge (its BilledCost is negative); null for ordinary usage.
ChargeDescriptionstringText such as `<service>/<offering> usage` that says what was charged.
x_RequestIdstring | nullAlways null in the export; look up the request id of an event with getOrganizationEvent.
x_EventIdstringId of the usage event this record comes from; pass it to getOrganizationEvent.

响应字段

字段说明
ChargePeriodStart / ChargePeriodEnd计费周期起止(UTC)
BilledCost / BillingCurrency该事件费用(美元十进制字符串)与币种(USD)
ServiceName / ServiceCategory / ResourceId / ResourceNameFOCUS 服务与资源列
ConsumedQuantity / ConsumedUnit消耗数量与计量单位
ChargeCategoryUsage(用量)或 Adjustment(调整)
ChargeClass更正记录为 "Correction",普通记录为 null
ChargeDescription计量项的人类可读描述
x_RequestId / x_EventId产生这条记录的 API 调用的 X-Request-Id;对应的用量事件 id

单条明细的逐计量项拆分见查看单个用量事件。

Meta API

基础地址

加载中…

接入

加载中…

端点

方法路径说明支持
GET/v1/health健康检查● 支持
GET/v1/methods搜索方法● 支持
GET/v1/methods/{name}读取方法● 支持

与官方的差异

  • 本面是平台自描述面,不对应任何第三方官方 API;healthCheck 与方法目录都无需鉴权,healthCheck 返回纯文本 ok。
  • 搜索方法:非空 q 按方法名、摘要和描述的相关度搜索,词序和大小写不影响匹配;limit 为 1 到 50 的整数,默认 20。不带 q 或 q 全为空白时按方法名排序列出,limit 为 1 到 200 的整数,默认 50;has_more 为 true 时将 last_id 原样作为 after_id 取下一页。搜索时忽略 after_id。limit 越界返回 400 INVALID_PARAMS。目录只包含平台方法(praxis.*),不含会话里的 MCP 工具。
  • 读取方法:name 取自搜索结果,必须与方法名完全一致。声明不会被截断,字段名和枚举值请直接从中复制。未知名称返回 404 METHOD_NOT_FOUND,hint 列出最多三个相近的名称。

Meta 是平台自描述面:/meta/v1/openapi.yaml 返回当前环境的完整 OpenAPI 规范,参数与字段以它为准。

错误按 problem+json 格式返回,参见错误;额度与响应头参见限流。

健康检查

GET /meta/v1/health● 支持

返回

200

错误按 problem+json 格式返回,参见 错误码

响应

HTTP 200

The API edge is up; the body is the plain text `ok`.

text/plain

名称类型说明
$stringAlways the literal `ok`.

搜索方法

GET /meta/v1/methods● 支持

请求参数

  • qstring可选

    query: Words to look for, for example `list agents` or `create table`. Matched against method name, summary and description; every word must match when the query has two words or fewer, otherwise at least 60% of them. Omit to list methods without ranking.

  • limitinteger可选
    默认 50

    query: Maximum methods returned. Without q, defaults to 50 and accepts 1–200. Search with q defaults to 20 and accepts 1–50. Out-of-range values return 400 INVALID_PARAMS.

  • after_idstring可选

    query: Return names lexically after this method name, usually last_id from the previous page. Ignored when q is present. An empty or expired cursor still uses lexical ordering.

返回

200

非空 q 按方法名、摘要和描述的相关度搜索,词序和大小写不影响匹配;limit 为 1 到 50 的整数,默认 20。不带 q 或 q 全为空白时按方法名排序列出,limit 为 1 到 200 的整数,默认 50;has_more 为 true 时将 last_id 原样作为 after_id 取下一页。搜索时忽略 after_id。limit 越界返回 400 INVALID_PARAMS。目录只包含平台方法(praxis.*),不含会话里的 MCP 工具。

错误按 problem+json 格式返回,参见 错误码

响应

HTTP 200

Matching methods, best match first. An empty `data` array means nothing matched; try fewer or different words.

application/json

名称类型说明
has_morebooleanPresent without q; true when another page follows.
first_idstring | nullPresent without q; first method name in this page, or null for an empty page.
last_idstring | nullPresent without q; last method name in this page, or null for an empty page. Pass as after_id to continue.
dataarray<object>Matching methods ordered by relevance for search, or by name for unranked listing.
data[].paramsstringCompact argument list grouped by location, for example `path: database_id*, table* · query: select, order · body*`. A trailing `*` marks a required argument; `body` stands for the JSON request body. Call `GET /meta/v1/methods/{name}` for each argument's type and description.
data[].namestringMethod name such as `praxis.agent.agents.list`. Pass it to `GET /meta/v1/methods/{name}` and call it as `await praxis.agent.agents.list(args)` in codemode or an automation script.
data[].summarystringOne-line statement of what the method does.
data[].httpstringHTTP verb the method sends, for example GET or POST.
data[].pathstringPublic API path template the method calls, with `{param}` placeholders filled from `args.path`.

读取方法

GET /meta/v1/methods/{name}● 支持

请求参数

  • namestring必填

    path: Exact method name from the search results, for example `praxis.database.databases.tables.create`.

返回

200

name 取自搜索结果,必须与方法名完全一致。声明不会被截断,字段名和枚举值请直接从中复制。未知名称返回 404 METHOD_NOT_FOUND,hint 列出最多三个相近的名称。

错误按 problem+json 格式返回,参见 错误码

响应

HTTP 200

The method with its complete declaration.

application/json

名称类型说明
namestringMethod name, for example `praxis.agent.agents.list`.
summarystringOne-line statement of what the method does.
descriptionstringFull guidance for the method from the API reference, including when to use it, limits and error behaviour. May be empty for methods documented only by summary.
httpstringHTTP verb the method sends.
pathstringPublic API path template with `{param}` placeholders.
declarationstringComplete TypeScript signature, `name(args): Promise<Result>`. `args` carries `path`, `query`, `headers` and `body` members exactly as declared. Never truncated.
parametersarray<object>Path, query and header parameters of the operation.
parameters[].namestringParameter name as sent on the wire.
parameters[].instringWhere the parameter goes, one of `path`, `query` or `header`; maps to the matching member of `args`.
parameters[].requiredbooleanWhether the call is rejected when the parameter is missing.
parameters[].descriptionstringMeaning, format and allowed values of the parameter.
parameters[].typestringTypeScript type of the parameter value.
request_bodyobjectRequest body expectations; null when the method takes no body.
request_body.requiredbooleanWhether `args.body` must be supplied.
request_body.descriptionstringWhat the body carries.
request_body.content_typesarray<string>Media types the body may use; the first is the default.
responsesarray<object>Documented responses, successful and failed.
responses[].statusstringHTTP status code or `default`.
responses[].descriptionstringWhat the response means and what to do next.
responses[].content_typesarray<string>Media types the response may use.

云端浏览器 API

连接与使用指南

基础地址: https://api-develop.deepraxis.ai/browser

请求头: Authorization: Bearer $PRAXIS_API_KEY

请求 ID 响应头: X-Request-Id

操作方法与路径
创建浏览器会话POST /browser/v1/sessions
列出浏览器会话GET /browser/v1/sessions
读取浏览器会话GET /browser/v1/sessions/{sessionId}
关闭浏览器会话POST /browser/v1/sessions/{sessionId}
读取调试地址GET /browser/v1/sessions/{sessionId}/debug
列出会话事件GET /browser/v1/sessions/{sessionId}/events
请求人工接管POST /browser/v1/sessions/{sessionId}/handoff
完成人工接管POST /browser/v1/sessions/{sessionId}/handoff/complete
更新查看者心跳POST /browser/v1/sessions/{sessionId}/viewer
创建登录态POST /browser/v1/contexts
列出登录态GET /browser/v1/contexts
读取登录态GET /browser/v1/contexts/{contextId}
更新登录态PUT /browser/v1/contexts/{contextId}
删除登录态DELETE /browser/v1/contexts/{contextId}
连接云端浏览器GET /browser/v1/connect
打开实时浏览器画面GET /browser/v1/live/{sessionId}/{pageId}
订阅会话动态GET /browser/v1/sessions/{sessionId}/stream
读取 Selenium 不支持提示GET /browser/v1/selenium-unsupported

创建浏览器会话

POST /browser/v1/sessions● 支持

请求参数

  • projectIdstring可选

    可省略;账户使用 default 项目。

  • keepAliveboolean可选
    默认 false

    false 时最后一个客户端断开且无人观看后结束会话;true 时保留至关闭或超时。

  • timeoutnumber可选
    默认 3600

    从创建时刻起算的会话最长寿命,单位为秒;可含小数。

  • browserSettingsobject可选

    创建浏览器时的登录态、视口及兼容选项;省略时不加载已保存的登录态。

    ▸ 展开子字段(13)
    • contextobject可选

      新会话使用的已保存登录态;必须属于当前账户;persist 为 true 时同一登录态只能有一个写入会话。

      ▸ 展开子字段(2)
      • idstring必填

        登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。

      • persistboolean可选
        默认 false

        关闭会话时合并保存 cookie 和 localStorage;false 只读取登录态;不保存 IndexedDB。

    • viewportobject可选

      浏览器视口尺寸;创建时省略整个对象则使用宽 1280、高 800 像素。

      ▸ 展开子字段(2)
      • widthinteger必填

        浏览器视口宽度,单位为像素,必须为正整数。

      • heightinteger必填

        浏览器视口高度,单位为像素,必须为正整数。

    • blockAdsboolean可选◐ 部分支持

      接受但忽略;不会启用此能力。

    • solveCaptchasboolean可选◐ 部分支持

      接受但忽略;不会启用此能力。

    • recordSessionboolean可选◐ 部分支持

      接受但忽略;不会启用此能力。

    • logSessionboolean可选◐ 部分支持

      接受但忽略;不会启用此能力。

    • extensionIdstring可选○ 未支持

      不支持此配置。

    • verifiedboolean可选○ 未支持

      不支持此配置。

    • advancedStealthboolean可选○ 未支持

      不支持此配置。

    • osstring可选○ 未支持

      不支持此配置。

    • fingerprintobject可选○ 未支持

      不支持此配置。

    • allowedDomainsarray可选○ 未支持

      不支持此配置。

    • ignoreCertificateErrorsboolean可选○ 未支持

      不支持此配置。

  • proxiesunion可选◐ 部分支持

    仅省略、false 或 [{type: 'none'}] 可用,其它代理配置返回 501。

  • regionstring可选◐ 部分支持

    接受但忽略;不会启用此能力。

  • extensionIdstring可选○ 未支持

    不支持此配置。

  • userMetadataobject可选

    自定义 JSON 元数据;序列化后的长度最多为 512 个 UTF-16 代码单元。

  • namestring可选

    会话名称;1–128 个 ASCII 字母、数字或 . _ : -,可用于筛选会话。

  • labelsobject可选

    自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。

返回

201

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 201

请求成功。

application/json

名称类型说明
idstring浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。
projectIdstring兼容项目标识,当前账户的会话固定返回 default。
statusstring会话生命周期状态;释放中的会话仍显示 RUNNING,但已不能建立新连接。
keepAlivebooleanAPI 创建的会话是否在客户端断开后保留;true 不因空闲释放,仍受最长寿命限制。
regionstring兼容字段,不代表可选择部署区域。
proxyBytesinteger兼容的代理流量字节数;当前未使用代理,固定返回 0。
createdAtstring会话创建时刻,UTC ISO 8601 时间。
updatedAtstring会话状态最近一次更新的时刻,UTC ISO 8601 时间。
startedAtstring浏览器开始运行的时刻;尚未开始运行时返回创建时刻,UTC ISO 8601 时间。
expiresAtstring会话最长寿命的到期时刻,等于创建时刻加 timeout 秒,UTC ISO 8601 时间。
endedAtstring浏览器使用区间的结束时刻,UTC ISO 8601 时间;尚未记录结束时刻时省略。
contextIdstring登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。
userMetadataobject创建会话时传入的自定义 JSON 元数据;未设置时为空对象。
namestring会话名称;1–128 个 ASCII 字母、数字或 . _ : -,可用于筛选会话。
labelsobject自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。
originstring会话创建入口;api 为 API 创建,connect 为一步连接创建,console 为 Console 创建。
closeReasonstring会话释放原因;未开始释放时省略。
viewportobject浏览器视口尺寸;创建时省略整个对象则使用宽 1280、高 800 像素。
viewport.widthinteger浏览器视口宽度,单位为像素,必须为正整数。
viewport.heightinteger浏览器视口高度,单位为像素,必须为正整数。
billedSecondsnumber会话计费时长,单位为秒;运行时随时长增长,结束后为最终计费时长,可含小数。
currentUrlstring最近观察到的页面导航地址;尚未观察到导航时省略。
clientsinteger当前连接的 CDP 客户端数量;不包含仅观看页面的用户。
handoffobject | null待完成的人工接管请求;没有请求、已完成或已过期时为 null。
handoff.messagestring请求人工接管时提供给操作者的说明文字。
handoff.requestedAtstring人工接管请求的发起时刻,UTC ISO 8601 时间。
handoff.expiresAtstring人工接管请求的失效时刻,UTC ISO 8601 时间。
connectUrlstring自带凭证的 CDP WebSocket 地址,有效期覆盖会话寿命;连接无需额外 API Key。
signingKeystringconnectUrl 内的连接凭证,请勿公开。
seleniumRemoteUrlstring该地址返回 501;不支持 Selenium。

列出浏览器会话

GET /browser/v1/sessions● 支持

请求参数

  • statusstring可选

    按会话生命周期状态筛选;省略时返回所有状态。

    取值 PENDINGRUNNINGERRORTIMED_OUTCOMPLETED
  • qstring可选

    按单个用户元数据键的字符串值精确筛选,例如 user_metadata['purpose']:'docs'。

  • namestring可选

    按会话名称精确匹配;省略时不按名称筛选。

  • labelsstring可选

    JSON 编码的标签对象;仅返回同时匹配所有标签键值的会话。

  • cursorstring可选

    上一页返回的 nextCursor,原样传入以继续读取;省略时读取第一页。

  • limitinteger可选

    每页最多返回的记录数量;默认 50,范围 1–200。

返回

200

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 200

请求成功。

application/json

名称类型说明
dataarray<object>本页查询匹配的记录;没有匹配项时为空数组。
data[].idstring浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。
data[].projectIdstring兼容项目标识,当前账户的会话固定返回 default。
data[].statusstring会话生命周期状态;释放中的会话仍显示 RUNNING,但已不能建立新连接。
data[].keepAlivebooleanAPI 创建的会话是否在客户端断开后保留;true 不因空闲释放,仍受最长寿命限制。
data[].regionstring兼容字段,不代表可选择部署区域。
data[].proxyBytesinteger兼容的代理流量字节数;当前未使用代理,固定返回 0。
data[].createdAtstring会话创建时刻,UTC ISO 8601 时间。
data[].updatedAtstring会话状态最近一次更新的时刻,UTC ISO 8601 时间。
data[].startedAtstring浏览器开始运行的时刻;尚未开始运行时返回创建时刻,UTC ISO 8601 时间。
data[].expiresAtstring会话最长寿命的到期时刻,等于创建时刻加 timeout 秒,UTC ISO 8601 时间。
data[].endedAtstring浏览器使用区间的结束时刻,UTC ISO 8601 时间;尚未记录结束时刻时省略。
data[].contextIdstring登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。
data[].userMetadataobject创建会话时传入的自定义 JSON 元数据;未设置时为空对象。
data[].namestring会话名称;1–128 个 ASCII 字母、数字或 . _ : -,可用于筛选会话。
data[].labelsobject自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。
data[].originstring会话创建入口;api 为 API 创建,connect 为一步连接创建,console 为 Console 创建。
data[].closeReasonstring会话释放原因;未开始释放时省略。
data[].viewportobject浏览器视口尺寸;创建时省略整个对象则使用宽 1280、高 800 像素。
data[].billedSecondsnumber会话计费时长,单位为秒;运行时随时长增长,结束后为最终计费时长,可含小数。
data[].currentUrlstring最近观察到的页面导航地址;尚未观察到导航时省略。
data[].clientsinteger当前连接的 CDP 客户端数量;不包含仅观看页面的用户。
data[].handoffobject | null待完成的人工接管请求;没有请求、已完成或已过期时为 null。
nextCursorstring | null下一页游标;原样传入 cursor,null 表示没有更多结果。

读取浏览器会话

GET /browser/v1/sessions/{sessionId}● 支持

请求参数

  • sessionIdstring必填

    浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。

  • expandstring可选

    逗号分隔的 debug、events;在同一响应中返回调试地址和事件。

返回

200

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 200

请求成功。

application/json

名称类型说明
idstring浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。
projectIdstring兼容项目标识,当前账户的会话固定返回 default。
statusstring会话生命周期状态;释放中的会话仍显示 RUNNING,但已不能建立新连接。
keepAlivebooleanAPI 创建的会话是否在客户端断开后保留;true 不因空闲释放,仍受最长寿命限制。
regionstring兼容字段,不代表可选择部署区域。
proxyBytesinteger兼容的代理流量字节数;当前未使用代理,固定返回 0。
createdAtstring会话创建时刻,UTC ISO 8601 时间。
updatedAtstring会话状态最近一次更新的时刻,UTC ISO 8601 时间。
startedAtstring浏览器开始运行的时刻;尚未开始运行时返回创建时刻,UTC ISO 8601 时间。
expiresAtstring会话最长寿命的到期时刻,等于创建时刻加 timeout 秒,UTC ISO 8601 时间。
endedAtstring浏览器使用区间的结束时刻,UTC ISO 8601 时间;尚未记录结束时刻时省略。
contextIdstring登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。
userMetadataobject创建会话时传入的自定义 JSON 元数据;未设置时为空对象。
namestring会话名称;1–128 个 ASCII 字母、数字或 . _ : -,可用于筛选会话。
labelsobject自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。
originstring会话创建入口;api 为 API 创建,connect 为一步连接创建,console 为 Console 创建。
closeReasonstring会话释放原因;未开始释放时省略。
viewportobject浏览器视口尺寸;创建时省略整个对象则使用宽 1280、高 800 像素。
viewport.widthinteger浏览器视口宽度,单位为像素,必须为正整数。
viewport.heightinteger浏览器视口高度,单位为像素,必须为正整数。
billedSecondsnumber会话计费时长,单位为秒;运行时随时长增长,结束后为最终计费时长,可含小数。
currentUrlstring最近观察到的页面导航地址;尚未观察到导航时省略。
clientsinteger当前连接的 CDP 客户端数量;不包含仅观看页面的用户。
handoffobject | null待完成的人工接管请求;没有请求、已完成或已过期时为 null。
handoff.messagestring请求人工接管时提供给操作者的说明文字。
handoff.requestedAtstring人工接管请求的发起时刻,UTC ISO 8601 时间。
handoff.expiresAtstring人工接管请求的失效时刻,UTC ISO 8601 时间。
debugobject会话和标签页的实时观看地址,以及当前会话的 CDP 连接地址。
debug.debuggerFullscreenUrlstring会话实时画面的完整跳转地址,携带观看凭证;与 debuggerUrl 相同。
debug.debuggerUrlstring会话实时画面的完整跳转地址;直接打开,勿移除查询凭证。
debug.wsUrlstring连接当前会话的 CDP WebSocket 地址,自带 signingKey,无需额外 API Key。
debug.pagesarray<object>当前浏览器标签页及各页的实时观看地址;会话不在运行状态时为空数组。
eventsobjectexpand 包含 events 时返回的会话事件首页;后续页通过事件列表读取。
events.dataarray<object>本页查询匹配的记录;没有匹配项时为空数组。
events.nextCursorstring | null下一页游标;原样传入 cursor,null 表示没有更多结果。

关闭浏览器会话

POST /browser/v1/sessions/{sessionId}● 支持

请求参数

  • sessionIdstring必填

    浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。

  • statusstring必填

    会话操作指令;REQUEST_RELEASE 表示请求关闭浏览器并结束会话。

    取值 REQUEST_RELEASE

返回

200

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 200

请求成功。

application/json

名称类型说明
idstring浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。
projectIdstring兼容项目标识,当前账户的会话固定返回 default。
statusstring会话生命周期状态;释放中的会话仍显示 RUNNING,但已不能建立新连接。
keepAlivebooleanAPI 创建的会话是否在客户端断开后保留;true 不因空闲释放,仍受最长寿命限制。
regionstring兼容字段,不代表可选择部署区域。
proxyBytesinteger兼容的代理流量字节数;当前未使用代理,固定返回 0。
createdAtstring会话创建时刻,UTC ISO 8601 时间。
updatedAtstring会话状态最近一次更新的时刻,UTC ISO 8601 时间。
startedAtstring浏览器开始运行的时刻;尚未开始运行时返回创建时刻,UTC ISO 8601 时间。
expiresAtstring会话最长寿命的到期时刻,等于创建时刻加 timeout 秒,UTC ISO 8601 时间。
endedAtstring浏览器使用区间的结束时刻,UTC ISO 8601 时间;尚未记录结束时刻时省略。
contextIdstring登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。
userMetadataobject创建会话时传入的自定义 JSON 元数据;未设置时为空对象。
namestring会话名称;1–128 个 ASCII 字母、数字或 . _ : -,可用于筛选会话。
labelsobject自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。
originstring会话创建入口;api 为 API 创建,connect 为一步连接创建,console 为 Console 创建。
closeReasonstring会话释放原因;未开始释放时省略。
viewportobject浏览器视口尺寸;创建时省略整个对象则使用宽 1280、高 800 像素。
viewport.widthinteger浏览器视口宽度,单位为像素,必须为正整数。
viewport.heightinteger浏览器视口高度,单位为像素,必须为正整数。
billedSecondsnumber会话计费时长,单位为秒;运行时随时长增长,结束后为最终计费时长,可含小数。
currentUrlstring最近观察到的页面导航地址;尚未观察到导航时省略。
clientsinteger当前连接的 CDP 客户端数量;不包含仅观看页面的用户。
handoffobject | null待完成的人工接管请求;没有请求、已完成或已过期时为 null。
handoff.messagestring请求人工接管时提供给操作者的说明文字。
handoff.requestedAtstring人工接管请求的发起时刻,UTC ISO 8601 时间。
handoff.expiresAtstring人工接管请求的失效时刻,UTC ISO 8601 时间。

读取调试地址

GET /browser/v1/sessions/{sessionId}/debug● 支持

请求参数

  • sessionIdstring必填

    浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。

返回

200

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 200

请求成功。

application/json

名称类型说明
debuggerFullscreenUrlstring会话实时画面的完整跳转地址,携带观看凭证;与 debuggerUrl 相同。
debuggerUrlstring会话实时画面的完整跳转地址;直接打开,勿移除查询凭证。
wsUrlstring连接当前会话的 CDP WebSocket 地址,自带 signingKey,无需额外 API Key。
pagesarray<object>当前浏览器标签页及各页的实时观看地址;会话不在运行状态时为空数组。
pages[].idstring浏览器标签页的目标 ID,可用于实时画面地址中的 pageId。
pages[].urlstring该浏览器标签页当前报告的页面地址。
pages[].titlestring该浏览器标签页当前报告的页面标题。
pages[].faviconUrlstring兼容的页面图标地址字段,当前固定返回空字符串。
pages[].debuggerUrlstring此标签页实时画面的完整跳转地址,包含观看凭证。
pages[].debuggerFullscreenUrlstring此标签页实时画面的完整跳转地址,与该页 debuggerUrl 相同。

列出会话事件

GET /browser/v1/sessions/{sessionId}/events● 支持

请求参数

  • sessionIdstring必填

    浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。

  • cursorstring可选

    上一页返回的 nextCursor,表示已读到的事件序号;省略时从最早事件开始。

  • limitinteger可选

    每页最多返回的记录数量;默认 50,范围 1–200。

  • typesstring可选

    逗号分隔的账本事件类型,仅返回匹配项;省略时不按类型筛选。

返回

200

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 200

请求成功。

application/json

名称类型说明
dataarray<object>本页查询匹配的记录;没有匹配项时为空数组。
data[].seqinteger当前会话内递增的事件序号,用于事件排序及分页。
data[].idstring服务生成的事件唯一标识,使用 UUID 格式。
data[].typestring会话账本中的事件类型,用于区分状态变化和会话操作。
data[].processed_atstring事件记录时刻,UTC ISO 8601 时间。
data[].session_idstring浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。
data[].reasonstring事件发生原因;关闭相关事件记录对应的会话释放原因。
data[].payloadobject事件附加数据,内容取决于事件类型;没有附加数据时省略。
nextCursorstring | null下一页游标;原样传入 cursor,null 表示没有更多结果。

请求人工接管

POST /browser/v1/sessions/{sessionId}/handoff● 支持

请求参数

  • sessionIdstring必填

    浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。

  • messagestring必填

    交给人工操作者的接管说明,可为空字符串。

  • timeoutMsnumber可选
    默认 1800000

    接管请求有效时长,单位为毫秒;必须大于 0,可含小数。

返回

200

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 200

请求成功。

application/json

名称类型说明
seqinteger当前会话内递增的事件序号,用于事件排序及分页。
idstring服务生成的事件唯一标识,使用 UUID 格式。
typestring会话账本中的事件类型,用于区分状态变化和会话操作。
processed_atstring事件记录时刻,UTC ISO 8601 时间。
session_idstring浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。
reasonstring事件发生原因;关闭相关事件记录对应的会话释放原因。
payloadobject事件附加数据,内容取决于事件类型;没有附加数据时省略。

完成人工接管

POST /browser/v1/sessions/{sessionId}/handoff/complete● 支持

请求参数

  • sessionIdstring必填

    浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。

返回

200

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 200

请求成功。

application/json

名称类型说明
seqinteger当前会话内递增的事件序号,用于事件排序及分页。
idstring服务生成的事件唯一标识,使用 UUID 格式。
typestring会话账本中的事件类型,用于区分状态变化和会话操作。
processed_atstring事件记录时刻,UTC ISO 8601 时间。
session_idstring浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。
reasonstring事件发生原因;关闭相关事件记录对应的会话释放原因。
payloadobject事件附加数据,内容取决于事件类型;没有附加数据时省略。

更新查看者心跳

POST /browser/v1/sessions/{sessionId}/viewer● 支持

请求参数

  • sessionIdstring必填

    浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。

  • viewerIdstring必填

    当前观看者的稳定标识;同一观看者重复心跳应使用相同值,长度为 1–128 个 UTF-16 代码单元。

返回

200

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 200

请求成功。

application/json

名称类型说明
okboolean心跳已被接受,成功时固定返回 true。

创建登录态

POST /browser/v1/contexts● 支持

请求参数

  • projectIdstring可选

    兼容项目字段;传入值被忽略,创建结果的 projectId 固定为 default。

  • namestring可选

    登录态名称;非空时为 1–128 个 ASCII 字母、数字或 . _ : -,在当前账户内唯一;空字符串表示不设名称或清除名称。

  • labelsobject可选

    自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。

返回

201

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 201

请求成功。

application/json

名称类型说明
idstring登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。
projectIdstring兼容项目标识,当前账户的登录态固定返回 default。
createdAtstring登录态创建时刻,UTC ISO 8601 时间。
updatedAtstring登录态名称、标签或保存内容最近一次更新的时刻,UTC ISO 8601 时间。
namestring登录态名称;非空时为 1–128 个 ASCII 字母、数字或 . _ : -,在当前账户内唯一;空字符串表示不设名称或清除名称。
labelsobject自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。
sitesarray<string>已保存的 localStorage 主机名和 cookie 域名,去掉 cookie 域名前导点后去重排序。
cookieCountinteger登录态中已保存的 cookie 条目数量;新登录态为 0。
bytesinteger登录态加密后保存内容的大小,单位为 UTF-8 字节。
lockedBystring当前登录态写入租约的持有者标识;无有效租约时省略。
lastUsedAtstring
publicKeystring
cipherAlgorithmstring
initializationVectorSizeinteger

列出登录态

GET /browser/v1/contexts● 支持

请求参数

  • cursorstring可选

    上一页返回的 nextCursor,原样传入以继续读取;省略时读取第一页。

  • limitinteger可选

    每页最多返回的登录态数量;默认 25,范围 1–100。

返回

200

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 200

请求成功。

application/json

名称类型说明
dataarray<object>本页查询匹配的记录;没有匹配项时为空数组。
data[].idstring登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。
data[].projectIdstring兼容项目标识,当前账户的登录态固定返回 default。
data[].createdAtstring登录态创建时刻,UTC ISO 8601 时间。
data[].updatedAtstring登录态名称、标签或保存内容最近一次更新的时刻,UTC ISO 8601 时间。
data[].namestring登录态名称;非空时为 1–128 个 ASCII 字母、数字或 . _ : -,在当前账户内唯一;空字符串表示不设名称或清除名称。
data[].labelsobject自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。
data[].sitesarray<string>已保存的 localStorage 主机名和 cookie 域名,去掉 cookie 域名前导点后去重排序。
data[].cookieCountinteger登录态中已保存的 cookie 条目数量;新登录态为 0。
data[].bytesinteger登录态加密后保存内容的大小,单位为 UTF-8 字节。
data[].lockedBystring当前登录态写入租约的持有者标识;无有效租约时省略。
data[].lastUsedAtstring
nextCursorstring | null下一页游标;原样传入 cursor,null 表示没有更多结果。

读取登录态

GET /browser/v1/contexts/{contextId}● 支持

请求参数

  • contextIdstring必填

    登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。

返回

200

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 200

请求成功。

application/json

名称类型说明
idstring登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。
projectIdstring兼容项目标识,当前账户的登录态固定返回 default。
createdAtstring登录态创建时刻,UTC ISO 8601 时间。
updatedAtstring登录态名称、标签或保存内容最近一次更新的时刻,UTC ISO 8601 时间。
namestring登录态名称;非空时为 1–128 个 ASCII 字母、数字或 . _ : -,在当前账户内唯一;空字符串表示不设名称或清除名称。
labelsobject自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。
sitesarray<string>已保存的 localStorage 主机名和 cookie 域名,去掉 cookie 域名前导点后去重排序。
cookieCountinteger登录态中已保存的 cookie 条目数量;新登录态为 0。
bytesinteger登录态加密后保存内容的大小,单位为 UTF-8 字节。
lockedBystring当前登录态写入租约的持有者标识;无有效租约时省略。
lastUsedAtstring

更新登录态

PUT /browser/v1/contexts/{contextId}● 支持

请求参数

  • contextIdstring必填

    登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。

  • namestring可选

    登录态名称;非空时为 1–128 个 ASCII 字母、数字或 . _ : -,在当前账户内唯一;空字符串表示不设名称或清除名称。

  • labelsobject可选

    自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。 更新时整体替换;空对象清除标签,省略则保留。

返回

200

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 200

请求成功。

application/json

名称类型说明
idstring登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。
projectIdstring兼容项目标识,当前账户的登录态固定返回 default。
createdAtstring登录态创建时刻,UTC ISO 8601 时间。
updatedAtstring登录态名称、标签或保存内容最近一次更新的时刻,UTC ISO 8601 时间。
namestring登录态名称;非空时为 1–128 个 ASCII 字母、数字或 . _ : -,在当前账户内唯一;空字符串表示不设名称或清除名称。
labelsobject自定义字符串标签;最多 32 项,键最多 128 个 UTF-8 字节,值最多 1024 个 UTF-8 字节。
sitesarray<string>已保存的 localStorage 主机名和 cookie 域名,去掉 cookie 域名前导点后去重排序。
cookieCountinteger登录态中已保存的 cookie 条目数量;新登录态为 0。
bytesinteger登录态加密后保存内容的大小,单位为 UTF-8 字节。
lockedBystring当前登录态写入租约的持有者标识;无有效租约时省略。
lastUsedAtstring

删除登录态

DELETE /browser/v1/contexts/{contextId}● 支持

请求参数

  • contextIdstring必填

    登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。

返回

200

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 200

请求成功。

application/json

名称类型说明
deletedboolean登录态及保存内容已删除,成功时固定返回 true。

连接云端浏览器

GET /browser/v1/connect● 支持

请求参数

  • sessionstring可选

    要连接的已有会话 ID,来自创建或列表响应;不能同时提供 name。

  • namestring可选

    按名称连接或创建。

  • signingKeystring可选

    connectUrl 自带凭证;必须同时带 session。

  • contextstring可选

    新会话使用的登录态 ID,来自创建或列表响应;连接已有会话时忽略。

  • persistboolean可选

    关闭时保存登录态。

  • timeoutnumber可选

    新会话最长寿命,单位为秒,可含小数;连接已有会话时忽略。

  • idlenumber可选

    新会话无人连接或观看后的释放等待时长,单位为毫秒;允许 0 或小数,连接已有会话时忽略。

  • labelsstring可选

    JSON 编码的字符串标签对象。

  • viewportstring可选

    JSON 编码的视口,例如 {"width":1280,"height":800}。

返回

101

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

此端点没有声明成功响应。

打开实时浏览器画面

GET /browser/v1/live/{sessionId}/{pageId}● 支持

请求参数

  • sessionIdstring必填

    浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。

  • pageIdstring必填

    实时观看地址中的标签页 ID;使用 debug 返回链接中的原值,_ 表示会话级画面。

  • tstring可选

    实时观看地址自带的凭证。

返回

302

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

此端点没有声明成功响应。

订阅会话动态

GET /browser/v1/sessions/{sessionId}/stream● 支持

请求参数

  • sessionIdstring必填

    浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。

返回

200

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

HTTP 200

持续推送会话状态。

text/event-stream — chunk / 事件对象

名称类型说明
$stringevent: <事件名>\ndata: <JSON>\n\n

GET /browser/v1/selenium-unsupported○ 未支持

返回

501

错误含 statusCode、error、message;自有面另含 code。请求 ID 见 X-Request-Id。 错误

连接与使用指南

响应

此端点没有声明成功响应。

文件 API

基础地址

加载中…

接入

加载中…

单文件上限 100 MB(104857600 字节),上传与下载全程流式。不提供 Uploads 分片。文件按内容识别类型;支持格式见上传端点。组织之间的文件互不可见。

端点

方法路径说明支持
POST/v1/files上传文件◐ 部分支持
GET/v1/files列出文件● 支持
GET/v1/files/{file_id}查看文件● 支持
GET/v1/files/{file_id}/content下载文件● 支持
DELETE/v1/files/{file_id}删除文件● 支持

与官方的差异

  • 沿用 OpenAI 的文件和分页形状,增加 mime_type、downloadable,以及 before 查询游标。仅自有面支持请求体 praxis.expires_in_seconds(3600–7776000 秒),不可与 expires_after 同时使用;multipart 编码为 praxis[expires_in_seconds]。
  • 上传文件:支持 PDF、DOCX / XLSX / PPTX、PNG / JPEG / GIF / WebP、MP3 / WAV / FLAC / OGG / M4A、MP4 / WebM,以及 UTF-8 JSON / NDJSON / CSV / Markdown / 纯文本。purpose 支持 user_data / assistants / vision。上限 104857600 字节;空文件、类型不支持、用途不支持、超限均返回 400。不提供 Uploads 分片。可用 expires_after[anchor] 与 expires_after[seconds] 或 praxis[expires_in_seconds] 设置有效期,两组互斥。

参数与字段的权威定义以 OpenAI 官方文档为准。

错误按 OpenAI 格式返回,参见错误;额度与响应头参见限流。

POST /file/v1/files◐ 部分支持

OpenAI 官方文档 ↗

请求体

  • filestring必填

    The File object (not file name) to be uploaded.

  • purposestring必填

    The file purpose: user_data, assistants or vision.

    取值 user_dataassistantsvision
  • expires_afterobject可选

    Optional expiry relative to created_at. Files without an expiry persist until deleted.

    ▸ 展开子字段(2)
    • anchorstring必填

      Anchor timestamp after which the expiration policy applies. Supported anchors: `created_at`.

      取值 created_at
    • secondsinteger必填

      The number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).

  • praxisobject可选

    Own-face extensions. Use at most one expiry setting.

    ▸ 展开子字段(1)
    • expires_in_secondsinteger可选

      Expiry up to 90 days (Anthropic union). Mutually exclusive with expires_after.

返回

200 file

支持 PDF、DOCX / XLSX / PPTX、PNG / JPEG / GIF / WebP、MP3 / WAV / FLAC / OGG / M4A、MP4 / WebM,以及 UTF-8 JSON / NDJSON / CSV / Markdown / 纯文本。purpose 支持 user_data / assistants / vision。上限 104857600 字节;空文件、类型不支持、用途不支持、超限均返回 400。不提供 Uploads 分片。可用 expires_after[anchor] 与 expires_after[seconds] 或 praxis[expires_in_seconds] 设置有效期,两组互斥。

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

OK

application/json

名称类型说明
idstringThe file identifier, which can be referenced in the API endpoints.
bytesintegerThe size of the file, in bytes.
created_atintegerThe Unix timestamp (in seconds) for when the file was created.
expires_atintegerThe Unix timestamp (in seconds) for when the file will expire.
filenamestringThe name of the file.
objectstringThe object type, which is always `file`.
purposestringUpload purpose. Image references in conversations require user_data.
statusstringDeprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
status_detailsstring | nullDeprecated; always null or absent.
mime_typestringContent-detected MIME type.
downloadablebooleanTenant-owned live files can be downloaded through this face.
scopeobjectPresent for session output files.
scope.typestringKind of scope; always `session`.
scope.idstringId of the session the file belongs to.
relative_pathstringPath within the session output directory; present for session outputs.
revisionintegerSession output revision; present for session outputs.

列出文件

GET /file/v1/files● 支持

请求参数

  • purposestring可选

    query: Only return files with the given purpose.

  • limitinteger可选
    默认 10000

    query: A limit on the number of objects to be returned. Limit can range between 1 and 10,000, and the default is 10,000.

  • orderstring可选
    默认 "desc"

    query: Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

    取值 ascdesc
  • afterstring可选

    query: A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • scope_idstring可选

    query: Filter files by session scope. A nonexistent scope returns 404.

  • beforestring可选

    query: Return the preceding page; mutually exclusive with after.

返回

200 list

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

OK

application/json

名称类型说明
objectstringObject type; always `list`.
dataarray<object>Files of the page, in the requested order.
data[].idstringThe file identifier, which can be referenced in the API endpoints.
data[].bytesintegerThe size of the file, in bytes.
data[].created_atintegerThe Unix timestamp (in seconds) for when the file was created.
data[].expires_atintegerThe Unix timestamp (in seconds) for when the file will expire.
data[].filenamestringThe name of the file.
data[].objectstringThe object type, which is always `file`.
data[].purposestringUpload purpose. Image references in conversations require user_data.
data[].statusstringDeprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
data[].status_detailsstring | nullDeprecated; always null or absent.
data[].mime_typestringContent-detected MIME type.
data[].downloadablebooleanTenant-owned live files can be downloaded through this face.
data[].scopeobjectPresent for session output files.
data[].relative_pathstringPath within the session output directory; present for session outputs.
data[].revisionintegerSession output revision; present for session outputs.
first_idstringId of the first file of the page; usable as `before` to read the preceding page.
last_idstringId of the last file of the page; usable as `after` to read the next page.
has_morebooleanWhether more files exist beyond this page.

查看文件

先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。

GET /file/v1/files/{file_id}● 支持

请求参数

  • file_idstring必填

    path: The ID of the file to use for this request.

返回

200 file

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

OK

application/json

名称类型说明
idstringThe file identifier, which can be referenced in the API endpoints.
bytesintegerThe size of the file, in bytes.
created_atintegerThe Unix timestamp (in seconds) for when the file was created.
expires_atintegerThe Unix timestamp (in seconds) for when the file will expire.
filenamestringThe name of the file.
objectstringThe object type, which is always `file`.
purposestringUpload purpose. Image references in conversations require user_data.
statusstringDeprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
status_detailsstring | nullDeprecated; always null or absent.
mime_typestringContent-detected MIME type.
downloadablebooleanTenant-owned live files can be downloaded through this face.
scopeobjectPresent for session output files.
scope.typestringKind of scope; always `session`.
scope.idstringId of the session the file belongs to.
relative_pathstringPath within the session output directory; present for session outputs.
revisionintegerSession output revision; present for session outputs.

下载文件

先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。

GET /file/v1/files/{file_id}/content● 支持

请求参数

  • file_idstring必填

    path: The ID of the file to use for this request.

返回

200

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

OK

application/octet-stream

名称类型说明
$string (binary)

删除文件

先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。

DELETE /file/v1/files/{file_id}● 支持

请求参数

  • file_idstring必填

    path: The ID of the file to use for this request.

返回

200 file

错误按 OpenAI 格式返回,参见 错误码

响应

HTTP 200

OK

application/json

名称类型说明
idstringId of the deleted file.
objectstringObject type; always `file`.
deletedbooleanAlways true; the file can no longer be read, though downloads already authorized may finish.

Media API

使用 API Key 作为 Bearer 凭据访问素材库。

https://api.deepraxis.ai/media/v1

指南 →

资源参考
素材库素材库
素材素材
理解结果理解结果
检索检索
文件夹文件夹
批量操作批量操作
事件事件

错误码

素材库

指南 →

基础地址与鉴权

创建库

POST /media/v1/libraries

请求体

字段类型必填说明
modelsMediaModelsInput否各角色的模型调用 ID;局部更新,null 恢复默认
namestring是名称,1–64 个字符;允许重名
labelsobject否标签对象;GET 时传 JSON 字符串;PATCH 整体替换,传 {} 清空
understandingobject否视觉、转写与语义理解开关

返回: Library.

响应

HTTP 200

Successful response.

application/json

名称类型说明
searchobjectSearch capabilities of this library’s embedding model.
search.imagebooleanWhether this library’s embedding model supports image-based visual search.
modelsobjectResolved model call IDs used for new uploads and reprocessing.
models.visionstringModel call ID for visual descriptions; the model must support image input.
models.embeddingstringModel call ID for search embeddings; must produce compatible vectors and cannot change while assets exist.
models.transcriptionstringModel call ID for speech transcription.
idstringGenerated library identifier: lib_ followed by 32 lowercase hexadecimal characters.
namestringDisplay name of the library; duplicate names are allowed.
labelsobjectCaller-defined string labels used to organize and filter libraries.
statusstringLibrary lifecycle: provisioning initializes the library; active permits asset operations; deleting awaits purge and may be restored before purge_at; deleted has been purged; failed indicates initialization failure.
asset_countnumberNumber of assets currently stored in the library.
bytesnumberTotal source-content size of the library’s assets, in bytes.
understandingobjectSettings controlling understanding tasks for new uploads.
understanding.visualbooleanEnable captions, tags and OCR for images and video frames.
understanding.transcriptbooleanEnable speech transcription for audio and video soundtracks.
understanding.embeddingbooleanEnable generation of vectors for semantic search.
created_atstringTime the library was created, in UTC.
updated_atstringTime library settings, lifecycle or usage were last updated, in UTC.
deleted_atstring | nullTime the library entered deleting, or null when active or restored.
purge_atstring | nullScheduled purge time while the library is deleting; null for an active or restored library.
curl -X POST "https://api.deepraxis.ai/media/v1/libraries" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"name":"walk-lib-r1-MDP-1791733789929","labels":{"sample":"walk-lib-r1-MDP-1791733789929"}}'

HTTP 200

{
  "id": "lib_d3881a2f54a34cd79121b9d659e8378c",
  "name": "walk-lib-r1-MDP-1791733789929",
  "labels": {
    "sample": "walk-lib-r1-MDP-1791733789929"
  },
  "status": "active",
  "asset_count": 0,
  "bytes": 0,
  "models": {
    "vision": "qwen3.8-flash",
    "embedding": "qwen3-vl-embedding",
    "transcription": "whisper-large-v3-turbo"
  },
  "search": {
    "image": true
  },
  "understanding": {
    "visual": true,
    "transcript": true,
    "embedding": true
  },
  "created_at": "2026-10-11T15:50:04.230Z",
  "updated_at": "2026-10-11T15:50:04.931Z",
  "deleted_at": null,
  "purge_at": null
}

列出库

GET /media/v1/libraries

参数位置类型说明
cursorquerystring上一页的 next_cursor
limitqueryinteger每页 1–200 条,默认 50
labelsquerystring标签对象;GET 时传 JSON 字符串;PATCH 整体替换,传 {} 清空
statusqueryactive / deleting资源状态

返回: LibraryPage.

响应

HTTP 200

Successful response.

application/json

名称类型说明
dataarray<object>Libraries in this page, ordered by creation time descending.
data[].searchobjectSearch capabilities of this library’s embedding model.
data[].modelsobjectResolved model call IDs used for new uploads and reprocessing.
data[].idstringGenerated library identifier: lib_ followed by 32 lowercase hexadecimal characters.
data[].namestringDisplay name of the library; duplicate names are allowed.
data[].labelsobjectCaller-defined string labels used to organize and filter libraries.
data[].statusstringLibrary lifecycle: provisioning initializes the library; active permits asset operations; deleting awaits purge and may be restored before purge_at; deleted has been purged; failed indicates initialization failure.
data[].asset_countnumberNumber of assets currently stored in the library.
data[].bytesnumberTotal source-content size of the library’s assets, in bytes.
data[].understandingobjectSettings controlling understanding tasks for new uploads.
data[].created_atstringTime the library was created, in UTC.
data[].updated_atstringTime library settings, lifecycle or usage were last updated, in UTC.
data[].deleted_atstring | nullTime the library entered deleting, or null when active or restored.
data[].purge_atstring | nullScheduled purge time while the library is deleting; null for an active or restored library.
next_cursorstring | nullOpaque token to pass as cursor to listLibraries; null means no further page.
curl -X GET "https://api.deepraxis.ai/media/v1/libraries?labels=%7B%22sample%22%3A%22walk-lib-r1-MDP-1791733789929%22%7D" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "data": [
    {
      "id": "lib_d3881a2f54a34cd79121b9d659e8378c",
      "name": "walk-lib-r1-MDP-1791733789929",
      "status": "active",
      "asset_count": 0,
      "bytes": 0,
      "created_at": "2026-10-11T15:50:04.230Z",
      "updated_at": "2026-10-11T15:50:04.931Z",
      "deleted_at": null,
      "purge_at": null,
      "search": {
        "image": true
      },
      "models": {
        "vision": "qwen3.8-flash",
        "embedding": "qwen3-vl-embedding",
        "transcription": "whisper-large-v3-turbo"
      },
      "labels": {
        "sample": "walk-lib-r1-MDP-1791733789929"
      },
      "understanding": {
        "visual": true,
        "transcript": true,
        "embedding": true
      }
    }
  ],
  "next_cursor": null
}

读取库

GET /media/v1/libraries/{library_id}

参数位置类型说明
library_idpathstring库 ID

返回: Library.

响应

HTTP 200

Successful response.

application/json

名称类型说明
searchobjectSearch capabilities of this library’s embedding model.
search.imagebooleanWhether this library’s embedding model supports image-based visual search.
modelsobjectResolved model call IDs used for new uploads and reprocessing.
models.visionstringModel call ID for visual descriptions; the model must support image input.
models.embeddingstringModel call ID for search embeddings; must produce compatible vectors and cannot change while assets exist.
models.transcriptionstringModel call ID for speech transcription.
idstringGenerated library identifier: lib_ followed by 32 lowercase hexadecimal characters.
namestringDisplay name of the library; duplicate names are allowed.
labelsobjectCaller-defined string labels used to organize and filter libraries.
statusstringLibrary lifecycle: provisioning initializes the library; active permits asset operations; deleting awaits purge and may be restored before purge_at; deleted has been purged; failed indicates initialization failure.
asset_countnumberNumber of assets currently stored in the library.
bytesnumberTotal source-content size of the library’s assets, in bytes.
understandingobjectSettings controlling understanding tasks for new uploads.
understanding.visualbooleanEnable captions, tags and OCR for images and video frames.
understanding.transcriptbooleanEnable speech transcription for audio and video soundtracks.
understanding.embeddingbooleanEnable generation of vectors for semantic search.
created_atstringTime the library was created, in UTC.
updated_atstringTime library settings, lifecycle or usage were last updated, in UTC.
deleted_atstring | nullTime the library entered deleting, or null when active or restored.
purge_atstring | nullScheduled purge time while the library is deleting; null for an active or restored library.
curl -X GET "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "id": "lib_d3881a2f54a34cd79121b9d659e8378c",
  "name": "walk-lib-r1-MDP-1791733789929",
  "status": "active",
  "asset_count": 0,
  "bytes": 0,
  "created_at": "2026-10-11T15:50:04.230Z",
  "updated_at": "2026-10-11T15:50:04.931Z",
  "deleted_at": null,
  "purge_at": null,
  "search": {
    "image": true
  },
  "models": {
    "vision": "qwen3.8-flash",
    "embedding": "qwen3-vl-embedding",
    "transcription": "whisper-large-v3-turbo"
  },
  "labels": {
    "sample": "walk-lib-r1-MDP-1791733789929"
  },
  "understanding": {
    "visual": true,
    "transcript": true,
    "embedding": true
  }
}

更新库

PATCH /media/v1/libraries/{library_id}

参数位置类型说明
library_idpathstring库 ID

请求体

字段类型必填说明
modelsMediaModelsInput否各角色的模型调用 ID;局部更新,null 恢复默认
namestring否名称,1–64 个字符;允许重名
labelsobject否标签对象;GET 时传 JSON 字符串;PATCH 整体替换,传 {} 清空
understandingobject否视觉、转写与语义理解开关

返回: Library.

响应

HTTP 200

Successful response.

application/json

名称类型说明
searchobjectSearch capabilities of this library’s embedding model.
search.imagebooleanWhether this library’s embedding model supports image-based visual search.
modelsobjectResolved model call IDs used for new uploads and reprocessing.
models.visionstringModel call ID for visual descriptions; the model must support image input.
models.embeddingstringModel call ID for search embeddings; must produce compatible vectors and cannot change while assets exist.
models.transcriptionstringModel call ID for speech transcription.
idstringGenerated library identifier: lib_ followed by 32 lowercase hexadecimal characters.
namestringDisplay name of the library; duplicate names are allowed.
labelsobjectCaller-defined string labels used to organize and filter libraries.
statusstringLibrary lifecycle: provisioning initializes the library; active permits asset operations; deleting awaits purge and may be restored before purge_at; deleted has been purged; failed indicates initialization failure.
asset_countnumberNumber of assets currently stored in the library.
bytesnumberTotal source-content size of the library’s assets, in bytes.
understandingobjectSettings controlling understanding tasks for new uploads.
understanding.visualbooleanEnable captions, tags and OCR for images and video frames.
understanding.transcriptbooleanEnable speech transcription for audio and video soundtracks.
understanding.embeddingbooleanEnable generation of vectors for semantic search.
created_atstringTime the library was created, in UTC.
updated_atstringTime library settings, lifecycle or usage were last updated, in UTC.
deleted_atstring | nullTime the library entered deleting, or null when active or restored.
purge_atstring | nullScheduled purge time while the library is deleting; null for an active or restored library.
curl -X PATCH "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"name":"walk-lib-r1-MDP-1791733789929-updated"}'

HTTP 200

{
  "id": "lib_d3881a2f54a34cd79121b9d659e8378c",
  "name": "walk-lib-r1-MDP-1791733789929-updated",
  "status": "active",
  "asset_count": 0,
  "bytes": 0,
  "created_at": "2026-10-11T15:50:04.230Z",
  "updated_at": "2026-10-11T15:50:07.147Z",
  "deleted_at": null,
  "purge_at": null,
  "search": {
    "image": true
  },
  "models": {
    "vision": "qwen3.8-flash",
    "embedding": "qwen3-vl-embedding",
    "transcription": "whisper-large-v3-turbo"
  },
  "labels": {
    "sample": "walk-lib-r1-MDP-1791733789929"
  },
  "understanding": {
    "visual": true,
    "transcript": true,
    "embedding": true
  }
}

删除库

DELETE /media/v1/libraries/{library_id}

参数位置类型说明
library_idpathstring库 ID

返回: Library.

响应

HTTP 200

Successful response.

application/json

名称类型说明
searchobjectSearch capabilities of this library’s embedding model.
search.imagebooleanWhether this library’s embedding model supports image-based visual search.
modelsobjectResolved model call IDs used for new uploads and reprocessing.
models.visionstringModel call ID for visual descriptions; the model must support image input.
models.embeddingstringModel call ID for search embeddings; must produce compatible vectors and cannot change while assets exist.
models.transcriptionstringModel call ID for speech transcription.
idstringGenerated library identifier: lib_ followed by 32 lowercase hexadecimal characters.
namestringDisplay name of the library; duplicate names are allowed.
labelsobjectCaller-defined string labels used to organize and filter libraries.
statusstringLibrary lifecycle: provisioning initializes the library; active permits asset operations; deleting awaits purge and may be restored before purge_at; deleted has been purged; failed indicates initialization failure.
asset_countnumberNumber of assets currently stored in the library.
bytesnumberTotal source-content size of the library’s assets, in bytes.
understandingobjectSettings controlling understanding tasks for new uploads.
understanding.visualbooleanEnable captions, tags and OCR for images and video frames.
understanding.transcriptbooleanEnable speech transcription for audio and video soundtracks.
understanding.embeddingbooleanEnable generation of vectors for semantic search.
created_atstringTime the library was created, in UTC.
updated_atstringTime library settings, lifecycle or usage were last updated, in UTC.
deleted_atstring | nullTime the library entered deleting, or null when active or restored.
purge_atstring | nullScheduled purge time while the library is deleting; null for an active or restored library.
curl -X DELETE "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "id": "lib_d3881a2f54a34cd79121b9d659e8378c",
  "name": "walk-lib-r1-MDP-1791733789929-updated",
  "status": "deleting",
  "asset_count": 2,
  "bytes": 140,
  "created_at": "2026-10-11T15:50:04.230Z",
  "updated_at": "2026-10-11T15:50:30.664Z",
  "deleted_at": "2026-10-11T15:50:30.664Z",
  "purge_at": "2026-10-18T15:50:30.664Z",
  "search": {
    "image": true
  },
  "models": {
    "vision": "qwen3.8-flash",
    "embedding": "qwen3-vl-embedding",
    "transcription": "whisper-large-v3-turbo"
  },
  "labels": {
    "sample": "walk-lib-r1-MDP-1791733789929"
  },
  "understanding": {
    "visual": true,
    "transcript": true,
    "embedding": true
  }
}

恢复库

POST /media/v1/libraries/{library_id}/restore

参数位置类型说明
library_idpathstring库 ID

返回: Library.

响应

HTTP 200

Successful response.

application/json

名称类型说明
searchobjectSearch capabilities of this library’s embedding model.
search.imagebooleanWhether this library’s embedding model supports image-based visual search.
modelsobjectResolved model call IDs used for new uploads and reprocessing.
models.visionstringModel call ID for visual descriptions; the model must support image input.
models.embeddingstringModel call ID for search embeddings; must produce compatible vectors and cannot change while assets exist.
models.transcriptionstringModel call ID for speech transcription.
idstringGenerated library identifier: lib_ followed by 32 lowercase hexadecimal characters.
namestringDisplay name of the library; duplicate names are allowed.
labelsobjectCaller-defined string labels used to organize and filter libraries.
statusstringLibrary lifecycle: provisioning initializes the library; active permits asset operations; deleting awaits purge and may be restored before purge_at; deleted has been purged; failed indicates initialization failure.
asset_countnumberNumber of assets currently stored in the library.
bytesnumberTotal source-content size of the library’s assets, in bytes.
understandingobjectSettings controlling understanding tasks for new uploads.
understanding.visualbooleanEnable captions, tags and OCR for images and video frames.
understanding.transcriptbooleanEnable speech transcription for audio and video soundtracks.
understanding.embeddingbooleanEnable generation of vectors for semantic search.
created_atstringTime the library was created, in UTC.
updated_atstringTime library settings, lifecycle or usage were last updated, in UTC.
deleted_atstring | nullTime the library entered deleting, or null when active or restored.
purge_atstring | nullScheduled purge time while the library is deleting; null for an active or restored library.
curl -X POST "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/restore" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{}'

HTTP 200

{
  "id": "lib_d3881a2f54a34cd79121b9d659e8378c",
  "name": "walk-lib-r1-MDP-1791733789929-updated",
  "status": "active",
  "asset_count": 2,
  "bytes": 140,
  "created_at": "2026-10-11T15:50:04.230Z",
  "updated_at": "2026-10-11T15:50:31.379Z",
  "deleted_at": null,
  "purge_at": null,
  "search": {
    "image": true
  },
  "models": {
    "vision": "qwen3.8-flash",
    "embedding": "qwen3-vl-embedding",
    "transcription": "whisper-large-v3-turbo"
  },
  "labels": {
    "sample": "walk-lib-r1-MDP-1791733789929"
  },
  "understanding": {
    "visual": true,
    "transcript": true,
    "embedding": true
  }
}

立即清除库

POST /media/v1/libraries/{library_id}/purge

参数位置类型说明
library_idpathstring库 ID

返回: PurgedLibrary.

响应

HTTP 200

Successful response.

application/json

名称类型说明
idstringIdentifier of the library that was permanently purged.
objectstringResource discriminator identifying a library receipt.
purgedbooleanTrue when permanent library cleanup has completed.
curl -X POST "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/purge" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{}'

HTTP 200

{
  "id": "lib_d3881a2f54a34cd79121b9d659e8378c",
  "object": "library",
  "purged": true
}

Library

字段类型必填说明
searchobject是检索能力;search.image 为 true 时支持以图搜图
modelsMediaModels是各角色的模型调用 ID;局部更新,null 恢复默认
idLibraryId是资源 ID
namestring是名称,1–64 个字符;允许重名
labelsobject是标签对象;GET 时传 JSON 字符串;PATCH 整体替换,传 {} 清空
statusLibraryStatus是资源状态
asset_countnumber是素材数量
bytesnumber是文件字节数
understandingUnderstandingSettings是视觉、转写与语义理解开关
created_atIsoTimestamp是创建时间
updated_atIsoTimestamp是更新时间
deleted_atIsoTimestamp / null是删除时间;未删除为 null
purge_atIsoTimestamp / null是恢复截止时间

LibraryPage

字段类型必填说明
dataLibrary[]是本页结果
next_cursorstring / null是下一页游标;没有时为 null 或省略

PurgedLibrary

字段类型必填说明
idLibraryId是资源 ID
object"library"是—
purgedtrue是—

Page

字段类型必填说明
dataJSON[]是本页结果
next_cursorstring / null是下一页游标;没有时为 null 或省略

UnderstandingSettings

字段类型必填说明
visualboolean是视觉理解开关
transcriptboolean是转写开关
embeddingboolean是语义理解开关

模型角色

models 指定三个角色使用的模型调用 ID(callModelId)。创建库时省略它会使用下表默认值;更新时只改传入的角色,未传的角色保持不变。某个角色传 null 恢复该角色默认值,models: null 恢复全部默认值。

角色用途默认值
vision图片与视频帧的视觉理解qwen3.8-flash
embedding将内容和检索查询生成向量,用于语义检索qwen3-vl-embedding
transcription音频转写whisper-large-v3-turbo

写入时查询模型目录,校验传入的模型调用 ID。模型不存在返回 400 INVALID_PARAMS,消息为 Model <id> is not available;目录查询失败返回 502 UPSTREAM_FAILED。vision 必须支持图片输入,否则返回 400 INVALID_PARAMS。未知角色、空白 ID 或不合法的值也返回 400。

库中已有素材时不能更换 embedding,返回 409 LIBRARY_INVALID_STATE,消息为「库中已有素材时不能更换嵌入模型」。同一个向量空间必须由同一个模型生成,才能比较已有素材与查询向量;恢复默认值如果改变了 embedding,也受此限制。

修改 vision 或 transcription 只对新上传或重新处理(reprocess)的素材生效,不会自动重跑已有素材。reprocess 不带 kinds 时只重试失败项;显式指定 kinds 时,会强制重跑所选的已成功、失败或不支持项并替换结果。例如,修改 vision 后传入 { kinds: ["visual"] },修改 transcription 后传入 { kinds: ["transcript"] }。

以下 PATCH 只将 vision 恢复默认,保留其他角色:

curl -X PATCH "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"models":{"vision":null}}'

新建库默认使用 qwen3-vl-embedding,支持以图搜图;旧库保留 bge-m3。只读字段 search.image 表示当前库是否支持以图搜图。选择其他模型时,会验证它能否输出 1024 维向量;无法输出则返回 INVALID_PARAMS,探测不可用或缺少调用者身份返回 UPSTREAM_FAILED。

素材

指南 →

基础地址与鉴权

列出素材

GET /media/v1/libraries/{library_id}/assets

参数位置类型说明
library_idpathstring库 ID
asset_folderquerystring组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
resource_typequeryimage / video / rawimage、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
cursorquerystring上一页的 next_cursor
limitqueryinteger每页 1–200 条,默认 50

返回: AssetPage.

响应

HTTP 200

Successful response.

application/json

名称类型说明
dataarray<object>Assets in this page, ordered by creation time descending.
data[].asset_idstringGenerated asset identifier: 32 lowercase hexadecimal characters, preserved across overwrites.
data[].public_idstringDelivery identifier unique within this library, used in asset URLs.
data[].display_namestringHuman-readable asset name, independent of its delivery identifier.
data[].asset_folderstringOrganizational folder path; the empty string denotes the root folder.
data[].resource_typestringStored media category: image for images, video for video or audio, and raw for other files. Upload also accepts auto for detection.
data[].typestringPublic asset delivery mode; upload is the only supported value.
data[].formatstringDetected file format used as the delivery URL extension.
data[].versionnumberMonotonically increasing asset version used in delivery URLs; based on upload time in Unix seconds and advanced on overwrite.
data[].version_idstringIdentifier for this asset version, regenerated on overwrite.
data[].bytesnumberSize of the original source content, in bytes.
data[].etagstringMD5 digest of the source bytes, as 32 lowercase hexadecimal characters.
data[].widthnumberSource image or video width in pixels, when known.
data[].heightnumberSource image or video height in pixels, when known.
data[].durationnumberSource audio or video duration in seconds, when known.
data[].pagesnumber
data[].is_audiobooleanTrue for audio-only media, which uses resource_type video.
data[].original_filenamestringOriginal or overridden source filename with its final extension removed.
data[].tagsarray<string>Labels attached to the asset.
data[].contextobjectCustom string metadata; omitted when empty or excluded by the search projection.
data[].created_atstringTime this asset identity was created, in UTC.
data[].urlstringURL for retrieving this version of the asset’s original content.
data[].secure_urlstringHTTPS delivery URL for this asset version; equal to url.
data[].placeholderbooleanFalse because this response represents stored source content.
data[].existingboolean
data[].processingobjectProgress of understanding and embedding tasks for the asset.
data[].library_idstringIdentifier of the library containing this asset.
data[].sha256stringSHA-256 digest of the source bytes, as 64 lowercase hexadecimal characters.
data[].statusstringResource status; active identifies an asset that has not been deleted.
data[].semanticstringSearch-vector status: pending awaits vector generation or reprocessing; ready has searchable vectors; unavailable indicates disabled, unsupported or failed embedding. Existing vectors may still serve searches while reprocessing is pending.
data[].previewobjectGenerated video previews, present once preview generation succeeds.
next_cursorstring | nullOpaque token to pass as cursor to listAssets; null means no further page.
curl -X GET "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/assets" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "data": [
    {
      "asset_id": "9dfa312ef9bc4b00816339b598b1152c",
      "public_id": "walk-lib-r1-MDP-1791733789929-tagged",
      "display_name": "walk-lib-r1-MDP-1791733789929-tagged",
      "asset_folder": "",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791733815,
      "version_id": "26cb8171caa5431b8373ad417fd71e32",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "tags": [
        "docs"
      ],
      "processing": {
        "state": "processing",
        "kinds": {
          "embedding": "pending",
          "visual": "running",
          "tagging": "running"
        },
        "updated_at": "2026-10-11T15:50:17.571Z"
      },
      "created_at": "2026-10-11T15:50:15.996Z",
      "url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733815/walk-lib-r1-MDP-1791733789929-tagged.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733815/walk-lib-r1-MDP-1791733789929-tagged.png",
      "placeholder": false,
      "library_id": "lib_d3881a2f54a34cd79121b9d659e8378c",
      "sha256": "497790947d4666760ce38f3c00e852c71fdb66cae849bae8e9ede352719e1581",
      "status": "active",
      "semantic": "pending"
    },
    {
      "asset_id": "85b7ef616a8b4719a41777a036ebc1d2",
      "public_id": "walk-lib-r1-MDP-1791733789929-plain",
      "display_name": "walk-lib-r1-MDP-1791733789929-plain",
      "asset_folder": "",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791733810,
      "version_id": "fdf3c8cd40c2424d86e8397425a69857",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "tags": [
        "docs"
      ],
      "created_at": "2026-10-11T15:50:10.842Z",
      "url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733810/walk-lib-r1-MDP-1791733789929-plain.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733810/walk-lib-r1-MDP-1791733789929-plain.png",
      "placeholder": false,
      "library_id": "lib_d3881a2f54a34cd79121b9d659e8378c",
      "sha256": "497790947d4666760ce38f3c00e852c71fdb66cae849bae8e9ede352719e1581",
      "status": "active",
      "processing": {
        "state": "processing",
        "kinds": {
          "embedding": "pending",
          "visual": "running"
        },
        "updated_at": "2026-10-11T15:50:17.571Z"
      },
      "semantic": "pending"
    }
  ],
  "next_cursor": null
}

上传素材

POST /media/v1/libraries/{library_id}/assets

参数位置类型说明
library_idpathstring库 ID
X-Unique-Upload-Idheaderstring—
Content-Rangeheaderstring—

请求体

字段类型必填说明
filestring / string是文件字节、HTTPS URL、data URI 或同账户 file_…
public_idstring否交付地址中的素材名称,可带路径
public_id_prefixstring否public_id 的路径前缀;末尾的 / 可有可无,前缀与 ID 之间只保留一个 /
display_namestring否显示名称
asset_folderstring否组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
use_filenameboolean否用文件名生成 public_id
unique_filenameboolean否自动附加唯一后缀
use_filename_as_display_nameboolean否用文件名作为显示名称
filename_overridestring否覆盖原文件名称
overwriteboolean否是否覆盖同名素材
tagsstring / string[]否素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextstring / object否自定义文字键值;PATCH 整体替换,传 {} 清空
auto_taggingnumber否理解后将达到阈值的标签合并;0–1
resource_typeimage / video / raw / auto否image、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400

返回: CloudinaryResource.

响应

HTTP 200

Successful response.

application/json

名称类型说明
asset_idstringGenerated asset identifier: 32 lowercase hexadecimal characters, preserved across overwrites.
public_idstringDelivery identifier unique within this library, used in asset URLs.
display_namestringHuman-readable asset name, independent of its delivery identifier.
asset_folderstringOrganizational folder path; the empty string denotes the root folder.
resource_typestringStored media category: image for images, video for video or audio, and raw for other files. Upload also accepts auto for detection.
typestringPublic asset delivery mode; upload is the only supported value.
formatstringDetected file format used as the delivery URL extension.
versionnumberMonotonically increasing asset version used in delivery URLs; based on upload time in Unix seconds and advanced on overwrite.
version_idstringIdentifier for this asset version, regenerated on overwrite.
bytesnumberSize of the original source content, in bytes.
etagstringMD5 digest of the source bytes, as 32 lowercase hexadecimal characters.
widthnumberSource image or video width in pixels, when known.
heightnumberSource image or video height in pixels, when known.
durationnumberSource audio or video duration in seconds, when known.
pagesnumber
is_audiobooleanTrue for audio-only media, which uses resource_type video.
original_filenamestringOriginal or overridden source filename with its final extension removed.
tagsarray<string>Labels attached to the asset.
contextobjectCustom string metadata; omitted when empty or excluded by the search projection.
context.customobjectCaller-supplied metadata entries with string values.
created_atstringTime this asset identity was created, in UTC.
urlstringURL for retrieving this version of the asset’s original content.
secure_urlstringHTTPS delivery URL for this asset version; equal to url.
placeholderbooleanFalse because this response represents stored source content.
existingbooleanTrue when overwrite=false returns the asset already stored under the requested public_id.
processingobjectProcessing progress, included when auto_tagging was requested.
processing.statestring
processing.kindsobjectProcessing states by kind. tagging is present when auto_tagging was requested and follows visual understanding.
processing.updated_atstringTime the processing state was last updated, in UTC.
donebooleanFalse while more chunks are needed before the asset is complete. / True when the final chunk has completed the asset upload.
upload_idstringUpload session identifier supplied in X-Unique-Upload-Id; reuse it for subsequent chunks.
curl -X POST "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/assets" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"file":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==","public_id":"walk-lib-r1-MDP-1791733789929-tagged","tags":["docs"],"auto_tagging":0.6}'

HTTP 200

{
  "asset_id": "9dfa312ef9bc4b00816339b598b1152c",
  "public_id": "walk-lib-r1-MDP-1791733789929-tagged",
  "display_name": "walk-lib-r1-MDP-1791733789929-tagged",
  "asset_folder": "",
  "resource_type": "image",
  "type": "upload",
  "format": "png",
  "version": 1791733815,
  "version_id": "26cb8171caa5431b8373ad417fd71e32",
  "bytes": 70,
  "etag": "b357a19c87624c7c4d131aeeb4ae677f",
  "width": 1,
  "height": 1,
  "original_filename": "file",
  "tags": [
    "docs"
  ],
  "processing": {
    "state": "pending",
    "kinds": {
      "visual": "pending",
      "embedding": "pending",
      "tagging": "pending"
    },
    "updated_at": "2026-10-11T15:50:15.996Z"
  },
  "created_at": "2026-10-11T15:50:15.996Z",
  "url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733815/walk-lib-r1-MDP-1791733789929-tagged.png",
  "secure_url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733815/walk-lib-r1-MDP-1791733789929-tagged.png",
  "placeholder": false
}

导入文件

POST /media/v1/libraries/{library_id}/assets/import

参数位置类型说明
library_idpathstring库 ID

请求体

字段类型必填说明
file_idstring是同账户文件 ID
public_idstring否交付地址中的素材名称,可带路径
public_id_prefixstring否public_id 的路径前缀;末尾的 / 可有可无,前缀与 ID 之间只保留一个 /
display_namestring否显示名称
asset_folderstring否组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
use_filenameboolean否用文件名生成 public_id
unique_filenameboolean否自动附加唯一后缀
use_filename_as_display_nameboolean否用文件名作为显示名称
filename_overridestring否覆盖原文件名称
overwriteboolean否是否覆盖同名素材
tagsstring / string[]否素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextstring / object否自定义文字键值;PATCH 整体替换,传 {} 清空
auto_taggingnumber否理解后将达到阈值的标签合并;0–1
resource_typeimage / video / raw / auto否image、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400

返回: Asset.

响应

HTTP 200

Successful response.

application/json

名称类型说明
asset_idstringGenerated asset identifier: 32 lowercase hexadecimal characters, preserved across overwrites.
public_idstringDelivery identifier unique within this library, used in asset URLs.
display_namestringHuman-readable asset name, independent of its delivery identifier.
asset_folderstringOrganizational folder path; the empty string denotes the root folder.
resource_typestringStored media category: image for images, video for video or audio, and raw for other files. Upload also accepts auto for detection.
typestringPublic asset delivery mode; upload is the only supported value.
formatstringDetected file format used as the delivery URL extension.
versionnumberMonotonically increasing asset version used in delivery URLs; based on upload time in Unix seconds and advanced on overwrite.
version_idstringIdentifier for this asset version, regenerated on overwrite.
bytesnumberSize of the original source content, in bytes.
etagstringMD5 digest of the source bytes, as 32 lowercase hexadecimal characters.
widthnumberSource image or video width in pixels, when known.
heightnumberSource image or video height in pixels, when known.
durationnumberSource audio or video duration in seconds, when known.
pagesnumber
is_audiobooleanTrue for audio-only media, which uses resource_type video.
original_filenamestringOriginal or overridden source filename with its final extension removed.
tagsarray<string>Labels attached to the asset.
contextobjectCustom string metadata; omitted when empty or excluded by the search projection.
context.customobjectCaller-supplied metadata entries with string values.
created_atstringTime this asset identity was created, in UTC.
urlstringURL for retrieving this version of the asset’s original content.
secure_urlstringHTTPS delivery URL for this asset version; equal to url.
placeholderbooleanFalse because this response represents stored source content.
existingboolean
processingobjectProgress of understanding and embedding tasks for the asset.
processing.statestring
processing.kindsobjectProcessing states by kind. tagging is present when auto_tagging was requested and follows visual understanding.
processing.updated_atstringTime the processing state was last updated, in UTC.
library_idstringIdentifier of the library containing this asset.
sha256stringSHA-256 digest of the source bytes, as 64 lowercase hexadecimal characters.
statusstringResource status; active identifies an asset that has not been deleted.
semanticstringSearch-vector status: pending awaits vector generation or reprocessing; ready has searchable vectors; unavailable indicates disabled, unsupported or failed embedding. Existing vectors may still serve searches while reprocessing is pending.
previewobjectGenerated video previews, present once preview generation succeeds.
preview.poster_urlstringDelivery URL of the video’s first-frame poster.
preview.storyboardobjectPreview sprite sheet with tile dimensions and sample spacing.

读取素材

GET /media/v1/libraries/{library_id}/assets/{asset_id}

参数位置类型说明
library_idpathstring库 ID
asset_idpathstring素材 ID

返回: Asset.

响应

HTTP 200

Successful response.

application/json

名称类型说明
asset_idstringGenerated asset identifier: 32 lowercase hexadecimal characters, preserved across overwrites.
public_idstringDelivery identifier unique within this library, used in asset URLs.
display_namestringHuman-readable asset name, independent of its delivery identifier.
asset_folderstringOrganizational folder path; the empty string denotes the root folder.
resource_typestringStored media category: image for images, video for video or audio, and raw for other files. Upload also accepts auto for detection.
typestringPublic asset delivery mode; upload is the only supported value.
formatstringDetected file format used as the delivery URL extension.
versionnumberMonotonically increasing asset version used in delivery URLs; based on upload time in Unix seconds and advanced on overwrite.
version_idstringIdentifier for this asset version, regenerated on overwrite.
bytesnumberSize of the original source content, in bytes.
etagstringMD5 digest of the source bytes, as 32 lowercase hexadecimal characters.
widthnumberSource image or video width in pixels, when known.
heightnumberSource image or video height in pixels, when known.
durationnumberSource audio or video duration in seconds, when known.
pagesnumber
is_audiobooleanTrue for audio-only media, which uses resource_type video.
original_filenamestringOriginal or overridden source filename with its final extension removed.
tagsarray<string>Labels attached to the asset.
contextobjectCustom string metadata; omitted when empty or excluded by the search projection.
context.customobjectCaller-supplied metadata entries with string values.
created_atstringTime this asset identity was created, in UTC.
urlstringURL for retrieving this version of the asset’s original content.
secure_urlstringHTTPS delivery URL for this asset version; equal to url.
placeholderbooleanFalse because this response represents stored source content.
existingboolean
processingobjectProgress of understanding and embedding tasks for the asset.
processing.statestring
processing.kindsobjectProcessing states by kind. tagging is present when auto_tagging was requested and follows visual understanding.
processing.updated_atstringTime the processing state was last updated, in UTC.
library_idstringIdentifier of the library containing this asset.
sha256stringSHA-256 digest of the source bytes, as 64 lowercase hexadecimal characters.
statusstringResource status; active identifies an asset that has not been deleted.
semanticstringSearch-vector status: pending awaits vector generation or reprocessing; ready has searchable vectors; unavailable indicates disabled, unsupported or failed embedding. Existing vectors may still serve searches while reprocessing is pending.
previewobjectGenerated video previews, present once preview generation succeeds.
preview.poster_urlstringDelivery URL of the video’s first-frame poster.
preview.storyboardobjectPreview sprite sheet with tile dimensions and sample spacing.
curl -X GET "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/assets/85b7ef616a8b4719a41777a036ebc1d2" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "asset_id": "85b7ef616a8b4719a41777a036ebc1d2",
  "public_id": "walk-lib-r1-MDP-1791733789929-plain",
  "display_name": "walk-lib-r1-MDP-1791733789929-plain",
  "asset_folder": "",
  "resource_type": "image",
  "type": "upload",
  "format": "png",
  "version": 1791733810,
  "version_id": "fdf3c8cd40c2424d86e8397425a69857",
  "bytes": 70,
  "etag": "b357a19c87624c7c4d131aeeb4ae677f",
  "width": 1,
  "height": 1,
  "original_filename": "file",
  "tags": [
    "docs"
  ],
  "created_at": "2026-10-11T15:50:10.842Z",
  "url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733810/walk-lib-r1-MDP-1791733789929-plain.png",
  "secure_url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733810/walk-lib-r1-MDP-1791733789929-plain.png",
  "placeholder": false,
  "library_id": "lib_d3881a2f54a34cd79121b9d659e8378c",
  "sha256": "497790947d4666760ce38f3c00e852c71fdb66cae849bae8e9ede352719e1581",
  "status": "active",
  "processing": {
    "state": "processing",
    "kinds": {
      "embedding": "pending",
      "visual": "running"
    },
    "updated_at": "2026-10-11T15:50:17.571Z"
  },
  "semantic": "pending"
}

更新素材

PATCH /media/v1/libraries/{library_id}/assets/{asset_id}

参数位置类型说明
library_idpathstring库 ID
asset_idpathstring素材 ID

请求体

字段类型必填说明
display_namestring否显示名称
asset_folderstring否组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
tagsstring[]否素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextobject否自定义文字键值;PATCH 整体替换,传 {} 清空

返回: Asset.

响应

HTTP 200

Successful response.

application/json

名称类型说明
asset_idstringGenerated asset identifier: 32 lowercase hexadecimal characters, preserved across overwrites.
public_idstringDelivery identifier unique within this library, used in asset URLs.
display_namestringHuman-readable asset name, independent of its delivery identifier.
asset_folderstringOrganizational folder path; the empty string denotes the root folder.
resource_typestringStored media category: image for images, video for video or audio, and raw for other files. Upload also accepts auto for detection.
typestringPublic asset delivery mode; upload is the only supported value.
formatstringDetected file format used as the delivery URL extension.
versionnumberMonotonically increasing asset version used in delivery URLs; based on upload time in Unix seconds and advanced on overwrite.
version_idstringIdentifier for this asset version, regenerated on overwrite.
bytesnumberSize of the original source content, in bytes.
etagstringMD5 digest of the source bytes, as 32 lowercase hexadecimal characters.
widthnumberSource image or video width in pixels, when known.
heightnumberSource image or video height in pixels, when known.
durationnumberSource audio or video duration in seconds, when known.
pagesnumber
is_audiobooleanTrue for audio-only media, which uses resource_type video.
original_filenamestringOriginal or overridden source filename with its final extension removed.
tagsarray<string>Labels attached to the asset.
contextobjectCustom string metadata; omitted when empty or excluded by the search projection.
context.customobjectCaller-supplied metadata entries with string values.
created_atstringTime this asset identity was created, in UTC.
urlstringURL for retrieving this version of the asset’s original content.
secure_urlstringHTTPS delivery URL for this asset version; equal to url.
placeholderbooleanFalse because this response represents stored source content.
existingboolean
processingobjectProgress of understanding and embedding tasks for the asset.
processing.statestring
processing.kindsobjectProcessing states by kind. tagging is present when auto_tagging was requested and follows visual understanding.
processing.updated_atstringTime the processing state was last updated, in UTC.
library_idstringIdentifier of the library containing this asset.
sha256stringSHA-256 digest of the source bytes, as 64 lowercase hexadecimal characters.
statusstringResource status; active identifies an asset that has not been deleted.
semanticstringSearch-vector status: pending awaits vector generation or reprocessing; ready has searchable vectors; unavailable indicates disabled, unsupported or failed embedding. Existing vectors may still serve searches while reprocessing is pending.
previewobjectGenerated video previews, present once preview generation succeeds.
preview.poster_urlstringDelivery URL of the video’s first-frame poster.
preview.storyboardobjectPreview sprite sheet with tile dimensions and sample spacing.
curl -X PATCH "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/assets/85b7ef616a8b4719a41777a036ebc1d2" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"display_name":"walk-lib-r1-MDP-1791733789929-plain"}'

HTTP 200

{
  "asset_id": "85b7ef616a8b4719a41777a036ebc1d2",
  "public_id": "walk-lib-r1-MDP-1791733789929-plain",
  "display_name": "walk-lib-r1-MDP-1791733789929-plain",
  "asset_folder": "",
  "resource_type": "image",
  "type": "upload",
  "format": "png",
  "version": 1791733810,
  "version_id": "fdf3c8cd40c2424d86e8397425a69857",
  "bytes": 70,
  "etag": "b357a19c87624c7c4d131aeeb4ae677f",
  "width": 1,
  "height": 1,
  "original_filename": "file",
  "tags": [
    "docs"
  ],
  "created_at": "2026-10-11T15:50:10.842Z",
  "url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733810/walk-lib-r1-MDP-1791733789929-plain.png",
  "secure_url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733810/walk-lib-r1-MDP-1791733789929-plain.png",
  "placeholder": false,
  "library_id": "lib_d3881a2f54a34cd79121b9d659e8378c",
  "sha256": "497790947d4666760ce38f3c00e852c71fdb66cae849bae8e9ede352719e1581",
  "status": "active",
  "processing": {
    "state": "processing",
    "kinds": {
      "embedding": "pending",
      "visual": "running"
    },
    "updated_at": "2026-10-11T15:50:17.571Z"
  },
  "semantic": "pending"
}

删除素材

DELETE /media/v1/libraries/{library_id}/assets/{asset_id}

参数位置类型说明
library_idpathstring库 ID
asset_idpathstring素材 ID

返回: Deleted.

响应

HTTP 200

Successful response.

application/json

名称类型说明
deletedbooleanTrue once this asset has been removed from the library.
curl -X DELETE "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/assets/e5f3de0d8609482d8b351894b133c8cb" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "deleted": true
}

重新处理素材

POST /media/v1/libraries/{library_id}/assets/{asset_id}/reprocess

参数位置类型说明
library_idpathstring库 ID
asset_idpathstring素材 ID

请求体

字段类型必填说明
kindsProcessingKind[]否要强制重跑的处理种类;省略时只重试失败项

返回: Asset.

kinds 可选 visual、frames、transcript、embedding。不带 kinds 时,只重跑当前素材版本的失败任务。显式传 kinds 时,所选的 ready、failed、unsupported 任务会重置为 pending 并强制重跑;pending 或 running 任务原样跳过,重复请求不会重复入队。

kinds 必须适用于素材类型:图片为 visual、embedding;音频为 transcript、embedding;视频为 frames、visual、transcript、embedding;raw 没有可重跑的种类。全部不适用时返回 400 INVALID_PARAMS,消息列出该素材可用的 kinds;部分适用时只处理适用的种类,其余忽略(返回的 Asset 没有字段说明被忽略的种类,请以 processing.kinds 为准)。

重跑 visual、frames 或 transcript 时,旧结果立即标记为 superseded,同时将 embedding 与素材的 semantic 置为 pending。旧向量继续服务语义检索,直到新的向量写入后才被替换,因此重新处理期间素材不会从检索结果中消失;期间命中片段可能显示素材名称而非旧描述。默认读取只返回当前结果;使用 include_superseded=true 可查看历史。请求立即返回更新后的 Asset,处理异步完成。

curl -X POST "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/assets/${ASSET_ID}/reprocess" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{}'

响应

HTTP 200

Successful response.

application/json

名称类型说明
asset_idstringGenerated asset identifier: 32 lowercase hexadecimal characters, preserved across overwrites.
public_idstringDelivery identifier unique within this library, used in asset URLs.
display_namestringHuman-readable asset name, independent of its delivery identifier.
asset_folderstringOrganizational folder path; the empty string denotes the root folder.
resource_typestringStored media category: image for images, video for video or audio, and raw for other files. Upload also accepts auto for detection.
typestringPublic asset delivery mode; upload is the only supported value.
formatstringDetected file format used as the delivery URL extension.
versionnumberMonotonically increasing asset version used in delivery URLs; based on upload time in Unix seconds and advanced on overwrite.
version_idstringIdentifier for this asset version, regenerated on overwrite.
bytesnumberSize of the original source content, in bytes.
etagstringMD5 digest of the source bytes, as 32 lowercase hexadecimal characters.
widthnumberSource image or video width in pixels, when known.
heightnumberSource image or video height in pixels, when known.
durationnumberSource audio or video duration in seconds, when known.
pagesnumber
is_audiobooleanTrue for audio-only media, which uses resource_type video.
original_filenamestringOriginal or overridden source filename with its final extension removed.
tagsarray<string>Labels attached to the asset.
contextobjectCustom string metadata; omitted when empty or excluded by the search projection.
context.customobjectCaller-supplied metadata entries with string values.
created_atstringTime this asset identity was created, in UTC.
urlstringURL for retrieving this version of the asset’s original content.
secure_urlstringHTTPS delivery URL for this asset version; equal to url.
placeholderbooleanFalse because this response represents stored source content.
existingboolean
processingobjectProgress of understanding and embedding tasks for the asset.
processing.statestring
processing.kindsobjectProcessing states by kind. tagging is present when auto_tagging was requested and follows visual understanding.
processing.updated_atstringTime the processing state was last updated, in UTC.
library_idstringIdentifier of the library containing this asset.
sha256stringSHA-256 digest of the source bytes, as 64 lowercase hexadecimal characters.
statusstringResource status; active identifies an asset that has not been deleted.
semanticstringSearch-vector status: pending awaits vector generation or reprocessing; ready has searchable vectors; unavailable indicates disabled, unsupported or failed embedding. Existing vectors may still serve searches while reprocessing is pending.
previewobjectGenerated video previews, present once preview generation succeeds.
preview.poster_urlstringDelivery URL of the video’s first-frame poster.
preview.storyboardobjectPreview sprite sheet with tile dimensions and sample spacing.

AssetPage

字段类型必填说明
dataAsset[]是本页结果
next_cursorstring / null是下一页游标;没有时为 null 或省略

CloudinaryResource

字段类型必填说明
asset_idAssetId是素材 ID
public_idstring是交付地址中的素材名称,可带路径
display_namestring是显示名称
asset_folderstring是组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
resource_typeResourceType是image、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
typeDeliveryType是资源或事件类型
formatstring是文件格式
versionnumber是交付版本号
version_idstring是版本标识
bytesnumber是文件字节数
etagstring是文件校验标识
widthnumber否宽度像素
heightnumber否高度像素
durationnumber否时长秒数
pagesnumber否文档页数
is_audioboolean否是否为音频
original_filenamestring否原文件名称
tagsstring[]是素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextobject否自定义文字键值;PATCH 整体替换,传 {} 清空
created_atIsoTimestamp是创建时间
urlstring是原文件地址
secure_urlstring是HTTPS 交付地址
placeholderfalse是固定为 false
existingboolean否未覆盖时是否返回已有素材
processingProcessing否整体与各项理解状态

Asset

字段类型必填说明
asset_idAssetId是素材 ID
public_idstring是交付地址中的素材名称,可带路径
display_namestring是显示名称
asset_folderstring是组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
resource_typeResourceType是image、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
typeDeliveryType是资源或事件类型
formatstring是文件格式
versionnumber是交付版本号
version_idstring是版本标识
bytesnumber是文件字节数
etagstring是文件校验标识
widthnumber否宽度像素
heightnumber否高度像素
durationnumber否时长秒数
pagesnumber否文档页数
is_audioboolean否是否为音频
original_filenamestring否原文件名称
tagsstring[]是素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextobject否自定义文字键值;PATCH 整体替换,传 {} 清空
created_atIsoTimestamp是创建时间
urlstring是原文件地址
secure_urlstring是HTTPS 交付地址
placeholderfalse是固定为 false
existingboolean否未覆盖时是否返回已有素材
processingProcessing是整体与各项理解状态
library_idLibraryId是库 ID
sha256string是内容校验摘要
status"active"是资源状态
semantic"pending" / "ready" / "unavailable"是ready 时可语义检索
previewobject否预览海报和故事板

Deleted

字段类型必填说明
deletedtrue是删除结果

Processing

字段类型必填说明
stateProcessingState是整体处理状态
kindsobject是各项处理状态
updated_atIsoTimestamp是更新时间

Storyboard

字段类型必填说明
urlstring是原文件地址
tilesnumber是故事板画面数
interval_msnumber是画面间隔毫秒数
tile_widthnumber是单个画面宽度
tile_heightnumber是单个画面高度

理解结果

重新理解已有素材

kinds 可选 visual、frames、transcript、embedding。不带 kinds 时,只重跑当前素材版本的失败任务。显式传 kinds 时,所选的 ready、failed、unsupported 任务会重置为 pending 并强制重跑;pending 或 running 任务原样跳过,重复请求不会重复入队。

kinds 必须适用于素材类型:图片为 visual、embedding;音频为 transcript、embedding;视频为 frames、visual、transcript、embedding;raw 没有可重跑的种类。全部不适用时返回 400 INVALID_PARAMS,消息列出该素材可用的 kinds;部分适用时只处理适用的种类,其余忽略(返回的 Asset 没有字段说明被忽略的种类,请以 processing.kinds 为准)。

重跑 visual、frames 或 transcript 时,旧结果立即标记为 superseded,同时将 embedding 与素材的 semantic 置为 pending。旧向量继续服务语义检索,直到新的向量写入后才被替换,因此重新处理期间素材不会从检索结果中消失;期间命中片段可能显示素材名称而非旧描述。默认读取只返回当前结果;使用 include_superseded=true 可查看历史。请求立即返回更新后的 Asset,处理异步完成。

转写幻听过滤

转写片段先做全角转半角、转小写并去除首尾空白和标点。规范化后为空,或整段命中常见幻听短语表时,丢弃该片段。仅完整匹配,不做子串匹配,例如 “thank you for the report” 会保留。

短语表包括:thank you、thanks for watching、thank you for watching、please subscribe、subscribe、you、bye、字幕由amara.org社区提供、请不吝点赞 订阅 转发 打赏支持明镜与点点栏目、谢谢观看、优优独播剧场——yoyo television series exclusive。

被过滤的片段不进入转写文字、关键词索引或转写向量。全部被过滤时,transcript 理解仍为 ready,content 为空字符串,data 为 { "filtered_segments": n },n 是被过滤的片段数;该素材不会生成转写向量。

指南 →

基础地址与鉴权

读取理解

GET /media/v1/libraries/{library_id}/assets/{asset_id}/understandings

参数位置类型说明
library_idpathstring库 ID
asset_idpathstring素材 ID
include_supersededqueryboolean包含已被新版本替代的结果;只接受 true 或 false
kindquerycaption / tags / ocr / transcript / frame理解或处理种类;列出理解结果时按此筛选
cursorquerystring上一页的 next_cursor
limitqueryinteger每页 1–200 条,默认 200

返回: UnderstandingPage.

响应

HTTP 200

Successful response.

application/json

名称类型说明
dataarray<object>Understanding results in this page, ordered by creation time ascending.
data[].idstringGenerated identifier of this understanding result.
data[].asset_idstringIdentifier of the asset from which this result was produced.
data[].asset_versionnumberAsset version processed to produce this result; compare with the asset’s current version.
data[].kindstringResult kind: caption is a visual description, tags are recognized labels, ocr is text recognized in the image, transcript is speech text, and frame is a description of a video segment.
data[].producerstringProducer model identifier; a failure may use the configured model when no model response is available.
data[].producer_versionstring
data[].segmentobject | nullSource-media time range for a frame or transcript segment; null for results without a segment.
data[].statusstringResult status: ready contains completed output; failed records an error.
data[].contentstring | nullText output, such as a caption, recognized text or transcript; null for structured-only or failed results.
data[].dataany | nullStructured producer output, such as recognized labels or frame details; null when absent.
data[].confidencenumber | null
data[].errorobject | nullFailure code and message, or null for a successful result.
data[].supersededbooleanWhether a newer result or asset version has replaced this result. Excluded from listing unless include_superseded is true.
data[].created_atstringTime this immutable result was recorded, in UTC.
next_cursorstring | nullOpaque token to pass as cursor to listUnderstandings; null means no further page.
curl -X GET "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/assets/9339cdae93804c0c8c65d5189ef1f646/understandings" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "data": [],
  "next_cursor": null
}

UnderstandingPage

字段类型必填说明
dataUnderstanding[]是本页结果
next_cursorstring / null是下一页游标;没有时为 null 或省略

Understanding

字段类型必填说明
idUnderstandingId是资源 ID
asset_idAssetId是素材 ID
asset_versionnumber是理解对应的素材版本
kindUnderstandingKind是理解或处理种类;列出理解结果时按此筛选
producerstring是理解生成者
producer_versionstring是生成者版本
segmentSegment / null是起止毫秒;整份素材为 null
status"ready" / "failed"是资源状态
contentstring / null是理解的文字内容
dataJSON / null是本页结果
confidencenumber / null是置信度;可能为空
errorobject / null是错误码与消息;成功时为空
supersededboolean是是否被新版本替代
created_atIsoTimestamp是创建时间

Segment

字段类型必填说明
start_msnumber是片段开始毫秒
end_msnumber是片段结束毫秒

检索

expression 接受表达式;semantic 与 search 接受自然语言。语义检索只返回就绪素材。

表达式语法

指南 →

基础地址与鉴权

表达式检索

POST /media/v1/libraries/{library_id}/search/expression

参数位置类型说明
library_idpathstring库 ID

请求体

字段类型必填说明
expressionstring否结构化查询表达式;空表达式返回全部素材
sort_byobject[]否排序字段与方向
max_resultsinteger否最多 500;检索默认 100,Admin 默认 10
next_cursorstring否下一页游标;没有时为 null 或省略
with_fieldtags / context[]否额外返回 tags 或 context
aggregateAggregateField[]否统计字段

返回: ExpressionSearchResult.

响应

HTTP 200

Successful response.

application/json

名称类型说明
total_countnumberNumber of matching assets across pages; a lower bound when total_count_exact is false.
timenumberElapsed search time in whole milliseconds.
next_cursorstringContinuation token for the next page; omitted when no further page is available.
resourcesarray<object>Assets in this page, ordered by sort_by; tags and context follow with_field.
resources[].asset_idstringGenerated asset identifier: 32 lowercase hexadecimal characters, preserved across overwrites.
resources[].public_idstringDelivery identifier unique within this library, used in asset URLs.
resources[].display_namestringHuman-readable asset name, independent of its delivery identifier.
resources[].asset_folderstringOrganizational folder path; the empty string denotes the root folder.
resources[].resource_typestringStored media category: image for images, video for video or audio, and raw for other files. Upload also accepts auto for detection.
resources[].typestringPublic asset delivery mode; upload is the only supported value.
resources[].formatstringDetected file format used as the delivery URL extension.
resources[].versionnumberMonotonically increasing asset version used in delivery URLs; based on upload time in Unix seconds and advanced on overwrite.
resources[].version_idstringIdentifier for this asset version, regenerated on overwrite.
resources[].bytesnumberSize of the original source content, in bytes.
resources[].etagstringMD5 digest of the source bytes, as 32 lowercase hexadecimal characters.
resources[].widthnumberSource image or video width in pixels, when known.
resources[].heightnumberSource image or video height in pixels, when known.
resources[].durationnumberSource audio or video duration in seconds, when known.
resources[].pagesnumber
resources[].is_audiobooleanTrue for audio-only media, which uses resource_type video.
resources[].original_filenamestringOriginal or overridden source filename with its final extension removed.
resources[].tagsarray<string>Labels attached to the asset.
resources[].contextobjectCustom string metadata; omitted when empty or excluded by the search projection.
resources[].created_atstringTime this asset identity was created, in UTC.
resources[].urlstringURL for retrieving this version of the asset’s original content.
resources[].secure_urlstringHTTPS delivery URL for this asset version; equal to url.
resources[].placeholderbooleanFalse because this response represents stored source content.
resources[].existingboolean
resources[].processingobjectProgress of understanding and embedding tasks for the asset.
resources[].library_idstringIdentifier of the library containing this asset.
resources[].sha256stringSHA-256 digest of the source bytes, as 64 lowercase hexadecimal characters.
resources[].statusstringResource status; active identifies an asset that has not been deleted.
resources[].semanticstringSearch-vector status: pending awaits vector generation or reprocessing; ready has searchable vectors; unavailable indicates disabled, unsupported or failed embedding. Existing vectors may still serve searches while reprocessing is pending.
resources[].previewobjectGenerated video previews, present once preview generation succeeds.
aggregationsobjectRequested facet counts, keyed by facet name and then by field value.
total_count_exactbooleanWhether total_count covers all matches; false indicates a bounded partial count.
aggregations_exactbooleanWhether the returned facet counts cover all matching assets.
curl -X POST "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/search/expression" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"expression":"tags:docs"}'

HTTP 200

{
  "total_count": 2,
  "total_count_exact": true,
  "time": 0,
  "resources": [
    {
      "asset_id": "9dfa312ef9bc4b00816339b598b1152c",
      "public_id": "walk-lib-r1-MDP-1791733789929-tagged",
      "display_name": "walk-lib-r1-MDP-1791733789929-tagged",
      "asset_folder": "",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791733815,
      "version_id": "26cb8171caa5431b8373ad417fd71e32",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "processing": {
        "state": "processing",
        "kinds": {
          "embedding": "pending",
          "visual": "running",
          "tagging": "running"
        },
        "updated_at": "2026-10-11T15:50:17.571Z"
      },
      "created_at": "2026-10-11T15:50:15.996Z",
      "url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733815/walk-lib-r1-MDP-1791733789929-tagged.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733815/walk-lib-r1-MDP-1791733789929-tagged.png",
      "placeholder": false,
      "library_id": "lib_d3881a2f54a34cd79121b9d659e8378c",
      "sha256": "497790947d4666760ce38f3c00e852c71fdb66cae849bae8e9ede352719e1581",
      "status": "active",
      "semantic": "pending"
    },
    {
      "asset_id": "85b7ef616a8b4719a41777a036ebc1d2",
      "public_id": "walk-lib-r1-MDP-1791733789929-plain",
      "display_name": "walk-lib-r1-MDP-1791733789929-plain",
      "asset_folder": "",
      "resource_type": "image",
      "type": "upload",
      "format": "png",
      "version": 1791733810,
      "version_id": "fdf3c8cd40c2424d86e8397425a69857",
      "bytes": 70,
      "etag": "b357a19c87624c7c4d131aeeb4ae677f",
      "width": 1,
      "height": 1,
      "original_filename": "file",
      "created_at": "2026-10-11T15:50:10.842Z",
      "url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733810/walk-lib-r1-MDP-1791733789929-plain.png",
      "secure_url": "https://media-develop.praxisusercontent.com/lib_d3881a2f54a34cd79121b9d659e8378c/image/upload/v1791733810/walk-lib-r1-MDP-1791733789929-plain.png",
      "placeholder": false,
      "library_id": "lib_d3881a2f54a34cd79121b9d659e8378c",
      "sha256": "497790947d4666760ce38f3c00e852c71fdb66cae849bae8e9ede352719e1581",
      "status": "active",
      "processing": {
        "state": "processing",
        "kinds": {
          "embedding": "pending",
          "visual": "running"
        },
        "updated_at": "2026-10-11T15:50:17.571Z"
      },
      "semantic": "pending"
    }
  ]
}

以图搜图

POST /media/v1/libraries/{library_id}/search/visual

参数位置类型说明
library_idpathstring库 ID

请求体

字段类型必填说明
asset_idAssetId否素材 ID
imageobject否查询图片对象,data 为 base64,mime 为图片类型
top_kinteger否命中数,1–50
filterstring否表达式筛选条件

返回: SemanticSearchResult.

库的 search.image 为 true 时可用;不支持的库返回 LIBRARY_INVALID_STATE。图片仅接受 JPEG、PNG、WebP、GIF,解码后最大 10 MiB。每个素材返回最高分命中,视频定位到最佳帧。qwen3-vl-embedding 的图片相似度门槛为 0.35。标定来自 2026-10-10 的测试:同图变体 0.82–0.96,同类场景 0.38–0.66,无关图片最高 0.34。

asset_id 与 image: { data, mime } 必须且只能给一个。asset_id 复用已有图片理解并排除素材自身;视频使用第一帧,未完成理解返回 LIBRARY_INVALID_STATE。上传图片的 data 为 base64。top_k 默认 20,范围 1–50;filter 使用与 semantic 相同的表达式。仅检索图片相似内容,返回与 semantic 相同的 hits、embedding_producer、not_ready_excluded;matches.kind 为 image,snippet 为最新描述或素材名称。删除、旧版本及已替换的理解不会出现在结果中。

响应

HTTP 200

Successful response.

application/json

名称类型说明
hitsarray<object>Ranked assets up to top_k; an empty array means no eligible matches were found.
hits[].assetobjectAsset matched by the query.
hits[].scorenumberRanking score: cosine similarity for semantic or visual search; normalized rank-fusion score for hybrid search. Higher values rank first.
hits[].semantic_scorenumber | nullCosine similarity for hybrid hits with a semantic match; null for keyword-only hybrid hits. Omitted outside hybrid mode.
hits[].matchesarray<object>Supporting content or metadata matches contributing to this asset’s hit.
embedding_producerstringEmbedding model identifier used for the query, or for the source asset embedding in an asset-based visual query.
not_ready_excludednumberNumber of distinct candidate asset identifiers, or unresolved vector identifiers, excluded because their vectors or assets were missing, deleted or stale; not a count of all pending assets in the library.

语义检索

POST /media/v1/libraries/{library_id}/search/semantic

参数位置类型说明
library_idpathstring库 ID

请求体

字段类型必填说明
querystring是用自然语言描述要找的内容
filterstring否表达式筛选条件
top_kinteger否命中数,1–50
modehybrid / semantic否hybrid 结合关键词与语义;semantic 仅语义

返回: SemanticSearchResult.

使用 bge-m3 时,向量候选在与关键词结果融合前按余弦相似度 ≥ 0.55 筛选,新完成的内容也使用相同门槛。门槛依据 2026-10-09 的 7 个演示素材标定:相关结果最低约 0.58(0.581–0.729),不相关结果最高 0.523;完全无关的查询最高 0.478。qwen3-vl-embedding 的文字查询对文字内容(描述、转写)门槛为 0.40,对图片内容门槛为 0.25;其他模型尚未标定,暂不过滤。关键词命中不受此门槛影响。查询与库内容都不相关时返回空列表;mode=semantic 只返回达到向量门槛的结果。

响应

HTTP 200

Successful response.

application/json

名称类型说明
hitsarray<object>Ranked assets up to top_k; an empty array means no eligible matches were found.
hits[].assetobjectAsset matched by the query.
hits[].scorenumberRanking score: cosine similarity for semantic or visual search; normalized rank-fusion score for hybrid search. Higher values rank first.
hits[].semantic_scorenumber | nullCosine similarity for hybrid hits with a semantic match; null for keyword-only hybrid hits. Omitted outside hybrid mode.
hits[].matchesarray<object>Supporting content or metadata matches contributing to this asset’s hit.
embedding_producerstringEmbedding model identifier used for the query, or for the source asset embedding in an asset-based visual query.
not_ready_excludednumberNumber of distinct candidate asset identifiers, or unresolved vector identifiers, excluded because their vectors or assets were missing, deleted or stale; not a count of all pending assets in the library.

语义检索别名

POST /media/v1/libraries/{library_id}/search

参数位置类型说明
library_idpathstring库 ID

请求体

字段类型必填说明
querystring是用自然语言描述要找的内容
filterstring否表达式筛选条件
top_kinteger否命中数,1–50
modehybrid / semantic否hybrid 结合关键词与语义;semantic 仅语义

返回: SemanticSearchResult.

响应

HTTP 200

Successful response.

application/json

名称类型说明
hitsarray<object>Ranked assets up to top_k; an empty array means no eligible matches were found.
hits[].assetobjectAsset matched by the query.
hits[].scorenumberRanking score: cosine similarity for semantic or visual search; normalized rank-fusion score for hybrid search. Higher values rank first.
hits[].semantic_scorenumber | nullCosine similarity for hybrid hits with a semantic match; null for keyword-only hybrid hits. Omitted outside hybrid mode.
hits[].matchesarray<object>Supporting content or metadata matches contributing to this asset’s hit.
embedding_producerstringEmbedding model identifier used for the query, or for the source asset embedding in an asset-based visual query.
not_ready_excludednumberNumber of distinct candidate asset identifiers, or unresolved vector identifiers, excluded because their vectors or assets were missing, deleted or stale; not a count of all pending assets in the library.

ExpressionSearchResult

字段类型必填说明
total_countnumber是匹配总数
timenumber是检索耗时,整数毫秒,由服务端测得
next_cursorstring否下一页游标;没有时为 null 或省略
resourcesSearchAsset[]是本页素材
aggregationsobject否按请求字段统计
total_count_exactboolean否计数是否精确
aggregations_exactboolean否统计是否精确

SemanticSearchResult

字段类型必填说明
hitsSemanticHit[]是检索命中
embedding_producerstring是语义理解生成者
not_ready_excludednumber是因未就绪而排除的素材数

SearchAsset

字段类型必填说明
asset_idAssetId是素材 ID
public_idstring是交付地址中的素材名称,可带路径
display_namestring是显示名称
asset_folderstring是组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
resource_typeResourceType是image、video(含音频)或 raw;auto 只用于上传,列表传 auto 或其他值返回 400
typeDeliveryType是资源或事件类型
formatstring是文件格式
versionnumber是交付版本号
version_idstring是版本标识
bytesnumber是文件字节数
etagstring是文件校验标识
widthnumber否宽度像素
heightnumber否高度像素
durationnumber否时长秒数
pagesnumber否文档页数
is_audioboolean否是否为音频
original_filenamestring否原文件名称
tagsstring[]否素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
contextobject否自定义文字键值;PATCH 整体替换,传 {} 清空
created_atIsoTimestamp是创建时间
urlstring是原文件地址
secure_urlstring是HTTPS 交付地址
placeholderfalse是固定为 false
existingboolean否未覆盖时是否返回已有素材
processingProcessing是整体与各项理解状态
library_idLibraryId是库 ID
sha256string是内容校验摘要
status"active"是资源状态
semantic"pending" / "ready" / "unavailable"是ready 时可语义检索
previewobject否预览海报和故事板

SemanticHit

字段类型必填说明
assetAsset是命中的素材
scorenumber是相关度分数
semantic_scorenumber / null否—
matchesSemanticMatch[]是匹配内容与片段时间

SemanticMatch

字段类型必填说明
kindUnderstandingKind / "metadata" / "image"是理解或处理种类;列出理解结果时按此筛选
understanding_idUnderstandingId / null是对应的理解记录;元数据命中为空
segmentSegment / null是起止毫秒;整份素材为 null
snippetstring是命中文字片段

文件夹

指南 →

基础地址与鉴权

列出文件夹

GET /media/v1/libraries/{library_id}/folders

参数位置类型说明
library_idpathstring库 ID
parentquerystring父文件夹路径;省略或空字符串为根。一次返回这一层的全部子文件夹,不分页;传 limit 或 cursor 返回 400

返回: Folders.

响应

HTTP 200

Successful response.

application/json

名称类型说明
foldersarray<object>All immediate child folders of parent, sorted by path.
folders[].namestringFinal path segment naming the child folder.
folders[].pathstringFull folder path relative to the library root.
folders[].asset_countnumberNumber of assets in this folder and all descendant folders.
curl -X GET "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/folders" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "folders": [
    {
      "name": "examples",
      "path": "examples",
      "asset_count": 1
    }
  ]
}

Folders

字段类型必填说明
foldersobject[]是文件夹列表

批量操作

指南 →

基础地址与鉴权

批量操作

POST /media/v1/libraries/{library_id}/batches

参数位置类型说明
library_idpathstring库 ID

请求体

字段类型必填说明
action"tag" / "untag"是批量操作
tagsstring[]是素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
字段类型必填说明
action"set_context"是批量操作
contextobject是自定义文字键值;PATCH 整体替换,传 {} 清空
字段类型必填说明
action"move"是批量操作
asset_folderstring是组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
字段类型必填说明
action"delete"是批量操作
字段类型必填说明
selectorBatchSelector是按 ID 或表达式选择

返回: Job.

响应

HTTP 200

Successful response.

application/json

名称类型说明
idstringGenerated batch identifier: job_ followed by 32 lowercase hexadecimal characters.
library_idstringIdentifier of the library in which the batch operates.
actionstringBatch operation: tag adds labels, untag removes labels, set_context replaces custom metadata, move changes asset_folder, and delete removes selected assets.
statusstringJob status: queued awaits execution; running is processing items; completed means all items succeeded; completed_with_errors means some succeeded and some failed; failed means all selected items failed. An empty job completes successfully.
totalnumberNumber of distinct assets selected when the job was created.
donenumberNumber of items successfully processed; failed items are counted separately.
failednumberNumber of items that could not be processed successfully.
failuresarray<object>Always present, including an empty array before any item failure or when all items succeed. At most 20 item failures are returned.
failures[].asset_idstringIdentifier supplied for the failed item; it may identify a missing asset.
failures[].codestringDomain error code explaining the individual item failure.
created_atstringTime the batch job was created, in UTC.
finished_atstring | nullTime the job reached a terminal status, or null while queued or running.
curl -X POST "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/batches" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"action":"tag","tags":["sample"],"selector":{"ids":["85b7ef616a8b4719a41777a036ebc1d2","00000000000000000000000000000000"]}}'

HTTP 200

{
  "id": "job_b562f087623c4756b43813e3dce670ba",
  "library_id": "lib_d3881a2f54a34cd79121b9d659e8378c",
  "action": "tag",
  "status": "queued",
  "total": 2,
  "done": 0,
  "failed": 0,
  "created_at": "2026-10-11T15:50:24.942Z",
  "failures": [],
  "finished_at": null
}

读取任务

GET /media/v1/libraries/{library_id}/batches/{job_id}

参数位置类型说明
library_idpathstring库 ID
job_idpathstring任务 ID

返回: Job.

响应

HTTP 200

Successful response.

application/json

名称类型说明
idstringGenerated batch identifier: job_ followed by 32 lowercase hexadecimal characters.
library_idstringIdentifier of the library in which the batch operates.
actionstringBatch operation: tag adds labels, untag removes labels, set_context replaces custom metadata, move changes asset_folder, and delete removes selected assets.
statusstringJob status: queued awaits execution; running is processing items; completed means all items succeeded; completed_with_errors means some succeeded and some failed; failed means all selected items failed. An empty job completes successfully.
totalnumberNumber of distinct assets selected when the job was created.
donenumberNumber of items successfully processed; failed items are counted separately.
failednumberNumber of items that could not be processed successfully.
failuresarray<object>Always present, including an empty array before any item failure or when all items succeed. At most 20 item failures are returned.
failures[].asset_idstringIdentifier supplied for the failed item; it may identify a missing asset.
failures[].codestringDomain error code explaining the individual item failure.
created_atstringTime the batch job was created, in UTC.
finished_atstring | nullTime the job reached a terminal status, or null while queued or running.
curl -X GET "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/batches/job_b562f087623c4756b43813e3dce670ba" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "id": "job_b562f087623c4756b43813e3dce670ba",
  "library_id": "lib_d3881a2f54a34cd79121b9d659e8378c",
  "action": "tag",
  "status": "completed_with_errors",
  "total": 2,
  "done": 1,
  "failed": 1,
  "created_at": "2026-10-11T15:50:24.942Z",
  "failures": [
    {
      "asset_id": "00000000000000000000000000000000",
      "code": "ASSET_NOT_FOUND"
    }
  ],
  "finished_at": "2026-10-11T15:50:27.555Z"
}

批量操作别名

POST /media/v1/libraries/{library_id}/assets:batch

参数位置类型说明
library_idpathstring库 ID

请求体

字段类型必填说明
action"tag" / "untag"是批量操作
tagsstring[]是素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
字段类型必填说明
action"set_context"是批量操作
contextobject是自定义文字键值;PATCH 整体替换,传 {} 清空
字段类型必填说明
action"move"是批量操作
asset_folderstring是组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
字段类型必填说明
action"delete"是批量操作
字段类型必填说明
selectorBatchSelector是按 ID 或表达式选择

返回: Job.

响应

HTTP 200

Successful response.

application/json

名称类型说明
idstringGenerated batch identifier: job_ followed by 32 lowercase hexadecimal characters.
library_idstringIdentifier of the library in which the batch operates.
actionstringBatch operation: tag adds labels, untag removes labels, set_context replaces custom metadata, move changes asset_folder, and delete removes selected assets.
statusstringJob status: queued awaits execution; running is processing items; completed means all items succeeded; completed_with_errors means some succeeded and some failed; failed means all selected items failed. An empty job completes successfully.
totalnumberNumber of distinct assets selected when the job was created.
donenumberNumber of items successfully processed; failed items are counted separately.
failednumberNumber of items that could not be processed successfully.
failuresarray<object>Always present, including an empty array before any item failure or when all items succeed. At most 20 item failures are returned.
failures[].asset_idstringIdentifier supplied for the failed item; it may identify a missing asset.
failures[].codestringDomain error code explaining the individual item failure.
created_atstringTime the batch job was created, in UTC.
finished_atstring | nullTime the job reached a terminal status, or null while queued or running.
curl -X POST "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/assets:batch" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"action":"tag","tags":["sample"],"selector":{"ids":["85b7ef616a8b4719a41777a036ebc1d2"]}}'

HTTP 200

{
  "id": "job_3c2fe728de054c7396058c7438b289d2",
  "library_id": "lib_d3881a2f54a34cd79121b9d659e8378c",
  "action": "tag",
  "status": "queued",
  "total": 1,
  "done": 0,
  "failed": 0,
  "created_at": "2026-10-11T15:50:29.266Z",
  "failures": [],
  "finished_at": null
}

读取任务别名

GET /media/v1/libraries/{library_id}/jobs/{job_id}

参数位置类型说明
library_idpathstring库 ID
job_idpathstring任务 ID

返回: Job.

响应

HTTP 200

Successful response.

application/json

名称类型说明
idstringGenerated batch identifier: job_ followed by 32 lowercase hexadecimal characters.
library_idstringIdentifier of the library in which the batch operates.
actionstringBatch operation: tag adds labels, untag removes labels, set_context replaces custom metadata, move changes asset_folder, and delete removes selected assets.
statusstringJob status: queued awaits execution; running is processing items; completed means all items succeeded; completed_with_errors means some succeeded and some failed; failed means all selected items failed. An empty job completes successfully.
totalnumberNumber of distinct assets selected when the job was created.
donenumberNumber of items successfully processed; failed items are counted separately.
failednumberNumber of items that could not be processed successfully.
failuresarray<object>Always present, including an empty array before any item failure or when all items succeed. At most 20 item failures are returned.
failures[].asset_idstringIdentifier supplied for the failed item; it may identify a missing asset.
failures[].codestringDomain error code explaining the individual item failure.
created_atstringTime the batch job was created, in UTC.
finished_atstring | nullTime the job reached a terminal status, or null while queued or running.
curl -X GET "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/jobs/job_3c2fe728de054c7396058c7438b289d2" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "id": "job_3c2fe728de054c7396058c7438b289d2",
  "library_id": "lib_d3881a2f54a34cd79121b9d659e8378c",
  "action": "tag",
  "status": "completed",
  "total": 1,
  "done": 1,
  "failed": 0,
  "created_at": "2026-10-11T15:50:29.266Z",
  "failures": [],
  "finished_at": "2026-10-11T15:50:29.494Z"
}

Job

字段类型必填说明
idJobId是资源 ID
library_idLibraryId是库 ID
actiontag / untag / set_context / move / delete是批量操作
status"queued" / "running" / "completed" / "completed_with_errors" / "failed"是资源状态
totalnumber是任务素材总数
donenumber是已完成数量;分片响应中表示是否完成
failednumber是失败数量
failuresobject[]是—
created_atIsoTimestamp是创建时间
finished_atIsoTimestamp / null是结束时间;未结束为空

BatchSelector

字段类型必填说明
idsAssetId[]是素材 ID 列表
字段类型必填说明
expressionstring是结构化查询表达式;空表达式返回全部素材
exclusionsAssetId[]否从选择中排除的素材 ID

BatchAction

字段类型必填说明
action"tag" / "untag"是批量操作
tagsstring[]是素材标签。上传可传逗号分隔字符串(每项去首尾空白、丢弃空项)、数组或重复的 tags 字段;PATCH 只接受数组并整体替换
字段类型必填说明
action"set_context"是批量操作
contextobject是自定义文字键值;PATCH 整体替换,传 {} 清空
字段类型必填说明
action"move"是批量操作
asset_folderstring是组织文件夹;不改变 public_id。按它列出时只匹配这一层、不含子文件夹;空字符串表示根
字段类型必填说明
action"delete"是批量操作

事件

按 seq 翻页:asc 配 after_seq,desc 配 before_seq;两个游标不可同用。

指南 →

基础地址与鉴权

读取事件

GET /media/v1/libraries/{library_id}/events

参数位置类型说明
library_idpathstring库 ID
after_seqqueryinteger升序游标;不可与 before_seq 同用
before_seqqueryinteger降序游标;不可与 after_seq 同用
orderqueryasc / descasc 默认升序或 desc 降序
limitqueryinteger每页 1–200 条,默认 50

返回: MediaEventPage.

响应

HTTP 200

Successful response.

application/json

名称类型说明
dataarray<object>Events in this page, ordered by sequence in the requested direction.
data[].seqnumberIncreasing sequence number within this library; use it with after_seq or before_seq to page through events.
data[].idstringUnique identifier of this recorded event.
data[].typestringType of lifecycle, asset, processing, search or batch change recorded.
data[].processed_atstringTime this event was recorded, in UTC.
data[].library_idstringIdentifier of the library whose event was recorded.
data[].asset_idstringRelated asset identifier, when the event concerns an asset.
data[].job_idstringRelated batch job identifier, when present.
data[].kindstringRelated processing task: visual, frames, transcript or embedding.
data[].detailobjectEvent-specific details, such as changed values, reprocessing kinds or failed-item counts.
next_cursorstring | nullLast returned sequence as a string when more events exist; convert to a number and pass as after_seq for asc or before_seq for desc. Null means no further page.
curl -X GET "https://api.deepraxis.ai/media/v1/libraries/${LIBRARY_ID}/events?limit=1" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

HTTP 200

{
  "data": [
    {
      "seq": 1,
      "id": "2cd2cd71-1fc5-41fc-aeb0-29583af9b900",
      "type": "library.status_provisioning",
      "processed_at": "2026-10-09T09:34:09.858Z",
      "library_id": "lib_fff73e25733449b1bf6f880d91f5c045"
    }
  ],
  "next_cursor": "1"
}

MediaEventPage

字段类型必填说明
dataMediaEvent[]是本页结果
next_cursorstring / null是下一页游标;没有时为 null 或省略

MediaEvent

字段类型必填说明
seqnumber是库内递增的事件序号
idstring是资源 ID
typeMediaEventType是资源或事件类型
processed_atIsoTimestamp是事件时间
library_idLibraryId是库 ID
asset_idAssetId否素材 ID
job_idJobId否任务 ID
kindProcessingKind否理解或处理种类;列出理解结果时按此筛选
detailobject否事件详情

错误码

指南 →

自有 API 返回 error.code、error.message、error.details。兼容接口返回 error.message,并通过 X-Cld-Error 响应头重复消息;非 ASCII 消息在响应头中使用百分号编码。

领域码自有 HTTP兼容 HTTP可重试
LIBRARY_NOT_FOUND404404否
ASSET_NOT_FOUND404404否
JOB_NOT_FOUND404404否
UNDERSTANDING_NOT_FOUND404404否
LIBRARY_INVALID_STATE409400否
INVALID_PARAMS400400否
INVALID_EXPRESSION400400否
UNSUPPORTED400400否
NOT_IMPLEMENTED501400否
FILE_TOO_LARGE413400否
FILE_EMPTY400400否
UNSUPPORTED_MEDIA415400否
FETCH_FAILED400400否
LIMIT_EXCEEDED400400否
CHUNK_INVALID400400否
RATE_LIMITED429420是
CAPACITY503500是
UPSTREAM_FAILED502500是

可重试错误采用退避重试;其它错误先修正请求或资源状态。

模型配置错误

  • 400 INVALID_PARAMS:模型调用 ID 不存在(Model <id> is not available)、vision 模型不支持图片输入,或 models 含未知角色、空白 ID 或不合法的值。
  • 409 LIBRARY_INVALID_STATE:库中已有素材时更换 embedding,包括恢复默认值导致模型改变。消息为「库中已有素材时不能更换嵌入模型」。
  • 502 UPSTREAM_FAILED:写入模型配置时无法查询模型目录;可退避重试。

知识库 API

把文件加入知识库,按语义和关键词搜索相关分段。使用 API Key 作为 Bearer 凭据,建议从服务端调用。

https://api.deepraxis.ai/knowledge/v1

快速开始:官方 Python SDK

资源用途
知识库创建、读取、更新、删除与恢复
文件添加、读取、更新属性、移除与重试
批量成批添加文件、读取状态与取消
搜索检索相关文本分段
分段读取分段、位置与关键词
事件读取知识库与文件处理事件

错误码 · 上限与格式支持 · OpenAI vector stores

知识库

快速开始:官方 Python SDK

基础地址与鉴权

路径中的 ID 使用已有资源的 ID。示例中的环境变量由调用者设置。

创建知识库

POST /knowledge/v1/vector_stores

创建知识库。可用 file_ids 添加已有 File 并异步入库;后续调用使用返回的 id。最小请求体:{"name":"Refund policies"}。

请求体

字段类型说明
namestring可选; 省略时为空字符串;不接受 null。; 最长字符数: 256; 默认: ""
metadataobject / null可选; 知识库自定义字符串元数据;省略或 null 得到空对象。; 默认: {}
expires_afterobject / null可选; 从最近活动计算的过期策略;省略或 null 表示不自动过期。; 默认: null
expires_after (1).anchor"last_active_at"必填; last_active_at 表示从最近活动时间开始计算过期。
expires_after (1).daysinteger必填; 自最近活动起的天数;添加文件和搜索会刷新活动时间。; 最小: 1; 最大: 365
file_idsstring[]可选; 要加入的已有文件 ID;每库最多 10,000 个文件。
chunking_strategyobject / object可选; auto 等同于每段 800 token、重叠 400 token。; 默认: {"type":"auto"}
chunking_strategy (1).type"auto"必填; auto 使用默认静态分段:800 个估算 token,重叠 400 个。
chunking_strategy (2).type"static"必填; static 表示使用显式分段大小与重叠设置。
chunking_strategy (2).staticobject必填; 以估算 token 数表示的分段大小与重叠限制。
chunking_strategy (2).static.max_chunk_size_tokensinteger必填; 每段的估算 token 数。; 最小: 100; 最大: 4096
chunking_strategy (2).static.chunk_overlap_tokensinteger必填; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
descriptionstring可选; 不生效: 接受后丢弃,不保存也不返回;当前不校验类型。
modelsobject / null可选; 要设置的模型角色。模型必须在模型目录中且支持该角色(embedding → openai.embeddings,rerank → cohere.rerank,query_rewrite → openai.chat.completions)。嵌入模型必须输出 1024 维向量。省略的角色不变;null 恢复全部默认。未知角色或空 ID 返回 400 INVALID_PARAMS。OpenAI 兼容接口传入此字段返回 400。; Praxis 扩展
models (1).embeddingstring / null可选; 给文件分段和查询生成向量。库中已有文件后不能更换。null 恢复默认(bge-m3)。
models (1).rerankstring / null可选; ranking_options.ranker 为 default-2024-11-15 时用于重排结果。null 恢复默认(bge-reranker-base)。
models (1).query_rewritestring / null可选; 搜索设置 rewrite_query 时用于改写查询。null 恢复默认(qwen3.8-flash)。

请求示例

curl -X POST "https://api.deepraxis.ai/knowledge/v1/vector_stores" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"name\":\"Refund policies\"}"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store"必有; 对象标记;vector_store 表示知识库。
namestring必有; 知识库显示名称;空字符串表示未设置名称。; 最长字符数: 256
status"in_progress" / "completed" / "expired" / "deleting"必有; in_progress 表示仍有文件入库中;completed 表示没有入库中的文件,不保证全部成功;expired 表示过期策略已生效。deleting 表示已软删除、等待永久清除。
usage_bytesinteger必有; 已完成源文件的字节数之和。; 最小: 0
file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。
last_active_atinteger / null必有; 最近创建、添加文件或搜索的 Unix 秒时间戳;不可用时为 null。
expires_afterobject / null必有; 从最近活动开始计算的过期策略;null 表示不自动过期。
expires_after (1).anchor"last_active_at"必有; last_active_at 表示从最近活动时间开始计算过期。
expires_after (1).daysinteger必有; 自最近活动起的天数;添加文件和搜索会刷新活动时间。; 最小: 1; 最大: 365
expires_atinteger / null必有; 预计过期的 Unix 秒时间戳;未设置过期策略时为 null。
metadataobject必有; 最多 16 个键;键最多 64 字符;字符串值最多 512 字符。; 最多键数: 16; 键最多 64 字符; 值: string
purge_atstring / null可选; ISO 8601 格式的恢复截止时间;未软删除时为 null。
modelsobject可选; 各角色生效的模型(Router 模型 ID);未设置的角色使用默认模型。; Praxis 扩展
models.embeddingstring必有; 给文件分段和查询生成向量。库中已有文件后不能更换。默认 bge-m3。; 最短字符数: 1
models.rerankstring必有; ranking_options.ranker 为 default-2024-11-15 时用于重排结果。默认 bge-reranker-base。; 最短字符数: 1
models.query_rewritestring必有; 搜索设置 rewrite_query 时用于改写查询。默认 qwen3.8-flash。; 最短字符数: 1
praxisobject可选; 此知识库的原生生命周期与恢复信息。
praxis.lifecycle"provisioning" / "active" / "expired" / "deleted" / "failed"必有; provisioning 表示正在初始化;active 允许文件操作与搜索;expired 表示已过期;deleted 表示已软删除;failed 表示初始化失败。
praxis.deleted_atinteger / null必有; 软删除的 Unix 秒时间戳;未软删除时为 null。
praxis.purge_atinteger / null必有; 恢复截止的 Unix 秒时间戳;未软删除时为 null。

错误码与错误对象

列出知识库

GET /knowledge/v1/vector_stores

列出调用方可见的知识库,默认最新在前。将 last_id 作为 after 读取下一页,例如 ?limit=20。

参数

名称位置与类型说明
statusquery: "active" / "deleting"active 筛选活跃库;deleting 筛选软删除待清除的库。省略时排除软删除库。
afterquery: string上一页的 ID 游标。 最短字符数: 1
beforequery: string返回此 ID 之前的条目。 最短字符数: 1
limitquery: integer每页条数。 最小: 1; 最大: 100; 默认: 20
orderquery: "asc" / "desc"知识库和文件默认按创建时间降序;分段默认按序号升序。 默认: "desc"

请求示例

curl -X GET "https://api.deepraxis.ai/knowledge/v1/vector_stores" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
object"list"必有; 对象标记;list 表示游标分页集合。
dataobject[]必有; 按请求顺序返回的当前页条目。
data[].idstring必有; 资源 ID。; 最短字符数: 1
data[].object"vector_store"必有; 对象标记;vector_store 表示知识库。
data[].namestring必有; 知识库显示名称;空字符串表示未设置名称。; 最长字符数: 256
data[].status"in_progress" / "completed" / "expired" / "deleting"必有; in_progress 表示仍有文件入库中;completed 表示没有入库中的文件,不保证全部成功;expired 表示过期策略已生效。deleting 表示已软删除、等待永久清除。
data[].usage_bytesinteger必有; 已完成源文件的字节数之和。; 最小: 0
data[].file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
data[].file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
data[].file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
data[].file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
data[].file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
data[].file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
data[].created_atinteger必有; Unix 时间戳,单位秒。
data[].last_active_atinteger / null必有; 最近创建、添加文件或搜索的 Unix 秒时间戳;不可用时为 null。
data[].expires_afterobject / null必有; 从最近活动开始计算的过期策略;null 表示不自动过期。
data[].expires_after (1).anchor"last_active_at"必有; last_active_at 表示从最近活动时间开始计算过期。
data[].expires_after (1).daysinteger必有; 自最近活动起的天数;添加文件和搜索会刷新活动时间。; 最小: 1; 最大: 365
data[].expires_atinteger / null必有; 预计过期的 Unix 秒时间戳;未设置过期策略时为 null。
data[].metadataobject必有; 最多 16 个键;键最多 64 字符;字符串值最多 512 字符。; 最多键数: 16; 键最多 64 字符; 值: string
data[].purge_atstring / null可选; ISO 8601 格式的恢复截止时间;未软删除时为 null。
data[].modelsobject可选; 各角色生效的模型(Router 模型 ID);未设置的角色使用默认模型。; Praxis 扩展
data[].models.embeddingstring必有; 给文件分段和查询生成向量。库中已有文件后不能更换。默认 bge-m3。; 最短字符数: 1
data[].models.rerankstring必有; ranking_options.ranker 为 default-2024-11-15 时用于重排结果。默认 bge-reranker-base。; 最短字符数: 1
data[].models.query_rewritestring必有; 搜索设置 rewrite_query 时用于改写查询。默认 qwen3.8-flash。; 最短字符数: 1
data[].praxisobject可选; 此知识库的原生生命周期与恢复信息。
data[].praxis.lifecycle"provisioning" / "active" / "expired" / "deleted" / "failed"必有; provisioning 表示正在初始化;active 允许文件操作与搜索;expired 表示已过期;deleted 表示已软删除;failed 表示初始化失败。
data[].praxis.deleted_atinteger / null必有; 软删除的 Unix 秒时间戳;未软删除时为 null。
data[].praxis.purge_atinteger / null必有; 恢复截止的 Unix 秒时间戳;未软删除时为 null。
first_idstring / null必有; 本页首项的 ID;空页为 null。
last_idstring / null必有; 本页末项的 ID,可作为 after 继续查询;空页为 null。
has_moreboolean必有; 当前游标范围内,本页之后是否还有条目。

错误码与错误对象

读取知识库

GET /knowledge/v1/vector_stores/{vector_store_id}

使用创建或列表返回的 id 读取知识库。添加 ?expand=files 可同时返回附件首页。软删除的库在永久清除前仍可读取,status 为 deleting。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
expandquery: "files"[]两个地址均支持的 Praxis 扩展:files 附带文件首页;未知值忽略。
expand[]query: "files"[]两个地址均支持的 Praxis 扩展:files 附带文件首页;未知值忽略。

请求示例

curl -X GET "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
(1).idstring必有; 资源 ID。; 最短字符数: 1
(1).object"vector_store"必有; 对象标记;vector_store 表示知识库。
(1).namestring必有; 知识库显示名称;空字符串表示未设置名称。; 最长字符数: 256
(1).status"in_progress" / "completed" / "expired" / "deleting"必有; in_progress 表示仍有文件入库中;completed 表示没有入库中的文件,不保证全部成功;expired 表示过期策略已生效。deleting 表示已软删除、等待永久清除。
(1).usage_bytesinteger必有; 已完成源文件的字节数之和。; 最小: 0
(1).file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
(1).file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
(1).file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
(1).file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
(1).file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
(1).file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
(1).created_atinteger必有; Unix 时间戳,单位秒。
(1).last_active_atinteger / null必有; 最近创建、添加文件或搜索的 Unix 秒时间戳;不可用时为 null。
(1).expires_afterobject / null必有; 从最近活动开始计算的过期策略;null 表示不自动过期。
(1).expires_after (1).anchor"last_active_at"必有; last_active_at 表示从最近活动时间开始计算过期。
(1).expires_after (1).daysinteger必有; 自最近活动起的天数;添加文件和搜索会刷新活动时间。; 最小: 1; 最大: 365
(1).expires_atinteger / null必有; 预计过期的 Unix 秒时间戳;未设置过期策略时为 null。
(1).metadataobject必有; 最多 16 个键;键最多 64 字符;字符串值最多 512 字符。; 最多键数: 16; 键最多 64 字符; 值: string
(1).purge_atstring / null可选; ISO 8601 格式的恢复截止时间;未软删除时为 null。
(1).modelsobject可选; 各角色生效的模型(Router 模型 ID);未设置的角色使用默认模型。; Praxis 扩展
(1).models.embeddingstring必有; 给文件分段和查询生成向量。库中已有文件后不能更换。默认 bge-m3。; 最短字符数: 1
(1).models.rerankstring必有; ranking_options.ranker 为 default-2024-11-15 时用于重排结果。默认 bge-reranker-base。; 最短字符数: 1
(1).models.query_rewritestring必有; 搜索设置 rewrite_query 时用于改写查询。默认 qwen3.8-flash。; 最短字符数: 1
(1).praxisobject可选; 此知识库的原生生命周期与恢复信息。
(1).praxis.lifecycle"provisioning" / "active" / "expired" / "deleted" / "failed"必有; provisioning 表示正在初始化;active 允许文件操作与搜索;expired 表示已过期;deleted 表示已软删除;failed 表示初始化失败。
(1).praxis.deleted_atinteger / null必有; 软删除的 Unix 秒时间戳;未软删除时为 null。
(1).praxis.purge_atinteger / null必有; 恢复截止的 Unix 秒时间戳;未软删除时为 null。
(2).filesobject可选; 仅在 expand=files 时返回文件首页。
(2).files.object"list"必有; 对象标记;list 表示游标分页集合。
(2).files.dataobject[]必有; 按请求顺序返回的当前页条目。
(2).files.data[].idstring必有; 与源文件相同的 ID。; 最短字符数: 1
(2).files.data[].object"vector_store.file"必有; 对象标记;vector_store.file 表示知识库中的附件。
(2).files.data[].vector_store_idstring必有; 资源 ID。; 最短字符数: 1
(2).files.data[].status"in_progress" / "completed" / "cancelled" / "failed"必有; in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。
(2).files.data[].last_errorobject / null必有; 入库失败详情;未失败、成功完成或重新入库时为 null。
(2).files.data[].last_error (1).code"server_error" / "unsupported_file" / "invalid_file"必有; unsupported_file 表示不支持的文件类型;invalid_file 表示加密、空文件或超过解析 token 上限;server_error 表示其它入库失败或超过截止时间。
(2).files.data[].last_error (1).messagestring必有; 与 code 对应的入库失败说明。
(2).files.data[].usage_bytesinteger必有; 完成后计入源文件字节数;处理中、失败或已取消时为零。; 最小: 0
(2).files.data[].created_atinteger必有; Unix 时间戳,单位秒。
(2).files.data[].chunking_strategyobject / object必有; 此附件已保存的分段策略;auto 输入返回为具体 static 设置。
(2).files.data[].chunking_strategy (1).type"static"必有; static 表示使用显式分段大小与重叠设置。
(2).files.data[].chunking_strategy (1).staticobject必有; 以估算 token 数表示的分段大小与重叠限制。
(2).files.data[].chunking_strategy (1).static.max_chunk_size_tokensinteger必有; 每段的估算 token 数。; 最小: 100; 最大: 4096
(2).files.data[].chunking_strategy (1).static.chunk_overlap_tokensinteger必有; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
(2).files.data[].chunking_strategy (2).type"other"必有
(2).files.data[].attributesobject / null必有; 用于搜索筛选的文件属性;null 表示未设置。
(2).files.data[].praxisobject可选; 原生入库进度与源文件统计。
(2).files.data[].praxis.stage"queued" / "parse" / "chunk" / "embed" / "index" / null必有; queued 表示等待;parse 提取文本;chunk 划分分段;embed 生成向量;index 建立检索索引。null 表示入库已不在进行中。
(2).files.data[].praxis.deadline_atinteger / null必有; 入库截止的 Unix 秒时间戳;到点仍未完成的入库转为失败。
(2).files.data[].praxis.filenamestring必有; File 服务返回的源文件名。
(2).files.data[].praxis.bytesinteger必有; 源文件字节数。; 最小: 0
(2).files.data[].praxis.pagesinteger / null必有; 成功入库后的解析页数;成功结果保存前为 null。
(2).files.data[].praxis.chunk_countinteger必有; 已完成入库的分段数;完成前、失败或取消后为零。; 最小: 0
(2).files.first_idstring / null必有; 本页首项的 ID;空页为 null。
(2).files.last_idstring / null必有; 本页末项的 ID,可作为 after 继续查询;空页为 null。
(2).files.has_moreboolean必有; 当前游标范围内,本页之后是否还有条目。

错误码与错误对象

更新知识库

POST /knowledge/v1/vector_stores/{vector_store_id}

使用返回的 id 修改活跃知识库。省略的字段不变;metadata 替换整个对象。请求体示例:{"name":"Refund policies"}。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1

请求体

字段类型说明
namestring / null可选; null 将名称清空为空字符串;省略的字段不变。
metadataobject / null可选; 替换全部元数据;null 清空为一个空对象。
expires_afterobject / null可选; null 取消自动过期。
expires_after (1).anchor"last_active_at"必填; last_active_at 表示从最近活动时间开始计算过期。
expires_after (1).daysinteger必填; 自最近活动起的天数;添加文件和搜索会刷新活动时间。; 最小: 1; 最大: 365
modelsobject / null可选; 要设置的模型角色。模型必须在模型目录中且支持该角色(embedding → openai.embeddings,rerank → cohere.rerank,query_rewrite → openai.chat.completions)。嵌入模型必须输出 1024 维向量。省略的角色不变;null 恢复全部默认。未知角色或空 ID 返回 400 INVALID_PARAMS。OpenAI 兼容接口传入此字段返回 400。; Praxis 扩展
models (1).embeddingstring / null可选; 给文件分段和查询生成向量。库中已有文件后不能更换。null 恢复默认(bge-m3)。
models (1).rerankstring / null可选; ranking_options.ranker 为 default-2024-11-15 时用于重排结果。null 恢复默认(bge-reranker-base)。
models (1).query_rewritestring / null可选; 搜索设置 rewrite_query 时用于改写查询。null 恢复默认(qwen3.8-flash)。

请求示例

curl -X POST "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"models\":{\"query_rewrite\":\"qwen3.8-flash\"}}"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store"必有; 对象标记;vector_store 表示知识库。
namestring必有; 知识库显示名称;空字符串表示未设置名称。; 最长字符数: 256
status"in_progress" / "completed" / "expired" / "deleting"必有; in_progress 表示仍有文件入库中;completed 表示没有入库中的文件,不保证全部成功;expired 表示过期策略已生效。deleting 表示已软删除、等待永久清除。
usage_bytesinteger必有; 已完成源文件的字节数之和。; 最小: 0
file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。
last_active_atinteger / null必有; 最近创建、添加文件或搜索的 Unix 秒时间戳;不可用时为 null。
expires_afterobject / null必有; 从最近活动开始计算的过期策略;null 表示不自动过期。
expires_after (1).anchor"last_active_at"必有; last_active_at 表示从最近活动时间开始计算过期。
expires_after (1).daysinteger必有; 自最近活动起的天数;添加文件和搜索会刷新活动时间。; 最小: 1; 最大: 365
expires_atinteger / null必有; 预计过期的 Unix 秒时间戳;未设置过期策略时为 null。
metadataobject必有; 最多 16 个键;键最多 64 字符;字符串值最多 512 字符。; 最多键数: 16; 键最多 64 字符; 值: string
purge_atstring / null可选; ISO 8601 格式的恢复截止时间;未软删除时为 null。
modelsobject可选; 各角色生效的模型(Router 模型 ID);未设置的角色使用默认模型。; Praxis 扩展
models.embeddingstring必有; 给文件分段和查询生成向量。库中已有文件后不能更换。默认 bge-m3。; 最短字符数: 1
models.rerankstring必有; ranking_options.ranker 为 default-2024-11-15 时用于重排结果。默认 bge-reranker-base。; 最短字符数: 1
models.query_rewritestring必有; 搜索设置 rewrite_query 时用于改写查询。默认 qwen3.8-flash。; 最短字符数: 1
praxisobject可选; 此知识库的原生生命周期与恢复信息。
praxis.lifecycle"provisioning" / "active" / "expired" / "deleted" / "failed"必有; provisioning 表示正在初始化;active 允许文件操作与搜索;expired 表示已过期;deleted 表示已软删除;failed 表示初始化失败。
praxis.deleted_atinteger / null必有; 软删除的 Unix 秒时间戳;未软删除时为 null。
praxis.purge_atinteger / null必有; 恢复截止的 Unix 秒时间戳;未软删除时为 null。

错误码与错误对象

删除知识库

DELETE /knowledge/v1/vector_stores/{vector_store_id}

软删除后保留 7 天;返回 status=deleting 和 ISO purge_at,重复删除幂等。读取仍为 200,对象操作返回 409。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1

请求示例

curl -X DELETE "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store"必有; 对象标记;vector_store 表示知识库。
namestring必有; 知识库显示名称;空字符串表示未设置名称。; 最长字符数: 256
status"in_progress" / "completed" / "expired" / "deleting"必有; in_progress 表示仍有文件入库中;completed 表示没有入库中的文件,不保证全部成功;expired 表示过期策略已生效。deleting 表示已软删除、等待永久清除。
usage_bytesinteger必有; 已完成源文件的字节数之和。; 最小: 0
file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。
last_active_atinteger / null必有; 最近创建、添加文件或搜索的 Unix 秒时间戳;不可用时为 null。
expires_afterobject / null必有; 从最近活动开始计算的过期策略;null 表示不自动过期。
expires_after (1).anchor"last_active_at"必有; last_active_at 表示从最近活动时间开始计算过期。
expires_after (1).daysinteger必有; 自最近活动起的天数;添加文件和搜索会刷新活动时间。; 最小: 1; 最大: 365
expires_atinteger / null必有; 预计过期的 Unix 秒时间戳;未设置过期策略时为 null。
metadataobject必有; 最多 16 个键;键最多 64 字符;字符串值最多 512 字符。; 最多键数: 16; 键最多 64 字符; 值: string
purge_atstring / null可选; ISO 8601 格式的恢复截止时间;未软删除时为 null。
modelsobject可选; 各角色生效的模型(Router 模型 ID);未设置的角色使用默认模型。; Praxis 扩展
models.embeddingstring必有; 给文件分段和查询生成向量。库中已有文件后不能更换。默认 bge-m3。; 最短字符数: 1
models.rerankstring必有; ranking_options.ranker 为 default-2024-11-15 时用于重排结果。默认 bge-reranker-base。; 最短字符数: 1
models.query_rewritestring必有; 搜索设置 rewrite_query 时用于改写查询。默认 qwen3.8-flash。; 最短字符数: 1
praxisobject可选; 此知识库的原生生命周期与恢复信息。
praxis.lifecycle"provisioning" / "active" / "expired" / "deleted" / "failed"必有; provisioning 表示正在初始化;active 允许文件操作与搜索;expired 表示已过期;deleted 表示已软删除;failed 表示初始化失败。
praxis.deleted_atinteger / null必有; 软删除的 Unix 秒时间戳;未软删除时为 null。
praxis.purge_atinteger / null必有; 恢复截止的 Unix 秒时间戳;未软删除时为 null。

错误码与错误对象

恢复知识库

POST /knowledge/v1/vector_stores/{vector_store_id}/restore

恢复删除未满 7 天的知识库;可用库返回 409 VECTOR_STORE_INVALID_STATE,不存在返回 404;请求体可为空。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1

请求示例

curl -X POST "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/restore" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store"必有; 对象标记;vector_store 表示知识库。
namestring必有; 知识库显示名称;空字符串表示未设置名称。; 最长字符数: 256
status"in_progress" / "completed" / "expired" / "deleting"必有; in_progress 表示仍有文件入库中;completed 表示没有入库中的文件,不保证全部成功;expired 表示过期策略已生效。deleting 表示已软删除、等待永久清除。
usage_bytesinteger必有; 已完成源文件的字节数之和。; 最小: 0
file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。
last_active_atinteger / null必有; 最近创建、添加文件或搜索的 Unix 秒时间戳;不可用时为 null。
expires_afterobject / null必有; 从最近活动开始计算的过期策略;null 表示不自动过期。
expires_after (1).anchor"last_active_at"必有; last_active_at 表示从最近活动时间开始计算过期。
expires_after (1).daysinteger必有; 自最近活动起的天数;添加文件和搜索会刷新活动时间。; 最小: 1; 最大: 365
expires_atinteger / null必有; 预计过期的 Unix 秒时间戳;未设置过期策略时为 null。
metadataobject必有; 最多 16 个键;键最多 64 字符;字符串值最多 512 字符。; 最多键数: 16; 键最多 64 字符; 值: string
purge_atstring / null可选; ISO 8601 格式的恢复截止时间;未软删除时为 null。
modelsobject可选; 各角色生效的模型(Router 模型 ID);未设置的角色使用默认模型。; Praxis 扩展
models.embeddingstring必有; 给文件分段和查询生成向量。库中已有文件后不能更换。默认 bge-m3。; 最短字符数: 1
models.rerankstring必有; ranking_options.ranker 为 default-2024-11-15 时用于重排结果。默认 bge-reranker-base。; 最短字符数: 1
models.query_rewritestring必有; 搜索设置 rewrite_query 时用于改写查询。默认 qwen3.8-flash。; 最短字符数: 1
praxisobject可选; 此知识库的原生生命周期与恢复信息。
praxis.lifecycle"provisioning" / "active" / "expired" / "deleted" / "failed"必有; provisioning 表示正在初始化;active 允许文件操作与搜索;expired 表示已过期;deleted 表示已软删除;failed 表示初始化失败。
praxis.deleted_atinteger / null必有; 软删除的 Unix 秒时间戳;未软删除时为 null。
praxis.purge_atinteger / null必有; 恢复截止的 Unix 秒时间戳;未软删除时为 null。

错误码与错误对象

永久清除知识库

POST /knowledge/v1/vector_stores/{vector_store_id}/purge

立即永久清除删除中的知识库,不可撤销;复用到期清理路径。可用库返回 409,不存在返回 404;请求体可为空。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1

请求示例

curl -X POST "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/purge" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
idstring必有; 已永久清除的知识库 ID。
object"vector_store"必有; 对象标记;vector_store 表示此操作回执。
purgedtrue必有; 确认已永久清除知识库及其索引内容。

错误码与错误对象

文件

快速开始:官方 Python SDK

基础地址与鉴权

路径中的 ID 使用已有资源的 ID。示例中的环境变量由调用者设置。

添加文件

POST /knowledge/v1/vector_stores/{vector_store_id}/files

异步处理。重复加入同一文件返回已有记录,不应用新的属性或分段策略。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1

请求体

字段类型说明
file_idstring必填; 上传文件返回的已有源 File ID;文件必须对调用方可见。; 最短字符数: 1
attributesobject / null可选; 新附件的搜索筛选属性;省略或 null 表示不设置。重复加入已有文件不改变属性。
chunking_strategyobject / object可选; auto 等同于每段 800 token、重叠 400 token。; 默认: {"type":"auto"}
chunking_strategy (1).type"auto"必填; auto 使用默认静态分段:800 个估算 token,重叠 400 个。
chunking_strategy (2).type"static"必填; static 表示使用显式分段大小与重叠设置。
chunking_strategy (2).staticobject必填; 以估算 token 数表示的分段大小与重叠限制。
chunking_strategy (2).static.max_chunk_size_tokensinteger必填; 每段的估算 token 数。; 最小: 100; 最大: 4096
chunking_strategy (2).static.chunk_overlap_tokensinteger必填; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048

请求示例

curl -X POST "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/files" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"file_id\":\"${FILE_ID}\"}"

响应

HTTP 200

字段类型说明
idstring必有; 与源文件相同的 ID。; 最短字符数: 1
object"vector_store.file"必有; 对象标记;vector_store.file 表示知识库中的附件。
vector_store_idstring必有; 资源 ID。; 最短字符数: 1
status"in_progress" / "completed" / "cancelled" / "failed"必有; in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。
last_errorobject / null必有; 入库失败详情;未失败、成功完成或重新入库时为 null。
last_error (1).code"server_error" / "unsupported_file" / "invalid_file"必有; unsupported_file 表示不支持的文件类型;invalid_file 表示加密、空文件或超过解析 token 上限;server_error 表示其它入库失败或超过截止时间。
last_error (1).messagestring必有; 与 code 对应的入库失败说明。
usage_bytesinteger必有; 完成后计入源文件字节数;处理中、失败或已取消时为零。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。
chunking_strategyobject / object必有; 此附件已保存的分段策略;auto 输入返回为具体 static 设置。
chunking_strategy (1).type"static"必有; static 表示使用显式分段大小与重叠设置。
chunking_strategy (1).staticobject必有; 以估算 token 数表示的分段大小与重叠限制。
chunking_strategy (1).static.max_chunk_size_tokensinteger必有; 每段的估算 token 数。; 最小: 100; 最大: 4096
chunking_strategy (1).static.chunk_overlap_tokensinteger必有; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
chunking_strategy (2).type"other"必有
attributesobject / null必有; 用于搜索筛选的文件属性;null 表示未设置。
praxisobject可选; 原生入库进度与源文件统计。
praxis.stage"queued" / "parse" / "chunk" / "embed" / "index" / null必有; queued 表示等待;parse 提取文本;chunk 划分分段;embed 生成向量;index 建立检索索引。null 表示入库已不在进行中。
praxis.deadline_atinteger / null必有; 入库截止的 Unix 秒时间戳;到点仍未完成的入库转为失败。
praxis.filenamestring必有; File 服务返回的源文件名。
praxis.bytesinteger必有; 源文件字节数。; 最小: 0
praxis.pagesinteger / null必有; 成功入库后的解析页数;成功结果保存前为 null。
praxis.chunk_countinteger必有; 已完成入库的分段数;完成前、失败或取消后为零。; 最小: 0

错误码与错误对象

列出文件

GET /knowledge/v1/vector_stores/{vector_store_id}/files

列出附件及入库状态,默认最新附件在前。使用 last_id 作为 after 继续查询;?filter=failed 筛选可重新入库的失败文件。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
afterquery: string上一页的 ID 游标。 最短字符数: 1
beforequery: string返回此 ID 之前的条目。 最短字符数: 1
limitquery: integer每页条数。 最小: 1; 最大: 100; 默认: 20
orderquery: "asc" / "desc"知识库和文件默认按创建时间降序;分段默认按序号升序。 默认: "desc"
filterquery: "in_progress" / "completed" / "failed" / "cancelled"in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。省略时包含全部状态。

请求示例

curl -X GET "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/files" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
object"list"必有; 对象标记;list 表示游标分页集合。
dataobject[]必有; 按请求顺序返回的当前页条目。
data[].idstring必有; 与源文件相同的 ID。; 最短字符数: 1
data[].object"vector_store.file"必有; 对象标记;vector_store.file 表示知识库中的附件。
data[].vector_store_idstring必有; 资源 ID。; 最短字符数: 1
data[].status"in_progress" / "completed" / "cancelled" / "failed"必有; in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。
data[].last_errorobject / null必有; 入库失败详情;未失败、成功完成或重新入库时为 null。
data[].last_error (1).code"server_error" / "unsupported_file" / "invalid_file"必有; unsupported_file 表示不支持的文件类型;invalid_file 表示加密、空文件或超过解析 token 上限;server_error 表示其它入库失败或超过截止时间。
data[].last_error (1).messagestring必有; 与 code 对应的入库失败说明。
data[].usage_bytesinteger必有; 完成后计入源文件字节数;处理中、失败或已取消时为零。; 最小: 0
data[].created_atinteger必有; Unix 时间戳,单位秒。
data[].chunking_strategyobject / object必有; 此附件已保存的分段策略;auto 输入返回为具体 static 设置。
data[].chunking_strategy (1).type"static"必有; static 表示使用显式分段大小与重叠设置。
data[].chunking_strategy (1).staticobject必有; 以估算 token 数表示的分段大小与重叠限制。
data[].chunking_strategy (1).static.max_chunk_size_tokensinteger必有; 每段的估算 token 数。; 最小: 100; 最大: 4096
data[].chunking_strategy (1).static.chunk_overlap_tokensinteger必有; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
data[].chunking_strategy (2).type"other"必有
data[].attributesobject / null必有; 用于搜索筛选的文件属性;null 表示未设置。
data[].praxisobject可选; 原生入库进度与源文件统计。
data[].praxis.stage"queued" / "parse" / "chunk" / "embed" / "index" / null必有; queued 表示等待;parse 提取文本;chunk 划分分段;embed 生成向量;index 建立检索索引。null 表示入库已不在进行中。
data[].praxis.deadline_atinteger / null必有; 入库截止的 Unix 秒时间戳;到点仍未完成的入库转为失败。
data[].praxis.filenamestring必有; File 服务返回的源文件名。
data[].praxis.bytesinteger必有; 源文件字节数。; 最小: 0
data[].praxis.pagesinteger / null必有; 成功入库后的解析页数;成功结果保存前为 null。
data[].praxis.chunk_countinteger必有; 已完成入库的分段数;完成前、失败或取消后为零。; 最小: 0
first_idstring / null必有; 本页首项的 ID;空页为 null。
last_idstring / null必有; 本页末项的 ID,可作为 after 继续查询;空页为 null。
has_moreboolean必有; 当前游标范围内,本页之后是否还有条目。

错误码与错误对象

读取文件

GET /knowledge/v1/vector_stores/{vector_store_id}/files/{file_id}

使用添加附件或附件列表返回的 id 读取文件。可轮询此操作,直到 status 离开 in_progress 后确认入库结果。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
file_idpath: string必填;添加附件或附件列表返回的源 File ID。 最短字符数: 1

请求示例

curl -X GET "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/files/${FILE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
idstring必有; 与源文件相同的 ID。; 最短字符数: 1
object"vector_store.file"必有; 对象标记;vector_store.file 表示知识库中的附件。
vector_store_idstring必有; 资源 ID。; 最短字符数: 1
status"in_progress" / "completed" / "cancelled" / "failed"必有; in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。
last_errorobject / null必有; 入库失败详情;未失败、成功完成或重新入库时为 null。
last_error (1).code"server_error" / "unsupported_file" / "invalid_file"必有; unsupported_file 表示不支持的文件类型;invalid_file 表示加密、空文件或超过解析 token 上限;server_error 表示其它入库失败或超过截止时间。
last_error (1).messagestring必有; 与 code 对应的入库失败说明。
usage_bytesinteger必有; 完成后计入源文件字节数;处理中、失败或已取消时为零。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。
chunking_strategyobject / object必有; 此附件已保存的分段策略;auto 输入返回为具体 static 设置。
chunking_strategy (1).type"static"必有; static 表示使用显式分段大小与重叠设置。
chunking_strategy (1).staticobject必有; 以估算 token 数表示的分段大小与重叠限制。
chunking_strategy (1).static.max_chunk_size_tokensinteger必有; 每段的估算 token 数。; 最小: 100; 最大: 4096
chunking_strategy (1).static.chunk_overlap_tokensinteger必有; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
chunking_strategy (2).type"other"必有
attributesobject / null必有; 用于搜索筛选的文件属性;null 表示未设置。
praxisobject可选; 原生入库进度与源文件统计。
praxis.stage"queued" / "parse" / "chunk" / "embed" / "index" / null必有; queued 表示等待;parse 提取文本;chunk 划分分段;embed 生成向量;index 建立检索索引。null 表示入库已不在进行中。
praxis.deadline_atinteger / null必有; 入库截止的 Unix 秒时间戳;到点仍未完成的入库转为失败。
praxis.filenamestring必有; File 服务返回的源文件名。
praxis.bytesinteger必有; 源文件字节数。; 最小: 0
praxis.pagesinteger / null必有; 成功入库后的解析页数;成功结果保存前为 null。
praxis.chunk_countinteger必有; 已完成入库的分段数;完成前、失败或取消后为零。; 最小: 0

错误码与错误对象

更新文件属性

POST /knowledge/v1/vector_stores/{vector_store_id}/files/{file_id}

替换已有附件的搜索筛选属性,不重新入库。使用附件 id。请求体示例:{"attributes":{"category":"refund"}};null 清空属性。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
file_idpath: string必填;添加附件或附件列表返回的源 File ID。 最短字符数: 1

请求体

字段类型说明
attributesobject / null可选; 替换全部搜索筛选属性;null 清空属性。

请求示例

curl -X POST "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/files/${FILE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"attributes\":{\"category\":\"refund\"}}"

响应

HTTP 200

字段类型说明
idstring必有; 与源文件相同的 ID。; 最短字符数: 1
object"vector_store.file"必有; 对象标记;vector_store.file 表示知识库中的附件。
vector_store_idstring必有; 资源 ID。; 最短字符数: 1
status"in_progress" / "completed" / "cancelled" / "failed"必有; in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。
last_errorobject / null必有; 入库失败详情;未失败、成功完成或重新入库时为 null。
last_error (1).code"server_error" / "unsupported_file" / "invalid_file"必有; unsupported_file 表示不支持的文件类型;invalid_file 表示加密、空文件或超过解析 token 上限;server_error 表示其它入库失败或超过截止时间。
last_error (1).messagestring必有; 与 code 对应的入库失败说明。
usage_bytesinteger必有; 完成后计入源文件字节数;处理中、失败或已取消时为零。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。
chunking_strategyobject / object必有; 此附件已保存的分段策略;auto 输入返回为具体 static 设置。
chunking_strategy (1).type"static"必有; static 表示使用显式分段大小与重叠设置。
chunking_strategy (1).staticobject必有; 以估算 token 数表示的分段大小与重叠限制。
chunking_strategy (1).static.max_chunk_size_tokensinteger必有; 每段的估算 token 数。; 最小: 100; 最大: 4096
chunking_strategy (1).static.chunk_overlap_tokensinteger必有; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
chunking_strategy (2).type"other"必有
attributesobject / null必有; 用于搜索筛选的文件属性;null 表示未设置。
praxisobject可选; 原生入库进度与源文件统计。
praxis.stage"queued" / "parse" / "chunk" / "embed" / "index" / null必有; queued 表示等待;parse 提取文本;chunk 划分分段;embed 生成向量;index 建立检索索引。null 表示入库已不在进行中。
praxis.deadline_atinteger / null必有; 入库截止的 Unix 秒时间戳;到点仍未完成的入库转为失败。
praxis.filenamestring必有; File 服务返回的源文件名。
praxis.bytesinteger必有; 源文件字节数。; 最小: 0
praxis.pagesinteger / null必有; 成功入库后的解析页数;成功结果保存前为 null。
praxis.chunk_countinteger必有; 已完成入库的分段数;完成前、失败或取消后为零。; 最小: 0

错误码与错误对象

移除文件

DELETE /knowledge/v1/vector_stores/{vector_store_id}/files/{file_id}

返回后立即不再搜索到该文件;不会删除源文件。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
file_idpath: string必填;添加附件或附件列表返回的源 File ID。 最短字符数: 1

请求示例

curl -X DELETE "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/files/${FILE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store.file.deleted"必有; 对象标记;vector_store.file.deleted 表示此操作回执。
deletedtrue必有; 确认已从此知识库移出;源 File 未删除。

错误码与错误对象

读取抽取内容

GET /knowledge/v1/vector_stores/{vector_store_id}/files/{file_id}/content

抽取文本按分段返回,可能重叠。图片内容可能是生成的描述,并非逐字 OCR。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
file_idpath: string必填;添加附件或附件列表返回的源 File ID。 最短字符数: 1

请求示例

curl -X GET "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/files/${FILE_ID}/content" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
object"vector_store.file_content.page"必有; 对象标记;vector_store.file_content.page 表示提取的文件内容。
dataobject[]必有; 按分段序号排列的全部现存文本分段;相邻分段可能重叠。
data[].type"text"必有; text 表示提取出的文本分段。
data[].textstring必有; 此分段的提取文本;可能与相邻分段重叠。
has_morefalse必有; 恒为 false;此响应返回全部现存分段。
next_pagenull必有; 恒为 null;提取内容不分页。

错误码与错误对象

重试失败文件

POST /knowledge/v1/vector_stores/{vector_store_id}/files/{file_id}/retry

仅重试 failed 文件;其他状态返回 409 FILE_INVALID_STATE。本次实测尚未覆盖失败后的重试。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
file_idpath: string必填;添加附件或附件列表返回的源 File ID。 最短字符数: 1

请求示例

curl -X POST "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/files/${FILE_ID}/retry" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
idstring必有; 与源文件相同的 ID。; 最短字符数: 1
object"vector_store.file"必有; 对象标记;vector_store.file 表示知识库中的附件。
vector_store_idstring必有; 资源 ID。; 最短字符数: 1
status"in_progress" / "completed" / "cancelled" / "failed"必有; in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。
last_errorobject / null必有; 入库失败详情;未失败、成功完成或重新入库时为 null。
last_error (1).code"server_error" / "unsupported_file" / "invalid_file"必有; unsupported_file 表示不支持的文件类型;invalid_file 表示加密、空文件或超过解析 token 上限;server_error 表示其它入库失败或超过截止时间。
last_error (1).messagestring必有; 与 code 对应的入库失败说明。
usage_bytesinteger必有; 完成后计入源文件字节数;处理中、失败或已取消时为零。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。
chunking_strategyobject / object必有; 此附件已保存的分段策略;auto 输入返回为具体 static 设置。
chunking_strategy (1).type"static"必有; static 表示使用显式分段大小与重叠设置。
chunking_strategy (1).staticobject必有; 以估算 token 数表示的分段大小与重叠限制。
chunking_strategy (1).static.max_chunk_size_tokensinteger必有; 每段的估算 token 数。; 最小: 100; 最大: 4096
chunking_strategy (1).static.chunk_overlap_tokensinteger必有; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
chunking_strategy (2).type"other"必有
attributesobject / null必有; 用于搜索筛选的文件属性;null 表示未设置。
praxisobject可选; 原生入库进度与源文件统计。
praxis.stage"queued" / "parse" / "chunk" / "embed" / "index" / null必有; queued 表示等待;parse 提取文本;chunk 划分分段;embed 生成向量;index 建立检索索引。null 表示入库已不在进行中。
praxis.deadline_atinteger / null必有; 入库截止的 Unix 秒时间戳;到点仍未完成的入库转为失败。
praxis.filenamestring必有; File 服务返回的源文件名。
praxis.bytesinteger必有; 源文件字节数。; 最小: 0
praxis.pagesinteger / null必有; 成功入库后的解析页数;成功结果保存前为 null。
praxis.chunk_countinteger必有; 已完成入库的分段数;完成前、失败或取消后为零。; 最小: 0

错误码与错误对象

批量

快速开始:官方 Python SDK

基础地址与鉴权

路径中的 ID 使用已有资源的 ID。示例中的环境变量由调用者设置。

创建文件批次

POST /knowledge/v1/vector_stores/{vector_store_id}/file_batches

批量添加已有 File 并异步入库。file_ids 与 files 必须且只能提供一个;files 支持逐文件设置。已有附件直接复用。使用返回的批次 id 查询进度。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1

请求体

file_ids 与 files 必须且只能提供一个。已有文件直接复用,不修改属性或分段策略。

字段类型说明
(1).file_idsstring[]必填; 使用共同属性和分段设置的已有 File ID 列表。file_ids 与 files 二选一。; 最少条数: 1; 最多条数: 500
(1).attributesobject / null可选; 用于每个新附件的搜索筛选属性;省略或 null 表示不设置。
(1).chunking_strategyobject / object可选; auto 等同于每段 800 token、重叠 400 token。; 默认: {"type":"auto"}
(1).chunking_strategy (1).type"auto"必填; auto 使用默认静态分段:800 个估算 token,重叠 400 个。
(1).chunking_strategy (2).type"static"必填; static 表示使用显式分段大小与重叠设置。
(1).chunking_strategy (2).staticobject必填; 以估算 token 数表示的分段大小与重叠限制。
(1).chunking_strategy (2).static.max_chunk_size_tokensinteger必填; 每段的估算 token 数。; 最小: 100; 最大: 4096
(1).chunking_strategy (2).static.chunk_overlap_tokensinteger必填; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
(2).filesobject[]必填; 分别指定属性和分段设置的附件列表;忽略顶层 attributes 与 chunking_strategy。; 最少条数: 1; 最多条数: 500
(2).files[].file_idstring必填; 上传文件返回的已有源 File ID;文件必须对调用方可见。; 最短字符数: 1
(2).files[].attributesobject可选; 用于搜索筛选的文件属性。最多 16 个键,键最多 64 字符,字符串值最多 512 字符。; 最多键数: 16; 键最多 64 字符; 值: string / number / boolean
(2).files[].chunking_strategyobject / object可选; auto 等同于每段 800 token、重叠 400 token。; 默认: {"type":"auto"}
(2).files[].chunking_strategy (1).type"auto"必填; auto 使用默认静态分段:800 个估算 token,重叠 400 个。
(2).files[].chunking_strategy (2).type"static"必填; static 表示使用显式分段大小与重叠设置。
(2).files[].chunking_strategy (2).staticobject必填; 以估算 token 数表示的分段大小与重叠限制。
(2).files[].chunking_strategy (2).static.max_chunk_size_tokensinteger必填; 每段的估算 token 数。; 最小: 100; 最大: 4096
(2).files[].chunking_strategy (2).static.chunk_overlap_tokensinteger必填; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
(2).attributesJSON可选; 不生效: 使用 files 时不生效。
(2).chunking_strategyJSON可选; 不生效: 使用 files 时不生效。

请求示例

curl -X POST "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/file_batches" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"file_ids\":[\"${FILE_ID}\"]}"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store.files_batch"必有; 对象标记;vector_store.files_batch 表示批量附件。
vector_store_idstring必有; 资源 ID。; 最短字符数: 1
status"in_progress" / "completed" / "cancelled" / "failed"必有; cancelled 表示批次已取消;否则 in_progress 表示仍有成员入库中,failed 表示入库结束且有失败成员,completed 表示无入库中或失败成员。取消终态批次不会改变它。
file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。

错误码与错误对象

读取文件批次

GET /knowledge/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}

读取此知识库中创建的批次,包括当前状态和文件计数。使用创建批次返回的 id 监测入库结果。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
batch_idpath: string必填;此知识库创建批次时返回的文件批次 ID。 最短字符数: 1

请求示例

curl -X GET "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/file_batches/${BATCH_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store.files_batch"必有; 对象标记;vector_store.files_batch 表示批量附件。
vector_store_idstring必有; 资源 ID。; 最短字符数: 1
status"in_progress" / "completed" / "cancelled" / "failed"必有; cancelled 表示批次已取消;否则 in_progress 表示仍有成员入库中,failed 表示入库结束且有失败成员,completed 表示无入库中或失败成员。取消终态批次不会改变它。
file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。

错误码与错误对象

取消文件批次

POST /knowledge/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel

只取消处理中的批次和文件。已完成、失败或已取消的批次原样返回(200,幂等),计数不变。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
batch_idpath: string必填;此知识库创建批次时返回的文件批次 ID。 最短字符数: 1

请求示例

curl -X POST "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/file_batches/${BATCH_ID}/cancel" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
object"vector_store.files_batch"必有; 对象标记;vector_store.files_batch 表示批量附件。
vector_store_idstring必有; 资源 ID。; 最短字符数: 1
status"in_progress" / "completed" / "cancelled" / "failed"必有; cancelled 表示批次已取消;否则 in_progress 表示仍有成员入库中,failed 表示入库结束且有失败成员,completed 表示无入库中或失败成员。取消终态批次不会改变它。
file_countsobject必有; 仍属于该库或批次的附件数量,按入库状态分组。
file_counts.in_progressinteger必有; 等待或正在入库的文件数。; 最小: 0
file_counts.completedinteger必有; 已完成入库的文件数。; 最小: 0
file_counts.failedinteger必有; 入库失败的文件数。; 最小: 0
file_counts.cancelledinteger必有; 因批次取消而停止入库的文件数。; 最小: 0
file_counts.totalinteger必有; 全部入库状态的附件总数。; 最小: 0
created_atinteger必有; Unix 时间戳,单位秒。

错误码与错误对象

列出批次文件

GET /knowledge/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/files

列出指定批次仍在库中的附件,默认最新附件在前。使用批次创建返回的 id;?filter=failed 查看失败文件,last_id 可作为下一页 after。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
batch_idpath: string必填;此知识库创建批次时返回的文件批次 ID。 最短字符数: 1
afterquery: string上一页的 ID 游标。 最短字符数: 1
beforequery: string返回此 ID 之前的条目。 最短字符数: 1
limitquery: integer每页条数。 最小: 1; 最大: 100; 默认: 20
orderquery: "asc" / "desc"知识库和文件默认按创建时间降序;分段默认按序号升序。 默认: "desc"
filterquery: "in_progress" / "completed" / "failed" / "cancelled"in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。省略时包含全部状态。

请求示例

curl -X GET "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/file_batches/${BATCH_ID}/files" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
object"list"必有; 对象标记;list 表示游标分页集合。
dataobject[]必有; 按请求顺序返回的当前页条目。
data[].idstring必有; 与源文件相同的 ID。; 最短字符数: 1
data[].object"vector_store.file"必有; 对象标记;vector_store.file 表示知识库中的附件。
data[].vector_store_idstring必有; 资源 ID。; 最短字符数: 1
data[].status"in_progress" / "completed" / "cancelled" / "failed"必有; in_progress 表示等待或正在入库;completed 表示可检索;failed 表示入库失败;cancelled 表示批次取消已停止入库。
data[].last_errorobject / null必有; 入库失败详情;未失败、成功完成或重新入库时为 null。
data[].last_error (1).code"server_error" / "unsupported_file" / "invalid_file"必有; unsupported_file 表示不支持的文件类型;invalid_file 表示加密、空文件或超过解析 token 上限;server_error 表示其它入库失败或超过截止时间。
data[].last_error (1).messagestring必有; 与 code 对应的入库失败说明。
data[].usage_bytesinteger必有; 完成后计入源文件字节数;处理中、失败或已取消时为零。; 最小: 0
data[].created_atinteger必有; Unix 时间戳,单位秒。
data[].chunking_strategyobject / object必有; 此附件已保存的分段策略;auto 输入返回为具体 static 设置。
data[].chunking_strategy (1).type"static"必有; static 表示使用显式分段大小与重叠设置。
data[].chunking_strategy (1).staticobject必有; 以估算 token 数表示的分段大小与重叠限制。
data[].chunking_strategy (1).static.max_chunk_size_tokensinteger必有; 每段的估算 token 数。; 最小: 100; 最大: 4096
data[].chunking_strategy (1).static.chunk_overlap_tokensinteger必有; 不得超过 max_chunk_size_tokens 的一半。; 最小: 0; 最大: 2048
data[].chunking_strategy (2).type"other"必有
data[].attributesobject / null必有; 用于搜索筛选的文件属性;null 表示未设置。
data[].praxisobject可选; 原生入库进度与源文件统计。
data[].praxis.stage"queued" / "parse" / "chunk" / "embed" / "index" / null必有; queued 表示等待;parse 提取文本;chunk 划分分段;embed 生成向量;index 建立检索索引。null 表示入库已不在进行中。
data[].praxis.deadline_atinteger / null必有; 入库截止的 Unix 秒时间戳;到点仍未完成的入库转为失败。
data[].praxis.filenamestring必有; File 服务返回的源文件名。
data[].praxis.bytesinteger必有; 源文件字节数。; 最小: 0
data[].praxis.pagesinteger / null必有; 成功入库后的解析页数;成功结果保存前为 null。
data[].praxis.chunk_countinteger必有; 已完成入库的分段数;完成前、失败或取消后为零。; 最小: 0
first_idstring / null必有; 本页首项的 ID;空页为 null。
last_idstring / null必有; 本页末项的 ID,可作为 after 继续查询;空页为 null。
has_moreboolean必有; 当前游标范围内,本页之后是否还有条目。

错误码与错误对象

搜索

快速开始:官方 Python SDK

基础地址与鉴权

路径中的 ID 使用已有资源的 ID。示例中的环境变量由调用者设置。

搜索知识库

POST /knowledge/v1/vector_stores/{vector_store_id}/search

按分段返回,同一文件可出现多次。最多 50 条,没有下一页。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1

请求体

字段类型说明
querystring / string[]必填; 非空白文本;多个查询以换行连接后共同搜索。
filtersobject / object / object可选; 按类型严格匹配文件属性;根条件以下最多嵌套 20 层。
filters (1).type"eq" / "ne" / "gt" / "gte" / "lt" / "lte"必填; eq 等于,ne 不等于,gt 大于,gte 大于等于,lt 小于,lte 小于等于;属性必须存在且值类型一致。
filters (1).keystring必填; 要比较的文件属性原始键名,标点也是键名的一部分。; 最短字符数: 1
filters (1).valuestring / number / boolean必填; 不进行类型转换的比较值。
filters (2).type"in" / "nin"必填; in 匹配数组中的值;nin 匹配不在数组中的值。属性不存在时均不匹配。
filters (2).keystring必填; 要比较的文件属性原始键名,标点也是键名的一部分。; 最短字符数: 1
filters (2).valuestring / number[]必填; 不进行类型转换的字符串或数值成员列表。
filters (3).type"and" / "or"必填; and 要求所有子条件匹配;or 要求至少一个子条件匹配。
filters (3).filtersobject / object / object[]必填; 按选定 and/or 运算符组合的非空子条件列表。; 最少条数: 1
filters (3).filters[]object / object / object递归使用同一筛选结构,嵌套上限 20 层。
max_num_resultsinteger可选; 最多返回的分段数,不是不同文件数。; 最小: 1; 最大: 50; 默认: 10
rewrite_queryboolean可选; 支持: 为 true 时,先用该库 query_rewrite 角色的模型把每条查询改写为简洁的检索查询;检索使用改写结果,search_query 返回改写后的查询。每次改写是一次小模型调用,按模型用量计费。改写失败、超时(5 秒)或为空时,该条查询回退为原文,搜索照常完成。省略或为 false 时不调用模型。
next_pagestring可选; 不生效: 搜索不支持翻页;提供游标不生效。
ranking_optionsobject可选; 控制结果排序与纳入结果的最低分数。
ranking_options.ranker"none" / "auto" / "default-2024-11-15"可选; 只有 default-2024-11-15 请求重排;none、auto 和省略时使用初始排序。尚未单独实测重排效果。
ranking_options.score_thresholdnumber可选; 最低分数;分数不是相关性概率。尚未单独实测阈值效果。; 最小: 0; 最大: 1; 默认: 0
ranking_options.hybrid_searchobject可选; Praxis 扩展。两个权重均须提供,必须非负且总和大于 0;省略时使用 0.7 / 0.3。; Praxis 扩展
ranking_options.hybrid_search.embedding_weightnumber必填; 语义检索相对权重;零表示禁用语义检索。; 最小: 0; 默认: 0.7
ranking_options.hybrid_search.text_weightnumber必填; 关键词检索相对权重;零表示禁用关键词检索。; 最小: 0; 默认: 0.3
praxisobject可选; 设置 explain=true 返回分数和关键词解释。; Praxis 扩展
praxis.explainboolean可选; true 请求每条结果的分数、排名与关键词解释。; 默认: false

请求示例

curl -X POST "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/search" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"query\":\"When will I receive my refund?\",\"max_num_results\":5,\"praxis\":{\"explain\":true}}"

响应

HTTP 200

字段类型说明
object"vector_store.search_results.page"必有; 对象标记;vector_store.search_results.page 表示搜索结果页。
search_querystring[]必有; 实际用于检索的查询,与输入一一对应;rewrite_query 为 true 时为改写后的查询,否则原样返回。
dataobject[]必有; 每个命中分段返回一条;同一 file_id 可重复出现。
data[].file_idstring必有; 资源 ID。; 最短字符数: 1
data[].filenamestring必有; 命中文件的源文件名。
data[].scorenumber必有; 此分段的相关排序分数,限制在 0 到 1;不是概率。; 最小: 0; 最大: 1
data[].attributesobject / null必有; 用于筛选的当前文件属性;未设置时为 null。
data[].contentobject[]必有; 命中分段文本与源文坐标;原生结果每条包含一个分段。
data[].content[].type"text"必有; text 表示提取出的文本分段。
data[].content[].textstring必有; 命中分段的提取文本,可能与相邻分段重叠。
data[].content[].chunk_idstring可选; 资源 ID。; 最短字符数: 1
data[].content[].pageinteger / null可选; 此段起点所在的源文页码,从一开始;无页码映射时为 null。
data[].content[].spaninteger[]可选; 以 UTF-16 代码单元表示的起止位置。; 最少条数: 2; 最多条数: 2
data[].praxisobject可选; 原生搜索解释;仅请求 praxis.explain 时返回。
data[].praxis.explainobject必有; 每个命中分段的检索分数、排名与匹配词。
data[].praxis.explain.semantic_scorenumber / null必有; 此段语义检索分数;不在语义候选中时为 null。
data[].praxis.explain.keyword_scorenumber / null必有; 此段关键词检索分数;不在关键词候选中时为 null。
data[].praxis.explain.rerank_scorenumber / null必有; 重排模型分数;未重排时为 null。
data[].praxis.explain.semantic_rankinteger / null必有; 语义候选中的排名,从一开始;该路未召回时为 null。
data[].praxis.explain.keyword_rankinteger / null必有; 关键词候选中的排名,从一开始;该路未召回时为 null。
data[].praxis.explain.rank_before_rerankinteger必有; 最小: 1
data[].praxis.explain.query_termsstring[]必有; 解释使用的归一化查询词,包括相邻汉字组成的双字词。
data[].praxis.explain.matched_termsstring[]必有; 归一化分段文本中出现的查询词。
has_moreboolean必有; 过滤后的分段数超过 max_num_results 时为 true;next_page 仍为 null。; 支持:
next_pagenull必有; 不生效: 恒为 null,没有下一页搜索结果。

错误码与错误对象

分段

快速开始:官方 Python SDK

基础地址与鉴权

路径中的 ID 使用已有资源的 ID。示例中的环境变量由调用者设置。

列出文件分段

GET /knowledge/v1/vector_stores/{vector_store_id}/files/{file_id}/segments

列出附件已有分段,默认按分段序号升序。使用附件 id,并将 last_id 作为 after 继续查询;返回的分段 id 可单独读取。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
file_idpath: string必填;添加附件或附件列表返回的源 File ID。 最短字符数: 1
afterquery: string上一页的 ID 游标。 最短字符数: 1
beforequery: string返回此 ID 之前的条目。 最短字符数: 1
limitquery: integer每页条数。 最小: 1; 最大: 100; 默认: 20
orderquery: "asc" / "desc"知识库和文件默认按创建时间降序;分段默认按序号升序。 默认: "asc"

请求示例

curl -X GET "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/files/${FILE_ID}/segments" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
object"list"必有; 对象标记;list 表示游标分页集合。
dataobject[]必有; 按请求顺序返回的当前页条目。
data[].idstring必有; 资源 ID。; 最短字符数: 1
data[].file_idstring必有; 资源 ID。; 最短字符数: 1
data[].indexinteger必有; 此段在源文中的序号,从零开始。; 最小: 0
data[].textstring必有; 此分段覆盖的提取文本;相邻分段可能重叠。
data[].tokensinteger必有; 此段的估算 token 数,不是模型分词器计数。; 最小: 0
data[].pageinteger / null必有; 分段起点所在源文页码,从一开始;无页码映射时为 null。
data[].spaninteger[]必有; 以 UTF-16 代码单元表示的起止位置。; 最少条数: 2; 最多条数: 2
data[].overlap_prev_tokensinteger必有; 与前段重叠的估算 token 数;首段为零。; 最小: 0
data[].overlap_next_tokensinteger必有; 与后段重叠的估算 token 数;末段为零。; 最小: 0
first_idstring / null必有; 本页首项的 ID;空页为 null。
last_idstring / null必有; 本页末项的 ID,可作为 after 继续查询;空页为 null。
has_moreboolean必有; 当前游标范围内,本页之后是否还有条目。

错误码与错误对象

读取分段

GET /knowledge/v1/vector_stores/{vector_store_id}/segments/{chunk_id}

读取一个分段及其词频统计。chunk_id 来自分段列表或原生搜索 content;分段必须属于此知识库。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
chunk_idpath: string必填;分段列表或原生搜索 content 返回的分段 ID。 最短字符数: 1

请求示例

curl -X GET "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/segments/${CHUNK_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
idstring必有; 资源 ID。; 最短字符数: 1
file_idstring必有; 资源 ID。; 最短字符数: 1
indexinteger必有; 此段在源文中的序号,从零开始。; 最小: 0
textstring必有; 此分段覆盖的提取文本;相邻分段可能重叠。
tokensinteger必有; 此段的估算 token 数,不是模型分词器计数。; 最小: 0
pageinteger / null必有; 分段起点所在源文页码,从一开始;无页码映射时为 null。
spaninteger[]必有; 以 UTF-16 代码单元表示的起止位置。; 最少条数: 2; 最多条数: 2
overlap_prev_tokensinteger必有; 与前段重叠的估算 token 数;首段为零。; 最小: 0
overlap_next_tokensinteger必有; 与后段重叠的估算 token 数;末段为零。; 最小: 0
termsobject[]必有; 此段出现的关键词及其段内频次、全库包含段数。
terms[].termstring必有; 小写文本词;连续汉字还生成相邻双字词。
terms[].countinteger必有; 该词在此段中的出现次数。; 最小: 0
terms[].chunks_in_storeinteger必有; 此库索引中包含该词的分段数。; 最小: 0

错误码与错误对象

事件

快速开始:官方 Python SDK

基础地址与鉴权

路径中的 ID 使用已有资源的 ID。示例中的环境变量由调用者设置。

列出事件

GET /knowledge/v1/vector_stores/{vector_store_id}/events

按序号升序读取此知识库事件,软删除期间仍可读取。将 next_seq 作为 after_seq 继续查询;next_seq 为 null 表示当前已到末尾。例如 ?after_seq=0&limit=20。

参数

名称位置与类型说明
vector_store_idpath: string必填;创建或列表返回的知识库 ID;不要使用显示名称。 最短字符数: 1
after_seqquery: integer返回 seq 更大的事件;使用 next_seq 继续。当前忽略非数字文本。 默认: 0
limitquery: integer每页条数。 最小: 1; 最大: 100; 默认: 20

请求示例

curl -X GET "https://api.deepraxis.ai/knowledge/v1/vector_stores/${VECTOR_STORE_ID}/events" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

字段类型说明
dataobject[]必有; seq 大于 after_seq 的事件,按 seq 升序返回。
data[].seqinteger必有; 库内递增事件序号;将返回的 next_seq 作为 after_seq 继续查询。; 最小: 1
data[].idstring必有; 服务端生成的事件 UUID。
data[].type"vector_store.created" / "vector_store.updated" / "vector_store.expired" / "vector_store.deleted" / "vector_store.restored" / "file.attached" / "file.stage_changed" / "file.completed" / "file.failed" / "file.cancelled" / "file.removed" / "batch.created" / "batch.completed" / "batch.cancelled"必有; 此知识库记录的库、文件入库或批次事件类别。
data[].processed_atinteger必有; Unix 时间戳,单位秒。
data[].vector_store_idstring必有; 资源 ID。; 最短字符数: 1
data[].file_idstring / null必有; 关联的源 File ID;无关联文件时为 null。
data[].batch_idstring / null必有; 关联的文件批次 ID;无关联批次时为 null。
data[].dataobject必有; 事件详情;阶段变化含 stage,入库失败含 code,其它事件可为空对象。
next_seqinteger / null必有; 作为下一页的 after_seq;null 表示没有后续。

错误码与错误对象

错误

HTTPcode处理建议
400INVALID_PARAMS字段、筛选条件或分页参数无效。
400LIMIT_EXCEEDED超过容量或批次上限。
401UNAUTHENTICATED检查 API Key;兼容响应 code 为 null。
404VECTOR_STORE_NOT_FOUND知识库不存在或不可访问。
404FILE_NOT_FOUND源文件不存在。
404FILE_NOT_IN_STORE文件未加入此知识库。
404BATCH_NOT_FOUND批次不存在。
404CHUNK_NOT_FOUND分段不存在。
409VECTOR_STORE_INVALID_STATE知识库当前状态不允许该操作。
409FILE_INVALID_STATE仅 failed 文件可以重试。
413PAYLOAD_TOO_LARGEJSON 请求超过 1,000,000 字节;兼容响应的 code 可能为 null。
429RATE_LIMITED稍后重试。
500— / null服务内部错误;保留请求 ID 并稍后重试。
501NOT_IMPLEMENTED操作尚未实现。
503PROVIDER_UNAVAILABLE处理服务暂不可用,可稍后重试。

原生 API 错误对象

字段类型说明
errorobject必有
error.code"INVALID_PARAMS" / "LIMIT_EXCEEDED" / "UNAUTHENTICATED" / "VECTOR_STORE_NOT_FOUND" / "FILE_NOT_FOUND" / "FILE_NOT_IN_STORE" / "BATCH_NOT_FOUND" / "CHUNK_NOT_FOUND" / "VECTOR_STORE_INVALID_STATE" / "FILE_INVALID_STATE" / "PAYLOAD_TOO_LARGE" / "RATE_LIMITED" / "NOT_IMPLEMENTED" / "PROVIDER_UNAVAILABLE"可选
error.messagestring必有
error.detailsstring / null可选

OpenAI 兼容错误对象

字段类型说明
errorobject必有
error.messagestring必有
error.type"invalid_request_error" / "not_found_error" / "rate_limit_error" / "server_error"必有
error.paramstring / null必有
error.code"INVALID_PARAMS" / "LIMIT_EXCEEDED" / "UNAUTHENTICATED" / "VECTOR_STORE_NOT_FOUND" / "FILE_NOT_FOUND" / "FILE_NOT_IN_STORE" / "BATCH_NOT_FOUND" / "CHUNK_NOT_FOUND" / "VECTOR_STORE_INVALID_STATE" / "FILE_INVALID_STATE" / "PAYLOAD_TOO_LARGE" / "RATE_LIMITED" / "NOT_IMPLEMENTED" / "PROVIDER_UNAVAILABLE" / null必有

未知路径的 404 可能只有 error.message;401 可能没有 details,兼容接口的 413 可能返回 code: null。路径编码错误也可能返回 HTML。不要假定每个失败都有业务错误码。

异步文件错误

添加文件成功并不表示内容已可搜索。检查文件 status;failed 时读取 last_error。

last_error.code含义建议
unsupported_file解析器不支持该文件转换为 TXT、Markdown 或已验证的格式
invalid_file内容无效、为空、加密或超过估算 token 上限检查内容、解密或拆分文件
server_error处理失败或超过 30 分钟截止时间稍后用 retry 重试失败文件

Database API

用 API Key 作为 Bearer 凭据,通过以下地址管理库与表结构。

https://api.deepraxis.ai/database/v1

指南 →

资源路径
Databases/database/v1/databases
Tables/database/v1/databases/{database_id}/tables
Fields/database/v1/databases/{database_id}/tables/{table}/fields
Events/database/v1/databases/{database_id}/events
REST/database/v1/databases/{database_id}/rest/{table}

错误码

数据库

指南 →

基础地址与鉴权

创建库

POST /database/v1/databases

请求体

字段类型必填说明
namestring是名称
labelsobject否标签

返回: Database.

响应

HTTP 201

Success

application/json

名称类型说明
idstringDatabase identifier, prefixed db_. Pass it as database_id in every database, table, field, rows and events path.
namestringDisplay name given at creation or by the last update; it is not an identifier.
labelsobjectString tags attached to the database, as key and value pairs; empty object when none.
statusstringLifecycle state of the database. Table, field and row calls work only while it is active.
table_countintegerNumber of tables currently in the database, at most 50; refreshed when the schema changes.
size_bytesintegerStorage size; row writes and GET refresh usage at most once per five seconds, schema changes refresh immediately.
created_atstringTime the database was created, as an RFC 3339 UTC timestamp.
updated_atstringTime of the last change to the name, labels, status or usage snapshot, as an RFC 3339 UTC timestamp.
deleted_atstring | nullTime the database entered the deleting state, as an RFC 3339 UTC timestamp; null while it is active and again after a restore.
purge_atstring | nullPermanent deletion deadline for deleting databases; null otherwise.
curl -X POST "https://api.deepraxis.ai/database/v1/databases" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"walk-lib-r1-DOC-5320-tasks","labels":{"purpose":"docs","sample":"walk-lib-r1-doc-5320-"}}'

响应示例 — HTTP 201

{
  "id": "db_d6f0d743d5a645e8",
  "name": "walk-lib-r1-DOC-5320-tasks",
  "labels": {
    "purpose": "docs",
    "sample": "walk-lib-r1-doc-5320-"
  },
  "status": "active",
  "table_count": 0,
  "size_bytes": 53248,
  "created_at": "2026-10-11T17:41:40.620Z",
  "updated_at": "2026-10-11T17:41:41.488Z",
  "deleted_at": null,
  "purge_at": null
}

列出库

GET /database/v1/databases

参数位置说明
cursorquery上一页返回的 next_cursor。
limitquery最多返回的条数。 (default: 20) (1–100)
labelsquery精确匹配标签,例如 labels[purpose]=docs。
statusquery库状态:active 或 deleting;省略时只列出 active。

返回: Page + object.

响应

HTTP 200

Success

application/json

名称类型说明
dataarray<object>Databases on this page, newest first (created_at descending, ties by id). Deleting databases are excluded unless status=deleting.
data[].idstringDatabase identifier, prefixed db_. Pass it as database_id in every database, table, field, rows and events path.
data[].namestringDisplay name given at creation or by the last update; it is not an identifier.
data[].labelsobjectString tags attached to the database, as key and value pairs; empty object when none.
data[].statusstringLifecycle state of the database. Table, field and row calls work only while it is active.
data[].table_countintegerNumber of tables currently in the database, at most 50; refreshed when the schema changes.
data[].size_bytesintegerStorage size; row writes and GET refresh usage at most once per five seconds, schema changes refresh immediately.
data[].created_atstringTime the database was created, as an RFC 3339 UTC timestamp.
data[].updated_atstringTime of the last change to the name, labels, status or usage snapshot, as an RFC 3339 UTC timestamp.
data[].deleted_atstring | nullTime the database entered the deleting state, as an RFC 3339 UTC timestamp; null while it is active and again after a restore.
data[].purge_atstring | nullPermanent deletion deadline for deleting databases; null otherwise.
next_cursorstring | nullOpaque cursor for the next page, or null when there are no more items. Databases list: pass it as cursor. Events list: pass it as after_seq (order asc) or before_seq (order desc).
curl -g -X GET "https://api.deepraxis.ai/database/v1/databases?limit=10&labels[purpose]=docs&labels[sample]=walk-lib-r1-doc-5320-" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应示例 — HTTP 200

{
  "data": [
    {
      "id": "db_d6f0d743d5a645e8",
      "name": "walk-lib-r1-DOC-5320-tasks",
      "labels": {
        "purpose": "docs",
        "sample": "walk-lib-r1-doc-5320-"
      },
      "status": "active",
      "table_count": 0,
      "size_bytes": 53248,
      "created_at": "2026-10-11T17:41:40.620Z",
      "updated_at": "2026-10-11T17:41:41.488Z",
      "deleted_at": null,
      "purge_at": null
    }
  ],
  "next_cursor": null
}

读取库

GET /database/v1/databases/{database_id}

参数位置说明
database_idpath库 ID。

返回: Database.

响应

HTTP 200

Success

application/json

名称类型说明
idstringDatabase identifier, prefixed db_. Pass it as database_id in every database, table, field, rows and events path.
namestringDisplay name given at creation or by the last update; it is not an identifier.
labelsobjectString tags attached to the database, as key and value pairs; empty object when none.
statusstringLifecycle state of the database. Table, field and row calls work only while it is active.
table_countintegerNumber of tables currently in the database, at most 50; refreshed when the schema changes.
size_bytesintegerStorage size; row writes and GET refresh usage at most once per five seconds, schema changes refresh immediately.
created_atstringTime the database was created, as an RFC 3339 UTC timestamp.
updated_atstringTime of the last change to the name, labels, status or usage snapshot, as an RFC 3339 UTC timestamp.
deleted_atstring | nullTime the database entered the deleting state, as an RFC 3339 UTC timestamp; null while it is active and again after a restore.
purge_atstring | nullPermanent deletion deadline for deleting databases; null otherwise.
curl -X GET "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应示例 — HTTP 200

{
  "id": "db_d6f0d743d5a645e8",
  "name": "walk-lib-r1-DOC-5320-tasks",
  "labels": {
    "purpose": "docs",
    "sample": "walk-lib-r1-doc-5320-"
  },
  "status": "active",
  "table_count": 0,
  "size_bytes": 53248,
  "created_at": "2026-10-11T17:41:40.620Z",
  "updated_at": "2026-10-11T17:41:41.488Z",
  "deleted_at": null,
  "purge_at": null
}

更新库

PATCH /database/v1/databases/{database_id}

参数位置说明
database_idpath库 ID。

请求体

字段类型必填说明
namestring否名称
labelsobject否标签

返回: Database.

响应

HTTP 200

Success

application/json

名称类型说明
idstringDatabase identifier, prefixed db_. Pass it as database_id in every database, table, field, rows and events path.
namestringDisplay name given at creation or by the last update; it is not an identifier.
labelsobjectString tags attached to the database, as key and value pairs; empty object when none.
statusstringLifecycle state of the database. Table, field and row calls work only while it is active.
table_countintegerNumber of tables currently in the database, at most 50; refreshed when the schema changes.
size_bytesintegerStorage size; row writes and GET refresh usage at most once per five seconds, schema changes refresh immediately.
created_atstringTime the database was created, as an RFC 3339 UTC timestamp.
updated_atstringTime of the last change to the name, labels, status or usage snapshot, as an RFC 3339 UTC timestamp.
deleted_atstring | nullTime the database entered the deleting state, as an RFC 3339 UTC timestamp; null while it is active and again after a restore.
purge_atstring | nullPermanent deletion deadline for deleting databases; null otherwise.
curl -X PATCH "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"walk-lib-r1-DOC-5320-notes"}'

响应示例 — HTTP 200

{
  "id": "db_d6f0d743d5a645e8",
  "name": "walk-lib-r1-DOC-5320-notes",
  "labels": {
    "purpose": "docs",
    "sample": "walk-lib-r1-doc-5320-"
  },
  "status": "active",
  "table_count": 0,
  "size_bytes": 53248,
  "created_at": "2026-10-11T17:41:40.620Z",
  "updated_at": "2026-10-11T17:41:43.514Z",
  "deleted_at": null,
  "purge_at": null
}

删除库

DELETE /database/v1/databases/{database_id}

参数位置说明
database_idpath库 ID。

返回: Database.

响应

HTTP 200

Success

application/json

名称类型说明
idstringDatabase identifier, prefixed db_. Pass it as database_id in every database, table, field, rows and events path.
namestringDisplay name given at creation or by the last update; it is not an identifier.
labelsobjectString tags attached to the database, as key and value pairs; empty object when none.
statusstringLifecycle state of the database. Table, field and row calls work only while it is active.
table_countintegerNumber of tables currently in the database, at most 50; refreshed when the schema changes.
size_bytesintegerStorage size; row writes and GET refresh usage at most once per five seconds, schema changes refresh immediately.
created_atstringTime the database was created, as an RFC 3339 UTC timestamp.
updated_atstringTime of the last change to the name, labels, status or usage snapshot, as an RFC 3339 UTC timestamp.
deleted_atstring | nullTime the database entered the deleting state, as an RFC 3339 UTC timestamp; null while it is active and again after a restore.
purge_atstring | nullPermanent deletion deadline for deleting databases; null otherwise.
curl -X DELETE "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应示例 — HTTP 200

{
  "id": "db_d6f0d743d5a645e8",
  "name": "walk-lib-r1-DOC-5320-notes",
  "labels": {
    "purpose": "docs",
    "sample": "walk-lib-r1-doc-5320-"
  },
  "status": "deleting",
  "table_count": 0,
  "size_bytes": 53248,
  "created_at": "2026-10-11T17:41:40.620Z",
  "updated_at": "2026-10-11T17:41:51.868Z",
  "deleted_at": "2026-10-11T17:41:51.868Z",
  "purge_at": "2026-10-18T17:41:51.868Z"
}

恢复库

POST /database/v1/databases/{database_id}/restore

参数位置说明
database_idpath库 ID。

返回: Database.

响应

HTTP 200

Success

application/json

名称类型说明
idstringDatabase identifier, prefixed db_. Pass it as database_id in every database, table, field, rows and events path.
namestringDisplay name given at creation or by the last update; it is not an identifier.
labelsobjectString tags attached to the database, as key and value pairs; empty object when none.
statusstringLifecycle state of the database. Table, field and row calls work only while it is active.
table_countintegerNumber of tables currently in the database, at most 50; refreshed when the schema changes.
size_bytesintegerStorage size; row writes and GET refresh usage at most once per five seconds, schema changes refresh immediately.
created_atstringTime the database was created, as an RFC 3339 UTC timestamp.
updated_atstringTime of the last change to the name, labels, status or usage snapshot, as an RFC 3339 UTC timestamp.
deleted_atstring | nullTime the database entered the deleting state, as an RFC 3339 UTC timestamp; null while it is active and again after a restore.
purge_atstring | nullPermanent deletion deadline for deleting databases; null otherwise.
curl -X POST "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/restore" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应示例 — HTTP 200

{
  "id": "db_d6f0d743d5a645e8",
  "name": "walk-lib-r1-DOC-5320-notes",
  "labels": {
    "purpose": "docs",
    "sample": "walk-lib-r1-doc-5320-"
  },
  "status": "active",
  "table_count": 0,
  "size_bytes": 53248,
  "created_at": "2026-10-11T17:41:40.620Z",
  "updated_at": "2026-10-11T17:41:51.528Z",
  "deleted_at": null,
  "purge_at": null
}

清除库

POST /database/v1/databases/{database_id}/purge

参数位置说明
database_idpath库 ID。

返回: object.

响应

HTTP 200

Permanently purged

application/json

名称类型说明
idstringId (db_…) of the database that was permanently purged; it no longer resolves.
objectstringResource type of the purged object; always database.
purgedbooleanAlways true: the database and all of its data were permanently removed and cannot be recovered.
curl -X POST "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/purge" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应示例 — HTTP 200

{
  "id": "db_d6f0d743d5a645e8",
  "object": "database",
  "purged": true
}

Database

字段类型必填说明
idstring是资源 ID; ^db_
namestring是名称
labelsobject是标签
status"provisioning" / "active" / "deleting" / "deleted" / "failed"是库状态
table_countinteger是表数量
size_bytesinteger是占用字节数
created_atdate-time是创建时间
updated_atdate-time是更新时间
deleted_atdate-time / null是删除时间;未删除时为 null
purge_atdate-time / null是—

Page

字段类型必填说明
dataJSON[]是资源数组
next_cursorstring / null是下一页游标;没有后续时为 null

数据表

指南 →

基础地址与鉴权

创建表

POST /database/v1/databases/{database_id}/tables

参数位置说明
database_idpath库 ID。

请求体

字段类型必填说明
namestring是名称; ^[a-z_][a-z0-9_]{0,62}$
descriptionstring否描述
fieldsNewField[]是字段列表

返回: Table.

响应

HTTP 201

Success

application/json

名称类型说明
idstringTable identifier, prefixed tbl_. Stable across renames and accepted wherever a table path parameter takes an id or name.
namestringCurrent table name, usable in the rows path; may change when the table is renamed.
descriptionstring | nullFree-text note about the table, or null when none was set.
fieldsarray<object>Field definitions of the table, in display order. Row values are keyed by each field's name.
fields[].idstringField identifier, prefixed fld_. Stable across renames; accepted wherever a field path parameter takes an id or name.
fields[].namestringCurrent field name; rows are keyed by it in requests and responses. May change when the field is renamed.
fields[].descriptionstring | nullFree-text note about the field, or null when none was set.
fields[].requiredbooleanWhether every row must hold a non-null value for this field.
fields[].uniquebooleanWhether values must be distinct across rows; fixed at creation. A unique field is indexed, and a violation returns 409 UNIQUE_VIOLATION.
fields[].indexedbooleanWhether an index is maintained for faster filters and ordering. Always false for json and link fields.
fields[].typestringScalar data type of the field; it cannot be changed after the field is created. / Type json: the value is any JSON document validated against options.schema. It cannot be changed after the field is created. / Type link: the value is the id of a row in another table (an array of ids when options.multiple is true). It cannot be changed after the field is created.
fields[].optionsobjectScalar fields take no options; always an empty object. / Settings of a json field. schema is required. / Settings of a link field. Both linked_table_id and multiple are required.
fields[].defaultanyDefault JSON value for omitted insert fields; must match the field type and JSON schema. A datetime default of "now()" evaluates to server time on insertion and reads back as "now()" in the field definition. For string and json fields it is a literal string. Explicit null remains null. Link fields do not support defaults.
schema_revisionintegerCounter that starts at 1 and increases by one each time the table's name, description or fields change; use it to detect schema changes.
created_atstringTime the table was created, as an RFC 3339 UTC timestamp.
updated_atstringTime of the last schema change to the table, as an RFC 3339 UTC timestamp.
row_countintegerNumber of rows currently stored. Returned only by databaseGetTable; absent from list, create and field responses.
curl -X POST "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/tables" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"tasks","fields":[{"name":"title","type":"string","required":true,"unique":true},{"name":"done","type":"boolean"}]}'

响应示例 — HTTP 201

{
  "id": "tbl_2b3431c772754599",
  "name": "tasks",
  "description": null,
  "schema_revision": 1,
  "created_at": "2026-10-11T17:41:44.246Z",
  "updated_at": "2026-10-11T17:41:44.246Z",
  "fields": [
    {
      "id": "fld_bc71f7c6a1a848d2",
      "name": "title",
      "type": "string",
      "description": null,
      "required": true,
      "unique": true,
      "indexed": true
    },
    {
      "id": "fld_c7879883dfe04ca0",
      "name": "done",
      "type": "boolean",
      "description": null,
      "required": false,
      "unique": false,
      "indexed": true
    }
  ]
}

列出表

GET /database/v1/databases/{database_id}/tables

参数位置说明
database_idpath库 ID。

返回: Page + object.

响应

HTTP 200

Success

application/json

名称类型说明
dataarray<object>Every table of the database with its fields, in creation order; at most 50 items.
data[].idstringTable identifier, prefixed tbl_. Stable across renames and accepted wherever a table path parameter takes an id or name.
data[].namestringCurrent table name, usable in the rows path; may change when the table is renamed.
data[].descriptionstring | nullFree-text note about the table, or null when none was set.
data[].fieldsarray<object>Field definitions of the table, in display order. Row values are keyed by each field's name.
data[].schema_revisionintegerCounter that starts at 1 and increases by one each time the table's name, description or fields change; use it to detect schema changes.
data[].created_atstringTime the table was created, as an RFC 3339 UTC timestamp.
data[].updated_atstringTime of the last schema change to the table, as an RFC 3339 UTC timestamp.
data[].row_countintegerNumber of rows currently stored. Returned only by databaseGetTable; absent from list, create and field responses.
next_cursorstring | nullOpaque cursor for the next page, or null when there are no more items. Databases list: pass it as cursor. Events list: pass it as after_seq (order asc) or before_seq (order desc).
curl -X GET "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/tables" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应示例 — HTTP 200

{
  "data": [
    {
      "id": "tbl_2b3431c772754599",
      "name": "tasks",
      "description": null,
      "schema_revision": 1,
      "created_at": "2026-10-11T17:41:44.246Z",
      "updated_at": "2026-10-11T17:41:44.246Z",
      "fields": [
        {
          "id": "fld_bc71f7c6a1a848d2",
          "name": "title",
          "type": "string",
          "description": null,
          "required": true,
          "unique": true,
          "indexed": true
        },
        {
          "id": "fld_c7879883dfe04ca0",
          "name": "done",
          "type": "boolean",
          "description": null,
          "required": false,
          "unique": false,
          "indexed": true
        }
      ]
    }
  ],
  "next_cursor": null
}

读取表

GET /database/v1/databases/{database_id}/tables/{table}

参数位置说明
database_idpath库 ID。
tablepath表 ID 或名称。

返回: Table.

响应

HTTP 200

Success

application/json

名称类型说明
idstringTable identifier, prefixed tbl_. Stable across renames and accepted wherever a table path parameter takes an id or name.
namestringCurrent table name, usable in the rows path; may change when the table is renamed.
descriptionstring | nullFree-text note about the table, or null when none was set.
fieldsarray<object>Field definitions of the table, in display order. Row values are keyed by each field's name.
fields[].idstringField identifier, prefixed fld_. Stable across renames; accepted wherever a field path parameter takes an id or name.
fields[].namestringCurrent field name; rows are keyed by it in requests and responses. May change when the field is renamed.
fields[].descriptionstring | nullFree-text note about the field, or null when none was set.
fields[].requiredbooleanWhether every row must hold a non-null value for this field.
fields[].uniquebooleanWhether values must be distinct across rows; fixed at creation. A unique field is indexed, and a violation returns 409 UNIQUE_VIOLATION.
fields[].indexedbooleanWhether an index is maintained for faster filters and ordering. Always false for json and link fields.
fields[].typestringScalar data type of the field; it cannot be changed after the field is created. / Type json: the value is any JSON document validated against options.schema. It cannot be changed after the field is created. / Type link: the value is the id of a row in another table (an array of ids when options.multiple is true). It cannot be changed after the field is created.
fields[].optionsobjectScalar fields take no options; always an empty object. / Settings of a json field. schema is required. / Settings of a link field. Both linked_table_id and multiple are required.
fields[].defaultanyDefault JSON value for omitted insert fields; must match the field type and JSON schema. A datetime default of "now()" evaluates to server time on insertion and reads back as "now()" in the field definition. For string and json fields it is a literal string. Explicit null remains null. Link fields do not support defaults.
schema_revisionintegerCounter that starts at 1 and increases by one each time the table's name, description or fields change; use it to detect schema changes.
created_atstringTime the table was created, as an RFC 3339 UTC timestamp.
updated_atstringTime of the last schema change to the table, as an RFC 3339 UTC timestamp.
row_countintegerNumber of rows currently stored. Returned only by databaseGetTable; absent from list, create and field responses.
curl -X GET "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/tables/tasks" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应示例 — HTTP 200

{
  "id": "tbl_2b3431c772754599",
  "name": "tasks",
  "description": null,
  "schema_revision": 1,
  "created_at": "2026-10-11T17:41:44.246Z",
  "updated_at": "2026-10-11T17:41:44.246Z",
  "fields": [
    {
      "id": "fld_bc71f7c6a1a848d2",
      "name": "title",
      "type": "string",
      "description": null,
      "required": true,
      "unique": true,
      "indexed": true
    },
    {
      "id": "fld_c7879883dfe04ca0",
      "name": "done",
      "type": "boolean",
      "description": null,
      "required": false,
      "unique": false,
      "indexed": true
    }
  ],
  "row_count": 0
}

更新表

PATCH /database/v1/databases/{database_id}/tables/{table}

参数位置说明
database_idpath库 ID。
tablepath表 ID 或名称。

请求体

字段类型必填说明
namestring否名称
descriptionstring / null否描述

返回: Table.

响应

HTTP 200

Success

application/json

名称类型说明
idstringTable identifier, prefixed tbl_. Stable across renames and accepted wherever a table path parameter takes an id or name.
namestringCurrent table name, usable in the rows path; may change when the table is renamed.
descriptionstring | nullFree-text note about the table, or null when none was set.
fieldsarray<object>Field definitions of the table, in display order. Row values are keyed by each field's name.
fields[].idstringField identifier, prefixed fld_. Stable across renames; accepted wherever a field path parameter takes an id or name.
fields[].namestringCurrent field name; rows are keyed by it in requests and responses. May change when the field is renamed.
fields[].descriptionstring | nullFree-text note about the field, or null when none was set.
fields[].requiredbooleanWhether every row must hold a non-null value for this field.
fields[].uniquebooleanWhether values must be distinct across rows; fixed at creation. A unique field is indexed, and a violation returns 409 UNIQUE_VIOLATION.
fields[].indexedbooleanWhether an index is maintained for faster filters and ordering. Always false for json and link fields.
fields[].typestringScalar data type of the field; it cannot be changed after the field is created. / Type json: the value is any JSON document validated against options.schema. It cannot be changed after the field is created. / Type link: the value is the id of a row in another table (an array of ids when options.multiple is true). It cannot be changed after the field is created.
fields[].optionsobjectScalar fields take no options; always an empty object. / Settings of a json field. schema is required. / Settings of a link field. Both linked_table_id and multiple are required.
fields[].defaultanyDefault JSON value for omitted insert fields; must match the field type and JSON schema. A datetime default of "now()" evaluates to server time on insertion and reads back as "now()" in the field definition. For string and json fields it is a literal string. Explicit null remains null. Link fields do not support defaults.
schema_revisionintegerCounter that starts at 1 and increases by one each time the table's name, description or fields change; use it to detect schema changes.
created_atstringTime the table was created, as an RFC 3339 UTC timestamp.
updated_atstringTime of the last schema change to the table, as an RFC 3339 UTC timestamp.
row_countintegerNumber of rows currently stored. Returned only by databaseGetTable; absent from list, create and field responses.
curl -X PATCH "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/tables/tasks" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"description":"Tasks for an agent"}'

响应示例 — HTTP 200

{
  "id": "tbl_2b3431c772754599",
  "name": "tasks",
  "description": "Tasks for an agent",
  "schema_revision": 2,
  "created_at": "2026-10-11T17:41:44.246Z",
  "updated_at": "2026-10-11T17:41:45.127Z",
  "fields": [
    {
      "id": "fld_bc71f7c6a1a848d2",
      "name": "title",
      "type": "string",
      "description": null,
      "required": true,
      "unique": true,
      "indexed": true
    },
    {
      "id": "fld_c7879883dfe04ca0",
      "name": "done",
      "type": "boolean",
      "description": null,
      "required": false,
      "unique": false,
      "indexed": true
    }
  ]
}

删除表

DELETE /database/v1/databases/{database_id}/tables/{table}

参数位置说明
database_idpath库 ID。
tablepath表 ID 或名称。

返回: object.

响应

HTTP 200

Success

application/json

名称类型说明
deletedbooleanAlways true: the table and all of its rows were dropped immediately and cannot be recovered.
curl -X DELETE "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/tables/tasks" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应示例 — HTTP 200

{
  "deleted": true
}

Table

字段类型必填说明
idstring是资源 ID; ^tbl_
namestring是名称
descriptionstring / null是描述
fieldsField[]是字段列表
schema_revisioninteger是表结构版本
created_atdate-time是创建时间
updated_atdate-time是更新时间
row_countinteger否行数;仅单表查询返回

Field · Page

字段

指南 →

基础地址与鉴权

添加、更新和删除字段均返回完整 Table。字段 type 不可修改;link 的关联目标不可修改。json 的 schema 更新仅约束之后的写入。

新增带 default 的字段时,已有行一律用 default 回填(无论是否 required),行的 _version 不变;不带 default 的新字段在已有行上为 null。在已有行的表上新增 required 字段时必须提供 default,没有 default 时返回 400 VALIDATION_FAILED。把字段改为 required 时,若仍有行在该字段为空,返回 400 VALIDATION_FAILED 并在 message 中给出空行数。空请求体、只含被忽略键或所有值都与当前相同的 PATCH 不修改 updated_at 与 schema_revision、不产生事件,直接返回当前对象。

datetime 的 default 可以是字符串 "now()",插入时生成服务器当前 UTC 时间;读回字段定义仍是 "now()"。例如 {"name":"created_at","type":"datetime","default":"now()"}。string/json 的 "now()" 保持字面量;其他类型仍按原校验规则处理。新增字段回填已有行时也会求值。

添加字段

POST /database/v1/databases/{database_id}/tables/{table}/fields

参数位置说明
database_idpath库 ID。
tablepath表 ID 或名称。

请求体

"string" / "integer" / "number" / "boolean" / "datetime"

字段类型必填说明
namestring是字段名;只保留 id;新字段不能以下划线开头。created_at、updated_at、version 可作为用户字段名;已有下划线字段照常使用,且优先于同名元数据。; ^(?!id$)[a-z][a-z0-9_]{0,62}$
descriptionstring否描述
requiredboolean否是否必填
uniqueboolean否是否唯一
indexedboolean否是否索引
type"string" / "integer" / "number" / "boolean" / "datetime"是类型
optionsobject否json:schema;link:linked_table_id 与 multiple
defaultJSON否省略插入值时的默认值;datetime 的 now() 在写入时取服务器时间,字段定义仍读回 now()。string/json 中为字面量。显式 null 不使用默认值。

"json"

字段类型必填说明
namestring是字段名;只保留 id;新字段不能以下划线开头。created_at、updated_at、version 可作为用户字段名;已有下划线字段照常使用,且优先于同名元数据。; ^(?!id$)[a-z][a-z0-9_]{0,62}$
descriptionstring否描述
requiredboolean否是否必填
uniqueboolean否是否唯一
indexedboolean否是否索引
type"json"是类型
optionsobject是json:schema;link:linked_table_id 与 multiple
defaultJSON否省略插入值时的默认值;datetime 的 now() 在写入时取服务器时间,字段定义仍读回 now()。string/json 中为字面量。显式 null 不使用默认值。

"link"

字段类型必填说明
namestring是字段名;只保留 id;新字段不能以下划线开头。created_at、updated_at、version 可作为用户字段名;已有下划线字段照常使用,且优先于同名元数据。; ^(?!id$)[a-z][a-z0-9_]{0,62}$
descriptionstring否描述
requiredboolean否是否必填
uniqueboolean否是否唯一
indexedboolean否是否索引
type"link"是类型
optionsobject是json:schema;link:linked_table_id 与 multiple

返回: Table.

响应

HTTP 201

Success

application/json

名称类型说明
idstringTable identifier, prefixed tbl_. Stable across renames and accepted wherever a table path parameter takes an id or name.
namestringCurrent table name, usable in the rows path; may change when the table is renamed.
descriptionstring | nullFree-text note about the table, or null when none was set.
fieldsarray<object>Field definitions of the table, in display order. Row values are keyed by each field's name.
fields[].idstringField identifier, prefixed fld_. Stable across renames; accepted wherever a field path parameter takes an id or name.
fields[].namestringCurrent field name; rows are keyed by it in requests and responses. May change when the field is renamed.
fields[].descriptionstring | nullFree-text note about the field, or null when none was set.
fields[].requiredbooleanWhether every row must hold a non-null value for this field.
fields[].uniquebooleanWhether values must be distinct across rows; fixed at creation. A unique field is indexed, and a violation returns 409 UNIQUE_VIOLATION.
fields[].indexedbooleanWhether an index is maintained for faster filters and ordering. Always false for json and link fields.
fields[].typestringScalar data type of the field; it cannot be changed after the field is created. / Type json: the value is any JSON document validated against options.schema. It cannot be changed after the field is created. / Type link: the value is the id of a row in another table (an array of ids when options.multiple is true). It cannot be changed after the field is created.
fields[].optionsobjectScalar fields take no options; always an empty object. / Settings of a json field. schema is required. / Settings of a link field. Both linked_table_id and multiple are required.
fields[].defaultanyDefault JSON value for omitted insert fields; must match the field type and JSON schema. A datetime default of "now()" evaluates to server time on insertion and reads back as "now()" in the field definition. For string and json fields it is a literal string. Explicit null remains null. Link fields do not support defaults.
schema_revisionintegerCounter that starts at 1 and increases by one each time the table's name, description or fields change; use it to detect schema changes.
created_atstringTime the table was created, as an RFC 3339 UTC timestamp.
updated_atstringTime of the last schema change to the table, as an RFC 3339 UTC timestamp.
row_countintegerNumber of rows currently stored. Returned only by databaseGetTable; absent from list, create and field responses.
curl -X POST "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/tables/tasks/fields" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"priority","type":"integer"}'

响应示例 — HTTP 201

{
  "id": "tbl_2b3431c772754599",
  "name": "tasks",
  "description": "Tasks for an agent",
  "schema_revision": 3,
  "created_at": "2026-10-11T17:41:44.246Z",
  "updated_at": "2026-10-11T17:41:45.420Z",
  "fields": [
    {
      "id": "fld_bc71f7c6a1a848d2",
      "name": "title",
      "type": "string",
      "description": null,
      "required": true,
      "unique": true,
      "indexed": true
    },
    {
      "id": "fld_c7879883dfe04ca0",
      "name": "done",
      "type": "boolean",
      "description": null,
      "required": false,
      "unique": false,
      "indexed": true
    },
    {
      "id": "fld_4c3e63869e35458c",
      "name": "priority",
      "type": "integer",
      "description": null,
      "required": false,
      "unique": false,
      "indexed": true
    }
  ]
}

更新字段

PATCH /database/v1/databases/{database_id}/tables/{table}/fields/{field}

参数位置说明
database_idpath库 ID。
tablepath表 ID 或名称。
fieldpath字段 ID 或名称。

请求体

字段类型必填说明
namestring否名称
descriptionstring / null否描述
requiredboolean否是否必填
indexedboolean否是否索引
optionsobject否json:schema;link:linked_table_id 与 multiple
defaultJSON否省略插入值时的默认值;datetime 的 now() 在写入时取服务器时间,字段定义仍读回 now()。string/json 中为字面量。显式 null 不使用默认值。

返回: Table.

响应

HTTP 200

Success

application/json

名称类型说明
idstringTable identifier, prefixed tbl_. Stable across renames and accepted wherever a table path parameter takes an id or name.
namestringCurrent table name, usable in the rows path; may change when the table is renamed.
descriptionstring | nullFree-text note about the table, or null when none was set.
fieldsarray<object>Field definitions of the table, in display order. Row values are keyed by each field's name.
fields[].idstringField identifier, prefixed fld_. Stable across renames; accepted wherever a field path parameter takes an id or name.
fields[].namestringCurrent field name; rows are keyed by it in requests and responses. May change when the field is renamed.
fields[].descriptionstring | nullFree-text note about the field, or null when none was set.
fields[].requiredbooleanWhether every row must hold a non-null value for this field.
fields[].uniquebooleanWhether values must be distinct across rows; fixed at creation. A unique field is indexed, and a violation returns 409 UNIQUE_VIOLATION.
fields[].indexedbooleanWhether an index is maintained for faster filters and ordering. Always false for json and link fields.
fields[].typestringScalar data type of the field; it cannot be changed after the field is created. / Type json: the value is any JSON document validated against options.schema. It cannot be changed after the field is created. / Type link: the value is the id of a row in another table (an array of ids when options.multiple is true). It cannot be changed after the field is created.
fields[].optionsobjectScalar fields take no options; always an empty object. / Settings of a json field. schema is required. / Settings of a link field. Both linked_table_id and multiple are required.
fields[].defaultanyDefault JSON value for omitted insert fields; must match the field type and JSON schema. A datetime default of "now()" evaluates to server time on insertion and reads back as "now()" in the field definition. For string and json fields it is a literal string. Explicit null remains null. Link fields do not support defaults.
schema_revisionintegerCounter that starts at 1 and increases by one each time the table's name, description or fields change; use it to detect schema changes.
created_atstringTime the table was created, as an RFC 3339 UTC timestamp.
updated_atstringTime of the last schema change to the table, as an RFC 3339 UTC timestamp.
row_countintegerNumber of rows currently stored. Returned only by databaseGetTable; absent from list, create and field responses.
curl -X PATCH "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/tables/tasks/fields/priority" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"description":"Task priority"}'

响应示例 — HTTP 200

{
  "id": "tbl_2b3431c772754599",
  "name": "tasks",
  "description": "Tasks for an agent",
  "schema_revision": 4,
  "created_at": "2026-10-11T17:41:44.246Z",
  "updated_at": "2026-10-11T17:41:46.276Z",
  "fields": [
    {
      "id": "fld_bc71f7c6a1a848d2",
      "name": "title",
      "type": "string",
      "description": null,
      "required": true,
      "unique": true,
      "indexed": true
    },
    {
      "id": "fld_c7879883dfe04ca0",
      "name": "done",
      "type": "boolean",
      "description": null,
      "required": false,
      "unique": false,
      "indexed": true
    },
    {
      "id": "fld_4c3e63869e35458c",
      "name": "priority",
      "type": "integer",
      "description": "Task priority",
      "required": false,
      "unique": false,
      "indexed": true
    }
  ]
}

删除字段

DELETE /database/v1/databases/{database_id}/tables/{table}/fields/{field}

参数位置说明
database_idpath库 ID。
tablepath表 ID 或名称。
fieldpath字段 ID 或名称。

返回: Table.

响应

HTTP 200

Success

application/json

名称类型说明
idstringTable identifier, prefixed tbl_. Stable across renames and accepted wherever a table path parameter takes an id or name.
namestringCurrent table name, usable in the rows path; may change when the table is renamed.
descriptionstring | nullFree-text note about the table, or null when none was set.
fieldsarray<object>Field definitions of the table, in display order. Row values are keyed by each field's name.
fields[].idstringField identifier, prefixed fld_. Stable across renames; accepted wherever a field path parameter takes an id or name.
fields[].namestringCurrent field name; rows are keyed by it in requests and responses. May change when the field is renamed.
fields[].descriptionstring | nullFree-text note about the field, or null when none was set.
fields[].requiredbooleanWhether every row must hold a non-null value for this field.
fields[].uniquebooleanWhether values must be distinct across rows; fixed at creation. A unique field is indexed, and a violation returns 409 UNIQUE_VIOLATION.
fields[].indexedbooleanWhether an index is maintained for faster filters and ordering. Always false for json and link fields.
fields[].typestringScalar data type of the field; it cannot be changed after the field is created. / Type json: the value is any JSON document validated against options.schema. It cannot be changed after the field is created. / Type link: the value is the id of a row in another table (an array of ids when options.multiple is true). It cannot be changed after the field is created.
fields[].optionsobjectScalar fields take no options; always an empty object. / Settings of a json field. schema is required. / Settings of a link field. Both linked_table_id and multiple are required.
fields[].defaultanyDefault JSON value for omitted insert fields; must match the field type and JSON schema. A datetime default of "now()" evaluates to server time on insertion and reads back as "now()" in the field definition. For string and json fields it is a literal string. Explicit null remains null. Link fields do not support defaults.
schema_revisionintegerCounter that starts at 1 and increases by one each time the table's name, description or fields change; use it to detect schema changes.
created_atstringTime the table was created, as an RFC 3339 UTC timestamp.
updated_atstringTime of the last schema change to the table, as an RFC 3339 UTC timestamp.
row_countintegerNumber of rows currently stored. Returned only by databaseGetTable; absent from list, create and field responses.
curl -X DELETE "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/tables/tasks/fields/priority" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应示例 — HTTP 200

{
  "id": "tbl_2b3431c772754599",
  "name": "tasks",
  "description": "Tasks for an agent",
  "schema_revision": 5,
  "created_at": "2026-10-11T17:41:44.246Z",
  "updated_at": "2026-10-11T17:41:47.136Z",
  "fields": [
    {
      "id": "fld_bc71f7c6a1a848d2",
      "name": "title",
      "type": "string",
      "description": null,
      "required": true,
      "unique": true,
      "indexed": true
    },
    {
      "id": "fld_c7879883dfe04ca0",
      "name": "done",
      "type": "boolean",
      "description": null,
      "required": false,
      "unique": false,
      "indexed": true
    }
  ]
}

Field

"string" / "integer" / "number" / "boolean" / "datetime"

字段类型必填说明
idstring是资源 ID
namestring是名称
descriptionstring / null是描述
requiredboolean是是否必填
uniqueboolean是是否唯一
indexedboolean是是否索引
type"string" / "integer" / "number" / "boolean" / "datetime"是类型
optionsobject否json:schema;link:linked_table_id 与 multiple
defaultJSON否省略插入值时的默认值;datetime 的 now() 在写入时取服务器时间,字段定义仍读回 now()。string/json 中为字面量。显式 null 不使用默认值。

"json"

字段类型必填说明
idstring是资源 ID
namestring是名称
descriptionstring / null是描述
requiredboolean是是否必填
uniqueboolean是是否唯一
indexedboolean是是否索引
type"json"是类型
optionsobject是json:schema;link:linked_table_id 与 multiple
defaultJSON否省略插入值时的默认值;datetime 的 now() 在写入时取服务器时间,字段定义仍读回 now()。string/json 中为字面量。显式 null 不使用默认值。

"link"

字段类型必填说明
idstring是资源 ID
namestring是名称
descriptionstring / null是描述
requiredboolean是是否必填
uniqueboolean是是否唯一
indexedboolean是是否索引
type"link"是类型
optionsobject是json:schema;link:linked_table_id 与 multiple

NewField

"string" / "integer" / "number" / "boolean" / "datetime"

字段类型必填说明
namestring是字段名;只保留 id;新字段不能以下划线开头。created_at、updated_at、version 可作为用户字段名;已有下划线字段照常使用,且优先于同名元数据。; ^(?!id$)[a-z][a-z0-9_]{0,62}$
descriptionstring否描述
requiredboolean否是否必填
uniqueboolean否是否唯一
indexedboolean否是否索引
type"string" / "integer" / "number" / "boolean" / "datetime"是类型
optionsobject否json:schema;link:linked_table_id 与 multiple
defaultJSON否省略插入值时的默认值;datetime 的 now() 在写入时取服务器时间,字段定义仍读回 now()。string/json 中为字面量。显式 null 不使用默认值。

"json"

字段类型必填说明
namestring是字段名;只保留 id;新字段不能以下划线开头。created_at、updated_at、version 可作为用户字段名;已有下划线字段照常使用,且优先于同名元数据。; ^(?!id$)[a-z][a-z0-9_]{0,62}$
descriptionstring否描述
requiredboolean否是否必填
uniqueboolean否是否唯一
indexedboolean否是否索引
type"json"是类型
optionsobject是json:schema;link:linked_table_id 与 multiple
defaultJSON否省略插入值时的默认值;datetime 的 now() 在写入时取服务器时间,字段定义仍读回 now()。string/json 中为字面量。显式 null 不使用默认值。

"link"

字段类型必填说明
namestring是字段名;只保留 id;新字段不能以下划线开头。created_at、updated_at、version 可作为用户字段名;已有下划线字段照常使用,且优先于同名元数据。; ^(?!id$)[a-z][a-z0-9_]{0,62}$
descriptionstring否描述
requiredboolean否是否必填
uniqueboolean否是否唯一
indexedboolean否是否索引
type"link"是类型
optionsobject是json:schema;link:linked_table_id 与 multiple

事件

指南 →

基础地址与鉴权

事件记录库生命周期与表、字段结构变化,不记录行读写。

默认按 seq 升序;只给 before_seq 时默认按 desc(最新在前)。next_cursor 是不透明的字符串游标,原样传回:asc 时传给 after_seq,desc 时传给 before_seq。两个游标同时提供,或 before_seq 与 order=asc 同时提供,返回 400 INVALID_PARAMS。删除中的库仍可读取事件。

next_cursor 是不透明的字符串游标,原样传回,不要对它做运算;为 null 表示没有后续页。下方响应为省略 order 的升序实测结果。倒序翻页按以下请求使用;该扩展的线上响应将在服务更新后补充。

# 最新一页
curl "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/events?order=desc&limit=10" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

# 把 NEXT_CURSOR 设为上一页返回的 next_cursor
curl "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/events?order=desc&before_seq=${NEXT_CURSOR}&limit=10" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

读取事件

GET /database/v1/databases/{database_id}/events

参数位置说明
database_idpath库 ID。
after_seqqueryorder=asc 时,只取 seq 大于该值的事件;不可同时提供 before_seq。
limitquery最多返回的条数。 (default: 50) (1–200)
orderqueryasc 按 seq 升序,desc 为最新在前。默认 asc;只给 before_seq 时默认 desc。
before_seqquery只取 seq 小于该值的事件,最新在前;省略 order 时按 desc。不可同时提供 after_seq 或 order=asc。

返回: Page + object.

响应

HTTP 200

Success

application/json

名称类型说明
dataarray<object>Events on this page in the requested order (ascending seq by default, newest first with before_seq or order=desc).
data[].seqintegerPosition of the event in the database's event log; starts at 1 and strictly increases. Use it as after_seq or before_seq to page.
data[].idstringUnique identifier of this event record.
data[].typestringWhat happened: a lifecycle transition of the database, or a schema change to a table or field.
data[].processed_atstringTime the event was recorded, as an RFC 3339 UTC timestamp.
data[].database_idstringId (db_…) of the database the event belongs to.
data[].table_idstringId (tbl_…) of the affected table; present only for table and field events.
data[].field_idstringId (fld_…) of the affected field; present only for field events.
next_cursorstring | nullOpaque cursor for the next page, or null when there are no more items. Databases list: pass it as cursor. Events list: pass it as after_seq (order asc) or before_seq (order desc).
curl -X GET "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/events?after_seq=0&limit=10" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应示例 — HTTP 200

{
  "data": [
    {
      "seq": 1,
      "id": "7390d75e-216c-4799-891e-c043bac8bce5",
      "type": "database.status_provisioning",
      "processed_at": "2026-10-11T17:41:41.339Z",
      "database_id": "db_d6f0d743d5a645e8"
    },
    {
      "seq": 2,
      "id": "39db0ef4-99b4-4846-9d50-9998e25cf48f",
      "type": "database.status_active",
      "processed_at": "2026-10-11T17:41:41.339Z",
      "database_id": "db_d6f0d743d5a645e8"
    },
    {
      "seq": 3,
      "id": "d295651d-5e83-4b42-bcd3-c979fb71f375",
      "type": "table.created",
      "processed_at": "2026-10-11T17:41:44.246Z",
      "database_id": "db_d6f0d743d5a645e8",
      "table_id": "tbl_2b3431c772754599"
    },
    {
      "seq": 4,
      "id": "eb255753-3dd7-4eae-8861-d53408bfcaf4",
      "type": "table.updated",
      "processed_at": "2026-10-11T17:41:45.127Z",
      "database_id": "db_d6f0d743d5a645e8",
      "table_id": "tbl_2b3431c772754599"
    },
    {
      "seq": 5,
      "id": "99c86e22-0629-4391-85e5-d7b8b31de833",
      "type": "field.added",
      "processed_at": "2026-10-11T17:41:45.420Z",
      "database_id": "db_d6f0d743d5a645e8",
      "table_id": "tbl_2b3431c772754599",
      "field_id": "fld_4c3e63869e35458c"
    },
    {
      "seq": 6,
      "id": "a9b85950-363d-4ab3-8c85-6228eec3d099",
      "type": "field.updated",
      "processed_at": "2026-10-11T17:41:46.276Z",
      "database_id": "db_d6f0d743d5a645e8",
      "table_id": "tbl_2b3431c772754599",
      "field_id": "fld_4c3e63869e35458c"
    },
    {
      "seq": 7,
      "id": "73ca124f-6cbb-4a43-8a37-4ff50a211dd5",
      "type": "field.deleted",
      "processed_at": "2026-10-11T17:41:47.136Z",
      "database_id": "db_d6f0d743d5a645e8",
      "table_id": "tbl_2b3431c772754599",
      "field_id": "fld_4c3e63869e35458c"
    }
  ],
  "next_cursor": null
}

DatabaseEvent

字段类型必填说明
seqinteger是库内递增序号
idstring是资源 ID
type"database.status_provisioning" / "database.status_active" / "database.status_deleting" / "database.status_deleted" / "database.status_failed" / "database.restored" / "table.created" / "table.updated" / "table.deleted" / "field.added" / "field.updated" / "field.deleted"是类型
processed_atdate-time是事件时间
database_idstring是库 ID
table_idstring否相关表 ID(可选)
field_idstring否相关字段 ID(可选)

读写行

指南 →

/database/v1/databases/{database_id}/rest/{table}

与同一库的其它入口读写相同的行;错误使用 PostgREST code。

支持矩阵与初始化

完整参数、响应头与返回状态

一次批量 POST 最多插入 500 行,单次请求是原子的:任何一行失败,整批回滚。跨请求没有事务;需要一起成功的行应放在一次批量 POST 中。有关联依赖时先查后插,并处理并发变化导致的关联错误。

同一批次按所有行的键的并集补齐缺失值为 null(PostgREST 行为)。发送 Prefer: missing=default 可改用字段默认值;显式 null 仍为 null,没有默认值的必填字段仍必须提供。默认 return=minimal 返回 201、body 为空;发送 Prefer: return=representation 才返回行。

查询行

GET /database/v1/databases/{database_id}/rest/{table}

curl -X GET "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/rest/tasks?select=*&order=title.asc&limit=10" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

响应

HTTP 200

Success; write bodies require Prefer: return=representation

application/json

名称类型说明
[].idstringRow identifier of 1–64 characters from A-Z a-z 0-9 _ -. Generated by the service unless the insert supplied one; it cannot be changed by updates.

application/vnd.pgrst.object+json

名称类型说明
idstringRow identifier of 1–64 characters from A-Z a-z 0-9 _ -. Generated by the service unless the insert supplied one; it cannot be changed by updates.

HTTP 206

Partial range with requested count

application/json

名称类型说明
[].idstringRow identifier of 1–64 characters from A-Z a-z 0-9 _ -. Generated by the service unless the insert supplied one; it cannot be changed by updates.

application/vnd.pgrst.object+json

名称类型说明
idstringRow identifier of 1–64 characters from A-Z a-z 0-9 _ -. Generated by the service unless the insert supplied one; it cannot be changed by updates.

响应示例 — HTTP 200

响应头值
content-range0-0/*
etagW/"5.1"
range-unititems
[
  {
    "id": "rec_3e85a292099340e3",
    "version": 1,
    "created_at": "2026-10-11T17:41:47.896Z",
    "updated_at": "2026-10-11T17:41:47.896Z",
    "title": "Write a summary",
    "done": false
  }
]

统计行

HEAD /database/v1/databases/{database_id}/rest/{table}

curl --head "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/rest/tasks?select=*" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'prefer: count=exact'

响应

HTTP 200

Success; write bodies require Prefer: return=representation

未声明响应体。

HTTP 206

Partial range with requested count

未声明响应体。

响应示例 — HTTP 200

响应头值
content-range0-0/1
preference-appliedcount=exact
etagW/"5.1"
range-unititems

无响应正文。

插入行

POST /database/v1/databases/{database_id}/rest/{table}

curl -X POST "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/rest/tasks" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'prefer: return=representation' \
  -H "Content-Type: application/json" \
  -d '{"title":"Write a summary","done":false}'

响应

HTTP 201

Success (201). With the default return=minimal the body is empty; Prefer: return=representation returns rows.

application/json

名称类型说明
[].idstringRow identifier of 1–64 characters from A-Z a-z 0-9 _ -. Generated by the service unless the insert supplied one; it cannot be changed by updates.

application/vnd.pgrst.object+json

名称类型说明
idstringRow identifier of 1–64 characters from A-Z a-z 0-9 _ -. Generated by the service unless the insert supplied one; it cannot be changed by updates.

响应示例 — HTTP 201

响应头值
content-range0-0/*
preference-appliedreturn=representation
range-unititems
[
  {
    "id": "rec_3e85a292099340e3",
    "version": 1,
    "created_at": "2026-10-11T17:41:47.896Z",
    "updated_at": "2026-10-11T17:41:47.896Z",
    "title": "Write a summary",
    "done": false
  }
]

更新行

PATCH /database/v1/databases/{database_id}/rest/{table}

curl -X PATCH "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/rest/tasks?title=eq.Write%20a%20summary" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'prefer: return=representation' \
  -H "Content-Type: application/json" \
  -d '{"done":true}'

响应

HTTP 200

Success; write bodies require Prefer: return=representation

application/json

名称类型说明
[].idstringRow identifier of 1–64 characters from A-Z a-z 0-9 _ -. Generated by the service unless the insert supplied one; it cannot be changed by updates.

application/vnd.pgrst.object+json

名称类型说明
idstringRow identifier of 1–64 characters from A-Z a-z 0-9 _ -. Generated by the service unless the insert supplied one; it cannot be changed by updates.

HTTP 204

Success without a body

未声明响应体。

响应示例 — HTTP 200

响应头值
content-range0-0/*
preference-appliedreturn=representation
range-unititems
[
  {
    "id": "rec_3e85a292099340e3",
    "version": 2,
    "created_at": "2026-10-11T17:41:47.896Z",
    "updated_at": "2026-10-11T17:41:48.802Z",
    "title": "Write a summary",
    "done": true
  }
]

合并行

POST /database/v1/databases/{database_id}/rest/{table}

curl -X POST "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/rest/tasks?on_conflict=title" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'prefer: resolution=merge-duplicates,return=representation' \
  -H "Content-Type: application/json" \
  -d '{"title":"Write a summary","done":true}'

响应

HTTP 201

Success (201). With the default return=minimal the body is empty; Prefer: return=representation returns rows.

application/json

名称类型说明
[].idstringRow identifier of 1–64 characters from A-Z a-z 0-9 _ -. Generated by the service unless the insert supplied one; it cannot be changed by updates.

application/vnd.pgrst.object+json

名称类型说明
idstringRow identifier of 1–64 characters from A-Z a-z 0-9 _ -. Generated by the service unless the insert supplied one; it cannot be changed by updates.

响应示例 — HTTP 201

响应头值
content-range0-0/*
preference-appliedresolution=merge-duplicates, return=representation
range-unititems
[
  {
    "id": "rec_3e85a292099340e3",
    "version": 3,
    "created_at": "2026-10-11T17:41:47.896Z",
    "updated_at": "2026-10-11T17:41:49.076Z",
    "title": "Write a summary",
    "done": true
  }
]

删除行

DELETE /database/v1/databases/{database_id}/rest/{table}

curl -X DELETE "https://api.deepraxis.ai/database/v1/databases/${DATABASE_ID}/rest/tasks?title=eq.Write%20a%20summary" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H 'prefer: return=representation'

响应

HTTP 200

Success; write bodies require Prefer: return=representation

application/json

名称类型说明
[].idstringRow identifier of 1–64 characters from A-Z a-z 0-9 _ -. Generated by the service unless the insert supplied one; it cannot be changed by updates.

application/vnd.pgrst.object+json

名称类型说明
idstringRow identifier of 1–64 characters from A-Z a-z 0-9 _ -. Generated by the service unless the insert supplied one; it cannot be changed by updates.

HTTP 204

Success without a body

未声明响应体。

响应示例 — HTTP 200

响应头值
content-range0-0/*
preference-appliedreturn=representation
range-unititems
[
  {
    "id": "rec_3e85a292099340e3",
    "version": 3,
    "created_at": "2026-10-11T17:41:47.896Z",
    "updated_at": "2026-10-11T17:41:49.076Z",
    "title": "Write a summary",
    "done": true
  }
]

Row

默认投影、select=、return=representation 与 RPC 行对象只返回 id 和用户字段。系统元数据须显式点名,例如 select=,_version,_created_at,_updated_at;* 不展开它们。可用 _version=eq.3 过滤、order=_created_at.desc 排序,但不可写。未指定 order 时仍按内部创建时间、id 排序。没有同名用户字段时,旧名 created_at/updated_at/version 用于过滤或排序返回 400,details 为 use _created_at(或对应名字),hint 为 system metadata moved to underscore columns。已有下划线用户字段优先,同名系统元数据在该表上不可访问。上方历史响应样例采集于此规则调整前,仍可能包含旧元数据列;当前行形状以本节为准。

字段类型必填说明
idstring是资源 ID; ^[A-Za-z0-9_-]{1,64}$

错误码

管理端点返回领域码;两个表端点返回 PostgREST code。HTTP 状态与重试属性如下。

领域码HTTPPostgREST code可重试
SINGULAR_MISMATCH406PGRST116否
AMBIGUOUS_EMBED300PGRST201否
EMBED_NOT_FOUND400PGRST200否
INVALID_PREFERENCE400PGRST122否
QUERY_CANCELED50057014否
RANGE_NOT_SATISFIABLE416PGRST103否
NOT_ACCEPTABLE406PGRST107否
OPERATOR_TYPE_MISMATCH40042883否
DATABASE_NOT_FOUND404PGRST125否
TABLE_NOT_FOUND404PGRST205否
FIELD_NOT_FOUND40042703否
VALIDATION_FAILED40023514否
UNIQUE_VIOLATION40923505否
REFERENCE_RESTRICT40923503否
FIELD_TYPE_IMMUTABLE400—否
LIMIT_EXCEEDED40054000否
UNSUPPORTED400PGRST127否
INVALID_PARAMS400PGRST100否
DATABASE_INVALID_STATE409—否
CAPACITY503—是
NOT_IMPLEMENTED501PGRST127否

可重试不表示重复原请求一定成功。例如 57014 应先缩小查询范围或调整过滤条件,再重试。

管理端点错误体

响应示例 — HTTP 400

{
  "code": "FIELD_TYPE_IMMUTABLE",
  "message": "field type is immutable",
  "details": null,
  "hint": null
}

表端点错误体

响应示例 — HTTP 400

{
  "code": "PGRST127",
  "message": "operator fts is not supported",
  "details": null,
  "hint": null
}

code、message、details、hint 四个字段始终存在;details 与 hint 可以为 null。

未开放服务错误体

响应示例 — HTTP 501

响应头值
x-should-retryfalse
{
  "code": "not_implemented",
  "message": "auth is not provided by praxis-database"
}

这五个服务直接返回 not_implemented;它与错误表中的领域码 NOT_IMPLEMENTED 不同。

按错误细节修正请求

保留字段名只有 id;新字段名不能以 _ 开头,这个前缀留给系统元数据。created_at、updated_at、version 可用作普通字段名。datetime 字段可用 "now()" 作为默认值。

details 指出字段或 JSON 路径及实际收到的值,批量校验还包含从 0 开始的行号。值最多显示 80 个字符,不回显整行。hint 给出修正方式,没有建议时为 null。下面是省略第 2 行必填 title 的错误示例:

{
  "code": "23514",
  "message": "row validation failed",
  "details": "row 1: title: required value (got null)",
  "hint": "Rows in one insert are filled to the union of their keys with null (PostgREST behavior). Send every key in every row, or send Prefer: missing=default to use field defaults."
}

唯一冲突返回 409,例如:

{
  "code": "23505",
  "message": "unique constraint violated",
  "details": "Key (email)=(a@b.c) already exists.",
  "hint": null
}

Vault API

用 API Key 作为 Bearer 凭据,通过以下地址管理库与 Secret。Secret 的值只写,任何接口都不会返回。

https://api.deepraxis.ai/vault/v1

指南 →

资源路径
库/vault/v1/vaults
Secret/vault/v1/vaults/{vault_id}/secrets
模板/vault/v1/templates
一键授权/vault/v1/authorizations

Secret 可以用名字或 vsec_ 开头的 ID 寻址。列表用 cursor 与 limit 翻页(limit 默认 50,最大 200),返回的 next_cursor 为 null 表示没有后续页。

同一批库也可以通过 Claude 托管智能体的凭据库接口访问:Claude 托管智能体

错误码

库

创建和管理库,检查可用状态,并查询不含 Secret 值的审计事件。

指南 →

基础地址与鉴权

审计事件按时间倒序列出,可用 secret 按名称或 ID 过滤;未知 Secret 返回空列表。limit 默认 50、最大 200;超限或无效 cursor 返回 400 INVALID_PARAMS。事件没有按天自动过期的保留期;归档保留事件,删除库或 Secret 会清除其历史事件,仅保留删除记录。

列出库

GET /vault/v1/vaults

参数位置说明
cursorquery上一页返回的 next_cursor。
limitquery每页条数。 (默认: 50) (1–200)
include_archivedquery是否包含已归档的条目。 (默认: false)

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
dataVault[]是条目数组
data[].idstring是对象标识符
data[].type"vault"是对象类型
data[].display_namestring是显示名称,1–255 个字符
data[].metadataobject是自定义标签最多 16 对,键最长 64 字符,值最长 512 字符
data[].status"active" / "archived"是状态
data[].secret_countinteger是有效 Secret 数
data[].needs_reauthorization_countinteger是续期失败、需要重新授权的 OAuth Secret 数
data[].created_atdate-time是创建时间
data[].updated_atdate-time是更新时间
data[].archived_atdate-time / null是归档时间;未归档时为 null
next_cursorstring / null是下一页游标;没有后续时为 null

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
INVALID_PARAMS400字段、名称、域名、metadata、分页或回跳地址无效;修正请求validation_failurenone否
curl "https://api.deepraxis.ai/vault/v1/vaults" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

创建库

POST /vault/v1/vaults

请求体

字段类型 / 枚举必填说明
display_namestring是显示名称,1–255 个字符
metadataobject否自定义标签最多 16 对,键最长 64 字符,值最长 512 字符

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault"是对象类型
display_namestring是显示名称,1–255 个字符
metadataobject是自定义标签最多 16 对,键最长 64 字符,值最长 512 字符
status"active" / "archived"是状态
secret_countinteger是有效 Secret 数
needs_reauthorization_countinteger是续期失败、需要重新授权的 OAuth Secret 数
created_atdate-time是创建时间
updated_atdate-time是更新时间
archived_atdate-time / null是归档时间;未归档时为 null

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
INVALID_PARAMS400字段、名称、域名、metadata、分页或回跳地址无效;修正请求validation_failurenone否
curl -X POST "https://api.deepraxis.ai/vault/v1/vaults" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"display_name":"Agent credentials"}'

检查库

POST /vault/v1/vaults:check

请求体

字段类型 / 枚举必填说明
vault_idsstring[]是要检查的库 ID

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
dataobject[]是条目数组
data[].vault_idstring是库 ID
data[].status"ok" / "not_found" / "archived"是状态

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
INVALID_PARAMS400字段、名称、域名、metadata、分页或回跳地址无效;修正请求validation_failurenone否
curl -X POST "https://api.deepraxis.ai/vault/v1/vaults:check" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"vault_ids\":[\"${VAULT_ID}\"]}"

读取库

GET /vault/v1/vaults/{vault_id}

参数位置说明
vault_idpath库 ID。

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault"是对象类型
display_namestring是显示名称,1–255 个字符
metadataobject是自定义标签最多 16 对,键最长 64 字符,值最长 512 字符
status"active" / "archived"是状态
secret_countinteger是有效 Secret 数
needs_reauthorization_countinteger是续期失败、需要重新授权的 OAuth Secret 数
created_atdate-time是创建时间
updated_atdate-time是更新时间
archived_atdate-time / null是归档时间;未归档时为 null

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
curl "https://api.deepraxis.ai/vault/v1/vaults/${VAULT_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

更新库

POST /vault/v1/vaults/{vault_id}

参数位置说明
vault_idpath库 ID。

请求体

字段类型 / 枚举必填说明
display_namestring否显示名称,1–255 个字符
metadataobject否按键合并:字符串写入,null 删除,省略的键保留;自定义标签最多 16 对

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault"是对象类型
display_namestring是显示名称,1–255 个字符
metadataobject是自定义标签最多 16 对,键最长 64 字符,值最长 512 字符
status"active" / "archived"是状态
secret_countinteger是有效 Secret 数
needs_reauthorization_countinteger是续期失败、需要重新授权的 OAuth Secret 数
created_atdate-time是创建时间
updated_atdate-time是更新时间
archived_atdate-time / null是归档时间;未归档时为 null

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
VAULT_INVALID_STATE409向已归档的库或 Secret 写入;改用有效资源validation_failurenone否
INVALID_PARAMS400字段、名称、域名、metadata、分页或回跳地址无效;修正请求validation_failurenone否
curl -X POST "https://api.deepraxis.ai/vault/v1/vaults/${VAULT_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"metadata":{"team":"growth"}}'

删除库

DELETE /vault/v1/vaults/{vault_id}

参数位置说明
vault_idpath库 ID。

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault_deleted"是对象类型

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
curl -X DELETE "https://api.deepraxis.ai/vault/v1/vaults/${VAULT_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

归档库

POST /vault/v1/vaults/{vault_id}/archive

参数位置说明
vault_idpath库 ID。

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault"是对象类型
display_namestring是显示名称,1–255 个字符
metadataobject是自定义标签最多 16 对,键最长 64 字符,值最长 512 字符
status"active" / "archived"是状态
secret_countinteger是有效 Secret 数
needs_reauthorization_countinteger是续期失败、需要重新授权的 OAuth Secret 数
created_atdate-time是创建时间
updated_atdate-time是更新时间
archived_atdate-time / null是归档时间;未归档时为 null

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
curl -X POST "https://api.deepraxis.ai/vault/v1/vaults/${VAULT_ID}/archive" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

查看事件

GET /vault/v1/vaults/{vault_id}/events

参数位置说明
vault_idpath库 ID。
secretquerySecret 名称或 vsec_ 开头的 ID。
cursorquery上一页返回的 next_cursor。
limitquery每页条数。 (默认: 50) (1–200)

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
dataVaultEvent[]是条目数组
data[].iduuid是对象标识符
data[].type"vault.created" / "vault.updated" / "vault.archived" / "vault.deleted" / "vault_secret.created" / "vault_secret.updated" / "vault_secret.archived" / "vault_secret.deleted" / "vault_secret.used" / "vault_secret.refreshed" / "vault_secret.refresh_failed" / "vault_authorization.completed" / "vault_authorization.failed" / "vault_authorization.expired"是对象类型
data[].secret_idstring / null是关联的 Secret ID;未关联时为 null
data[].secret_namestring / null是关联的 Secret 名称
data[].atdate-time是事件或错误发生时间
data[].detailobject / null是事件详情,不含 Secret 值;更新事件的 changed 列出变更字段
data[].detail.changedstring[]否本次更新的字段名,例如 value、allowed_hosts
next_cursorstring / null是下一页游标;没有后续时为 null

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
INVALID_PARAMS400字段、名称、域名、metadata、分页或回跳地址无效;修正请求validation_failurenone否
curl "https://api.deepraxis.ai/vault/v1/vaults/${VAULT_ID}/events" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

Vault

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault"是对象类型
display_namestring是显示名称,1–255 个字符
metadataobject是自定义标签最多 16 对,键最长 64 字符,值最长 512 字符
status"active" / "archived"是状态
secret_countinteger是有效 Secret 数
needs_reauthorization_countinteger是续期失败、需要重新授权的 OAuth Secret 数
created_atdate-time是创建时间
updated_atdate-time是更新时间
archived_atdate-time / null是归档时间;未归档时为 null

VaultPage

字段类型 / 枚举必填说明
dataVault[]是条目数组
data[].idstring是对象标识符
data[].type"vault"是对象类型
data[].display_namestring是显示名称,1–255 个字符
data[].metadataobject是自定义标签最多 16 对,键最长 64 字符,值最长 512 字符
data[].status"active" / "archived"是状态
data[].secret_countinteger是有效 Secret 数
data[].needs_reauthorization_countinteger是续期失败、需要重新授权的 OAuth Secret 数
data[].created_atdate-time是创建时间
data[].updated_atdate-time是更新时间
data[].archived_atdate-time / null是归档时间;未归档时为 null
next_cursorstring / null是下一页游标;没有后续时为 null

VaultEvent

字段类型 / 枚举必填说明
iduuid是对象标识符
type"vault.created" / "vault.updated" / "vault.archived" / "vault.deleted" / "vault_secret.created" / "vault_secret.updated" / "vault_secret.archived" / "vault_secret.deleted" / "vault_secret.used" / "vault_secret.refreshed" / "vault_secret.refresh_failed" / "vault_authorization.completed" / "vault_authorization.failed" / "vault_authorization.expired"是对象类型
secret_idstring / null是关联的 Secret ID;未关联时为 null
secret_namestring / null是关联的 Secret 名称
atdate-time是事件或错误发生时间
detailobject / null是事件详情,不含 Secret 值;更新事件的 changed 列出变更字段
detail.changedstring[]否本次更新的字段名,例如 value、allowed_hosts

Secret

添加、导入和更新 Secret;值只写,校验与续期仅用于 OAuth Secret。

指南 →

基础地址与鉴权

导入同名 Secret 只替换值;只有该行自己的 allowed_hosts 才能改变原域名,顶层默认域名不覆盖已有域名。新建行优先使用该行域名,否则使用顶层默认域名。逐行失败在 HTTP 200 的 failed 中返回(包括 SECRET_TOO_LARGE、VAULT_LIMIT_EXCEEDED、INVALID_PARAMS),其它行仍然写入。用非法名称查找 Secret 返回 404 SECRET_NOT_FOUND。

列出 Secret

GET /vault/v1/vaults/{vault_id}/secrets

参数位置说明
vault_idpath库 ID。
cursorquery上一页返回的 next_cursor。
limitquery每页条数。 (默认: 50) (1–200)
include_archivedquery是否包含已归档的条目。 (默认: false)

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
dataSecret[]是条目数组
data[].idstring是对象标识符
data[].type"vault_secret"是对象类型
data[].vault_idstring是库 ID
data[].namestring是名称,库内唯一且不可改;1–128 个大写字母、数字或下划线,以字母或下划线开头
data[].kind"static" / "oauth"是static:你填写的值;oauth:授权得到、由平台续期
data[].allowed_hostsstring[]是1–16 个域名、公网 IPv4 或 .example.com;不匹配根域名。拒绝 IPv6、单标签主机、localhost、.internal、平台域名及回环/链路本地/私网/CGNAT IPv4;规范化并去重
data[].descriptionstring / null是备注;更新时 null 清除,省略则保留
data[].metadataobject是自定义标签最多 16 对;source、template 为系统保留键,不占这 16 对且不能由调用方写入
data[].status"active" / "refreshing" / "refresh_failed" / "archived"是状态
data[].oauthSecretOAuthSummary / null是OAuth 摘要;kind 为 static 时为 null
data[].oauth.expires_atdate-time / null是过期时间
data[].oauth.last_refreshed_atdate-time / null是最近一次续期时间
data[].oauth.next_refresh_atdate-time / null是下次计划续期时间
data[].oauth.scopestring / null是授权范围
data[].oauth.last_errorobject / null是最近一次续期失败
data[].oauth.last_error.codestring是稳定的错误码
data[].oauth.last_error.messagestring是可读的错误说明
data[].oauth.last_error.atdate-time是事件或错误发生时间
data[].versioninteger是值每次变化时递增
data[].last_used_atdate-time / null是最近一次被使用的时间
data[].created_atdate-time是创建时间
data[].updated_atdate-time是更新时间
data[].archived_atdate-time / null是归档时间;未归档时为 null
next_cursorstring / null是下一页游标;没有后续时为 null

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
INVALID_PARAMS400字段、名称、域名、metadata、分页或回跳地址无效;修正请求validation_failurenone否
curl "https://api.deepraxis.ai/vault/v1/vaults/${VAULT_ID}/secrets" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

添加 Secret

POST /vault/v1/vaults/{vault_id}/secrets

参数位置说明
vault_idpath库 ID。

请求体

字段类型 / 枚举必填说明
namestring是名称,库内唯一且不可改;1–128 个大写字母、数字或下划线,以字母或下划线开头
valuestring是Secret 的值,只写,不会返回;最大 16 KiB
allowed_hostsstring[]是1–16 个域名、公网 IPv4 或 .example.com;不匹配根域名。拒绝 IPv6、单标签主机、localhost、.internal、平台域名及回环/链路本地/私网/CGNAT IPv4;规范化并去重
descriptionstring / null否备注;更新时 null 清除,省略则保留
metadataobject否自定义标签最多 16 对;source、template 为系统保留键,不占这 16 对且不能由调用方写入
template_id"github" / "openai" / "anthropic" / "stripe"否仅支持 static 模板 ID;记录为 metadata.template
kind"static"否只能为 static;OAuth Secret 通过一键授权创建

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault_secret"是对象类型
vault_idstring是库 ID
namestring是名称,库内唯一且不可改;1–128 个大写字母、数字或下划线,以字母或下划线开头
kind"static" / "oauth"是static:你填写的值;oauth:授权得到、由平台续期
allowed_hostsstring[]是1–16 个域名、公网 IPv4 或 .example.com;不匹配根域名。拒绝 IPv6、单标签主机、localhost、.internal、平台域名及回环/链路本地/私网/CGNAT IPv4;规范化并去重
descriptionstring / null是备注;更新时 null 清除,省略则保留
metadataobject是自定义标签最多 16 对;source、template 为系统保留键,不占这 16 对且不能由调用方写入
status"active" / "refreshing" / "refresh_failed" / "archived"是状态
oauthSecretOAuthSummary / null是OAuth 摘要;kind 为 static 时为 null
oauth.expires_atdate-time / null是过期时间
oauth.last_refreshed_atdate-time / null是最近一次续期时间
oauth.next_refresh_atdate-time / null是下次计划续期时间
oauth.scopestring / null是授权范围
oauth.last_errorobject / null是最近一次续期失败
oauth.last_error.codestring是稳定的错误码
oauth.last_error.messagestring是可读的错误说明
oauth.last_error.atdate-time是事件或错误发生时间
versioninteger是值每次变化时递增
last_used_atdate-time / null是最近一次被使用的时间
created_atdate-time是创建时间
updated_atdate-time是更新时间
archived_atdate-time / null是归档时间;未归档时为 null

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
VAULT_INVALID_STATE409向已归档的库或 Secret 写入;改用有效资源validation_failurenone否
INVALID_PARAMS400字段、名称、域名、metadata、分页或回跳地址无效;修正请求validation_failurenone否
SECRET_CONFLICT409创建时名称已占用;更换名称或更新已有 Secretvalidation_failurenone否
VAULT_LIMIT_EXCEEDED400超过有效 Secret 数量上限;先清理不用的 Secretvalidation_failurenone否
SECRET_TOO_LARGE413值超过 16384 字节;缩小值后重试validation_failurenone否
curl -X POST "https://api.deepraxis.ai/vault/v1/vaults/${VAULT_ID}/secrets" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"GITHUB_TOKEN","value":"ghp_example","allowed_hosts":["api.github.com"]}'

批量导入

POST /vault/v1/vaults/{vault_id}/secrets:import

参数位置说明
vault_idpath库 ID。

请求体

字段类型 / 枚举必填说明
linesImportLine[]否逐行导入的 Secret
lines[].namestring是名称,库内唯一且不可改;1–128 个大写字母、数字或下划线,以字母或下划线开头
lines[].valuestring是Secret 的值,只写,不会返回;最大 16 KiB
lines[].allowed_hostsstring[]否新建时用本行域名或导入的默认域名;替换时仅本行显式 allowed_hosts 才会更新域名
dotenvstring否.env 格式的 KEY=VALUE 文本;与 lines 二选一
allowed_hostsstring[]否新建时用本行域名或导入的默认域名;替换时仅本行显式 allowed_hosts 才会更新域名

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
createdstring[]是新建的 Secret 名称
replacedstring[]是被替换的 Secret 名称
failedobject[]是失败的行
failed[].lineinteger是失败行号,从 1 开始
failed[].namestring / null是名称,库内唯一且不可改;1–128 个大写字母、数字或下划线,以字母或下划线开头
failed[].code"VAULT_NOT_FOUND" / "SECRET_NOT_FOUND" / "AUTHORIZATION_NOT_FOUND" / "SECRET_CONFLICT" / "VAULT_INVALID_STATE" / "VAULT_LIMIT_EXCEEDED" / "INVALID_PARAMS" / "SECRET_KIND_MISMATCH" / "VALIDATE_UNSUPPORTED" / "SECRET_TOO_LARGE" / "RATE_LIMITED" / "AUTHORIZATION_EXPIRED" / "OAUTH_DISCOVERY_FAILED" / "OAUTH_REGISTRATION_UNSUPPORTED" / "OAUTH_ISSUER_MISMATCH" / "OAUTH_STATE_INVALID" / "OAUTH_EXCHANGE_FAILED" / "NOT_IMPLEMENTED"是稳定的错误码
failed[].messagestring是可读的错误说明

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
VAULT_INVALID_STATE409向已归档的库或 Secret 写入;改用有效资源validation_failurenone否
INVALID_PARAMS400字段、名称、域名、metadata、分页或回跳地址无效;修正请求validation_failurenone否
curl -X POST "https://api.deepraxis.ai/vault/v1/vaults/${VAULT_ID}/secrets:import" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"dotenv":"OPENAI_API_KEY=sk-example\nLINEAR_API_KEY=lin_example","allowed_hosts":["api.openai.com","api.linear.app"]}'

读取 Secret

GET /vault/v1/vaults/{vault_id}/secrets/{secret}

参数位置说明
vault_idpath库 ID。
secretpathSecret 名称或 vsec_ 开头的 ID。

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault_secret"是对象类型
vault_idstring是库 ID
namestring是名称,库内唯一且不可改;1–128 个大写字母、数字或下划线,以字母或下划线开头
kind"static" / "oauth"是static:你填写的值;oauth:授权得到、由平台续期
allowed_hostsstring[]是1–16 个域名、公网 IPv4 或 .example.com;不匹配根域名。拒绝 IPv6、单标签主机、localhost、.internal、平台域名及回环/链路本地/私网/CGNAT IPv4;规范化并去重
descriptionstring / null是备注;更新时 null 清除,省略则保留
metadataobject是自定义标签最多 16 对;source、template 为系统保留键,不占这 16 对且不能由调用方写入
status"active" / "refreshing" / "refresh_failed" / "archived"是状态
oauthSecretOAuthSummary / null是OAuth 摘要;kind 为 static 时为 null
oauth.expires_atdate-time / null是过期时间
oauth.last_refreshed_atdate-time / null是最近一次续期时间
oauth.next_refresh_atdate-time / null是下次计划续期时间
oauth.scopestring / null是授权范围
oauth.last_errorobject / null是最近一次续期失败
oauth.last_error.codestring是稳定的错误码
oauth.last_error.messagestring是可读的错误说明
oauth.last_error.atdate-time是事件或错误发生时间
versioninteger是值每次变化时递增
last_used_atdate-time / null是最近一次被使用的时间
created_atdate-time是创建时间
updated_atdate-time是更新时间
archived_atdate-time / null是归档时间;未归档时为 null

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
SECRET_NOT_FOUND404Secret 不存在,包括用非法名称查找;检查名称或 IDvalidation_failurenone否
curl "https://api.deepraxis.ai/vault/v1/vaults/${VAULT_ID}/secrets/GITHUB_TOKEN" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

更新 Secret

POST /vault/v1/vaults/{vault_id}/secrets/{secret}

参数位置说明
vault_idpath库 ID。
secretpathSecret 名称或 vsec_ 开头的 ID。

请求体

字段类型 / 枚举必填说明
valuestring否Secret 的值,只写,不会返回;最大 16 KiB
allowed_hostsstring[]否1–16 个域名、公网 IPv4 或 .example.com;不匹配根域名。拒绝 IPv6、单标签主机、localhost、.internal、平台域名及回环/链路本地/私网/CGNAT IPv4;规范化并去重
descriptionstring / null否备注;更新时 null 清除,省略则保留
metadataobject否按键合并:字符串写入,null 删除,省略的键保留;source、template 为保留键

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault_secret"是对象类型
vault_idstring是库 ID
namestring是名称,库内唯一且不可改;1–128 个大写字母、数字或下划线,以字母或下划线开头
kind"static" / "oauth"是static:你填写的值;oauth:授权得到、由平台续期
allowed_hostsstring[]是1–16 个域名、公网 IPv4 或 .example.com;不匹配根域名。拒绝 IPv6、单标签主机、localhost、.internal、平台域名及回环/链路本地/私网/CGNAT IPv4;规范化并去重
descriptionstring / null是备注;更新时 null 清除,省略则保留
metadataobject是自定义标签最多 16 对;source、template 为系统保留键,不占这 16 对且不能由调用方写入
status"active" / "refreshing" / "refresh_failed" / "archived"是状态
oauthSecretOAuthSummary / null是OAuth 摘要;kind 为 static 时为 null
oauth.expires_atdate-time / null是过期时间
oauth.last_refreshed_atdate-time / null是最近一次续期时间
oauth.next_refresh_atdate-time / null是下次计划续期时间
oauth.scopestring / null是授权范围
oauth.last_errorobject / null是最近一次续期失败
oauth.last_error.codestring是稳定的错误码
oauth.last_error.messagestring是可读的错误说明
oauth.last_error.atdate-time是事件或错误发生时间
versioninteger是值每次变化时递增
last_used_atdate-time / null是最近一次被使用的时间
created_atdate-time是创建时间
updated_atdate-time是更新时间
archived_atdate-time / null是归档时间;未归档时为 null

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
SECRET_NOT_FOUND404Secret 不存在,包括用非法名称查找;检查名称或 IDvalidation_failurenone否
VAULT_INVALID_STATE409向已归档的库或 Secret 写入;改用有效资源validation_failurenone否
INVALID_PARAMS400字段、名称、域名、metadata、分页或回跳地址无效;修正请求validation_failurenone否
SECRET_TOO_LARGE413值超过 16384 字节;缩小值后重试validation_failurenone否
curl -X POST "https://api.deepraxis.ai/vault/v1/vaults/${VAULT_ID}/secrets/GITHUB_TOKEN" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"value":"ghp_rotated"}'

删除 Secret

DELETE /vault/v1/vaults/{vault_id}/secrets/{secret}

参数位置说明
vault_idpath库 ID。
secretpathSecret 名称或 vsec_ 开头的 ID。

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault_secret_deleted"是对象类型

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
SECRET_NOT_FOUND404Secret 不存在,包括用非法名称查找;检查名称或 IDvalidation_failurenone否
curl -X DELETE "https://api.deepraxis.ai/vault/v1/vaults/${VAULT_ID}/secrets/GITHUB_TOKEN" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

归档 Secret

POST /vault/v1/vaults/{vault_id}/secrets/{secret}/archive

参数位置说明
vault_idpath库 ID。
secretpathSecret 名称或 vsec_ 开头的 ID。

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault_secret"是对象类型
vault_idstring是库 ID
namestring是名称,库内唯一且不可改;1–128 个大写字母、数字或下划线,以字母或下划线开头
kind"static" / "oauth"是static:你填写的值;oauth:授权得到、由平台续期
allowed_hostsstring[]是1–16 个域名、公网 IPv4 或 .example.com;不匹配根域名。拒绝 IPv6、单标签主机、localhost、.internal、平台域名及回环/链路本地/私网/CGNAT IPv4;规范化并去重
descriptionstring / null是备注;更新时 null 清除,省略则保留
metadataobject是自定义标签最多 16 对;source、template 为系统保留键,不占这 16 对且不能由调用方写入
status"active" / "refreshing" / "refresh_failed" / "archived"是状态
oauthSecretOAuthSummary / null是OAuth 摘要;kind 为 static 时为 null
oauth.expires_atdate-time / null是过期时间
oauth.last_refreshed_atdate-time / null是最近一次续期时间
oauth.next_refresh_atdate-time / null是下次计划续期时间
oauth.scopestring / null是授权范围
oauth.last_errorobject / null是最近一次续期失败
oauth.last_error.codestring是稳定的错误码
oauth.last_error.messagestring是可读的错误说明
oauth.last_error.atdate-time是事件或错误发生时间
versioninteger是值每次变化时递增
last_used_atdate-time / null是最近一次被使用的时间
created_atdate-time是创建时间
updated_atdate-time是更新时间
archived_atdate-time / null是归档时间;未归档时为 null

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
SECRET_NOT_FOUND404Secret 不存在,包括用非法名称查找;检查名称或 IDvalidation_failurenone否
curl -X POST "https://api.deepraxis.ai/vault/v1/vaults/${VAULT_ID}/secrets/GITHUB_TOKEN/archive" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

校验 Secret

POST /vault/v1/vaults/{vault_id}/secrets/{secret}/validate

参数位置说明
vault_idpath库 ID。
secretpathSecret 名称或 vsec_ 开头的 ID。

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
type"vault_secret_validation"是对象类型
secret_idstring是关联的 Secret ID;未关联时为 null
vault_idstring是库 ID
validated_atdate-time是校验时间
has_refresh_tokenboolean是是否保存了刷新令牌
status"valid" / "invalid" / "unknown"是状态
probeobject是探测请求
probe.method"GET"是探测方式,当前为 GET
probe.http_responseHttpCapture / null是HTTP 响应摘要;未收到响应时为 null
probe.http_response.status_codeinteger是HTTP 状态码
probe.http_response.content_typestring / null是响应内容类型,或 null
probe.http_response.bodystring是已脱敏的响应正文
probe.http_response.body_truncatedboolean是正文是否被截断
refreshobject是续期结果
refresh.status"succeeded" / "failed" / "connect_error" / "no_refresh_token" / "skipped"是状态
refresh.http_responseHttpCapture / null是HTTP 响应摘要;未收到响应时为 null
refresh.http_response.status_codeinteger是HTTP 状态码
refresh.http_response.content_typestring / null是响应内容类型,或 null
refresh.http_response.bodystring是已脱敏的响应正文
refresh.http_response.body_truncatedboolean是正文是否被截断

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
SECRET_NOT_FOUND404Secret 不存在,包括用非法名称查找;检查名称或 IDvalidation_failurenone否
VALIDATE_UNSUPPORTED400对 static Secret 校验;校验仅支持 OAuth Secretvalidation_failurenone否
RATE_LIMITED429一分钟内超过授权或校验额度;等待下一窗口rate_limitwait_then_retry是

仅适用于 OAuth Secret。先完成一键授权,并将返回的 secret_id 设为 OAUTH_SECRET_ID;不要使用 static Secret。

curl -X POST "https://api.deepraxis.ai/vault/v1/vaults/${VAULT_ID}/secrets/${OAUTH_SECRET_ID}/validate" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

续期 Secret

POST /vault/v1/vaults/{vault_id}/secrets/{secret}/refresh

参数位置说明
vault_idpath库 ID。
secretpathSecret 名称或 vsec_ 开头的 ID。

请求体

字段类型 / 枚举必填说明
reason"unauthorized"否触发续期的原因

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault_secret"是对象类型
vault_idstring是库 ID
namestring是名称,库内唯一且不可改;1–128 个大写字母、数字或下划线,以字母或下划线开头
kind"static" / "oauth"是static:你填写的值;oauth:授权得到、由平台续期
allowed_hostsstring[]是1–16 个域名、公网 IPv4 或 .example.com;不匹配根域名。拒绝 IPv6、单标签主机、localhost、.internal、平台域名及回环/链路本地/私网/CGNAT IPv4;规范化并去重
descriptionstring / null是备注;更新时 null 清除,省略则保留
metadataobject是自定义标签最多 16 对;source、template 为系统保留键,不占这 16 对且不能由调用方写入
status"active" / "refreshing" / "refresh_failed" / "archived"是状态
oauthSecretOAuthSummary / null是OAuth 摘要;kind 为 static 时为 null
oauth.expires_atdate-time / null是过期时间
oauth.last_refreshed_atdate-time / null是最近一次续期时间
oauth.next_refresh_atdate-time / null是下次计划续期时间
oauth.scopestring / null是授权范围
oauth.last_errorobject / null是最近一次续期失败
oauth.last_error.codestring是稳定的错误码
oauth.last_error.messagestring是可读的错误说明
oauth.last_error.atdate-time是事件或错误发生时间
versioninteger是值每次变化时递增
last_used_atdate-time / null是最近一次被使用的时间
created_atdate-time是创建时间
updated_atdate-time是更新时间
archived_atdate-time / null是归档时间;未归档时为 null

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
SECRET_NOT_FOUND404Secret 不存在,包括用非法名称查找;检查名称或 IDvalidation_failurenone否
VAULT_INVALID_STATE409向已归档的库或 Secret 写入;改用有效资源validation_failurenone否
SECRET_KIND_MISMATCH400对 static Secret 续期或执行不匹配种类的操作;使用 OAuth Secretvalidation_failurenone否
INVALID_PARAMS400字段、名称、域名、metadata、分页或回跳地址无效;修正请求validation_failurenone否

仅适用于 OAuth Secret。先完成一键授权,并将返回的 secret_id 设为 OAUTH_SECRET_ID;不要使用 static Secret。

curl -X POST "https://api.deepraxis.ai/vault/v1/vaults/${VAULT_ID}/secrets/${OAUTH_SECRET_ID}/refresh" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason":"unauthorized"}'

Secret

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault_secret"是对象类型
vault_idstring是库 ID
namestring是名称,库内唯一且不可改;1–128 个大写字母、数字或下划线,以字母或下划线开头
kind"static" / "oauth"是static:你填写的值;oauth:授权得到、由平台续期
allowed_hostsstring[]是1–16 个域名、公网 IPv4 或 .example.com;不匹配根域名。拒绝 IPv6、单标签主机、localhost、.internal、平台域名及回环/链路本地/私网/CGNAT IPv4;规范化并去重
descriptionstring / null是备注;更新时 null 清除,省略则保留
metadataobject是自定义标签最多 16 对;source、template 为系统保留键,不占这 16 对且不能由调用方写入
status"active" / "refreshing" / "refresh_failed" / "archived"是状态
oauthSecretOAuthSummary / null是OAuth 摘要;kind 为 static 时为 null
oauth.expires_atdate-time / null是过期时间
oauth.last_refreshed_atdate-time / null是最近一次续期时间
oauth.next_refresh_atdate-time / null是下次计划续期时间
oauth.scopestring / null是授权范围
oauth.last_errorobject / null是最近一次续期失败
oauth.last_error.codestring是稳定的错误码
oauth.last_error.messagestring是可读的错误说明
oauth.last_error.atdate-time是事件或错误发生时间
versioninteger是值每次变化时递增
last_used_atdate-time / null是最近一次被使用的时间
created_atdate-time是创建时间
updated_atdate-time是更新时间
archived_atdate-time / null是归档时间;未归档时为 null

SecretOAuthSummary

字段类型 / 枚举必填说明
expires_atdate-time / null是过期时间
last_refreshed_atdate-time / null是最近一次续期时间
next_refresh_atdate-time / null是下次计划续期时间
scopestring / null是授权范围
last_errorobject / null是最近一次续期失败
last_error.codestring是稳定的错误码
last_error.messagestring是可读的错误说明
last_error.atdate-time是事件或错误发生时间

ImportLine

字段类型 / 枚举必填说明
namestring是名称,库内唯一且不可改;1–128 个大写字母、数字或下划线,以字母或下划线开头
valuestring是Secret 的值,只写,不会返回;最大 16 KiB
allowed_hostsstring[]否新建时用本行域名或导入的默认域名;替换时仅本行显式 allowed_hosts 才会更新域名

ImportResult

字段类型 / 枚举必填说明
createdstring[]是新建的 Secret 名称
replacedstring[]是被替换的 Secret 名称
failedobject[]是失败的行
failed[].lineinteger是失败行号,从 1 开始
failed[].namestring / null是名称,库内唯一且不可改;1–128 个大写字母、数字或下划线,以字母或下划线开头
failed[].code"VAULT_NOT_FOUND" / "SECRET_NOT_FOUND" / "AUTHORIZATION_NOT_FOUND" / "SECRET_CONFLICT" / "VAULT_INVALID_STATE" / "VAULT_LIMIT_EXCEEDED" / "INVALID_PARAMS" / "SECRET_KIND_MISMATCH" / "VALIDATE_UNSUPPORTED" / "SECRET_TOO_LARGE" / "RATE_LIMITED" / "AUTHORIZATION_EXPIRED" / "OAUTH_DISCOVERY_FAILED" / "OAUTH_REGISTRATION_UNSUPPORTED" / "OAUTH_ISSUER_MISMATCH" / "OAUTH_STATE_INVALID" / "OAUTH_EXCHANGE_FAILED" / "NOT_IMPLEMENTED"是稳定的错误码
failed[].messagestring是可读的错误说明

SecretValidation

字段类型 / 枚举必填说明
type"vault_secret_validation"是对象类型
secret_idstring是关联的 Secret ID;未关联时为 null
vault_idstring是库 ID
validated_atdate-time是校验时间
has_refresh_tokenboolean是是否保存了刷新令牌
status"valid" / "invalid" / "unknown"是状态
probeobject是探测请求
probe.method"GET"是探测方式,当前为 GET
probe.http_responseHttpCapture / null是HTTP 响应摘要;未收到响应时为 null
probe.http_response.status_codeinteger是HTTP 状态码
probe.http_response.content_typestring / null是响应内容类型,或 null
probe.http_response.bodystring是已脱敏的响应正文
probe.http_response.body_truncatedboolean是正文是否被截断
refreshobject是续期结果
refresh.status"succeeded" / "failed" / "connect_error" / "no_refresh_token" / "skipped"是状态
refresh.http_responseHttpCapture / null是HTTP 响应摘要;未收到响应时为 null
refresh.http_response.status_codeinteger是HTTP 状态码
refresh.http_response.content_typestring / null是响应内容类型,或 null
refresh.http_response.bodystring是已脱敏的响应正文
refresh.http_response.body_truncatedboolean是正文是否被截断

HttpCapture

字段类型 / 枚举必填说明
status_codeinteger是HTTP 状态码
content_typestring / null是响应内容类型,或 null
bodystring是已脱敏的响应正文
body_truncatedboolean是正文是否被截断

模板

查询常用服务的模板 ID、Secret 名称、种类和允许域名。

指南 →

基础地址与鉴权

template_idkind服务
githubstaticGitHub (api.github.com, uploads.github.com)
openaistaticOpenAI
anthropicstaticAnthropic
stripestaticStripe
linearoauthLinear (CIMD)
atlassianoauthAtlassian (DCR)

列出模板

GET /vault/v1/templates

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
dataVaultTemplate[]是条目数组
data[].idstring是对象标识符
data[].display_namestring是显示名称,1–255 个字符
data[].kind"static" / "oauth"是static:你填写的值;oauth:授权得到、由平台续期
data[].namestring是名称,库内唯一且不可改;1–128 个大写字母、数字或下划线,以字母或下划线开头
data[].allowed_hostsstring[]是1–16 个域名、公网 IPv4 或 .example.com;不匹配根域名。拒绝 IPv6、单标签主机、localhost、.internal、平台域名及回环/链路本地/私网/CGNAT IPv4;规范化并去重
data[].value_hintstring / null是填写提示

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。 没有额外的领域错误。

curl "https://api.deepraxis.ai/vault/v1/templates" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

VaultTemplate

字段类型 / 枚举必填说明
idstring是对象标识符
display_namestring是显示名称,1–255 个字符
kind"static" / "oauth"是static:你填写的值;oauth:授权得到、由平台续期
namestring是名称,库内唯一且不可改;1–128 个大写字母、数字或下划线,以字母或下划线开头
allowed_hostsstring[]是1–16 个域名、公网 IPv4 或 .example.com;不匹配根域名。拒绝 IPv6、单标签主机、localhost、.internal、平台域名及回环/链路本地/私网/CGNAT IPv4;规范化并去重
value_hintstring / null是填写提示

一键授权

让用户授权第三方服务,并管理一次性授权链接与回跳地址。

指南 →

基础地址与鉴权

一键授权为支持 OAuth 的服务产生 kind 为 oauth 的 Secret。发起授权后把 connect_url 交给最终用户;用户在确认页同意并在服务方完成授权后,Secret 写入库中,之后由平台续期。确认页、回调与客户端元数据三个地址不需要 API Key。

发起授权

POST /vault/v1/authorizations

请求体

字段类型 / 枚举必填说明
vault_idstring是库 ID
template_id"linear" / "atlassian"否支持授权的模板 ID;与 resource_url 二选一
resource_urlstring否要授权的资源地址,例如 MCP 服务地址
return_urlstring否授权结束后回到的地址;须在回跳地址白名单内

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault_authorization"是对象类型
vault_idstring是库 ID
status"pending" / "authorizing" / "completed" / "failed" / "expired"是状态
resourcestring是资源地址
secret_namestring是关联的 Secret 名称
connect_urlstring是交给最终用户打开的确认页,30 分钟内有效、只能使用一次
client_registration"cimd" / "dcr" / null是cimd:通过客户端元数据 URL 注册;dcr:动态注册客户端;尚未注册时为 null
secret_idstring / null是关联的 Secret ID;未关联时为 null
errorobject / null是失败原因
error.codestring是稳定的错误码
error.messagestring是可读的错误说明
expires_atdate-time是过期时间
created_atdate-time是创建时间
updated_atdate-time是更新时间

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
VAULT_INVALID_STATE409向已归档的库或 Secret 写入;改用有效资源validation_failurenone否
INVALID_PARAMS400字段、名称、域名、metadata、分页或回跳地址无效;修正请求validation_failurenone否
RATE_LIMITED429一分钟内超过授权或校验额度;等待下一窗口rate_limitwait_then_retry是
OAUTH_DISCOVERY_FAILED400无法发现服务方 OAuth 配置;检查资源地址validation_failurecontinue_from_problem否
OAUTH_REGISTRATION_UNSUPPORTED400服务方不接受自动客户端注册;手动添加凭据validation_failurecontinue_from_problem否
OAUTH_ISSUER_MISMATCH400授权服务器与预期不一致;重新检查服务地址provider_upstreamretry_from_user否
curl -X POST "https://api.deepraxis.ai/vault/v1/authorizations" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"vault_id\":\"${VAULT_ID}\",\"template_id\":\"linear\"}"

读取授权

GET /vault/v1/authorizations/{authorization_id}

参数位置说明
authorization_idpath授权 ID。

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault_authorization"是对象类型
vault_idstring是库 ID
status"pending" / "authorizing" / "completed" / "failed" / "expired"是状态
resourcestring是资源地址
secret_namestring是关联的 Secret 名称
connect_urlstring是交给最终用户打开的确认页,30 分钟内有效、只能使用一次
client_registration"cimd" / "dcr" / null是cimd:通过客户端元数据 URL 注册;dcr:动态注册客户端;尚未注册时为 null
secret_idstring / null是关联的 Secret ID;未关联时为 null
errorobject / null是失败原因
error.codestring是稳定的错误码
error.messagestring是可读的错误说明
expires_atdate-time是过期时间
created_atdate-time是创建时间
updated_atdate-time是更新时间

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
AUTHORIZATION_NOT_FOUND404授权或确认链接不存在;重新发起授权validation_failurenone否
curl "https://api.deepraxis.ai/vault/v1/authorizations/${AUTHORIZATION_ID}" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

读取回跳地址

GET /vault/v1/settings/return_urls

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
urlsstring[]是https 地址,精确匹配,最多 10 个

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。 没有额外的领域错误。

curl "https://api.deepraxis.ai/vault/v1/settings/return_urls" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"

设置回跳地址

PUT /vault/v1/settings/return_urls

请求体

字段类型 / 枚举必填说明
urlsstring[]是https 地址,精确匹配,最多 10 个

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
urlsstring[]是https 地址,精确匹配,最多 10 个

错误响应

缺少或无效的 API Key 返回 401 UNAUTHENTICATED。

错误码HTTP含义、触发条件与处理kindrecovery可重试
INVALID_PARAMS400字段、名称、域名、metadata、分页或回跳地址无效;修正请求validation_failurenone否
curl -X PUT "https://api.deepraxis.ai/vault/v1/settings/return_urls" \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"urls":["https://app.example.com/connected"]}'

授权回调

GET /vault/v1/authorizations/callback · 无需 API Key

参数位置说明
codequery服务方返回的授权码。
statequery发起授权时产生的一次性状态值。
errorquery服务方拒绝授权时返回的错误。
issquery服务方声明的授权服务器地址。

响应

HTTP 200

text/html

浏览器显示的确认页或结果页。

HTTP 302

通过 Location 响应头跳转到服务方授权页或已允许的回跳地址。

错误响应

错误码HTTP含义、触发条件与处理kindrecovery可重试
OAUTH_STATE_INVALID400回调 state 缺失、无效或重放;重新发起授权validation_failurenone否
OAUTH_ISSUER_MISMATCH400授权服务器与预期不一致;重新检查服务地址provider_upstreamretry_from_user否
OAUTH_EXCHANGE_FAILED502服务方拒绝授权码换令牌;重新授权provider_upstreamretry_from_user否
AUTHORIZATION_EXPIRED410授权链接超过 30 分钟或已使用;重新发起授权validation_failureretry_from_user否

设置了 return_url 时返回 302;未设置时返回 HTTP 200 结果页。

curl "https://api.deepraxis.ai/vault/v1/authorizations/callback"

OAuth 客户端元数据

GET /vault/v1/oauth/client.json · 无需 API Key

响应

HTTP 200

application/json

字段类型 / 枚举必填说明
client_idstring是客户端元数据 URL
client_namestring是客户端显示名称
redirect_urisstring[]是允许的 OAuth 回调地址
token_endpoint_auth_method"none"是令牌端点认证方式
grant_types"authorization_code" / "refresh_token"[]否支持的授权类型
response_types"code"[]否支持的授权响应类型

错误响应

没有额外的领域错误。

curl "https://api.deepraxis.ai/vault/v1/oauth/client.json"

授权确认页

GET /vault/v1/connect/{token} · 无需 API Key

参数位置说明
tokenpathconnect_url 中的一次性令牌。

响应

HTTP 200

text/html

浏览器显示的确认页或结果页。

HTTP 410

text/html

浏览器显示的确认页或结果页。

错误响应

错误码HTTP含义、触发条件与处理kindrecovery可重试
AUTHORIZATION_NOT_FOUND404授权或确认链接不存在;重新发起授权validation_failurenone否
AUTHORIZATION_EXPIRED410授权链接超过 30 分钟或已使用;重新发起授权validation_failureretry_from_user否

无效链接返回 404;过期或已使用的链接返回 410,均为 HTML 页面。

curl "https://api.deepraxis.ai/vault/v1/connect/${TOKEN}"

继续授权

POST /vault/v1/connect/{token}/continue · 无需 API Key

参数位置说明
tokenpathconnect_url 中的一次性令牌。

响应

HTTP 302

通过 Location 响应头跳转到服务方授权页或已允许的回跳地址。

错误响应

错误码HTTP含义、触发条件与处理kindrecovery可重试
AUTHORIZATION_NOT_FOUND404授权或确认链接不存在;重新发起授权validation_failurenone否
AUTHORIZATION_EXPIRED410授权链接超过 30 分钟或已使用;重新发起授权validation_failureretry_from_user否
OAUTH_DISCOVERY_FAILED400无法发现服务方 OAuth 配置;检查资源地址validation_failurecontinue_from_problem否
curl -X POST "https://api.deepraxis.ai/vault/v1/connect/${TOKEN}/continue"

拒绝授权

POST /vault/v1/connect/{token}/deny · 无需 API Key

参数位置说明
tokenpathconnect_url 中的一次性令牌。

响应

HTTP 200

text/html

浏览器显示的确认页或结果页。

HTTP 302

通过 Location 响应头跳转到服务方授权页或已允许的回跳地址。

错误响应

错误码HTTP含义、触发条件与处理kindrecovery可重试
AUTHORIZATION_NOT_FOUND404授权或确认链接不存在;重新发起授权validation_failurenone否
AUTHORIZATION_EXPIRED410授权链接超过 30 分钟或已使用;重新发起授权validation_failureretry_from_user否

设置了 return_url 时返回 302;未设置时返回 HTTP 200 结果页。

curl -X POST "https://api.deepraxis.ai/vault/v1/connect/${TOKEN}/deny"

Authorization

字段类型 / 枚举必填说明
idstring是对象标识符
type"vault_authorization"是对象类型
vault_idstring是库 ID
status"pending" / "authorizing" / "completed" / "failed" / "expired"是状态
resourcestring是资源地址
secret_namestring是关联的 Secret 名称
connect_urlstring是交给最终用户打开的确认页,30 分钟内有效、只能使用一次
client_registration"cimd" / "dcr" / null是cimd:通过客户端元数据 URL 注册;dcr:动态注册客户端;尚未注册时为 null
secret_idstring / null是关联的 Secret ID;未关联时为 null
errorobject / null是失败原因
error.codestring是稳定的错误码
error.messagestring是可读的错误说明
expires_atdate-time是过期时间
created_atdate-time是创建时间
updated_atdate-time是更新时间

ReturnUrls

字段类型 / 枚举必填说明
urlsstring[]是https 地址,精确匹配,最多 10 个

错误码

错误响应体统一为下面的形状;code 是稳定的错误码,message 给人读。

{
  "request_id": "req_example",
  "error": {
    "code": "SECRET_CONFLICT",
    "message": "A secret named GITHUB_TOKEN already exists",
    "kind": "validation_failure",
    "recovery": "none",
    "retryable": false
  }
}

错误体包含 request_id,可用于定位请求。兼容接口使用下列错误形状;409 的类型为 conflict_error,不可重试的错误带 x-should-retry: false。

{
  "type": "error",
  "error": {
    "type": "conflict_error",
    "message": "A credential with this name already exists"
  },
  "request_id": "req_example"
}
错误码HTTP含义、触发条件与处理kindrecovery可重试
VAULT_NOT_FOUND404库不存在或不属于当前账户;检查库 IDvalidation_failurenone否
SECRET_NOT_FOUND404Secret 不存在,包括用非法名称查找;检查名称或 IDvalidation_failurenone否
AUTHORIZATION_NOT_FOUND404授权或确认链接不存在;重新发起授权validation_failurenone否
SECRET_CONFLICT409创建时名称已占用;更换名称或更新已有 Secretvalidation_failurenone否
VAULT_INVALID_STATE409向已归档的库或 Secret 写入;改用有效资源validation_failurenone否
VAULT_LIMIT_EXCEEDED400超过有效 Secret 数量上限;先清理不用的 Secretvalidation_failurenone否
INVALID_PARAMS400字段、名称、域名、metadata、分页或回跳地址无效;修正请求validation_failurenone否
SECRET_KIND_MISMATCH400对 static Secret 续期或执行不匹配种类的操作;使用 OAuth Secretvalidation_failurenone否
VALIDATE_UNSUPPORTED400对 static Secret 校验;校验仅支持 OAuth Secretvalidation_failurenone否
SECRET_TOO_LARGE413值超过 16384 字节;缩小值后重试validation_failurenone否
RATE_LIMITED429一分钟内超过授权或校验额度;等待下一窗口rate_limitwait_then_retry是
AUTHORIZATION_EXPIRED410授权链接超过 30 分钟或已使用;重新发起授权validation_failureretry_from_user否
OAUTH_DISCOVERY_FAILED400无法发现服务方 OAuth 配置;检查资源地址validation_failurecontinue_from_problem否
OAUTH_REGISTRATION_UNSUPPORTED400服务方不接受自动客户端注册;手动添加凭据validation_failurecontinue_from_problem否
OAUTH_ISSUER_MISMATCH400授权服务器与预期不一致;重新检查服务地址provider_upstreamretry_from_user否
OAUTH_STATE_INVALID400回调 state 缺失、无效或重放;重新发起授权validation_failurenone否
OAUTH_EXCHANGE_FAILED502服务方拒绝授权码换令牌;重新授权provider_upstreamretry_from_user否
NOT_IMPLEMENTED501功能尚不支持;使用文档列出的替代方式execution_failednone否