开发文档 · 请求规范

请求规范

路径、信封、幂等、二进制接口与限制。

基础约定

  • 协议:HTTPS;字符集:UTF-8;时间:ISO 8601,带时区。
  • 路径前缀 /open/v1;资源型接口用名词路径(/documents/{doc_id}),动作型接口用冒号后缀(/documents:merge)。
  • 请求体字段名一律小写下划线;未在契约中声明的字段会被拒绝(additionalProperties: false)。

响应信封

所有 JSON 响应(包括错误)都是同一个结构;判断成功只看 HTTP 状态与 success。

字段类型约束说明
success必填boolean
data必填任意
error必填任一
code必填string枚举 "conversion_failed" / "embedding_access_denied" / "embedding_output_invalid" / "embedding_unavailable" / "feature_disabled" / "forbidden" / "index_config_conflict" / "index_incomplete" / "input_invalid" / "input_too_large" / "internal_error" / "method_not_allowed" / "model_access_denied" / "model_output_invalid" / "model_unavailable" / "not_acceptable" / "not_found" / "payload_too_large" / "precondition_failed" / "precondition_required" / "processor_budget" / "processor_failed" / "processor_invalid_response" / "processor_rejected" / "processor_timeout" / "processor_unauthorized" / "processor_unavailable" / "queue_capacity_exceeded" / "rate_limited" / "resource_conflict" / "resource_not_found" / "semantic_unavailable" / "service_unavailable" / "source_ambiguous" / "source_changed" / "source_invalid" / "source_unavailable" / "source_writeback_unavailable" / "unauthorized" / "unsupported_media_type" / "upstream_rejected" / "upstream_timeout" / "upstream_unavailable"
message必填string长度≥1
retryable必填boolean
metering任一
status必填string枚举 "pending" / "reported" / "partial" / "unavailable" / "not_applicable"
job_idstring | null正则 ^[a-f0-9]{32}$
metered_request_idstring | null
document_page_countinteger | null≥0
models必填array<object>
[ ]object不接受额外字段
provider必填string | null
model_type必填string枚举 "chat" / "embedding" / "rerank" / "vision"
model_id必填string | null
model_id_source必填string枚举 "provider" / "configured" / "unavailable"
input_tokens必填integer | null≥0
output_tokens必填integer | null≥0
call_count必填integer≥1
duration_ms必填integer | null≥0
usage_status必填string枚举 "reported" / "partial" / "unavailable"
ocr必填array<object>
[ ]object不接受额外字段
provider必填string
service必填string
page_count必填integer | null≥0
call_count必填integer≥1
cache_hit_count必填integer≥0
duration_ms必填integer | null≥0
usage_status必填string枚举 "reported" / "partial" / "unavailable"
audioarray<object>
[ ]object不接受额外字段
provider必填string
model_id必填string
call_count必填integer≥1
unknown_call_count必填integer≥0
audio_duration_seconds必填integer | null≥0
input_tokens必填integer | null≥0
output_tokens必填integer | null≥0
usage_status必填string枚举 "reported" / "partial" / "unavailable"
image_generationobject不接受额外字段
attempt_count必填integer≥1
unknown_result_count必填integer≥0
image_count必填integer | null≥0
usage_status必填string枚举 "reported" / "partial" / "unavailable"
timing必填object不接受额外字段
gateway_ms必填integer | null≥0
execution_ms必填integer | null≥0
total_ms必填integer | null≥0
request_id必填string长度≥1;长度≤64;正则 ^[A-Za-z0-9_-]+$
{
  "success": true,
  "data": {
    "doc_id": 1001,
    "status": "created"
  },
  "error": null,
  "metering": null,
  "request_id": "req-7f3c2a"
}

失败时 success 为 false,data 为 null,error 给出 code、message 与 retryable。

幂等与重试

提交型接口都要求 client_request_id(调用方生成,1–128 位,字母数字与 ._:-)。同一共享 Principal 下的不同 Key 也共用任务幂等范围,调用方应避免重复 ID。相同 ID 重试时:

  • 载荷相同 → 返回原任务,不重复执行;
  • 载荷不同 → 409 resource_conflict,需更换 ID。

网络超时、502 / 503 / 504、429 都可以带同一个 client_request_id 直接重试;error.retryable 为 false 的错误重试无效。

二进制接口

convertToPdf、convertToWord、getDocumentOriginal、getDocumentPageAsset、getDocumentPageAssetByPageId 直接返回文件字节(application/pdf 或 application/octet-stream),错误时仍返回 JSON 信封;按 Content-Type 区分。

限制

  • 单次上传与直传解析的大小上限以接口页「约束」为准(如 Base64 直传解码后最多 6 MiB);超限返回 413。
  • 批量接口的元素数上限写在字段约束里(如合并最多 50 份、图片分类最多 20 张)。
  • 任务与结果沿用共享 Principal 的访问规则;跨空间访问返回 404。