模型

对话

发送一组对话消息,返回模型回复;支持流式输出、模型级回退与自带上游 Key。

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

官方文档 ↗

请求参数

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

    header: OpenRouter-style request header that asks for routing metadata in the response. It is accepted for compatibility and has no effect: the routing metadata is not returned.

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

  • modelstring必填

    Model to use for completion

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

  • messagesarray必填◐ 部分支持

    List of messages for the conversation

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

    ▸ 展开子字段(12)

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

    • configuration_updateobject可选

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

    • contentstring | array可选

      Tool response content

    • namestring可选

      Optional name for the assistant

    • rolestring可选

      Role of the message author; always tool.

      取值 tool
    • audioobject可选

      Audio output data or reference

    • imagesarray可选

      Generated images from image generation models

    • modelstring必填

      Model that generated this assistant message

    • reasoningstring可选

      Reasoning output

    • reasoning_detailsarray可选

      Reasoning details for extended thinking models

    • refusalstring可选

      Refusal message if content was refused

    • tool_callsarray可选

      Tool calls made by the assistant

    • tool_call_idstring可选

      ID of the assistant message tool call this message responds to

  • max_tokensinteger可选◐ 部分支持

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

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

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

    Enable streaming response

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

  • temperaturenumber可选◐ 部分支持

    Sampling temperature (0-2)

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

  • top_pnumber可选◐ 部分支持

    Nucleus sampling parameter (0-1)

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

  • toolsarray可选

    Available tools for function calling

    已验证生效。

  • tool_choicestring | object可选◐ 部分支持

    Tool choice configuration

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

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

      The function the model must call.

    • typestring必填

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

  • response_formatobject可选◐ 部分支持

    Response format configuration

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

    ▸ 展开子字段(3)

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

    • typestring必填

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

      取值 python
    • json_schemaobject必填

      JSON Schema configuration object

    • grammarstring必填

      Custom grammar for text generation

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

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

    • cache_controlobject可选

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

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

        Lifetime of an Anthropic-style cache breakpoint.

        取值 5m1h
      • typestring必填

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

        取值 ephemeral
    • debugobject可选

      Debug options for inspecting request transformations (streaming only)

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

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

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

    • frequency_penaltynumber可选◐ 部分支持

      Frequency penalty (-2.0 to 2.0)

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

    • image_configobject可选

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

    • logit_biasobject可选

      Token logit bias adjustments

    • logprobsboolean可选◐ 部分支持

      Return log probabilities

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

    • max_completion_tokensinteger可选◐ 部分支持

      Maximum tokens in completion

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

    • metadataobject可选

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

    • min_pnumber可选○ 当前不生效

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

      接受但当前不生效。

    • modalitiesarray可选

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

    • modelsarray可选

      Models to use for completion

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

    • parallel_tool_callsboolean可选◐ 部分支持

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

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

    • pluginsarray可选◐ 部分支持

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

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

      ▸ 展开子字段(27)

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

      • allowed_modelsarray可选

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

      • cost_quality_tradeoffinteger可选

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

      • cost_tierstring可选

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

        取值 lowmediumhighxhighmax
      • enabledboolean可选

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

      • excluded_modelsarray可选

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

      • idstring可选

        Plugin id; always fusion.

        取值 fusion
      • pin_modelboolean可选

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

      • enginestring可选

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

        取值 middle-out
      • exclude_domainsarray可选

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

      • include_domainsarray可选

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

      • max_resultsinteger可选

        Maximum number of search results to use.

      • max_usesinteger可选

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

      • modestring可选

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

        取值 instantfastautodeep-litedeepdeep-reasoningturbobasicadvanced
      • search_promptstring可选

        Prompt that introduces the search results to the model.

      • user_locationobject可选

        Approximate user location for location-biased search results.

      • allowed_domainsarray可选

        Only fetch from these domains.

      • blocked_domainsarray可选

        Never fetch from these domains.

      • max_content_tokensinteger可选

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

      • pdfobject可选

        Options for PDF parsing.

      • max_pricenumber可选

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

      • min_coding_scorenumber可选

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

      • price_sourcestring可选

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

        取值 promptweighted_avg
      • analysis_modelsarray可选

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

      • max_tool_callsinteger可选

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

      • modelstring必填

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

      • presetstring可选

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

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

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

    • predictionobject可选

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

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

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

      • typestring必填

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

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

      Presence penalty (-2.0 to 2.0)

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

    • prompt_cache_keystring可选

      Caller-chosen key that groups requests with a long shared prefix so that they can reuse the provider's prompt cache; null for none.

    • prompt_cache_optionsobject可选

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

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

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

        取值 explicit
      • ttlstring可选

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

    • providerobject可选◐ 部分支持

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

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

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

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

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

      • data_collectionstring可选○ 当前不生效

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

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

        取值 denyallownull
      • enforce_distillable_textboolean可选

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

      • ignorearray可选○ 未支持

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

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

      • max_priceobject可选○ 当前不生效

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

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

      • onlyarray可选○ 未支持

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

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

      • orderarray可选○ 未支持

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

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

      • preferred_max_latencynumber | object可选

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

      • preferred_min_throughputnumber | object可选

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

      • quantizationsarray可选○ 当前不生效

        A list of quantization levels to filter the provider by.

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

      • require_parametersboolean可选

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

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

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

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

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

      • zdrboolean可选○ 当前不生效

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

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

    • reasoningobject可选

      Configuration options for reasoning models

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

        Constrains effort on reasoning for reasoning models

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

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

        How detailed the reasoning summary should be.

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

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

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

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

      取值 maxxhighhighmediumlowminimalnonenull
    • repetition_penaltynumber可选

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

    • routestring可选

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

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

      Random seed for deterministic outputs

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

    • service_tierstring可选

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

      取值 autodefaultfastflexpriorityscalenull
    • session_idstring可选

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

    • stopstring | array可选◐ 部分支持

      Stop sequences (up to 4)

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

    • stop_server_tools_whenarray可选

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

      ▸ 展开子字段(6)

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

      • step_countinteger可选

        Number of steps after which the loop stops.

      • typestring可选

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

        取值 finish_reason_is
      • tool_namestring可选

        Name of the tool whose call stops the loop.

      • max_tokensinteger可选

        Cumulative token count after which the loop stops.

      • max_cost_in_dollarsnumber可选

        Cumulative cost in USD after which the loop stops.

      • reasonstring可选

        Finish reason that stops the loop.

    • stream_optionsobject可选

      Streaming configuration options

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

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

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

    • top_anumber可选○ 当前不生效

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

      接受但当前不生效。

    • top_kinteger可选◐ 部分支持

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

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

    • top_logprobsinteger可选◐ 部分支持

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

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

    • traceobject可选

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

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

        Name of this generation in the trace.

      • parent_span_idstring可选

        Id of the parent span in the trace.

      • span_namestring可选

        Name of this request's span in the trace.

      • trace_idstring可选

        Id that groups several requests into one trace.

      • trace_namestring可选

        Name of the trace.

    • userstring可选

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

    • storeboolean可选○ 当前不生效

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

    • max_output_tokensinteger可选○ 当前不生效

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

    • thinkingobject可选○ 当前不生效

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

    • web_search_optionsobject可选○ 当前不生效

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

    • functionsarray可选○ 当前不生效

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

    • audioobject可选○ 当前不生效

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

    • ninteger可选◐ 部分支持

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

    • usageobject可选○ 当前不生效

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

    • transformsarray可选○ 当前不生效

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

    • deferred_toolsobject可选○ 当前不生效

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

    • structured_outputsboolean可选○ 当前不生效

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

    • include_reasoningboolean可选○ 当前不生效

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

    • safe_promptboolean可选○ 当前不生效

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

    • raw_modeboolean可选○ 当前不生效

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

    • providerOptionsobject可选◐ 部分支持

      providerOptions.praxis.models 与顶层 models 使用同一有序回退。order/only 仅允许与已有的请求级 BYOK 凭证同时使用;非 BYOK 返回 400。

      ▸ 展开子字段(1)
      • praxisobject必填

        Platform options: ordered model fallback, request-level BYOK credentials and credential-gated provider selection.

返回

200 chat.completion

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

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

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

响应

HTTP 200

Chat completion (application/json) or streamed chunks (text/event-stream)

application/json

名称类型说明
idstringId of the completion.
objectstringObject type; always `chat.completion`.
creatednumberUnix time in seconds at which the completion was created.
modelstringModel that produced the completion; with fallback this is the model that finally answered.
choicesarray<object>Completion choices; one entry per generated answer.
choices[].indexnumberZero-based index of the choice.
choices[].messageobjectThe message the model generated.
choices[].finish_reasonstring | nullWhy generation stopped, for example `stop`, `length` or `tool_calls`; null while a stream is still generating.
choices[].logprobsany | nullLog probabilities of the output tokens, when requested; null otherwise.
usageobjectToken usage of the request.
usage.prompt_tokensnumberNumber of tokens in the prompt.
usage.completion_tokensnumberNumber of tokens in the completion.
usage.total_tokensnumberPrompt plus completion tokens.
usage.prompt_tokens_detailsobjectBreakdown of the prompt tokens.
usage.completion_tokens_detailsobjectBreakdown of the completion tokens.
usage.prompt_cache_hit_tokensnumberPrompt tokens served from the cache, as reported by providers that use this DeepSeek-style counter.
usage.prompt_cache_miss_tokensnumberPrompt tokens not served from the cache, as reported by providers that use this DeepSeek-style counter.
system_fingerprintstring | nullBackend fingerprint; always null on this face.
service_tierstring | nullService tier the provider used; null when not reported.
providerMetadataobjectPlatform metadata of the call.
providerMetadata.praxisobjectPlatform metadata of the call: generation id, cost, credential kind and serving model.

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

名称类型说明
idstringOptional id of the server-sent event.
eventstringName of the server-sent event.
dataobject | stringPayload of the server-sent event.
data.idstringId of the completion; every chunk of one stream carries the same id.
data.objectstringObject type; always `chat.completion.chunk`.
data.creatednumberUnix time in seconds at which the completion was created.
data.modelstringModel that produced the completion; with fallback this is the model that finally answered.
data.choicesarray<object>Completion choices of the chunk.
data.providerMetadataobjectPlatform metadata of the call.