OpenAI

Create chat completion

Generate a model reply for a list of messages.

POST /openai/v1/chat/completions● Supported

Official OpenAI docs ↗

Request parameters

  • X-OpenRouter-Metadatastring可选○ Currently ignored

    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.

    Accepted but currently has no effect; the requested routing metadata is not returned.

    取值 disabledenabled
  • messagesarray必填◐ Partially supported

    List of messages for the conversation

    Text, roles, history and tool round trips work. Images have model-specific size limits. file_id accepts user_data images, text and PDF; see the [file reference guide](/en/docs/cloud/services/model/guides/files) for model support and failure handling.

    ▸ 展开子字段(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

    Primary model; optional when a nonempty models list supplies the first candidate.

  • streamboolean可选◐ Partially supported
    默认 false

    Enable streaming response

    Content and tool deltas stream; gemini-2.5-flash may omit the end sentinel and budget exhaustion may report an incorrect finish_reason.

  • temperaturenumber可选◐ Partially supported

    Sampling temperature (0-2)

    An effect was observed on deepseek-v4-flash via /openai; sampling effects on other models remain unobservable.

  • max_tokensinteger可选◐ Partially supported

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

    Works on deepseek-v4-flash and glm-5.3-flash; small budgets may not take effect on qwen3.8-flash. Takes precedence over max_completion_tokens.

  • top_pnumber可选◐ Partially supported

    Nucleus sampling parameter (0-1)

    An effect was observed only on glm-5.3-flash via /model; other tested models or faces accepted it without an observed effect.

  • stopstring | array可选◐ Partially supported

    Stop sequences (up to 4)

    Works on qwen3.8-flash; deepseek-v4-flash and glm-5.3-flash may stop during reasoning and return empty content.

  • toolsarray可选

    Available tools for function calling

    Verified to take effect.

  • tool_choicestring | object可选◐ Partially supported

    Tool choice configuration

    auto works. deepseek-v4-flash ignores none/required/named functions; qwen3.8-flash rejects required/named functions in thinking mode; named selection on glm-5.3-flash is inconsistent.

    ▸ 展开子字段(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可选◐ Partially supported

      Response format configuration

      json_object works. json_schema works on deepseek-v4-flash and qwen3.8-flash but was not honored by 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可选○ Currently ignored

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

        Accepted but currently has no effect. Streaming requests do not echo the upstream request body.

    • frequency_penaltynumber可选◐ Partially supported

      Frequency penalty (-2.0 to 2.0)

      Some requests take effect on deepseek-v4-flash and glm-5.3-flash; qwen3.8-flash rejects some values or faces with 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可选◐ Partially supported

      Return log probabilities

      Works on qwen3.8-flash; deepseek-v4-flash works only via /openai and glm-5.3-flash differs between faces. gemini-2.5-flash returns 400.

    • max_completion_tokensinteger可选◐ Partially supported

      Maximum tokens in completion

      Works on deepseek-v4-flash and glm-5.3-flash; small budgets on qwen3.8-flash may be ineffective or exceed limits.

    • metadataobject可选

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

    • min_pnumber可选○ Currently ignored

      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.

      Accepted but currently has no effect.

    • modalitiesarray可选

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

    • modelsarray可选

      Models to use for completion

      Ordered fallback on an unknown primary, unavailable same-protocol line or upstream failure. models alone is accepted; response model and cost belong to the model that completes the request.

    • parallel_tool_callsboolean可选◐ Partially supported

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

      false works on qwen3.8-flash, is ignored by deepseek-v4-flash, and differs between faces on glm-5.3-flash.

    • pluginsarray可选◐ Partially supported

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

      Supports file-parser (pdf.engine native, mistral-ocr mapped to ocr, ocr, auto) and platform guardrails. Requests override account defaults but preserve locked settings. Unsupported plugins such as web, unknown engines and malformed configurations return 400 naming the field.

      ▸ 展开子字段(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可选◐ Partially supported

      Presence penalty (-2.0 to 2.0)

      An effect was observed on deepseek-v4-flash via /openai; some qwen3.8-flash requests return 400 and other effects are unobservable.

    • 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可选◐ Partially supported

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

      Only supplier choice (order / only / ignore) is BYOK-only and returns 400; require_parameters is honoured and other options are accepted no-ops.

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

        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.

        Accepted but currently has no effect (not supplier choice; available with platform credentials).

      • data_collectionstring可选○ Currently ignored

        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.

        Accepted but currently has no effect (not supplier choice; available with platform credentials).

        取值 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可选○ Unsupported

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

        Choosing suppliers (order / only / ignore) is BYOK-only; with platform credentials it returns 400 PROVIDER_SELECTION_NOT_ALLOWED.

      • max_priceobject可选○ Currently ignored

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

        Accepted but currently has no effect (not supplier choice; available with platform credentials).

      • onlyarray可选○ Unsupported

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

        Choosing suppliers (order / only / ignore) is BYOK-only; with platform credentials it returns 400 PROVIDER_SELECTION_NOT_ALLOWED.

      • orderarray可选○ Unsupported

        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.

        Choosing suppliers (order / only / ignore) is BYOK-only; with platform credentials it returns 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可选○ Currently ignored

        A list of quantization levels to filter the provider by.

        Accepted but currently has no effect (not supplier choice; available with platform credentials).

      • 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.

        Routes only to lines that can express every parameter; available with platform credentials.

      • sortstring | object可选○ Currently ignored

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

        Accepted but currently has no effect (not supplier choice; available with platform credentials).

      • zdrboolean可选○ Currently ignored

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

        Accepted but currently has no effect (not supplier choice; available with platform credentials).

    • reasoningobject可选

      Configuration options for reasoning models

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

        Constrains effort on reasoning for reasoning models

        none reliably disables thinking only on qwen3.8-flash; deepseek-v4-flash and glm-5.3-flash do not honor it.

        取值 maxxhighhighmediumlowminimalnonenull
      • summarystring可选○ Currently ignored

        How detailed the reasoning summary should be.

        Accepted but currently has no effect. deepseek-v4-flash did not return the requested summary.

        取值 autoconcisedetailednull
    • reasoning_effortstring可选◐ Partially supported

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

      none disables thinking on qwen3.8-flash; deepseek-v4-flash still thinks and glm-5.3-flash effort levels do not behave as expected.

      取值 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可选○ Currently ignored

      Random seed for deterministic outputs

      Accepted but currently has no effect. The same seed did not reproduce outputs on deepseek-v4-flash, glm-5.3-flash or qwen3.8-flash.

    • 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可选○ Currently ignored

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

        Accepted but currently has no effect. Usage is returned at the end whether true, false or omitted.

    • top_anumber可选○ Currently ignored

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

      Accepted but currently has no effect.

    • top_kinteger可选◐ Partially supported

      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.

      No sampling effect was observed on tested models; deepseek-v4-flash via /model returns an error.

    • top_logprobsinteger可选◐ Partially supported

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

      Requires logprobs=true; support follows logprobs and the selected model.

    • 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可选○ Currently ignored

      Accepted but currently has no effect. This applies to Chat Completions only.

    • max_output_tokensinteger可选○ Currently ignored

      Accepted but currently has no effect. This applies to Chat Completions only.

    • thinkingobject可选○ Currently ignored

      Accepted but currently has no effect. This applies to Chat Completions only.

    • web_search_optionsobject可选○ Currently ignored

      Accepted but currently has no effect. This applies to Chat Completions only.

    • functionsarray可选○ Currently ignored

      Accepted but currently has no effect. This applies to Chat Completions only.

    • audioobject可选○ Currently ignored

      Accepted but currently has no effect. This applies to Chat Completions only.

    • ninteger可选◐ Partially supported

      Works on glm-5.3-flash; accepted but ignored on deepseek-v4-flash; qwen3.8-flash errors.

    • usageobject可选○ Currently ignored

      Accepted and ignored; usage is always returned, regardless of include.

    • transformsarray可选○ Currently ignored

      Accepted and ignored; no middle-out or other message transformation is performed.

    • deferred_toolsobject可选○ Currently ignored

      Accepted and ignored; the OpenRouter deferred-tool protocol is not implemented.

    • promptstring可选○ Currently ignored

      Accepted and ignored; Chat still requires messages and this field does not replace them.

    • structured_outputsboolean可选○ Currently ignored

      Accepted and ignored; configure structured output with response_format, subject to its documented support.

    • include_reasoningboolean可选○ Currently ignored

      Accepted and ignored legacy alias; use reasoning subject to its documented support.

    • safe_promptboolean可选○ Currently ignored

      Accepted and ignored; the Mistral safe_prompt switch is not implemented.

    • raw_modeboolean可选○ Currently ignored

      Accepted and ignored; the Hyperbolic raw_mode switch is not implemented.

Returns

200 chat.completion

With stream=true the reply streams as server-sent events (text/event-stream).

Unknown top-level fields are forwarded unchanged to same-protocol upstream providers, which decide whether to accept them. Declared fields still undergo type and range validation; invalid values return 400 naming the field.

Errors follow the OpenAI format — see error codes

Response

HTTP 200

Successful chat completion response

application/json

NameTypeDescription
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 / event object

NameTypeDescription
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