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

# Gemini All-Model API - Native API Format

> Select the Gemini text model to call via `{model}` in the path (see the reference table for the `model` parameter for all available values).

- Uses the Google native API format and returns conversation content synchronously
- **Plain text / multimodal input**: mixed text + image / audio / video input
- **Streaming**: replace `generateContent` in the path with `streamGenerateContent` (append `?alt=sse` to receive SSE)

---

**Model specs and differences**
- **3.8 behavior**: compared with 3.7, it improves software engineering, agents, multi-step reasoning, and multimodal accuracy; it may consume more reasoning / output tokens, especially at `high`. Use `low` for latency-sensitive workloads, the default `medium` for general use, and `high` for complex code, long video, or multi-step reasoning.
- **Gemini 4 Argon behavior**: thinking is controlled only through `thinkingConfig.thinkingLevel`, with `low` / `medium` / `high` available; when omitted, the model determines how much to think. `minimal` is not supported (returns 400; use `low` instead), and neither is `thinkingBudget` (returns 400). `temperature` / `topP` outside the valid range return 400. In multi-turn function calling, the `thoughtSignature` returned in the previous turn must be sent back unchanged, otherwise the request returns 400. Input supports text / images / audio / video / PDF.
- **Sampling parameters** `temperature` / `topP` / `topK`: consistent across the entire Gemini 3.x series, custom values do not affect the output; `topK` is ignored and has no effect, and a `temperature` / `topP` value outside the valid range returns a 400.
- **Thinking control**: the Gemini 3.x / 4 series uses `thinkingConfig.thinkingLevel` (see the `thinkingLevel` parameter for the levels supported and the default of each model); the Gemini 2.5 series uses `thinkingConfig.thinkingBudget` (an integer, `0`=off). The two are mutually exclusive. `gemini-3.8-flash` / `gemini-3.7-flash` and the Pro models do not support `minimal`; a passed value is automatically downgraded to `low`.
- **Function calling**: for Gemini 3.x, the `FunctionResponse` must echo back the `id` and `name` matching the corresponding `FunctionCall`, otherwise the request errors.
- **Last-turn role**: the `role` of the last message must not be `model` (Gemini 3.5+ will error).
- **Token limits**: `gemini-3.8-flash` / `gemini-3.7-flash` / `gemini-3.6-flash` / `gemini-3.5-flash-lite` have a 1,048,576-token context and a maximum output of 65,536. `gemini-4-argon` shares a 1,048,576-token context across input, thinking, and output; each streaming request returns up to 65,536 tokens, or 32,768 non-streaming, including thinking and the answer. Use continuation for longer output; cumulative thinking and answer tokens are limited to the context space remaining after input. See “Long-output continuation” on this page. Other models follow their own specifications.
- **Gemini 2.5 IDs**: from 2026-10-19, `gemini-2.5-pro` / `gemini-2.5-flash` / `gemini-2.5-flash-lite` are served by `gemini-3.8-flash` / `gemini-3.5-flash-lite` / `gemini-3.1-flash-lite-preview` and billed at their rates; responses show the new model ID, and parameter behavior follows the new model. `thinkingBudget` is converted to a level (see the `thinkingBudget` parameter).

> [!TIP]
>
> **Streaming**: Replace `generateContent` with `streamGenerateContent` in the URL. Keep the request body unchanged; responses arrive in chunks. Append `?alt=sse` to request SSE format.

> [!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.

## Long-output continuation (Gemini 4 Argon)

A single `gemini-4-argon` streaming request returns up to 65,536 tokens; a non-streaming request returns up to 32,768. Both limits include thinking and answer tokens. Use continuation requests for longer output. Input, thinking, and the answer share a 1,048,576-token context window, so cumulative thinking and answer tokens can only use the space remaining after the input. Only the native API supports continuation; the OpenAI-compatible format does not.

| | Streaming `streamGenerateContent` | Non-streaming `generateContent` |
| - | - | - |
| Maximum output per request | 65,536 | 32,768 |
| Continuation token at completion | In the final chunk: `candidates[0].continuationToken` | `candidates[0].continuationToken` |

Set the client read timeout to 1,200 seconds (20 minutes) for long responses. This is a client configuration recommendation, not a guarantee of server request duration.

Procedure:

1. Set `generationConfig.maxOutputTokens` above the per-request cap: above 65,536 for streaming or 32,768 for non-streaming. The parameter accepts up to 1,048,576, but actual output is still limited by the shared context. This is the cumulative thinking and answer budget across all continuation requests.
2. When `candidates[0].finishReason` is `CONTINUATION`, generation is not finished. The same candidate includes a `continuationToken`.
3. Resend the original request with the same `contents`, `systemInstruction`, `tools`, and `generationConfig`. Add only a top-level `continuationToken` containing the latest returned token.
4. Repeat step 3 only while `finishReason` is `CONTINUATION`; stop for any other finish reason. `STOP` means normal completion, and `MAX_TOKENS` means the cumulative budget is exhausted. Each response contains only newly generated content; concatenate it in order.

> [!WARNING]
>
> * Do not append partial output to `contents` or send a new prompt such as “continue”.
> * A request may spend its entire budget on thinking and return empty answer text. Continue if the finish reason is `CONTINUATION`.
> * `MAX_TOKENS` may also include a `continuationToken`. To resume, manually raise `maxOutputTokens` and resend the original request with the latest token. Keeping the exhausted budget returns 400. See “Resume after budget exhaustion” below.
> * For multi-turn conversations, wait for `STOP` and then add the combined answer as a single `model` message to the history.

### Examples

First request:

```bash theme={null}
curl -X POST "https://direct.evolink.ai/v1beta/models/gemini-4-argon:generateContent" \
  -H "Authorization: Bearer $EVOLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      { "role": "user", "parts": [{ "text": "Write a complete design document for a Rust async runtime, including the architecture, scheduler, I/O driver, timers, and complete example code." }] }
    ],
    "generationConfig": {
      "maxOutputTokens": 262144,
      "thinkingConfig": { "thinkingLevel": "high" }
    }
  }'
```

If generation reaches the per-request cap with budget remaining, the response may look like this (only continuation-related fields are shown):

```json theme={null}
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "# Rust async runtime design\n\n## 1. Architecture\n…"
          }
        ]
      },
      "finishReason": "CONTINUATION",
      "continuationToken": "<a long opaque string; preserve it exactly>"
    }
  ]
}
```

If the previous response ended with `CONTINUATION`, send the same request again with a top-level `continuationToken`:

```bash theme={null}
curl -X POST "https://direct.evolink.ai/v1beta/models/gemini-4-argon:generateContent" \
  -H "Authorization: Bearer $EVOLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      { "role": "user", "parts": [{ "text": "Write a complete design document for a Rust async runtime, including the architecture, scheduler, I/O driver, timers, and complete example code." }] }
    ],
    "generationConfig": {
      "maxOutputTokens": 262144,
      "thinkingConfig": { "thinkingLevel": "high" }
    },
    "continuationToken": "<continuationToken from the previous response>"
  }'
```

This Python function automatically handles `CONTINUATION` and returns on completion or budget exhaustion. It preserves the latest token and does not raise the budget automatically on `MAX_TOKENS`:

```python theme={null}
import os
from copy import deepcopy

import requests

URL = "https://direct.evolink.ai/v1beta/models/gemini-4-argon:generateContent"
HEADERS = {"Authorization": f"Bearer {os.environ['EVOLINK_API_KEY']}"}


def generate_with_continuation(body):
    request_body = deepcopy(body)
    pieces = []
    while True:
        # Client read timeout: 1,200 seconds; this does not guarantee a 20-minute server connection.
        resp = requests.post(URL, headers=HEADERS, json=request_body, timeout=1200)
        resp.raise_for_status()
        candidates = resp.json().get("candidates", [])
        if not candidates:
            raise RuntimeError("No candidates in the response; check promptFeedback.")
        candidate = candidates[0]
        for part in candidate.get("content", {}).get("parts", []):
            if not part.get("thought"):
                pieces.append(part.get("text", ""))
        reason = candidate.get("finishReason")
        token = candidate.get("continuationToken")
        if reason == "CONTINUATION":
            if not token:
                raise RuntimeError("The response requests continuation but has no continuationToken.")
            request_body["continuationToken"] = token  # Keep all other fields unchanged
            continue
        return {
            "text": "".join(pieces),
            "finishReason": reason,
            "continuationToken": token,
        }


body = {
    "contents": [
        {"role": "user", "parts": [{"text": "Write a complete design document for a Rust async runtime, including the architecture, scheduler, I/O driver, timers, and complete example code."}]}
    ],
    "generationConfig": {"maxOutputTokens": 262144, "thinkingConfig": {"thinkingLevel": "high"}},
}

result = generate_with_continuation(body)
print(result["text"])
print("finishReason:", result["finishReason"])
if result["finishReason"] == "MAX_TOKENS":
    print("The cumulative output budget is exhausted. If a token was returned, you can manually raise maxOutputTokens to resume.")
```

### Resume after budget exhaustion

This example reuses `generate_with_continuation`, `URL`, and `HEADERS` above. It generates a number list with a small budget, then explicitly raises the total budget from 64 to 2,048. Keep the original `contents` and other settings unchanged; add the token and raise the budget to resume at the cutoff.

```python theme={null}
body = {
    "contents": [
        {"role": "user", "parts": [{"text": "Output integers 1 through 100, one per line. Start immediately."}]}
    ],
    "generationConfig": {"maxOutputTokens": 64, "thinkingConfig": {"thinkingLevel": "low"}},
}

first = generate_with_continuation(body)
print(first["text"], end="")
if first["finishReason"] == "MAX_TOKENS" and first["continuationToken"]:
    body["continuationToken"] = first["continuationToken"]
    body["generationConfig"]["maxOutputTokens"] = 2048  # The caller explicitly raises the cumulative budget
    resumed = generate_with_continuation(body)
    print(resumed["text"], end="")
    print("\nfinishReason:", resumed["finishReason"])
else:
    print("\nfinishReason:", first["finishReason"])
```

For streaming, read the final chunk containing `finishReason`: on `CONTINUATION`, resend the latest token with unchanged settings; on `MAX_TOKENS`, manually raise the cumulative budget if you want to resume; `STOP` means normal completion.

### Billing and errors

* Each request is billed separately. Continuation requests count the original input and all previously generated content as input again. Portions that hit implicit caching are billed at the cache rate.
* Each response’s `usageMetadata` covers only that request. Add usage across requests for the total. Streaming usage is cumulative within a request: use only the final `usageMetadata`, rather than adding cumulative values from the same stream.
* For the native API, the output pre-authorization estimate uses the smaller of `maxOutputTokens` and 65,536, including for non-streaming requests; input is estimated separately. Non-streaming output is actually capped at 32,768 per request, so budgets above 32,768 may reserve more than an estimate based on the actual per-request cap. Final charges use the response usage.
* Invalid tokens return 400. A well-formed but invalid token may return `Invalid continuation token.`, while malformed tokens may produce another parameter error. Other models ignore `continuationToken`.
* Resuming after `MAX_TOKENS` with a token but without raising the exhausted `maxOutputTokens` also returns 400.


## OpenAPI

````yaml en/api-manual/language-series/gemini/native-api/native-api-reference.json POST /v1beta/models/{model}:generateContent
openapi: 3.1.0
info:
  title: Gemini All-Model API (Native API Format)
  description: >-
    A unified native API for all Gemini text models. Select the specific model
    via model in the path. Supports text and multimodal (image / audio / video)
    input.
  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: Content Generation
    description: Gemini AI content generation related APIs
paths:
  /v1beta/models/{model}:generateContent:
    post:
      tags:
        - Content Generation
      summary: Gemini Content Generation (All Models)
      description: >-
        Select the Gemini text model to call via `{model}` in the path (see the
        reference table for the `model` parameter for all available values).


        - Uses the Google native API format and returns conversation content
        synchronously

        - **Plain text / multimodal input**: mixed text + image / audio / video
        input

        - **Streaming**: replace `generateContent` in the path with
        `streamGenerateContent` (append `?alt=sse` to receive SSE)


        ---


        **Model specs and differences**

        - **3.8 behavior**: compared with 3.7, it improves software engineering,
        agents, multi-step reasoning, and multimodal accuracy; it may consume
        more reasoning / output tokens, especially at `high`. Use `low` for
        latency-sensitive workloads, the default `medium` for general use, and
        `high` for complex code, long video, or multi-step reasoning.

        - **Gemini 4 Argon behavior**: thinking is controlled only through
        `thinkingConfig.thinkingLevel`, with `low` / `medium` / `high`
        available; when omitted, the model determines how much to think.
        `minimal` is not supported (returns 400; use `low` instead), and neither
        is `thinkingBudget` (returns 400). `temperature` / `topP` outside the
        valid range return 400. In multi-turn function calling, the
        `thoughtSignature` returned in the previous turn must be sent back
        unchanged, otherwise the request returns 400. Input supports text /
        images / audio / video / PDF.

        - **Sampling parameters** `temperature` / `topP` / `topK`: consistent
        across the entire Gemini 3.x series, custom values do not affect the
        output; `topK` is ignored and has no effect, and a `temperature` /
        `topP` value outside the valid range returns a 400.

        - **Thinking control**: the Gemini 3.x / 4 series uses
        `thinkingConfig.thinkingLevel` (see the `thinkingLevel` parameter for
        the levels supported and the default of each model); the Gemini 2.5
        series uses `thinkingConfig.thinkingBudget` (an integer, `0`=off). The
        two are mutually exclusive. `gemini-3.8-flash` / `gemini-3.7-flash` and
        the Pro models do not support `minimal`; a passed value is automatically
        downgraded to `low`.

        - **Function calling**: for Gemini 3.x, the `FunctionResponse` must echo
        back the `id` and `name` matching the corresponding `FunctionCall`,
        otherwise the request errors.

        - **Last-turn role**: the `role` of the last message must not be `model`
        (Gemini 3.5+ will error).

        - **Token limits**: `gemini-3.8-flash` / `gemini-3.7-flash` /
        `gemini-3.6-flash` / `gemini-3.5-flash-lite` have a 1,048,576-token
        context and a maximum output of 65,536. `gemini-4-argon` shares a
        1,048,576-token context across input, thinking, and output; each
        streaming request returns up to 65,536 tokens, or 32,768 non-streaming,
        including thinking and the answer. Use continuation for longer output;
        cumulative thinking and answer tokens are limited to the context space
        remaining after input. See “Long-output continuation” on this page.
        Other models follow their own specifications.

        - **Gemini 2.5 IDs**: from 2026-10-19, `gemini-2.5-pro` /
        `gemini-2.5-flash` / `gemini-2.5-flash-lite` are served by
        `gemini-3.8-flash` / `gemini-3.5-flash-lite` /
        `gemini-3.1-flash-lite-preview` and billed at their rates; responses
        show the new model ID, and parameter behavior follows the new model.
        `thinkingBudget` is converted to a level (see the `thinkingBudget`
        parameter).
      operationId: geminiGenerateContent
      parameters:
        - name: model
          in: path
          required: true
          description: >-
            Select the Gemini text model to call:


            | Model ID | Series | Positioning |

            |---|---|---|

            | `gemini-4-argon` | 4 Argon | Long reports and large coding tasks;
            up to 65,536 tokens per streaming request / 32,768 non-streaming;
            native API continuation is limited by the shared context |

            | `gemini-3.8-flash` | 3.8 Flash | Enhanced software engineering /
            agents / multi-step reasoning / multimodal accuracy |

            | `gemini-3.7-flash` | 3.7 Flash | Pro-level agentic / code
            generation / terminal execution |

            | `gemini-3.6-flash` | 3.6 Flash | Multi-step orchestration / code
            refactoring / general reasoning |

            | `gemini-3.5-flash` | 3.5 Flash | General-purpose Flash |

            | `gemini-3.5-flash-lite` | 3.5 Flash-Lite | Low cost / high
            throughput / lightweight agent |

            | `gemini-3.1-pro-preview` | 3.1 Pro (Preview) | Advanced reasoning
            |

            | `gemini-3.1-pro-preview-customtools` | 3.1 Pro · CustomTools |
            Advanced reasoning + custom tools |

            | `gemini-3.1-flash-lite-preview` | 3.1 Flash-Lite (Preview) | Low
            cost |

            | `gemini-3-pro-preview` | 3.0 Pro (Preview) | Advanced reasoning |

            | `gemini-3-flash-preview` | 3.0 Flash (Preview) | General-purpose
            Flash |

            | `gemini-2.5-pro` | 2.5 Pro | Legacy ID; from 2026-10-19 served by
            `gemini-3.8-flash` and billed at its rates |

            | `gemini-2.5-flash` | 2.5 Flash | Legacy ID; from 2026-10-19 served
            by `gemini-3.5-flash-lite` and billed at its rates |

            | `gemini-2.5-flash-lite` | 2.5 Flash-Lite | Legacy ID; from
            2026-10-19 served by `gemini-3.1-flash-lite-preview` and billed at
            its rates |
          schema:
            type: string
            enum:
              - gemini-4-argon
              - gemini-3.8-flash
              - gemini-3.7-flash
              - gemini-3.6-flash
              - gemini-3.5-flash
              - gemini-3.5-flash-lite
              - gemini-3.1-pro-preview
              - gemini-3.1-pro-preview-customtools
              - gemini-3.1-flash-lite-preview
              - gemini-3-pro-preview
              - gemini-3-flash-preview
              - gemini-2.5-pro
              - gemini-2.5-flash
              - gemini-2.5-flash-lite
            example: gemini-3.6-flash
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateContentRequest'
            examples:
              google_search:
                summary: Web search (Google Search grounding)
                value:
                  contents:
                    - role: user
                      parts:
                        - text: What is the weather in Shanghai today?
                  tools:
                    - googleSearch: {}
              simple_text:
                summary: Single-turn text conversation
                value:
                  contents:
                    - role: user
                      parts:
                        - text: Please introduce yourself
              multi_turn:
                summary: Multi-turn conversation (context understanding)
                value:
                  contents:
                    - role: user
                      parts:
                        - text: What is Python?
                    - role: model
                      parts:
                        - text: Python is a high-level programming language...
                    - role: user
                      parts:
                        - text: What are its advantages?
              audio_analysis:
                summary: Audio analysis
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Please analyze this song audio and answer: 1. Song
                            source and artist 2. Song mood 3. Complete lyrics
                            output
                        - fileData:
                            mimeType: audio/mp3
                            fileUri: https://example.com/audio.mp3
              image_understanding:
                summary: Image understanding
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Please describe the scene and main elements in this
                            image in detail
                        - fileData:
                            mimeType: image/jpeg
                            fileUri: https://example.com/image.jpg
              multi_file:
                summary: Multi-file input (mixed)
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Compare the relationship between these two images
                            and this audio
                        - fileData:
                            mimeType: image/jpeg
                            fileUri: https://example.com/image1.jpg
                        - fileData:
                            mimeType: image/png
                            fileUri: https://example.com/image2.png
                        - fileData:
                            mimeType: audio/mp3
                            fileUri: https://example.com/audio.mp3
              long_decode_continuation:
                summary: >-
                  Long-output continuation: resend the token (gemini-4-argon
                  only)
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Write a complete design document for a Rust async
                            runtime, including the architecture, scheduler, I/O
                            driver, timers, and complete example code.
                  generationConfig:
                    maxOutputTokens: 262144
                    thinkingConfig:
                      thinkingLevel: high
                  continuationToken: >-
                    Copy candidates[0].continuationToken from the previous
                    response exactly
      responses:
        '200':
          description: >-
            Content generated successfully


            **Response format description**:

            - When using the `generateContent` endpoint, returns
            `GenerateContentResponse` (returns complete response at once)

            - When using the `streamGenerateContent` endpoint, returns
            `StreamGenerateContentResponse` (streaming response, returns content
            in chunks)
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/GenerateContentResponse'
                  - $ref: '#/components/schemas/StreamGenerateContentResponse'
        '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/credits
        '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
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 404
                  message: Model not found
                  type: not_found_error
        '413':
          description: Request body too large, file too large
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 413
                  message: Request body too large
                  type: request_too_large_error
                  fallback_suggestion: reduce file size
        '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 again later
        '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:
    GenerateContentRequest:
      type: object
      required:
        - contents
      properties:
        contents:
          type: array
          description: >-
            List of conversation contents, supports multi-turn dialogue and
            multimodal input
          items:
            $ref: '#/components/schemas/Content'
          minItems: 1
        systemInstruction:
          $ref: '#/components/schemas/Content'
          description: System instruction (optional), mainly text content
        tools:
          type: array
          items:
            type: object
          description: >-
            Tools the model may call. Three kinds are supported:


            - `functionDeclarations`: function calling

            - `codeExecution`: code execution

            - `googleSearch`: web search (Google Search grounding). Pass
            `{"googleSearch": {}}` (camelCase; snake_case `google_search`
            returns 400); available on all Gemini text models.
            `candidates[].groundingMetadata` in the response carries the queries
            and sources; billed per call
          example:
            - googleSearch: {}
        toolConfig:
          type: object
          description: Tool calling configuration (optional)
        safetySettings:
          type: array
          items:
            type: object
          description: Safety settings list (optional)
        generationConfig:
          $ref: '#/components/schemas/GenerationConfig'
          description: Generation configuration parameters (optional)
        continuationToken:
          type: string
          description: >-
            Long-output continuation token (`gemini-4-argon` only). Put the
            latest `candidates[0].continuationToken` at the top level of the
            request. Preserve the original `contents`, `systemInstruction`, and
            `tools`; do not append partial output.


            - `CONTINUATION`: keep every generation setting unchanged and resend
            the token.

            - `MAX_TOKENS`: a token may also be returned; manually raise
            cumulative `maxOutputTokens` before resuming, leaving other settings
            unchanged. Keeping the exhausted budget returns 400.

            - Invalid tokens return 400.

            - Other models ignore this field.


            See [Native API
            reference](/en/api-manual/language-series/gemini/native-api/native-api-reference),
            under “Long-output continuation”.
        cachedContent:
          type: string
          description: Cached content name, in the form cachedContents/{cachedContent}
    GenerateContentResponse:
      title: Sync Response
      type: object
      properties:
        candidates:
          type: array
          description: List of candidate responses
          items:
            $ref: '#/components/schemas/Candidate'
        promptFeedback:
          $ref: '#/components/schemas/PromptFeedback'
        usageMetadata:
          $ref: '#/components/schemas/UsageMetadata'
        modelVersion:
          type: string
          description: Model version
          example: gemini-3.6-flash
        responseId:
          type: string
          description: Response ID
          example: l-LoaPu0BPmo1dkP6ZPHiQc
    StreamGenerateContentResponse:
      title: Stream Response
      type: object
      description: |-
        Stream response chunk

        **Intermediate chunk**:
        ```json
        {
          "candidates": [
            {
              "content": {
                "role": "model",
                "parts": [{ "text": "Partial text..." }]
              }
            }
          ],
          "usageMetadata": {
            "trafficType": "ON_DEMAND"
          },
          "modelVersion": "gemini-3.6-flash",
          "createTime": "2025-10-10T10:40:23.072315Z",
          "responseId": "xxx"
        }
        ```

        **Last chunk**:
        ```json
        {
          "candidates": [
            {
              "content": {
                "role": "model",
                "parts": [{ "text": "Final text fragment" }]
              },
              "finishReason": "STOP"
            }
          ],
          "usageMetadata": {
            "promptTokenCount": 4,
            "candidatesTokenCount": 522,
            "totalTokenCount": 2191,
            "trafficType": "ON_DEMAND"
          },
          "modelVersion": "gemini-3.6-flash",
          "createTime": "2025-10-10T10:40:23.072315Z",
          "responseId": "xxx"
        }
        ```
      properties:
        candidates:
          type: array
          description: >-
            List of candidate responses (streaming mode does not include index
            and safetyRatings)
          items:
            $ref: '#/components/schemas/StreamCandidate'
        usageMetadata:
          type: object
          description: >-
            Usage statistics (intermediate chunks only have trafficType, last
            chunk contains complete statistics)
          properties:
            promptTokenCount:
              type: integer
              description: Number of tokens in input content (last chunk only)
              example: 4
            candidatesTokenCount:
              type: integer
              description: Number of tokens in output content (last chunk only)
              example: 522
            totalTokenCount:
              type: integer
              description: Total number of tokens (last chunk only)
              example: 2191
            trafficType:
              type: string
              description: Traffic type
              example: ON_DEMAND
            cachedContentTokenCount:
              type: integer
              description: Number of cached content tokens (last chunk only)
              example: 0
        modelVersion:
          type: string
          description: Model version
          example: gemini-3.6-flash
        createTime:
          type: string
          format: date-time
          description: Creation time
          example: '2025-10-10T10:40:23.072315Z'
        responseId:
          type: string
          description: Response ID
          example: l-LoaPu0BPmo1dkP6ZPHiQc
    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
            fallback_suggestion:
              type: string
              description: Suggestion when error occurs
    Content:
      type: object
      required:
        - role
        - parts
      properties:
        role:
          type: string
          description: |-
            Content role

            - `user`: User input
            - `model`: AI model's reply (for multi-turn conversation)
          enum:
            - user
            - model
          example: user
        parts:
          type: array
          description: >-
            Content parts list, supports text, file data, inline data, function
            calls, function responses, and code execution results
          items:
            $ref: '#/components/schemas/Part'
          minItems: 1
    GenerationConfig:
      type: object
      description: Generation configuration parameters
      properties:
        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


            **Consistent across the entire Gemini 3.x series** (does not vary by
            model): custom values within the valid range do not affect the
            output; a value outside this parameter's valid range returns a 400
            rather than being silently ignored.
          minimum: 0
          maximum: 2
          example: 0.7
        maxOutputTokens:
          type: integer
          description: >-
            Maximum generated tokens, including thinking and the answer.


            - A small value may truncate the response.

            - `gemini-3.8-flash` / `gemini-3.7-flash` / `gemini-3.6-flash` /
            `gemini-3.5-flash-lite` support up to 65,536 tokens; other models
            follow their own specifications.

            - For `gemini-4-argon`, this is the cumulative budget across
            continuation requests. The parameter accepts up to 1,048,576, but
            input, thinking, and output share that context window, so actual
            output is limited by remaining space. A single streaming request
            returns up to 65,536 tokens; non-streaming returns up to 32,768. Use
            token-based continuation for longer output.

            - `CONTINUATION` means the per-request cap was reached with budget
            left; `MAX_TOKENS` means the cumulative budget is exhausted. If a
            token is returned, manually raise the budget to resume.
          minimum: 1
          example: 2000
        topP:
          type: number
          description: >-
            Nucleus Sampling parameter


            **Description**:

            - Controls sampling from tokens within the top cumulative
            probability

            - For example, 0.9 means selecting from tokens whose cumulative
            probability reaches 90%

            - Default: 0.95


            **Recommendation**: Do not adjust temperature and topP
            simultaneously


            **Consistent across the entire Gemini 3.x series** (does not vary by
            model): custom values within the valid range do not affect the
            output; a value outside this parameter's valid range returns a 400
            rather than being silently ignored.
          minimum: 0
          maximum: 1
          example: 0.9
        topK:
          type: integer
          description: >-
            Top-K sampling parameter


            **Description**:

            - For example, 10 means limiting each sampling step to only consider
            the 10 most probable tokens

            - Smaller values make the output more focused

            - Default: 64


            This parameter is ignored and has no effect on any Gemini 3.x model.
          minimum: 1
          example: 40
        responseMimeType:
          type: string
          description: >-
            MIME type of generated candidate content, for example text/plain or
            application/json
          example: application/json
        responseSchema:
          type: object
          description: >-
            Output schema definition for generated content (JSON mode /
            structured output)
        responseJsonSchema:
          type: object
          description: >-
            JSON Schema for generated content (useful for more complex
            structured output)
        thinkingConfig:
          type: object
          description: >-
            Thinking configuration that controls the model's reasoning behavior.


            - **Gemini 3.x / 4 series**: use `thinkingLevel` (see the
            `thinkingLevel` parameter for the levels supported and the default
            of each model)

            - **Gemini 2.5 series**: use `thinkingBudget`


            `thinkingLevel` and `thinkingBudget` are mutually exclusive; passing
            both will cause an error.
          properties:
            thinkingLevel:
              type: string
              enum:
                - minimal
                - low
                - medium
                - high
              description: >-
                Thinking level, controlling reasoning depth (case-insensitive):

                - `minimal`: near-zero thinking, aimed at high-throughput /
                low-latency scenarios (classification, extraction, routing,
                etc.)

                - `low`: less thinking, suitable for simple tasks

                - `medium`: balanced quality and speed, suitable for moderately
                complex tasks

                - `high`: deep multi-step reasoning, suitable for complex
                reasoning, math, and coding


                **Supported by the Gemini 3.x / 4 series**, with different
                supported levels and defaults per model (the Gemini 2.5 series
                uses `thinkingBudget` instead):


                | Model | Supported levels | Default |

                |---|---|---|

                | `gemini-4-argon` | `low` / `medium` / `high` | Long reports
                and large coding tasks; up to 65,536 tokens per streaming
                request / 32,768 non-streaming; native API continuation is
                limited by the shared context |

                | `gemini-3.8-flash` | `low` / `medium` / `high` | `medium` |

                | `gemini-3.7-flash` | `low` / `medium` / `high` | `medium` |

                | `gemini-3.6-flash` | `minimal` / `low` / `medium` / `high` |
                `medium` |

                | `gemini-3.5-flash` | `minimal` / `low` / `medium` / `high` |
                `medium` |

                | `gemini-3.5-flash-lite` | `minimal` / `low` / `medium` /
                `high` | `minimal` |

                | `gemini-3.1-flash-lite-preview` | `minimal` / `low` / `medium`
                / `high` | `minimal` |

                | `gemini-3-flash-preview` | `minimal` / `low` / `medium` /
                `high` | `medium` |

                | `gemini-3.1-pro-preview` | `low` / `medium` / `high` | `high`
                |

                | `gemini-3.1-pro-preview-customtools` | `low` / `medium` /
                `high` | `high` |

                | `gemini-3-pro-preview` | `low` / `medium` / `high` | `high` |


                Passing a level a model does not support (e.g., passing
                `minimal` to a Pro model or to `gemini-3.8-flash` /
                `gemini-3.7-flash`) is automatically downgraded to `low` and
                does not raise an error.


                `gemini-4-argon` does not support `minimal`: passing it returns
                400; use `low` instead.
              example: minimal
            thinkingBudget:
              type: integer
              description: >-
                Thinking token budget, used by the **Gemini 2.5 series**
                (`gemini-2.5-flash` / `gemini-2.5-flash-lite` /
                `gemini-2.5-pro`): `0`=disable thinking, `-1`=dynamic budget, a
                positive integer=fixed budget (the exact range depends on the
                specific model). Mutually exclusive with `thinkingLevel`.
                `gemini-4-argon` does not support this parameter; passing it
                returns 400.


                From 2026-10-19, requests to the 2.5 IDs are served by newer
                models (see the `model` parameter), and the budget is converted
                to `thinkingLevel` using the table below. We recommend switching
                to `thinkingLevel`.


                | Legacy model (documented range) | New model | `thinkingBudget`
                → `thinkingLevel` |

                |---|---|---|

                | `gemini-2.5-pro` (128–32,768) | `gemini-3.8-flash` |
                128–11,007 → `low`; 11,008–21,888 → `medium`; 21,889–32,768 →
                `high` |

                | `gemini-2.5-flash` (0–24,576) | `gemini-3.5-flash-lite` | 0
                (thinking off) → `minimal`; 1–8,192 → `low`; 8,193–16,384 →
                `medium`; 16,385–24,576 → `high` |

                | `gemini-2.5-flash-lite` (512–24,576, or 0) |
                `gemini-3.1-flash-lite-preview` | 0 (thinking off) → `minimal`;
                512–8,533 → `low`; 8,534–16,554 → `medium`; 16,555–24,576 →
                `high` |


                Values outside the range are clamped to the nearest end of the
                table. `-1` (dynamic) uses the new model's default level (see
                `thinkingLevel`). The conversion applies only to requests that
                use the 2.5 model IDs; requests to the 3.x IDs are not changed.
              example: -1
    Candidate:
      type: object
      properties:
        content:
          $ref: '#/components/schemas/ContentResponse'
        finishReason:
          type: string
          description: >-
            Finish reason


            - `CONTINUATION`: `gemini-4-argon` only. The per-request cap was
            reached with cumulative budget remaining; resend the token with the
            original settings unchanged.

            - `MAX_TOKENS`: the cumulative output budget is exhausted.
            `gemini-4-argon` may also return a continuation token; manually
            raise `maxOutputTokens` before resuming.


            See [Native API
            reference](/en/api-manual/language-series/gemini/native-api/native-api-reference),
            under “Long-output continuation”.
          enum:
            - FINISH_REASON_UNSPECIFIED
            - STOP
            - CONTINUATION
            - MAX_TOKENS
            - SAFETY
            - RECITATION
            - LANGUAGE
            - OTHER
            - BLOCKLIST
            - PROHIBITED_CONTENT
            - SPII
            - MALFORMED_FUNCTION_CALL
            - IMAGE_SAFETY
            - IMAGE_PROHIBITED_CONTENT
            - IMAGE_OTHER
            - NO_IMAGE
            - IMAGE_RECITATION
            - UNEXPECTED_TOOL_CALL
            - TOO_MANY_TOOL_CALLS
            - MISSING_THOUGHT_SIGNATURE
          example: STOP
        continuationToken:
          type: string
          description: >-
            Long-output continuation token (`gemini-4-argon` only). For
            `CONTINUATION`, resend the original request with the latest token
            and unchanged generation settings. `MAX_TOKENS` may also return a
            token; manually raise the cumulative `maxOutputTokens` to resume.


            See [Native API
            reference](/en/api-manual/language-series/gemini/native-api/native-api-reference),
            under “Long-output continuation”.
        index:
          type: integer
          description: Candidate index
          example: 0
        safetyRatings:
          type: array
          nullable: true
          description: Safety ratings
          items:
            type: object
    PromptFeedback:
      type: object
      properties:
        safetyRatings:
          type: array
          nullable: true
          description: Prompt safety ratings
          items:
            type: object
    UsageMetadata:
      type: object
      description: Usage statistics
      properties:
        promptTokenCount:
          type: integer
          description: Number of tokens in input content
          example: 4
        candidatesTokenCount:
          type: integer
          description: Number of tokens in output content
          example: 611
        totalTokenCount:
          type: integer
          description: Total number of tokens
          example: 2422
        thoughtsTokenCount:
          type: integer
          description: Number of reasoning tokens
          example: 1807
        promptTokensDetails:
          type: array
          description: Detailed input token information (by modality)
          items:
            $ref: '#/components/schemas/TokenDetail'
        cachedContentTokenCount:
          type: integer
          description: Number of cached content tokens
          example: 0
    StreamCandidate:
      type: object
      description: Stream response candidate (more simplified than regular response)
      properties:
        content:
          $ref: '#/components/schemas/ContentResponse'
        finishReason:
          type: string
          description: >-
            Finish reason (included in the final chunk at completion)


            - `CONTINUATION`: `gemini-4-argon` only. The per-request cap was
            reached with cumulative budget remaining; resend the token with the
            original settings unchanged.

            - `MAX_TOKENS`: the cumulative output budget is exhausted.
            `gemini-4-argon` may also return a continuation token; manually
            raise `maxOutputTokens` before resuming.


            See [Native API
            reference](/en/api-manual/language-series/gemini/native-api/native-api-reference),
            under “Long-output continuation”.
          enum:
            - FINISH_REASON_UNSPECIFIED
            - STOP
            - CONTINUATION
            - MAX_TOKENS
            - SAFETY
            - RECITATION
            - LANGUAGE
            - OTHER
            - BLOCKLIST
            - PROHIBITED_CONTENT
            - SPII
            - MALFORMED_FUNCTION_CALL
            - IMAGE_SAFETY
            - IMAGE_PROHIBITED_CONTENT
            - IMAGE_OTHER
            - NO_IMAGE
            - IMAGE_RECITATION
            - UNEXPECTED_TOOL_CALL
            - TOO_MANY_TOOL_CALLS
            - MISSING_THOUGHT_SIGNATURE
          example: STOP
        continuationToken:
          type: string
          description: >-
            Long-output continuation token (`gemini-4-argon` only). For
            `CONTINUATION`, resend the original request with the latest token
            and unchanged generation settings. `MAX_TOKENS` may also return a
            token; manually raise the cumulative `maxOutputTokens` to resume.


            See [Native API
            reference](/en/api-manual/language-series/gemini/native-api/native-api-reference),
            under “Long-output continuation”. At completion, read the latest
            token from the final chunk containing `finishReason`.
    Part:
      oneOf:
        - $ref: '#/components/schemas/TextPart'
        - $ref: '#/components/schemas/FilePart'
        - $ref: '#/components/schemas/InlineDataPart'
        - $ref: '#/components/schemas/FunctionCallPart'
        - $ref: '#/components/schemas/FunctionResponsePart'
        - $ref: '#/components/schemas/ExecutableCodePart'
        - $ref: '#/components/schemas/CodeExecutionResultPart'
      description: >-
        Content part union type. The thoughtSignature returned by thinking
        models must be echoed back in the next turn.
    ContentResponse:
      type: object
      properties:
        role:
          type: string
          description: Response role
          enum:
            - model
          example: model
        parts:
          type: array
          description: >-
            Response content parts, supports text, inline data, function calls,
            function responses, and code execution results
          items:
            $ref: '#/components/schemas/Part'
    TokenDetail:
      type: object
      description: Token details (statistics by modality)
      properties:
        modality:
          type: string
          description: Content modality type
          enum:
            - MODALITY_UNSPECIFIED
            - TEXT
            - IMAGE
            - AUDIO
            - VIDEO
            - DOCUMENT
          example: TEXT
        tokenCount:
          type: integer
          description: Number of tokens for this modality
          example: 4
    TextPart:
      title: Text Input
      type: object
      required:
        - text
      properties:
        text:
          type: string
          description: Text content
          example: |-
            Hello! I'm pleased to introduce myself.

            I'm a large language model, trained and developed by Google...
        thought:
          type: boolean
          description: Whether this is thought content
        thoughtSignature:
          type: string
          description: Thought signature, must be echoed back in the next turn
          example: <Signature_A>
    FilePart:
      title: Multimodal Input
      type: object
      required:
        - fileData
      properties:
        fileData:
          type: object
          required:
            - mimeType
            - fileUri
          properties:
            mimeType:
              type: string
              description: |-
                File MIME type

                **Supported types**:

                **Image**:
                - `image/jpeg`, `image/png`
                - Maximum size per image: 10 MB

                **Audio**:
                - `audio/mp3`
                - Maximum size per file: 10 MB
                - Recommended duration: no more than 10 minutes

                **Video**:
                - `video/mp4`
                - Maximum size per file: 50 MB
                - Recommended duration: no more than 180 seconds

                **Document**:
                - `application/pdf`
                - Maximum size per file: 20 MB
              example: audio/mp3
            fileUri:
              type: string
              format: uri
              description: >-
                File URI address


                **Requirements**:

                - Must be a publicly accessible URL

                - URL should end with file extension (e.g., .mp3, .jpg) and
                should match the mimeType parameter
              example: https://example.com/audio.mp3
    InlineDataPart:
      title: Inline Data
      type: object
      required:
        - inlineData
      properties:
        inlineData:
          $ref: '#/components/schemas/BlobData'
        thought:
          type: boolean
          description: Whether this is thought content
        thoughtSignature:
          type: string
          description: Thought signature, must be echoed back in the next turn
          example: <Signature_A>
    FunctionCallPart:
      title: Function Call
      type: object
      required:
        - functionCall
      properties:
        functionCall:
          $ref: '#/components/schemas/FunctionCall'
        thought:
          type: boolean
          description: Whether this is thought content
        thoughtSignature:
          type: string
          description: Thought signature, must be echoed back in the next turn
          example: <Signature_A>
    FunctionResponsePart:
      title: Function Response
      type: object
      required:
        - functionResponse
      properties:
        functionResponse:
          $ref: '#/components/schemas/FunctionResponse'
    ExecutableCodePart:
      title: Generated Code
      type: object
      required:
        - executableCode
      properties:
        executableCode:
          $ref: '#/components/schemas/ExecutableCode'
    CodeExecutionResultPart:
      title: Code Execution Result
      type: object
      required:
        - codeExecutionResult
      properties:
        codeExecutionResult:
          $ref: '#/components/schemas/CodeExecutionResult'
    BlobData:
      type: object
      properties:
        mimeType:
          type: string
          description: IANA MIME type
          example: image/png
        data:
          type: string
          format: byte
          description: Base64-encoded raw media data
      required:
        - mimeType
        - data
    FunctionCall:
      type: object
      required:
        - name
        - args
      properties:
        name:
          type: string
          description: Function name
          example: get_weather
        args:
          type: object
          description: Function arguments
        id:
          type: string
          description: >-
            Call ID. Generated by the model for Gemini 3.x, used to pair up
            parallel function calls.
          example: fc-abc123
    FunctionResponse:
      type: object
      required:
        - name
        - response
      properties:
        name:
          type: string
          description: Function name
          example: get_weather
        parts:
          type: array
          description: Optional multimodal response parts
          items:
            $ref: '#/components/schemas/FunctionResponseMediaPart'
        response:
          type: object
          description: Function response payload
        id:
          type: string
          description: >-
            The call ID of the corresponding `FunctionCall` (some docs / SDKs
            call it `call_id`). **Must be echoed back for Gemini 3.x**, used
            together with `name` for pairing, otherwise the request errors.
          example: fc-abc123
    ExecutableCode:
      type: object
      required:
        - language
        - code
      properties:
        language:
          type: string
          description: Code language
          example: python
        code:
          type: string
          description: Generated code
    CodeExecutionResult:
      type: object
      required:
        - outcome
      properties:
        outcome:
          type: string
          description: Code execution result
          enum:
            - OUTCOME_UNSPECIFIED
            - OUTCOME_OK
            - OUTCOME_FAILED
            - OUTCOME_DEADLINE_EXCEEDED
          example: OUTCOME_OK
        output:
          type: string
          description: Standard output, error output, or other description
    FunctionResponseMediaPart:
      type: object
      required:
        - inlineData
      properties:
        inlineData:
          $ref: '#/components/schemas/BlobData'
  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

        ```

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.