OpenAI 兼容接口

2026-10-20

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"必有; other identifies a stored strategy whose chunk-size settings are unavailable.
(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"必有; other identifies a stored strategy whose chunk-size settings are unavailable.
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"必有; other identifies a stored strategy whose chunk-size settings are unavailable.
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"必有; other identifies a stored strategy whose chunk-size settings are unavailable.
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"必有; other identifies a stored strategy whose chunk-size settings are unavailable.
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"必有; other identifies a stored strategy whose chunk-size settings are unavailable.
data[].attributesobject / null必有; 用于搜索筛选的文件属性;null 表示未设置。
first_idstring / null必有; 本页首项的 ID;空页为 null。
last_idstring / null必有; 本页末项的 ID,可作为 after 继续查询;空页为 null。
has_moreboolean必有; 当前游标范围内,本页之后是否还有条目。

错误码与错误对象