> ## 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 格式 - 简单对话

> - 适用于所有兼容 OpenAI 格式模型的通用简单对话 API 参考
- 最简化参数，快速上手
- 文本对话：单轮或多轮上下文对话
- 系统提示词：自定义 AI 的角色和行为
- 支持流式和非流式响应




## OpenAPI

````yaml openapi/zh/openai-format-simple-chat.json POST /v1/chat/completions
openapi: 3.1.0
info:
  title: OpenAI Format - Simple Chat
  version: '1.0'
servers:
  - url: https://api.aihubmax.com
security:
  - BearerAuth: []
paths:
  /v1/chat/completions:
    post:
      tags:
        - Text Series > OpenAI Format
      summary: OpenAI Format - Simple Chat
      description: |
        - 适用于所有兼容 OpenAI 格式模型的通用简单对话 API 参考
        - 最简化参数，快速上手
        - 文本对话：单轮或多轮上下文对话
        - 系统提示词：自定义 AI 的角色和行为
        - 支持流式和非流式响应
      operationId: openai-format-simple-chat
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SimpleChatRequest'
            examples:
              single-turn:
                summary: 单轮对话
                description: 最基础的单轮问答
                value:
                  model: gpt-5.4
                  messages:
                    - role: user
                      content: 用一句话解释什么是量子计算
              multi-turn:
                summary: 多轮对话
                description: 包含上下文的多轮对话
                value:
                  model: gpt-5.4
                  messages:
                    - role: system
                      content: 你是一位专业的健身教练
                    - role: user
                      content: 我想减脂，每周能锻炼3天
                    - role: assistant
                      content: 很好！对于每周3天的减脂计划，我建议安排全身性的力量训练结合高强度间歇训练（HIIT）。你之前有健身经验吗？
                    - role: user
                      content: 有一些基础，能做俯卧撑和深蹲
              streaming:
                summary: 流式响应
                description: 启用流式输出，实时获取生成内容
                value:
                  model: gpt-5.4
                  messages:
                    - role: user
                      content: 写一首关于春天的短诗
                  stream: true
              with-image:
                summary: 带图片
                description: 发送图片让模型分析（视觉理解）
                value:
                  model: gpt-5.4
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: 这张图片里有什么？请详细描述
                        - type: image_url
                          image_url:
                            url: >-
                              https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg
      responses:
        '200':
          $ref: '#/components/responses/ChatCompletionSuccess'
        '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:
    SimpleChatRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
          description: 模型名称，如 gpt-5.4、deepseek-chat、claude-sonnet-4-6 等
          example: gpt-5.4
        messages:
          type: array
          description: 对话消息列表
          items:
            type: object
            required:
              - role
              - content
            properties:
              role:
                type: string
                description: 消息发送者的角色
                enum:
                  - system
                  - user
                  - assistant
              content:
                type: string
                description: 消息内容
        stream:
          type: boolean
          description: 是否流式返回响应
          default: false
        temperature:
          type: number
          description: 采样温度 (0-2)
          minimum: 0
          maximum: 2
        max_tokens:
          type: integer
          description: 最大生成token数
        top_p:
          type: number
          description: 核采样参数 (0-1)
          minimum: 0
          maximum: 1
    ChatCompletionResponse:
      type: object
      properties:
        id:
          type: string
          description: 唯一补全ID
          example: chatcmpl-abc123
        object:
          type: string
          description: 对象类型
          enum:
            - chat.completion
        created:
          type: integer
          description: 创建时间戳
          example: 1757165031
        model:
          type: string
          description: 使用的模型
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
                description: 选项索引
                example: 0
              message:
                type: object
                properties:
                  role:
                    type: string
                    example: assistant
                  content:
                    type: string
                    example: Hello! How can I help you today?
              finish_reason:
                type: string
                description: 生成停止原因
                enum:
                  - stop
                  - length
                  - content_filter
                example: stop
        usage:
          type: object
          description: 用量统计
          properties:
            prompt_tokens:
              type: integer
              description: 提示token数
              example: 10
            completion_tokens:
              type: integer
              description: 补全token数
              example: 50
            total_tokens:
              type: integer
              description: 总token数
              example: 60
    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:
    ChatCompletionSuccess:
      description: 对话补全响应
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ChatCompletionResponse'
    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`

````