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

# OpenAI 格式 - 响应

> - 适用于所有兼容 Responses API 格式模型的通用参考
- 服务端上下文存储：通过 previous_response_id 实现多轮对话，无需手动传历史消息
- 支持流式和非流式响应
- 多模态输入：支持文本 + 图像 + 文件混合输入
- 工具调用：支持 Function Calling 和内置工具
- 结构化输出：支持 JSON Schema 格式




## OpenAPI

````yaml openapi/zh/openai-format-responses.json POST /v1/responses
openapi: 3.1.0
info:
  title: OpenAI Format - Responses
  version: '1.0'
servers:
  - url: https://api.aihubmax.com
security:
  - BearerAuth: []
paths:
  /v1/responses:
    post:
      tags:
        - Text Series > OpenAI Format
      summary: OpenAI Format - Responses
      description: |
        - 适用于所有兼容 Responses API 格式模型的通用参考
        - 服务端上下文存储：通过 previous_response_id 实现多轮对话，无需手动传历史消息
        - 支持流式和非流式响应
        - 多模态输入：支持文本 + 图像 + 文件混合输入
        - 工具调用：支持 Function Calling 和内置工具
        - 结构化输出：支持 JSON Schema 格式
      operationId: openai-format-responses
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponseRequest'
            examples:
              simple-input:
                summary: 简单文本输入
                description: 直接传入文本字符串作为输入
                value:
                  model: gpt-5.4
                  input: 解释一下 RESTful API 的设计原则
              multi-turn:
                summary: 多轮对话
                description: 通过消息列表实现多轮对话
                value:
                  model: gpt-5.4
                  input:
                    - role: developer
                      content: 你是一位旅行规划助手
                    - role: user
                      content: 我想去日本玩5天，预算2万元
                    - role: assistant
                      content: 5天日本之旅是个很好的选择！我建议集中在关西地区（大阪-京都-奈良）。你更偏好文化体验还是美食购物？
                    - role: user
                      content: 两者都想体验，但文化优先
              streaming:
                summary: 流式响应
                description: 启用流式输出
                value:
                  model: gpt-5.4
                  input: 写一篇关于人工智能在医疗领域应用的短文
                  stream: true
              previous-response:
                summary: 服务端上下文（多轮）
                description: 通过 previous_response_id 实现多轮对话，无需手动传历史消息
                value:
                  model: gpt-5.4
                  input: 那第三个原则呢？能举个例子吗？
                  previous_response_id: resp_abc123
              tool-calling:
                summary: 工具调用 - 天气查询
                description: 使用 Function Calling 调用外部工具
                value:
                  model: gpt-5.4
                  input: 上海明天会下雨吗？我计划去外滩
                  tools:
                    - type: function
                      function:
                        name: get_weather
                        description: 获取指定城市的天气预报
                        parameters:
                          type: object
                          properties:
                            city:
                              type: string
                              description: 城市名称
                            days:
                              type: integer
                              description: 预报天数
                              default: 1
                          required:
                            - city
      responses:
        '200':
          $ref: '#/components/responses/ResponseSuccess'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    ResponseRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          description: 模型名称
          example: gpt-5.4
        input:
          description: 用于生成响应的文本输入或消息列表
          oneOf:
            - type: string
              description: 用于生成响应的文本输入
            - type: array
              description: 输入消息列表
              items:
                type: object
                required:
                  - role
                  - content
                properties:
                  role:
                    type: string
                    description: 消息发送者的角色
                    enum:
                      - system
                      - user
                      - assistant
                      - developer
                  content:
                    type: string
                    description: 消息内容
        stream:
          type: boolean
          description: 是否流式返回响应
          default: false
        temperature:
          type: number
          description: 采样温度 (0-2)
          minimum: 0
          maximum: 2
        max_output_tokens:
          type: integer
          description: 最大输出token生成数
        top_p:
          type: number
          description: 核采样参数 (0-1)
          minimum: 0
          maximum: 1
        previous_response_id:
          type: string
          description: 上一个响应的ID，用于多轮对话
        instructions:
          type: string
          description: 系统级指令
        tools:
          type: array
          description: 可用工具列表
          items:
            type: object
            properties:
              type:
                type: string
                description: 工具类型
                enum:
                  - function
                  - web_search
                  - file_search
                  - code_interpreter
              function:
                type: object
                description: 函数定义（当 type 为 function 时）
                properties:
                  name:
                    type: string
                    description: 函数名称
                  description:
                    type: string
                    description: 函数描述
                  parameters:
                    type: object
                    description: 函数参数的 JSON Schema
                required:
                  - name
        text:
          type: object
          description: 文本输出格式配置
          properties:
            format:
              type: object
              description: 输出格式
              properties:
                type:
                  type: string
                  description: 格式类型
                  enum:
                    - text
                    - json_object
                    - json_schema
    ResponseObject:
      type: object
      properties:
        id:
          type: string
          description: 响应唯一ID
          example: resp_abc123
        object:
          type: string
          description: 对象类型
          enum:
            - response
        created_at:
          type: integer
          description: 创建时间戳
          example: 1757165031
        model:
          type: string
          description: 使用的模型
        status:
          type: string
          description: 响应状态
          enum:
            - completed
            - failed
            - in_progress
            - incomplete
          example: completed
        output:
          type: array
          description: 响应输出内容列表
          items:
            type: object
            properties:
              type:
                type: string
                description: 输出项类型
                example: message
              id:
                type: string
                description: 输出项ID
                example: msg_abc123
              role:
                type: string
                description: 角色
                example: assistant
              content:
                type: array
                description: 内容列表
                items:
                  type: object
                  properties:
                    type:
                      type: string
                      description: 内容类型
                      example: output_text
                    text:
                      type: string
                      description: 文本内容
                      example: Hello! How can I help you today?
        usage:
          type: object
          description: 用量统计
          properties:
            input_tokens:
              type: integer
              description: 输入token数
              example: 20
            output_tokens:
              type: integer
              description: 输出token数
              example: 50
            total_tokens:
              type: integer
              description: 总token数
              example: 70
    ErrorResponse400:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 请求参数无效
            type:
              type: string
              example: invalid_request_error
    ErrorResponse401:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: API密钥无效
            type:
              type: string
              example: authentication_error
    ErrorResponse403:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 访问被拒绝
            type:
              type: string
              example: permission_error
    ErrorResponse429:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 请求频率超限
            type:
              type: string
              example: rate_limit_error
    ErrorResponse500:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 服务器内部错误
            type:
              type: string
              example: server_error
  responses:
    ResponseSuccess:
      description: 响应对象
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ResponseObject'
    BadRequest:
      description: 请求错误
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse400'
    Unauthorized:
      description: 未授权
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse401'
    PaymentRequired:
      description: 余额不足
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse400'
    Forbidden:
      description: 禁止访问
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse403'
    TooManyRequests:
      description: 请求过多
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse429'
    InternalServerError:
      description: 服务器内部错误
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse500'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: |
        ## 所有接口均需要使用Bearer Token进行认证 ##

        使用时在请求头中添加：

        `Authorization: Bearer YOUR_API_KEY`

````