> ## 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 2.5 Flash - OpenAI SDK - API Reference

> - Call gemini-2.5-flash model using OpenAI SDK format
- Synchronous processing mode, returns conversation content in real-time
- **Plain text conversation**: Single-turn or multi-turn contextual dialogue, see simple_text and multi_turn examples in code samples
- **System prompt**: Customize AI role and behavior, see system_prompt example in code samples
- **Multimodal input**: Supports text + image mixed input, see vision and multi_image examples in code samples

<Note>
  **BaseURL**: The default BaseURL is `https://direct.evolink.ai`, which has better support for text models and long-lived connections. `https://api.evolink.ai` is the primary endpoint for multimodal services and serves as a fallback address for text models.
</Note>


## OpenAPI

````yaml /en/api-manual/language-series/gemini-2.5-flash/openai-sdk/openai-sdk-reference.json POST /v1/chat/completions
openapi: 3.1.0
info:
  title: gemini-2.5-flash Full Reference
  description: >-
    Complete API reference for gemini-2.5-flash chat interface, including all
    parameters and advanced features
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://direct.evolink.ai
    description: Production (recommended)
  - url: https://api.evolink.ai
    description: Alternative URL
security:
  - bearerAuth: []
tags:
  - name: Chat Completion
    description: AI chat completion related APIs
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat Completion
      summary: gemini-2.5-flash Chat API
      description: >-
        - Call gemini-2.5-flash model using OpenAI SDK format

        - Synchronous processing mode, returns conversation content in real-time

        - **Plain text conversation**: Single-turn or multi-turn contextual
        dialogue, see simple_text and multi_turn examples in code samples

        - **System prompt**: Customize AI role and behavior, see system_prompt
        example in code samples

        - **Multimodal input**: Supports text + image mixed input, see vision
        and multi_image examples in code samples
      operationId: createChatCompletion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
            examples:
              simple_text:
                summary: Single-turn text conversation
                value:
                  model: gemini-2.5-flash
                  messages:
                    - role: user
                      content: Please introduce yourself
              multi_turn:
                summary: Multi-turn conversation (context understanding)
                value:
                  model: gemini-2.5-flash
                  messages:
                    - role: user
                      content: What is Python?
                    - role: assistant
                      content: Python is a high-level programming language...
                    - role: user
                      content: What are its advantages?
              system_prompt:
                summary: Using system prompt
                value:
                  model: gemini-2.5-flash
                  messages:
                    - role: system
                      content: >-
                        You are a professional Python programming assistant,
                        answering questions concisely.
                    - role: user
                      content: How to read a file?
              vision:
                summary: Multimodal input (text + image)
                value:
                  model: gemini-2.5-flash
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: >-
                            Please describe the scene and main elements in this
                            image in detail.
                        - type: image_url
                          image_url:
                            url: https://example.com/image.png
              multi_image:
                summary: Multiple images input
                value:
                  model: gemini-2.5-flash
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: Compare the differences between these two images
                        - 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: Chat completion generated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 400
                  message: Invalid request parameters
                  type: invalid_request_error
        '401':
          description: Unauthorized, invalid or expired token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 401
                  message: Invalid or expired token
                  type: authentication_error
        '402':
          description: Insufficient quota, recharge required
          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: Access denied
          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: Resource not found
          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-2.5-flash
        '413':
          description: Request body too large
          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: Rate limit exceeded
          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: Internal server error
          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: Upstream service error
          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: Service temporarily unavailable
          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: Chat model name
          enum:
            - gemini-2.5-flash
          default: gemini-2.5-flash
          example: gemini-2.5-flash
        messages:
          type: array
          description: >-
            List of chat messages, supports multi-turn dialogue and multimodal
            input
          items:
            $ref: '#/components/schemas/Message'
          minItems: 1
        stream:
          type: boolean
          description: |-
            Whether to return response in streaming mode

            - `true`: Streaming return, receives content in real-time chunks
            - `false`: Returns complete response at once
          example: false
          default: false
        max_completion_tokens:
          type: integer
          nullable: true
          description: >-
            Maximum number of completion tokens for the generated response,
            corresponding to Gemini's maxOutputTokens.
          minimum: 1
          example: 2000
          maximum: 65536
        max_tokens:
          type: integer
          description: >-
            Maximum number of tokens for the generated response, compatible with
            the legacy OpenAI parameter.
          minimum: 1
          example: 2000
          maximum: 65536
        temperature:
          type: number
          description: |-
            Sampling temperature, controls output randomness

            **Description**:
            - Lower values (e.g., 0.2): More deterministic, focused output
            - Higher values (e.g., 1.5): More random, creative output
          minimum: 0
          maximum: 2
          example: 0.7
          default: 1
        top_p:
          type: number
          description: >-
            Nucleus Sampling parameter


            **Description**:

            - Controls sampling from tokens with cumulative probability

            - For example, 0.9 means selecting from tokens with cumulative
            probability up to 90%

            - Default: 1.0 (considers all tokens)


            **Recommendation**: Do not adjust temperature and top_p
            simultaneously
          minimum: 0
          maximum: 1
          example: 0.9
          default: 1
        frequency_penalty:
          type: number
          nullable: true
          description: >-
            Frequency penalty coefficient. Range: -2.0 to 2.0. Corresponds to
            Gemini's frequencyPenalty.
          minimum: -2
          maximum: 2
          default: 0
          example: 0
        presence_penalty:
          type: number
          nullable: true
          description: >-
            Presence penalty coefficient. Range: -2.0 to 2.0. Corresponds to
            Gemini's presencePenalty.
          minimum: -2
          maximum: 2
          default: 0
          example: 0
        stop:
          nullable: true
          description: >-
            Stop sequences. Supports a string or string array, corresponding to
            Gemini's stopSequences.
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        'n':
          type: integer
          nullable: true
          description: Number of generated candidates.
          minimum: 1
          default: 1
          example: 1
        reasoning_effort:
          type: string
          nullable: true
          description: >-
            Limits reasoning effort. Gemini 2.5 Flash and Flash Lite support
            none to disable thinking; low/medium/high map to different reasoning
            budgets.
          enum:
            - none
            - low
            - medium
            - high
          default: medium
          example: medium
        seed:
          type: integer
          nullable: true
          description: >-
            Random seed used to make output as reproducible as possible,
            corresponding to Gemini's seed.
          example: 12345
        logprobs:
          type: boolean
          nullable: true
          description: >-
            Whether to return token logprob information, corresponding to
            Gemini's responseLogprobs.
          example: true
          default: false
        top_logprobs:
          type: integer
          nullable: true
          description: >-
            Number of top logprob values returned for each token, corresponding
            to Gemini's logprobs.
          minimum: 0
          maximum: 20
          example: 5
        response_format:
          description: >-
            Response format settings, supporting JSON mode and JSON Schema,
            corresponding to Gemini's responseMimeType, responseSchema and
            responseJsonSchema.
          oneOf:
            - type: object
              required:
                - type
              properties:
                type:
                  type: string
                  enum:
                    - json_object
                  example: json_object
                  description: Response format type.
            - type: object
              required:
                - type
              properties:
                type:
                  type: string
                  enum:
                    - json_schema
                  example: json_schema
                  description: Response format type.
                json_schema:
                  type: object
                  nullable: true
                  description: JSON Schema definition.
        stream_options:
          type: object
          nullable: true
          description: Streaming response options. Can be set when stream is true.
          properties:
            include_usage:
              type: boolean
              nullable: true
              description: >-
                Whether to include token usage for this request before streaming
                finishes.
              default: false
              example: true
        tools:
          type: array
          nullable: true
          description: List of tool definitions for Function Calling.
          items:
            $ref: '#/components/schemas/Tool'
        tool_choice:
          description: Controls tool-calling behavior.
          oneOf:
            - type: string
              enum:
                - none
                - auto
                - required
            - $ref: '#/components/schemas/ToolChoiceObject'
        extra_body:
          type: object
          nullable: true
          description: Gemini extension parameters.
          properties:
            google:
              type: object
              nullable: true
              description: Gemini-specific extension parameters.
              properties:
                cached_content:
                  type: string
                  nullable: true
                  description: Gemini content cache.
                thinking_config:
                  type: object
                  nullable: true
                  description: Gemini ThinkingConfig.
    ChatCompletionResponse:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the chat completion
          example: chatcmpl-20251010015944503180122WJNB8Eid
        model:
          type: string
          description: Model name actually used
          example: gemini-2.5-flash
        object:
          type: string
          enum:
            - chat.completion
          description: Response type
          example: chat.completion
        created:
          type: integer
          description: Creation timestamp
          example: 1760032810
        choices:
          type: array
          description: List of chat completion choices
          items:
            $ref: '#/components/schemas/Choice'
        usage:
          $ref: '#/components/schemas/Usage'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
              description: HTTP status error code
            message:
              type: string
              description: Error description
            type:
              type: string
              description: Error type
            param:
              type: string
              description: Related parameter name
            fallback_suggestion:
              type: string
              description: Suggestion when error occurs
    Message:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          description: |-
            Message role

            - `user`: User message
            - `assistant`: AI assistant message (for multi-turn conversation)
            - `system`: System prompt (sets AI's role and behavior)
          enum:
            - user
            - assistant
            - system
            - tool
          example: user
        content:
          description: >-
            Message content. Supports two formats:


            **1. Plain text string**: You can pass a string directly, e.g.
            `"content":"Please introduce yourself"`


            **2. Object array** (supports text and multimodal input): see the
            example structure below
          oneOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/ContentPart'
        tool_call_id:
          type: string
          nullable: true
          description: Tool call ID, used only when role=tool.
    Tool:
      type: object
      required:
        - type
        - function
      description: Tool definition for Function Calling.
      properties:
        type:
          type: string
          enum:
            - function
          description: Tool type. Currently only function is supported.
        function:
          type: object
          required:
            - name
          description: Function definition.
          properties:
            name:
              type: string
              description: Name of the function to call.
            description:
              type: string
              description: >-
                Function description used by the model to decide whether to call
                the tool.
            parameters:
              type: object
              description: Function request parameters described in JSON Schema format.
    ToolChoiceObject:
      type: object
      required:
        - type
        - function
      description: Scope of the tool to call.
      properties:
        type:
          type: string
          enum:
            - function
          description: Call type.
        function:
          type: object
          required:
            - name
          properties:
            name:
              type: string
              description: Name of the tool to call.
    Choice:
      type: object
      properties:
        index:
          type: integer
          description: Choice index
          example: 0
        message:
          $ref: '#/components/schemas/AssistantMessage'
        logprobs:
          type: object
          nullable: true
          description: Token logprob information for this choice.
          properties:
            content:
              type: array
              nullable: true
              description: Logprob details for each output token.
              items:
                $ref: '#/components/schemas/LogProbToken'
        finish_reason:
          type: string
          description: Finish reason
          enum:
            - stop
            - length
            - content_filter
            - tool_calls
          example: stop
    Usage:
      type: object
      description: Token usage statistics
      properties:
        prompt_tokens:
          type: integer
          description: Number of tokens in input content
          example: 13
        completion_tokens:
          type: integer
          description: Number of tokens in output content
          example: 1891
        total_tokens:
          type: integer
          description: Total number of tokens
          example: 1904
        prompt_tokens_details:
          type: object
          description: Detailed input token information
          properties:
            cached_tokens:
              type: integer
              description: Number of cached tokens hit
              example: 0
            text_tokens:
              type: integer
              description: Number of text tokens
              example: 13
            audio_tokens:
              type: integer
              description: Number of audio tokens
              example: 0
            image_tokens:
              type: integer
              description: Number of image tokens
              example: 0
        completion_tokens_details:
          type: object
          description: Detailed completion token information.
          properties:
            text_tokens:
              type: integer
              description: Number of text tokens.
              example: 0
            audio_tokens:
              type: integer
              description: Number of audio tokens.
              example: 0
            reasoning_tokens:
              type: integer
              description: Number of reasoning tokens.
              example: 1480
        input_tokens:
          type: integer
          description: Input token count (compatibility field).
          example: 0
        output_tokens:
          type: integer
          description: Output token count (compatibility field).
          example: 0
        input_tokens_details:
          type: object
          nullable: true
          description: Detailed input token information (compatibility field).
          example: null
    ContentPart:
      oneOf:
        - $ref: '#/components/schemas/TextContent'
        - $ref: '#/components/schemas/ImageContent'
    AssistantMessage:
      type: object
      properties:
        role:
          type: string
          description: Message sender role
          enum:
            - assistant
          example: assistant
        content:
          type: string
          description: AI response message content
          example: >-
            Hello! I'm pleased to introduce myself.


            I'm a Large Language Model, trained and developed by Google.


            Simply put, you can think of me as a "smart brain" that has been
            trained on massive amounts of text data and is able to understand
            and generate human language. My core capability is processing and
            generating text. Specifically, I can do the following:


            **1. Information Query & Knowledge Answering**

            I can act like a "talking encyclopedia," answering various
            questions, whether they're about scientific knowledge, historical
            events, or everyday facts.


            **2. Creative Writing & Text Generation**

            I can create various types of text based on your requirements, such
            as:

            *   **Writing**: Poetry, stories, scripts, emails, speeches,
            advertising copy, etc.

            *   **Planning**: Travel plans, study outlines, event proposals,
            etc.

            *   **Brainstorming**: Working with you to generate new ideas and
            spark creativity.


            **3. Translation & Language Processing**

            I'm proficient in multiple languages and can provide fast, fluent
            translation services. I can also help you polish, proofread,
            summarize, or rewrite text to make your expression clearer and more
            professional.


            **4. Programming & Code Assistance**

            I can write code snippets, explain code logic, debug errors, or
            "translate" code from one programming language to another, making me
            a helpful companion for programmers.


            **5. Logical Analysis & Reasoning**

            I can help you analyze complex problems, organize logical chains,
            and make inferences and summaries based on the information you
            provide.


            ---


            **In summary**, my goal is to be a powerful and useful tool that
            helps you obtain information more efficiently, complete tasks, and
            spark creativity through natural language communication.


            **Remember:** I'm an artificial intelligence, my knowledge comes
            from the data I've learned, and it may not be the most up-to-date.
            Sometimes I may also make mistakes, so for very important
            information, I recommend you verify it again.
          nullable: true
        tool_calls:
          type: array
          nullable: true
          description: List of tool calls.
          items:
            $ref: '#/components/schemas/ToolCall'
    LogProbToken:
      type: object
      description: Logprob details for a single token.
      properties:
        token:
          type: string
          description: Token text.
        logprob:
          type: number
          description: Logprob value of the token.
        bytes:
          type: array
          nullable: true
          description: UTF-8 byte sequence of the token.
          items:
            type: integer
        top_logprobs:
          type: array
          nullable: true
          description: Candidate tokens at the same position and their logprobs.
          items:
            $ref: '#/components/schemas/TopLogProb'
    TextContent:
      title: Text Content
      type: object
      required:
        - type
        - text
      properties:
        type:
          type: string
          enum:
            - text
          description: Content type
        text:
          type: string
          description: Text content
          example: Please describe this image in detail
    ImageContent:
      title: Image Content
      type: object
      required:
        - type
        - image_url
      properties:
        type:
          type: string
          enum:
            - image_url
          description: Content type
        image_url:
          type: object
          required:
            - url
          properties:
            url:
              type: string
              format: uri
              description: >-
                Image URL address


                **Limits**:

                - Maximum size per image: `10MB`

                - Supported formats: `.jpeg`, `.jpg`, `.png`, `.webp`

                - URL requirements: Must be publicly accessible, generally ends
                with image extension
              example: https://example.com/image.png
    ToolCall:
      type: object
      required:
        - id
        - type
        - function
      properties:
        id:
          type: string
          description: Tool call ID.
        type:
          type: string
          enum:
            - function
          description: Tool call type.
        function:
          type: object
          required:
            - name
            - arguments
          properties:
            name:
              type: string
              description: Function name.
            arguments:
              type: string
              description: Function arguments as a JSON string.
    TopLogProb:
      type: object
      description: Logprob details for a candidate token.
      properties:
        token:
          type: string
          description: Candidate token text.
        logprob:
          type: number
          description: Logprob value of the candidate token.
        bytes:
          type: array
          nullable: true
          description: UTF-8 byte sequence of the candidate token.
          items:
            type: integer
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        ##All APIs require Bearer Token authentication##


        **Get API Key:**


        Visit [API Key Management Page](https://evolink.ai/dashboard/keys) to
        get your API Key


        **Add to request header:**

        ```

        Authorization: Bearer YOUR_API_KEY

        ```

````