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

# GPT-5.1 - 完整参数文档

> - 使用 OpenAI SDK 格式调用 GPT-5.1 系列模型
- 同步处理模式，实时响应
- **可用模型**：gpt-5.1（基础版）、gpt-5.1-chat（对话优化版）、gpt-5.1-thinking（推理增强版）
- **文本对话**：支持单轮或多轮上下文对话
- **系统提示词**：自定义 AI 角色和行为
- **多模态输入**：支持文本 + 图片混合输入
- **工具调用**：支持 Function Calling
- **推理输出**：gpt-5.1-thinking 模型返回 reasoning_content 字段，展示思维过程

<Note>
  **BaseURL 说明**：默认 BaseURL 为 `https://direct.evolink.ai`，对文本模型支持更好，支持长连接；`https://api.evolink.ai` 是多模态主力地址，对文本模型作为备用地址使用。
</Note>


## OpenAPI

````yaml cn/api-manual/language-series/gpt-5-1/gpt-5-1-api.json POST /v1/chat/completions
openapi: 3.1.0
info:
  title: GPT-5.1 完整 API 参考文档
  description: GPT-5.1 系列模型聊天接口的完整 API 参考，包含所有参数和高级功能
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://direct.evolink.ai
    description: 生产环境（推荐）
  - url: https://api.evolink.ai
    description: 备用地址
security:
  - bearerAuth: []
tags:
  - name: 聊天补全
    description: AI 聊天补全相关接口
paths:
  /v1/chat/completions:
    post:
      tags:
        - 聊天补全
      summary: GPT-5.1 聊天接口
      description: |-
        - 使用 OpenAI SDK 格式调用 GPT-5.1 系列模型
        - 同步处理模式，实时响应
        - **可用模型**：gpt-5.1（基础版）、gpt-5.1-chat（对话优化版）、gpt-5.1-thinking（推理增强版）
        - **文本对话**：支持单轮或多轮上下文对话
        - **系统提示词**：自定义 AI 角色和行为
        - **多模态输入**：支持文本 + 图片混合输入
        - **工具调用**：支持 Function Calling
        - **推理输出**：gpt-5.1-thinking 模型返回 reasoning_content 字段，展示思维过程
      operationId: createChatCompletion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
            examples:
              simple_text:
                summary: 单轮文本对话
                value:
                  model: gpt-5.1
                  messages:
                    - role: user
                      content: 请介绍一下你自己
                  temperature: 1
              multi_turn:
                summary: 多轮对话（上下文理解）
                value:
                  model: gpt-5.1
                  messages:
                    - role: user
                      content: 什么是 Python？
                    - role: assistant
                      content: Python 是一种高级编程语言...
                    - role: user
                      content: 它有什么优势？
                  temperature: 1
              system_prompt:
                summary: 使用系统提示词
                value:
                  model: gpt-5.1
                  messages:
                    - role: system
                      content: 你是一个专业的 AI 助手，提供安全、有帮助且准确的回答。
                    - role: user
                      content: 1+1 等于多少？
                  temperature: 1
              vision:
                summary: 多模态输入（文本 + 图片）
                value:
                  model: gpt-5.1
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: 请详细描述这张图片中的场景和主要元素。
                        - type: image_url
                          image_url:
                            url: >-
                              data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==
                  temperature: 1
              tool_use:
                summary: 工具调用（Function Calling）
                value:
                  model: gpt-5.1
                  messages:
                    - role: user
                      content: 今天北京的天气怎么样？
                  tools:
                    - type: function
                      function:
                        name: get_weather
                        description: 获取指定城市的当前天气信息
                        parameters:
                          type: object
                          properties:
                            location:
                              type: string
                              description: 城市名称，如：北京、上海
                          required:
                            - location
                  temperature: 1
      responses:
        '200':
          description: 聊天补全成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
        '400':
          description: 请求参数无效
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 400
                  message: 请求参数无效
                  type: invalid_request_error
        '401':
          description: 认证失败，令牌无效或已过期
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 401
                  message: 令牌无效或已过期
                  type: authentication_error
        '402':
          description: 额度不足，请充值
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 402
                  message: 额度不足
                  type: insufficient_quota_error
                  fallback_suggestion: https://evolink.ai/dashboard/billing
        '429':
          description: 请求频率超限
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 429
                  message: 请求频率超限
                  type: rate_limit_error
                  fallback_suggestion: 请等待 60 秒后重试
        '500':
          description: 服务器内部错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 500
                  message: 服务器内部错误
                  type: internal_server_error
                  fallback_suggestion: 请稍后重试
components:
  schemas:
    ChatCompletionRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
          description: |-
            用于聊天补全的模型名称

            - **gpt-5.1**：基础模型，适用于通用任务
            - **gpt-5.1-chat**：对话优化版，针对会话场景进行优化
            - **gpt-5.1-thinking**：推理增强版，支持思维链输出（返回 reasoning_content 字段）
          enum:
            - gpt-5.1
            - gpt-5.1-chat
            - gpt-5.1-thinking
          example: gpt-5.1
        messages:
          type: array
          description: 对话消息列表，支持多轮对话和多模态输入
          items:
            $ref: '#/components/schemas/Message'
          minItems: 1
        stream:
          type: boolean
          description: |-
            是否启用流式响应

            - `true`：流式响应，实时逐块返回内容
            - `false`：等待完整响应后一次性返回
          default: false
          example: false
        max_tokens:
          type: integer
          description: 生成响应的最大 token 数量
          minimum: 1
          example: 2000
        temperature:
          type: number
          description: |-
            采样温度，控制输出的随机性

            - 较低值（如 0.2）：输出更确定、更聚焦
            - 较高值（如 1.5）：输出更随机、更有创意
          minimum: 0
          maximum: 2
          default: 1
          example: 1
        top_p:
          type: number
          description: |-
            核采样参数

            - 控制从累积概率最高的 token 中进行采样
            - 例如 0.9 表示从累积概率前 90% 的 token 中采样
          minimum: 0
          maximum: 1
          default: 1
          example: 0.9
        frequency_penalty:
          type: number
          description: |-
            频率惩罚系数，取值范围 -2.0 到 2.0

            - 正值会根据 token 在文本中的出现频率进行惩罚，降低重复内容的概率
          minimum: -2
          maximum: 2
          default: 0
          example: 0
        presence_penalty:
          type: number
          description: |-
            存在惩罚系数，取值范围 -2.0 到 2.0

            - 正值会根据 token 是否已出现在文本中进行惩罚，鼓励模型讨论新话题
          minimum: -2
          maximum: 2
          default: 0
          example: 0
        stop:
          oneOf:
            - type: string
              description: 单个停止词
            - type: array
              description: 停止词列表，最多 4 个
              items:
                type: string
              maxItems: 4
          description: 停止序列，生成内容遇到这些序列时将停止
        tools:
          type: array
          description: 用于 Function Calling 的工具列表
          items:
            $ref: '#/components/schemas/Tool'
    ChatCompletionResponse:
      type: object
      properties:
        id:
          type: string
          description: 本次聊天补全的唯一标识符
          example: chatcmpl-abc123
        model:
          type: string
          description: 实际使用的模型名称
          example: gpt-5.1
        object:
          type: string
          enum:
            - chat.completion
          description: 响应对象类型
          example: chat.completion
        created:
          type: integer
          description: 响应创建时间（Unix 时间戳）
          example: 1698999496
        choices:
          type: array
          description: 生成的补全选项列表
          items:
            $ref: '#/components/schemas/Choice'
        usage:
          $ref: '#/components/schemas/Usage'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
              description: HTTP 状态错误码
            message:
              type: string
              description: 错误信息
            type:
              type: string
              description: 错误类型
            fallback_suggestion:
              type: string
              description: 错误处理建议
    Message:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          description: |-
            消息角色

            - `user`：用户消息
            - `assistant`：AI 助手消息
            - `system`：系统提示词
          enum:
            - user
            - assistant
            - system
          example: user
        content:
          oneOf:
            - type: string
              description: 纯文本消息内容
              example: 请介绍一下你自己
            - type: array
              description: 多模态消息内容，支持文本和图片混合输入
              items:
                $ref: '#/components/schemas/ContentPart'
          description: 消息内容
    Tool:
      type: object
      required:
        - type
        - function
      properties:
        type:
          type: string
          enum:
            - function
          description: 工具类型
        function:
          type: object
          required:
            - name
            - description
            - parameters
          properties:
            name:
              type: string
              description: 函数名称
              example: get_weather
            description:
              type: string
              description: 函数功能描述
              example: 获取指定城市的当前天气信息
            parameters:
              type: object
              description: 函数参数定义
    Choice:
      type: object
      properties:
        index:
          type: integer
          description: 当前选项的索引
          example: 0
        message:
          $ref: '#/components/schemas/AssistantMessage'
        finish_reason:
          type: string
          description: 生成停止的原因
          enum:
            - stop
            - length
            - tool_calls
            - content_filter
          example: stop
    Usage:
      type: object
      description: Token 使用量统计
      properties:
        prompt_tokens:
          type: integer
          description: 输入的 token 数量
          example: 8
        completion_tokens:
          type: integer
          description: 输出的 token 数量
          example: 292
        total_tokens:
          type: integer
          description: 总 token 使用量
          example: 300
    ContentPart:
      oneOf:
        - $ref: '#/components/schemas/TextContent'
        - $ref: '#/components/schemas/ImageContent'
    AssistantMessage:
      type: object
      properties:
        role:
          type: string
          description: 消息发送者角色
          enum:
            - assistant
          example: assistant
        content:
          type: string
          description: AI 生成的响应内容
          example: 你好！有什么我可以帮助你的吗？
        reasoning_content:
          type: string
          description: |-
            推理过程内容（仅 gpt-5.1-thinking 模型返回）

            **说明**：
            - 展示模型的思考和推理过程
            - 帮助理解模型如何得出最终答案
          example: 让我一步一步思考这个问题...
    TextContent:
      title: 文本内容
      type: object
      required:
        - type
        - text
      properties:
        type:
          type: string
          enum:
            - text
          description: 内容类型
        text:
          type: string
          description: 文本内容
          example: 请详细描述这张图片
    ImageContent:
      title: 图片内容
      type: object
      required:
        - type
        - image_url
      properties:
        type:
          type: string
          enum:
            - image_url
          description: 内容类型
        image_url:
          type: object
          required:
            - url
          properties:
            url:
              type: string
              format: uri
              description: |-
                图片 URL 或 Base64 编码

                **格式说明**：
                - URL 格式：`https://example.com/image.png`
                - Base64 格式：`data:image/<格式>;base64,<Base64 编码>`
              example: data:image/png;base64,iVBORw0KGgo...
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |-
        ##所有接口均需要使用Bearer Token进行认证##

        **获取 API Key：**

        访问 [API Key 管理页面](https://evolink.ai/dashboard/keys) 获取您的 API Key

        **使用时在请求头中添加：**
        ```
        Authorization: Bearer YOUR_API_KEY
        ```

````