> ## Documentation Index
> Fetch the complete documentation index at: https://omnirelay.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 创建响应

> 调用已启用模型，通过 GET /v1/models 查询工具、JSON 格式、采样、推理及组合限制。能力审查覆盖全部可调用路由；新增组合依据文档，仍待逐项真实调用验证。预留费用并按可信用量结算，请关闭 SDK 自动重试。Responses 为无状态／store:false，不支持托管工具及存储引用。所有可调用路由采用参数透传（parameter_policy upstream-first）；能力列表提供建议，普通 Schema 与扩展字段透传。保留原生响应与推理输出；模型服务方 400／422 拒绝释放预留，模型服务方故障、超时或断流需要对账。



## OpenAPI

````yaml /openapi.cn.json post /v1/responses
openapi: 3.1.0
info:
  title: OmniRelay API
  version: 1.0.0
  description: 面向已核验真实文本模型的兼容 OpenAI 网关。访问按工作空间开通，使用自己的模型列表查询能力与客户价格。
servers:
  - url: https://api.omnirelay.ai
security:
  - bearerAuth: []
tags:
  - name: 服务
  - name: 模型
  - name: 对话
  - name: 管理 API
  - name: 响应
  - name: 向量
  - name: 图片
  - name: 视频
paths:
  /v1/responses:
    post:
      tags:
        - 响应
      summary: 创建响应
      description: >-
        调用已启用模型，通过 GET /v1/models 查询工具、JSON
        格式、采样、推理及组合限制。能力审查覆盖全部可调用路由；新增组合依据文档，仍待逐项真实调用验证。预留费用并按可信用量结算，请关闭 SDK
        自动重试。Responses
        为无状态／store:false，不支持托管工具及存储引用。所有可调用路由采用参数透传（parameter_policy
        upstream-first）；能力列表提供建议，普通 Schema 与扩展字段透传。保留原生响应与推理输出；模型服务方 400／422
        拒绝释放预留，模型服务方故障、超时或断流需要对账。
      operationId: createResponses
      parameters:
        - name: X-Gateway-Tags
          in: header
          required: false
          description: >-
            本次调用的标签，以逗号分隔的 `key=value`，例如 `client=acme,env=prod`。与 API Key
            的默认标签合并；同名 key 以请求体 `tags` 字段为准。`X-OmniRelay-Tags` 是同一个请求头的旧名，继续接受。
          schema:
            type: string
          example: client=acme,env=prod
        - name: X-Gateway-Metadata
          in: header
          required: false
          description: >-
            传 `enabled` 时，响应会附带
            `gateway_metadata`，说明网关为本次调用做出的决定。其他值或不传此头，响应保持不变。`X-OmniRelay-Metadata`
            是同一个请求头的旧名，继续接受。
          schema:
            type: string
            enum:
              - enabled
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponsesRequest'
      responses:
        '200':
          description: 已验证结果，包含已结算用量和费用。
          headers:
            X-Request-ID:
              description: 用于诊断的 OmniRelay 请求 ID，与模型服务方追踪、响应头及响应体 ID 分别记录。
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponsesResponse'
            text/event-stream:
              schema:
                type: string
              example: >+
                event: response.completed

                data:
                {"type":"response.completed","response":{"status":"completed"}}

        '400':
          description: JSON、标签或参数不合法，模型不支持该能力，或 context_length_exceeded。发往模型服务方前即被拒绝。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: unsupported_parameter
                request_id: 2f6c1d0e9a
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          description: >-
            inference_budget_or_access_denied 表示钱包、Key
            或平台预算无法覆盖预留；member_budget_exceeded 表示成员上限超出。均在派发前拒绝。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: insufficient_balance
                request_id: 2f6c1d0e9a
        '403':
          description: '`model_not_allowed`：该 API Key 仅限调用其他模型。不会扣费。'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: model_not_allowed
                request_id: 2f6c1d0e9a
        '404':
          description: '`model_unavailable`：该模型不存在，或已在此工作区停用。'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: model_unavailable
                request_id: 2f6c1d0e9a
        '413':
          description: payload_too_large：请求体超过 4 MiB（4194304 字节 UTF-8）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: payload_too_large
                request_id: 2f6c1d0e9a
        '429':
          description: rate_limited：超过账户实际请求频率限制。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: rate_limited
                request_id: 2f6c1d0e9a
        '502':
          description: 模型服务方拒绝、传输失败、响应无效或用量缺失/无效。已发送的调用可能保留预留等待对账；此状态不代表模型服务方未计费。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: >-
            channel_unavailable、live_provider_not_configured、live_provider_unavailable、runtime_maintenance
            或 storage_unavailable。凭据与维护检查在发送前拒绝请求。已发送但结果不明确的请求保留
            pending；不要自动重试付费调用。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: live_provider_not_configured
                request_id: 2f6c1d0e9a
components:
  schemas:
    ResponsesRequest:
      type: object
      required:
        - model
        - input
      additionalProperties: true
      properties:
        model:
          type: string
        input:
          oneOf:
            - type: string
              maxLength: 1048576
            - type: array
              minItems: 1
              maxItems: 2000
              items:
                type: object
          description: 文本或显式消息／函数调用历史。仅文本片段，不支持托管工具或已存储响应引用。
        instructions:
          type: string
          maxLength: 1048576
        max_output_tokens:
          type: integer
          minimum: 1
        stream:
          type: boolean
          default: false
        store:
          type: boolean
          enum:
            - false
          default: false
        tools:
          type: array
          minItems: 1
          maxItems: 64
          items:
            type: object
            required:
              - type
              - name
            additionalProperties: false
            properties:
              type:
                type: string
                enum:
                  - function
              name:
                type: string
                maxLength: 64
              description:
                type: string
                maxLength: 4096
              parameters:
                type: object
              strict:
                type: boolean
          description: >-
            仅真实模式且模型支持 tools 时可用。只支持 function 工具；严格工具和 JSON Schema
            关键字另需支持。详见模型接入指南。
        tool_choice:
          oneOf:
            - type: string
              enum:
                - auto
                - none
                - required
            - type: object
              required:
                - type
                - name
              properties:
                type:
                  type: string
                  enum:
                    - function
                name:
                  type: string
          description: >-
            模型声明 tool_choice 时可使用 auto、none 或 required。指定函数名选择还要求
            capabilities.named_tool_choice。
        parallel_tool_calls:
          type: boolean
        text:
          type: object
          properties:
            format:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - text
                    - json_object
                    - json_schema
                name:
                  type: string
                schema:
                  type: object
                strict:
                  type: boolean
        reasoning:
          type: object
          properties:
            effort:
              type: string
        tags:
          type: object
          description: >-
            本次调用的标签。与请求头和 Key 默认标签合并后最多 10 个。key 为 1 至 64 个字符，统一存为小写；value 为 1 至
            128 个字符。两者只能包含字母、数字和 `- _ . : /`。以 `gateway:` 或 `omnirelay:` 开头的 key
            为保留字。`tags` 不是对象时会被忽略。
          additionalProperties:
            type: string
          example:
            client: acme
            project: invoices
      description: 参数透传：普通扩展字段透传，仍执行鉴权、文本／函数协议及预算结算边界。
    ResponsesResponse:
      type: object
      required:
        - id
        - object
        - status
        - model
        - output
        - usage
        - cost_microusd
      properties:
        id:
          type: string
        object:
          type: string
          enum:
            - response
        created_at:
          type: integer
        status:
          type: string
          enum:
            - completed
            - incomplete
        error:
          type:
            - object
            - 'null'
        incomplete_details:
          type:
            - object
            - 'null'
        model:
          type: string
        output:
          type: array
          items:
            type: object
        store:
          type: boolean
          enum:
            - false
        usage:
          type: object
          required:
            - input_tokens
            - output_tokens
            - total_tokens
          properties:
            input_tokens:
              type: integer
              minimum: 0
            output_tokens:
              type: integer
              minimum: 0
            total_tokens:
              type: integer
              minimum: 0
            input_tokens_details:
              type: object
              additionalProperties: false
              properties:
                cached_tokens:
                  type: integer
                  minimum: 0
                cache_write_tokens:
                  type: integer
                  minimum: 0
            output_tokens_details:
              type: object
              additionalProperties: false
              properties:
                reasoning_tokens:
                  type: integer
                  minimum: 0
        cost_microusd:
          type: integer
          description: 按冻结价格、Token 分项、阶梯和折扣计算的已结算费用，单位微美元。整次费用取整后应用折扣，再向上取整。这是最终费用，不是最高预留。
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - type
          properties:
            code:
              type: string
              example: model_unavailable
            message:
              type: string
              example: The model does not exist or is disabled.
              description: 用于日志和 SDK 异常的简短英文说明；措辞可能调整，请按 code 判断。
            type:
              type: string
              example: not_found_error
              description: >-
                按 HTTP
                状态划分的错误类别：invalid_request_error、authentication_error、insufficient_quota、permission_error、not_found_error、conflict_error、rate_limit_error、service_unavailable
                或 api_error。
            param:
              type: string
              maxLength: 200
              description: 可识别时返回被拒绝的请求字段路径，不包含参数值；Responses 使用原生字段名。
        request_id:
          type: string
          description: 在对话补全、Responses 和 Embeddings 出错时返回。
  responses:
    Unauthorized:
      description: '`unauthorized`：缺少 API Key，或该 Key 已吊销或无效。'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 在 OmniRelay 控制台创建的 API Key。所有者确认身份后可在控制台再次查看。

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.