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

# Gemini 3.5 Flash - OpenAI SDK - 完整参数文档

> - 使用 OpenAI SDK 格式调用 gemini-3.5-flash 模型
- 同步处理模式，实时返回对话内容
- **纯文本对话**：单轮或多轮上下文对话，可参考示例代码中simple_text、multi_turn示例
- **系统提示词**：自定义 AI 的角色和行为，可参考示例代码中system_prompt示例
- **多模态输入**：支持文本 + 图像混合输入，可参考示例代码中vision、multi_image示例

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


## OpenAPI

````yaml cn/api-manual/language-series/gemini-3.5-flash/openai-sdk/openai-sdk-reference.json POST /v1/chat/completions
openapi: 3.1.0
info:
  title: gemini-3.5-flash 完整参数文档
  description: gemini-3.5-flash 对话接口的完整 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: gemini-3.5-flash 对话接口
      description: |-
        - 使用 OpenAI SDK 格式调用 gemini-3.5-flash 模型
        - 同步处理模式，实时返回对话内容
        - **纯文本对话**：单轮或多轮上下文对话，可参考示例代码中simple_text、multi_turn示例
        - **系统提示词**：自定义 AI 的角色和行为，可参考示例代码中system_prompt示例
        - **多模态输入**：支持文本 + 图像混合输入，可参考示例代码中vision、multi_image示例
      operationId: createChatCompletion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
            examples:
              simple_text:
                summary: 单轮文本对话
                value:
                  model: gemini-3.5-flash
                  messages:
                    - role: user
                      content: 请介绍一下你自己
              multi_turn:
                summary: 多轮对话（上下文理解）
                value:
                  model: gemini-3.5-flash
                  messages:
                    - role: user
                      content: 什么是Python？
                    - role: assistant
                      content: Python是一种高级编程语言...
                    - role: user
                      content: 它有什么优点？
              system_prompt:
                summary: 使用系统提示词
                value:
                  model: gemini-3.5-flash
                  messages:
                    - role: system
                      content: 你是一个专业的Python编程助手，用简洁的语言回答问题。
                    - role: user
                      content: 如何读取文件？
              vision:
                summary: 多模态输入（文本 + 图像）
                value:
                  model: gemini-3.5-flash
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: 请详细描述这张图片中的场景和主要元素。
                        - type: image_url
                          image_url:
                            url: https://example.com/image.png
              multi_image:
                summary: 多图片输入
                value:
                  model: gemini-3.5-flash
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: 对比这两张图片的区别
                        - type: image_url
                          image_url:
                            url: https://example.com/image1.png
                        - type: image_url
                          image_url:
                            url: https://example.com/image2.png
      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: Invalid request parameters
                  type: invalid_request_error
        '401':
          description: 未认证、Token无效或过期
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 401
                  message: Invalid or expired token
                  type: authentication_error
        '402':
          description: 配额不足、需要充值
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 402
                  message: Insufficient quota
                  type: insufficient_quota_error
                  fallback_suggestion: https://evolink.ai/dashboard/billing
        '403':
          description: 无权限访问
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 403
                  message: Access denied for this model
                  type: permission_error
                  param: model
        '404':
          description: 资源不存在
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 404
                  message: Specified model not found
                  type: not_found_error
                  param: model
                  fallback_suggestion: gemini-3.5-flash
        '413':
          description: 请求体过大
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 413
                  message: Image file too large
                  type: request_too_large_error
                  param: content
                  fallback_suggestion: compress image to under 10MB
        '429':
          description: 请求频率超限
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 429
                  message: Rate limit exceeded
                  type: rate_limit_error
                  fallback_suggestion: retry after 60 seconds
        '500':
          description: 服务器内部错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 500
                  message: Internal server error
                  type: internal_server_error
                  fallback_suggestion: try again later
        '502':
          description: 上游服务错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 502
                  message: Upstream AI service unavailable
                  type: upstream_error
                  fallback_suggestion: try different model
        '503':
          description: 服务暂时不可用
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 503
                  message: Service temporarily unavailable
                  type: service_unavailable_error
                  fallback_suggestion: retry after 30 seconds
components:
  schemas:
    ChatCompletionRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
          description: 对话模型名称
          enum:
            - gemini-3.5-flash
          default: gemini-3.5-flash
          example: gemini-3.5-flash
        messages:
          type: array
          description: 对话消息列表，支持多轮对话和多模态输入
          items:
            $ref: '#/components/schemas/Message'
          minItems: 1
        stream:
          type: boolean
          description: |-
            是否以流式方式返回响应

            - `true`: 流式返回，逐块实时返回内容
            - `false`: 等待完整响应后一次性返回
          example: false
          default: false
        max_completion_tokens:
          type: integer
          nullable: true
          description: 生成回复的最大 completion token 数量，对应 Gemini 的 maxOutputTokens。
          minimum: 1
          example: 2000
          maximum: 65536
        max_tokens:
          type: integer
          description: 生成回复的最大 token 数量，兼容旧版 OpenAI 参数。
          minimum: 1
          example: 2000
          maximum: 65536
        temperature:
          type: number
          description: |-
            采样温度，控制输出的随机性

            **说明**:
            - 较低值(如 0.2): 更确定、更聚焦的输出
            - 较高值(如 1.5): 更随机、更有创意的输出
          minimum: 0
          maximum: 2
          example: 0.7
          default: 1
        top_p:
          type: number
          description: |-
            核采样(Nucleus Sampling)参数

            **说明**:
            - 控制从累积概率前多少的token中采样
            - 例如 0.9 表示从累积概率达到90%的token中选择
            - 默认值: 1.0（考虑所有token）

            **建议**: 不要同时调整 temperature 和 top_p
          minimum: 0
          maximum: 1
          example: 0.9
          default: 1
        frequency_penalty:
          type: number
          nullable: true
          description: 重复 token 惩罚系数，范围 -2 到 2，对应 Gemini 的 frequencyPenalty。
          minimum: -2
          maximum: 2
          default: 0
          example: 0
        presence_penalty:
          type: number
          nullable: true
          description: 已出现 token 惩罚系数，范围 -2 到 2，对应 Gemini 的 presencePenalty。
          minimum: -2
          maximum: 2
          default: 0
          example: 0
        stop:
          nullable: true
          description: 停止序列，支持字符串或字符串数组，对应 Gemini 的 stopSequences。
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        'n':
          type: integer
          nullable: true
          description: 生成候选数量
          minimum: 1
          default: 1
          example: 1
        reasoning_effort:
          type: string
          nullable: true
          description: 限制思考工作量。Gemini 3 仅支持 low/high 思考层级，medium 会映射到更高一级，且不支持 none。
          enum:
            - low
            - medium
            - high
          default: medium
          example: medium
        seed:
          type: integer
          nullable: true
          description: 用于尽可能复现输出的随机种子，对应 Gemini 的 seed。
          example: 12345
        logprobs:
          type: boolean
          nullable: true
          description: 是否返回 token 的 logprob 信息，对应 Gemini 的 responseLogprobs。
          example: true
          default: false
        top_logprobs:
          type: integer
          nullable: true
          description: 每个 token 返回的 top logprob 数量，对应 Gemini 的 logprobs。
          minimum: 0
          maximum: 20
          example: 5
        response_format:
          description: >-
            响应格式设置，支持 JSON mode 与 JSON Schema，对应 Gemini 的
            responseMimeType、responseSchema 和 responseJsonSchema。
          oneOf:
            - type: object
              required:
                - type
              properties:
                type:
                  type: string
                  enum:
                    - json_object
                  example: json_object
                  description: 响应格式类型。
            - type: object
              required:
                - type
              properties:
                type:
                  type: string
                  enum:
                    - json_schema
                  example: json_schema
                  description: 响应格式类型。
                json_schema:
                  type: object
                  nullable: true
                  description: JSON Schema 定义。
        stream_options:
          type: object
          nullable: true
          description: 流式响应的选项。当 stream 为 true 时，可设置此字段
          properties:
            include_usage:
              type: boolean
              nullable: true
              description: 模型流式输出时，是否在输出结束前输出本次请求的 token 用量信息
              default: false
              example: true
        tools:
          type: array
          nullable: true
          description: 工具定义列表，用于 Function Calling
          items:
            $ref: '#/components/schemas/Tool'
        tool_choice:
          description: 控制工具调用行为
          oneOf:
            - type: string
              enum:
                - none
                - auto
                - required
            - $ref: '#/components/schemas/ToolChoiceObject'
        extra_body:
          type: object
          nullable: true
          description: Gemini 扩展参数
          properties:
            google:
              type: object
              nullable: true
              description: Gemini 专属扩展参数
              properties:
                cached_content:
                  type: string
                  nullable: true
                  description: 对应 Gemini 的内容缓存
                thinking_config:
                  type: object
                  nullable: true
                  description: 对应 Gemini 的 ThinkingConfig
    ChatCompletionResponse:
      type: object
      properties:
        id:
          type: string
          description: 对话完成的唯一标识符
          example: chatcmpl-20251010015944503180122WJNB8Eid
        model:
          type: string
          description: 实际使用的模型名称
          example: gemini-3.5-flash
        object:
          type: string
          enum:
            - chat.completion
          description: 响应类型
          example: chat.completion
        created:
          type: integer
          description: 创建时间戳
          example: 1760032810
        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: 错误类型
            param:
              type: string
              description: 相关参数名称
            fallback_suggestion:
              type: string
              description: 错误时的建议
    Message:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          description: |-
            消息角色

            - `user`: 用户消息
            - `assistant`: AI助手消息（用于多轮对话）
            - `system`: 系统提示词（设定AI的角色和行为）
          enum:
            - user
            - assistant
            - system
            - tool
          example: user
        content:
          description: |-
            消息内容。支持两种格式：

            **1. 纯文本字符串**：可直接传入字符串，如 `"content":"请介绍一下自己"`

            **2. 对象数组**（支持文本输入、多模态输入）：见下方示例结构
          oneOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/ContentPart'
        tool_call_id:
          type: string
          nullable: true
          description: 工具调用 ID，仅在 role=tool 时使用
    Tool:
      type: object
      required:
        - type
        - function
      description: 工具定义，用于 Function Calling
      properties:
        type:
          type: string
          enum:
            - function
          description: 工具类型，目前仅支持 function
        function:
          type: object
          required:
            - name
          description: 函数定义
          properties:
            name:
              type: string
              description: 调用的函数名称
            description:
              type: string
              description: 函数的描述，模型会使用它来判断是否调用该工具
            parameters:
              type: object
              description: 函数请求参数，以 JSON Schema 格式描述
    ToolChoiceObject:
      type: object
      required:
        - type
        - function
      description: 指定待调用工具的范围
      properties:
        type:
          type: string
          enum:
            - function
          description: 调用的类型
        function:
          type: object
          required:
            - name
          properties:
            name:
              type: string
              description: 待调用工具的名称
    Choice:
      type: object
      properties:
        index:
          type: integer
          description: 选择的索引
          example: 0
        message:
          $ref: '#/components/schemas/AssistantMessage'
        logprobs:
          type: object
          nullable: true
          description: 该选项的 token logprob 信息。
          properties:
            content:
              type: array
              nullable: true
              description: 每个输出 token 的 logprob 详情。
              items:
                $ref: '#/components/schemas/LogProbToken'
        finish_reason:
          type: string
          description: 完成原因
          enum:
            - stop
            - length
            - content_filter
            - tool_calls
          example: stop
    Usage:
      type: object
      description: Token 使用统计信息
      properties:
        prompt_tokens:
          type: integer
          description: 输入内容的 token 数量
          example: 13
        completion_tokens:
          type: integer
          description: 输出内容的 token 数量
          example: 1891
        total_tokens:
          type: integer
          description: 总 token 数量
          example: 1904
        prompt_tokens_details:
          type: object
          description: 输入 token 详细信息
          properties:
            cached_tokens:
              type: integer
              description: 击中缓存的 token 数量
              example: 0
            text_tokens:
              type: integer
              description: 文本 token 数量
              example: 13
            audio_tokens:
              type: integer
              description: 音频 token 数量
              example: 0
            image_tokens:
              type: integer
              description: 图像 token 数量
              example: 0
        completion_tokens_details:
          type: object
          description: 输出 token 详细信息
          properties:
            text_tokens:
              type: integer
              description: 文本 token 数量
              example: 0
            audio_tokens:
              type: integer
              description: 音频 token 数量
              example: 0
            reasoning_tokens:
              type: integer
              description: 推理 token 数量
              example: 1480
        input_tokens:
          type: integer
          description: 输入 token 数量（兼容字段）
          example: 0
        output_tokens:
          type: integer
          description: 输出 token 数量（兼容字段）
          example: 0
        input_tokens_details:
          type: object
          nullable: true
          description: 输入 token 详细信息（兼容字段）
          example: null
    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: >-
            你好！很高兴能向你介绍自己。


            我是一个大型语言模型（Large Language Model），由 Google 训练和开发。


            简单来说，你可以把我理解为一个经过海量文本数据训练、能够理解和生成人类语言的"智能大脑"。我的核心能力是处理和生成文本，具体来说，我能做以下这些事情：


            **1. 信息查询与知识解答**

            我可以像一部"会说话的百科全书"，为你解答各种问题，无论是科学知识、历史事件，还是生活常识。


            **2. 创意写作与文本生成**

            我可以根据你的要求，创作各种类型的文本，比如：

            *   **写作**：诗歌、故事、剧本、邮件、演讲稿、广告文案等。

            *   **规划**：为你制定旅行计划、学习大纲、活动方案等。

            *   **头脑风暴**：和你一起碰撞想法，激发新的创意。


            **3. 翻译与语言处理**

            我精通多种语言，可以为你提供快速、流畅的翻译服务。同时，我也可以帮你润色、校对、总结或改写文本，让你的表达更清晰、更专业。


            **4. 编程与代码辅助**

            我可以编写代码片段、解释代码逻辑、调试错误，或者将代码从一种编程语言"翻译"成另一种，是程序员的好帮手。


            **5. 逻辑分析与推理**

            我可以帮助你分析复杂的问题，梳理逻辑链条，并根据你提供的信息进行推理和总结。


            ---


            **总而言之**，我的目标是成为一个强大而有用的工具，通过自然语言交流的方式，帮助你更高效地获取信息、完成任务和激发创意。


            **需要记住的是：**
            我是一个人工智能，我的知识来源于我所学习的数据，并且可能不是最新的。有时我也可能会犯错，所以对于非常重要的信息，建议你进行再次核实。
          nullable: true
        tool_calls:
          type: array
          nullable: true
          description: 工具调用列表
          items:
            $ref: '#/components/schemas/ToolCall'
    LogProbToken:
      type: object
      description: 单个 token 的 logprob 详情。
      properties:
        token:
          type: string
          description: token 文本。
        logprob:
          type: number
          description: token 的 logprob 值。
        bytes:
          type: array
          nullable: true
          description: token 的 UTF-8 字节序列。
          items:
            type: integer
        top_logprobs:
          type: array
          nullable: true
          description: 同一位置的候选 token 及其 logprob。
          items:
            $ref: '#/components/schemas/TopLogProb'
    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地址

                **限制**:
                - 单张图片最大: `10MB`
                - 支持格式: `.jpeg`, `.jpg`, `.png`, `.webp`
                - URL要求: 必须公网可访问，一般以图片扩展名结尾
              example: https://example.com/image.png
    ToolCall:
      type: object
      required:
        - id
        - type
        - function
      properties:
        id:
          type: string
          description: 工具调用 ID
        type:
          type: string
          enum:
            - function
          description: 工具调用类型
        function:
          type: object
          required:
            - name
            - arguments
          properties:
            name:
              type: string
              description: 函数名称
            arguments:
              type: string
              description: 函数参数，JSON 字符串
    TopLogProb:
      type: object
      description: 候选 token 的 logprob 详情。
      properties:
        token:
          type: string
          description: 候选 token 文本。
        logprob:
          type: number
          description: 候选 token 的 logprob 值。
        bytes:
          type: array
          nullable: true
          description: 候选 token 的 UTF-8 字节序列。
          items:
            type: integer
  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
        ```

````