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

# Generate content

> Use the Gemini native API format through CometAPI for text generation, video input, thinking summaries, Google Search grounding, JSON output, and streaming.

Use the Gemini native request format through CometAPI to generate text, send video input, and configure thinking or tools. The examples use `gemini-3.8-flash`.

<Tip>
  Use Google's [GenerateContent API reference](https://ai.google.dev/api/generate-content) for field definitions and model-specific options. This page shows the CometAPI base URL, authentication, and request examples.
</Tip>

<Note>
  Both `x-goog-api-key` and `Authorization: Bearer` headers are supported for authentication.
</Note>

## Quick start

To use the Google Gen AI SDK or an HTTP client with CometAPI, configure the base URL and API key:

| Setting  | Google default                      | CometAPI           |
| -------- | ----------------------------------- | ------------------ |
| Base URL | `generativelanguage.googleapis.com` | `api.cometapi.com` |
| API key  | `$GEMINI_API_KEY`                   | `$COMETAPI_KEY`    |

Use the [GenerateContent text generation guide](https://ai.google.dev/gemini-api/docs/generate-content/text-generation) for native API examples. Keep the `generateContent` request shape when changing the base URL.

## Send video input

Send video as a content part. Choose the input shape based on where the video is stored:

| Video source     | Request part       | Use when                                                                                |
| ---------------- | ------------------ | --------------------------------------------------------------------------------------- |
| Local video file | `inlineData`       | The video is small enough to send as base64 in the JSON request.                        |
| Public video URL | `fileData.fileUri` | The video is available through a public HTTPS URL that does not require authentication. |

<Note>
  For REST and curl requests, use camelCase field names such as `inlineData.mimeType` and `fileData.fileUri`.
</Note>

This example sends inline MP4 data. Replace `<base64-encoded-mp4>` with the base64 contents of your video:

```sh theme={null}
curl \
  "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $COMETAPI_KEY" \
  --data-binary @- <<'EOF'
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "inlineData": {
            "mimeType": "video/mp4",
            "data": "<base64-encoded-mp4>"
          }
        },
        {
          "text": "Analyze this video and list the key scenes."
        }
      ]
    }
  ],
  "generationConfig": {
    "maxOutputTokens": 2048,
    "thinkingConfig": {
      "thinkingLevel": "LOW"
    }
  }
}
EOF
```

This example analyzes a public MP4 of a flower opening:

```sh theme={null}
curl \
  "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $COMETAPI_KEY" \
  --data-binary @- <<'EOF'
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "fileData": {
            "mimeType": "video/mp4",
            "fileUri": "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4"
          }
        },
        {
          "text": "Analyze this video and list the key scenes."
        }
      ]
    }
  ],
  "generationConfig": {
    "maxOutputTokens": 2048,
    "thinkingConfig": {
      "thinkingLevel": "LOW"
    }
  }
}
EOF
```

## Configure thinking (reasoning)

Use `thinkingConfig.thinkingLevel` to guide reasoning depth. The examples below use `LOW` and `MEDIUM`.

<Tabs>
  <Tab title="Thinking level">
    This example sets the thinking level to `LOW`:

    ```sh theme={null}
    curl \
      "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
      -H "Content-Type: application/json" \
      -H "x-goog-api-key: $COMETAPI_KEY" \
      --data-binary @- <<'EOF'
    {
      "contents": [
        {
          "parts": [
            {
              "text": "How does quantum computing work?"
            }
          ]
        }
      ],
      "generationConfig": {
        "thinkingConfig": {
          "thinkingLevel": "LOW"
        }
      }
    }
    EOF
    ```
  </Tab>

  <Tab title="Thinking summaries">
    Set `includeThoughts` to request a thinking summary. When the response includes a summary, its text part has `thought: true`:

    ```sh theme={null}
    curl \
      "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
      -H "Content-Type: application/json" \
      -H "x-goog-api-key: $COMETAPI_KEY" \
      --data-binary @- <<'EOF'
    {
      "contents": [
        {
          "parts": [
            {
              "text": "What is the 10th Fibonacci number when F(0)=0 and F(1)=1? Briefly verify the result."
            }
          ]
        }
      ],
      "generationConfig": {
        "maxOutputTokens": 4096,
        "thinkingConfig": {
          "thinkingLevel": "MEDIUM",
          "includeThoughts": true
        }
      }
    }
    EOF
    ```
  </Tab>
</Tabs>

<Note>
  `thinkingBudget` is a numeric control for compatible models, including Gemini 2.5. Use `thinkingLevel` in the Gemini 3 examples and do not send both controls. See Google's [thinking guide](https://ai.google.dev/gemini-api/docs/generate-content/thinking) for model-specific values.
</Note>

## Stream responses

Use `streamGenerateContent?alt=sse` to receive Server-Sent Events. Each `data:` line contains a JSON `GenerateContentResponse` object:

```sh theme={null}
curl \
  "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:streamGenerateContent?alt=sse" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $COMETAPI_KEY" \
  --no-buffer \
  --data-binary @- <<'EOF'
{
  "contents": [
    {
      "parts": [
        {
          "text": "Write a short poem about the stars"
        }
      ]
    }
  ]
}
EOF
```

## Set system instructions

Use `systemInstruction` to guide the response. This example requests one equation without additional text:

```sh theme={null}
curl \
  "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $COMETAPI_KEY" \
  --data-binary @- <<'EOF'
{
  "contents": [
    {
      "parts": [
        {
          "text": "What is 2+2?"
        }
      ]
    }
  ],
  "systemInstruction": {
    "parts": [
      {
        "text": "You are a math tutor. Answer with exactly one equation and no other text."
      }
    ]
  }
}
EOF
```

## Request JSON output

Set `responseMimeType` to `application/json` and provide a `responseSchema`. This example requests an array of planets with names and numeric distances:

```sh theme={null}
curl \
  "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $COMETAPI_KEY" \
  --data-binary @- <<'EOF'
{
  "contents": [
    {
      "parts": [
        {
          "text": "Return a JSON array of 3 planets with name and average_distance_from_sun_au."
        }
      ]
    }
  ],
  "generationConfig": {
    "responseMimeType": "application/json",
    "responseSchema": {
      "type": "ARRAY",
      "items": {
        "type": "OBJECT",
        "properties": {
          "name": {
            "type": "STRING",
            "description": "Name of the planet."
          },
          "average_distance_from_sun_au": {
            "type": "NUMBER",
            "description": "Average distance from the Sun, in astronomical units."
          }
        },
        "required": [
          "name",
          "average_distance_from_sun_au"
        ]
      }
    }
  }
}
EOF
```

## Ground with Google Search

Add a `googleSearch` tool to request search grounding. This example asks for the result of the UEFA EURO 2024 final:

```sh theme={null}
curl \
  "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $COMETAPI_KEY" \
  --data-binary @- <<'EOF'
{
  "contents": [
    {
      "parts": [
        {
          "text": "Use Google Search to find the winner and final score of the UEFA EURO 2024 final. Cite your sources."
        }
      ]
    }
  ],
  "tools": [
    {
      "googleSearch": {}
    }
  ],
  "generationConfig": {
    "maxOutputTokens": 2048
  }
}
EOF
```

When search is used, inspect the candidate's `groundingMetadata` for search queries, source URLs, and links between sources and response text.

## Preserve conversation content

For multi-turn conversations, send the preceding `user` and `model` content in `contents`. The SDK chat examples maintain this history for you.

For function calling, return one `functionResponse` for each `functionCall`, with the matching `name` and any returned `id`. Pass the preceding model content back unchanged, including `thoughtSignature` fields. The signature is opaque; do not reconstruct it from displayed text.

## Response example

A text response includes generated content and token usage. This abbreviated example omits optional fields:

```json theme={null}
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "AI learns patterns from massive amounts of data to make predictions, solve problems, and generate new content. \n\nIn short: **Data in → Patterns found → Smart predictions out.**"
          }
        ]
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 9,
    "candidatesTokenCount": 36,
    "thoughtsTokenCount": 388,
    "totalTokenCount": 433
  },
  "modelVersion": "gemini-3.8-flash"
}
```

<Info>
  `thoughtsTokenCount` reports internal thinking tokens, even when the response does not include a thinking summary. Inspect each content part; a response can contain text, summaries, or function calls.
</Info>

## Compare request formats

Choose the native endpoint for Gemini request and response fields. See [Chat Completions](/api/text/chat) for the OpenAI-compatible format.

| Field              | Gemini native                     | OpenAI-compatible chat      |
| ------------------ | --------------------------------- | --------------------------- |
| Conversation input | `contents` with `parts`           | `messages`                  |
| Model ID           | In the request path               | `model` in the request body |
| Generated content  | `candidates` with `content.parts` | `choices` with `message`    |


## OpenAPI

````yaml api/openapi/text/post-gemini-generating-content.openapi.json POST /v1beta/models/{model}:{operator}
openapi: 3.1.0
info:
  title: Gemini Generating Content API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - apiKeyAuth: []
paths:
  /v1beta/models/{model}:{operator}:
    post:
      summary: Gemini Generating Content
      description: >-
        Generate text with Gemini native request and response formats. The
        examples cover system instructions, video input, thinking summaries,
        Google Search grounding, JSON output, conversation history, and
        streaming.
      operationId: gemini_generating_content
      parameters:
        - name: model
          in: path
          required: true
          description: >-
            Gemini model ID. These examples use `gemini-3.8-flash`. See the
            [Models page](/overview/models) for available model IDs.
          schema:
            type: string
            default: gemini-3.8-flash
          example: gemini-3.8-flash
        - name: operator
          in: path
          required: true
          description: >-
            Operation to perform. Use `generateContent` for a JSON response. For
            Server-Sent Events, select `streamGenerateContent` and set the
            separate `alt` query parameter to `sse`.
          schema:
            type: string
            enum:
              - generateContent
              - streamGenerateContent
            default: generateContent
        - name: alt
          in: query
          required: false
          description: >-
            Set to `sse` when the operator is `streamGenerateContent`. Omit this
            parameter for `generateContent`.
          schema:
            type: string
            enum:
              - sse
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: []
              properties:
                contents:
                  type: array
                  items:
                    type: object
                    properties:
                      role:
                        description: >-
                          The role of the content author. Use `user` for user
                          messages and `model` for assistant responses in
                          multi-turn conversations. Can be omitted for
                          single-turn requests.
                        enum:
                          - user
                          - model
                        type: string
                      parts:
                        description: >-
                          The content parts for this turn. Supports text, inline
                          base64 media, public file URLs, and function call
                          results.
                        items:
                          type: object
                          properties:
                            text:
                              type: string
                              description: Text content of this part.
                            inlineData:
                              type: object
                              description: >-
                                Inline binary media sent as base64 in the
                                request. Use this for local image, audio, video,
                                PDF, or other supported media files that are
                                small enough to include in the JSON body. Omit
                                this field when using `fileData`.
                              properties:
                                mimeType:
                                  type: string
                                  description: >-
                                    The MIME type of the media bytes, such as
                                    `image/png`, `audio/mpeg`, `video/mp4`, or
                                    `application/pdf`.
                                data:
                                  type: string
                                  description: >-
                                    Base64-encoded file bytes. Do not include a
                                    `data:video/mp4;base64,` prefix.
                            fileData:
                              type: object
                              description: >-
                                Media referenced by URL. Use a public HTTPS URL
                                that can be fetched without authentication. Omit
                                this field when using `inlineData`.
                              properties:
                                mimeType:
                                  type: string
                                  description: >-
                                    The MIME type of the referenced file, such
                                    as `video/mp4`, `image/png`, `audio/mpeg`,
                                    or `application/pdf`.
                                fileUri:
                                  type: string
                                  description: >-
                                    A public HTTPS URL for the media file. The
                                    URL must not require cookies, private
                                    headers, or a signed-in session.
                            functionCall:
                              type: object
                              description: A function call generated by the model.
                              properties:
                                name:
                                  type: string
                                  description: The function name.
                                args:
                                  type: object
                                  description: The function arguments as a JSON object.
                                id:
                                  type: string
                                  description: >-
                                    Identifier of the function call. If the
                                    model returns an ID, copy the same ID into
                                    the corresponding function response.
                            functionResponse:
                              type: object
                              description: >-
                                The result of a function call, provided by the
                                user.
                              properties:
                                name:
                                  type: string
                                  description: The function name.
                                response:
                                  type: object
                                  description: The function response as a JSON object.
                                id:
                                  type: string
                                  description: >-
                                    Identifier of the function call. If the
                                    model returns an ID, copy the same ID into
                                    the corresponding function response.
                            thoughtSignature:
                              type: string
                              description: >-
                                Opaque signature returned in a model content
                                part. Preserve the signature and the complete
                                part when sending conversation history or tool
                                results.
                        type: array
                  description: >-
                    Conversation content. Each entry has an optional `role`
                    (`user` or `model`) and a `parts` array. For tool results,
                    preserve the complete preceding model content, including any
                    `thoughtSignature` fields.
                systemInstruction:
                  type: object
                  description: >-
                    System instructions that guide the model's behavior across
                    the entire conversation. Text only.
                  properties:
                    parts:
                      type: array
                      items:
                        type: object
                        properties:
                          text:
                            type: string
                            description: The system instruction text.
                      description: Content parts of the system instruction.
                tools:
                  type: array
                  description: >-
                    Tools available to the model during generation. Use
                    `googleSearch` for search grounding.
                  items:
                    type: object
                    properties:
                      functionDeclarations:
                        type: array
                        description: A list of function declarations for function calling.
                        items:
                          type: object
                          properties:
                            name:
                              type: string
                              description: The function name.
                            description:
                              type: string
                              description: A description of what the function does.
                            parameters:
                              type: object
                              description: The function parameters as a JSON Schema object.
                      googleSearch:
                        type: object
                        description: >-
                          Enable Google Search grounding. Pass an empty object
                          `{}` to enable.
                      googleMaps:
                        type: object
                        description: >-
                          Enable Google Maps grounding. Pass an empty object
                          `{}` to enable.
                      codeExecution:
                        type: object
                        description: >-
                          Enable code execution. Pass an empty object `{}` to
                          enable.
                toolConfig:
                  type: object
                  description: Configuration for tool usage, such as function calling mode.
                  properties:
                    functionCallingConfig:
                      type: object
                      description: Configuration for function calling behavior.
                      properties:
                        mode:
                          type: string
                          description: The function calling mode.
                          enum:
                            - AUTO
                            - ANY
                            - NONE
                        allowedFunctionNames:
                          type: array
                          description: >-
                            Restrict the model to calling only these functions.
                            Only effective when `mode` is `ANY`.
                          items:
                            type: string
                    retrievalConfig:
                      type: object
                      description: >-
                        Configuration for retrieval-based tools (e.g., Google
                        Maps location context).
                      properties:
                        latLng:
                          type: object
                          description: Latitude and longitude for location-based grounding.
                          properties:
                            latitude:
                              type: number
                              description: Latitude in degrees.
                            longitude:
                              type: number
                              description: Longitude in degrees.
                safetySettings:
                  type: array
                  description: >-
                    Safety filter settings. Override default thresholds for
                    specific harm categories.
                  items:
                    type: object
                    properties:
                      category:
                        type: string
                        description: The harm category to configure.
                        enum:
                          - HARM_CATEGORY_HARASSMENT
                          - HARM_CATEGORY_HATE_SPEECH
                          - HARM_CATEGORY_SEXUALLY_EXPLICIT
                          - HARM_CATEGORY_DANGEROUS_CONTENT
                          - HARM_CATEGORY_CIVIC_INTEGRITY
                      threshold:
                        type: string
                        description: The blocking threshold for this category.
                        enum:
                          - BLOCK_NONE
                          - BLOCK_ONLY_HIGH
                          - BLOCK_MEDIUM_AND_ABOVE
                          - BLOCK_LOW_AND_ABOVE
                          - 'OFF'
                generationConfig:
                  type: object
                  description: >-
                    Configuration for model generation behavior including
                    temperature, output length, and response format.
                  properties:
                    temperature:
                      type: number
                      description: >-
                        Sampling temperature for models that accept this field.
                        Omit sampling overrides in the Gemini 3 examples.
                      minimum: 0
                      maximum: 2
                    topP:
                      type: number
                      description: >-
                        Nucleus sampling threshold for models that accept this
                        field. Omit sampling overrides in the Gemini 3 examples.
                      minimum: 0
                      maximum: 1
                    topK:
                      type: integer
                      description: >-
                        Sampling candidate limit for models that accept this
                        field. Omit sampling overrides in the Gemini 3 examples.
                    maxOutputTokens:
                      type: integer
                      description: >-
                        Maximum output token count, including thinking and
                        response text. Leave enough room for both when thinking
                        is enabled.
                    candidateCount:
                      type: integer
                      description: >-
                        Number of response candidates. Omit this field for the
                        Gemini 3 examples.
                    stopSequences:
                      type: array
                      description: >-
                        Up to 5 character sequences that will stop output
                        generation. The stop sequence is not included in the
                        response.
                      items:
                        type: string
                      maxItems: 5
                    seed:
                      type: integer
                      description: Seed used to initialize sampling.
                    presencePenalty:
                      type: number
                      description: >-
                        Penalizes tokens that have already appeared in the
                        response (binary on/off per token). Positive values
                        encourage diverse vocabulary.
                    frequencyPenalty:
                      type: number
                      description: >-
                        Penalizes tokens proportionally to how many times they
                        have appeared. Positive values discourage repetition.
                    responseMimeType:
                      type: string
                      description: >-
                        The MIME type for the response. Use `application/json`
                        for JSON mode, `text/x.enum` for enum output, or
                        `text/plain` (default) for free text.
                      enum:
                        - text/plain
                        - application/json
                        - text/x.enum
                    responseSchema:
                      type: object
                      description: >-
                        Schema for JSON output. Set `responseMimeType` to
                        `application/json` and provide this schema together, as
                        shown in the JSON example.
                    responseModalities:
                      type: array
                      description: >-
                        Requested output modalities. Available values and
                        combinations depend on the selected model. The text
                        examples omit this field; image and audio output require
                        a model that supports that modality.
                      items:
                        type: string
                        enum:
                          - TEXT
                          - IMAGE
                          - AUDIO
                    responseLogprobs:
                      type: boolean
                      description: If `true`, include log probabilities in the response.
                    logprobs:
                      type: integer
                      description: >-
                        Number of top log probabilities to return per token
                        (0–20). Only valid when `responseLogprobs` is `true`.
                      minimum: 0
                      maximum: 20
                    thinkingConfig:
                      type: object
                      description: >-
                        Controls the model's internal reasoning (thinking)
                        process. Supported by Gemini 2.5 and later models.
                      properties:
                        thinkingBudget:
                          type: integer
                          description: >-
                            Numeric thinking token budget for compatible models,
                            including Gemini 2.5. Accepted ranges and whether 0
                            disables thinking depend on the model; -1 selects
                            dynamic thinking where supported. The Gemini 3
                            examples use `thinkingLevel` instead. Do not send
                            both controls.
                        thinkingLevel:
                          type: string
                          description: >-
                            Preset reasoning level for Gemini 3 models. The
                            `gemini-3.8-flash` examples use `LOW` or `MEDIUM`;
                            accepted levels depend on the model. Omit this field
                            to use the model default. Do not combine it with
                            `thinkingBudget`.
                          enum:
                            - MINIMAL
                            - LOW
                            - MEDIUM
                            - HIGH
                        includeThoughts:
                          type: boolean
                          description: >-
                            Request thinking summaries in response parts. A
                            summary part has `thought: true`.
                    imageConfig:
                      type: object
                      description: >-
                        Configuration for image generation. Only applicable to
                        models that support image output.
                      properties:
                        aspectRatio:
                          type: string
                          description: The aspect ratio for generated images.
                          enum:
                            - '1:1'
                            - '2:3'
                            - '3:2'
                            - '3:4'
                            - '4:3'
                            - '4:5'
                            - '5:4'
                            - '9:16'
                            - '16:9'
                            - '21:9'
                        imageSize:
                          type: string
                          description: The resolution of generated images.
                          enum:
                            - 1K
                            - 2K
                            - 4K
                          default: 1K
                    mediaResolution:
                      type: string
                      description: Resolution for processing input media files.
                      enum:
                        - MEDIA_RESOLUTION_LOW
                        - MEDIA_RESOLUTION_MEDIUM
                        - MEDIA_RESOLUTION_HIGH
                cachedContent:
                  type: string
                  description: >-
                    The name of cached content to use as context. Format:
                    `cachedContents/{id}`. See the Gemini context caching
                    documentation for details.
            examples:
              Basic:
                summary: Basic
                value:
                  contents:
                    - parts:
                        - text: Explain how AI works in a few words
              System Instruction:
                summary: System Instruction
                value:
                  contents:
                    - parts:
                        - text: What is 2+2?
                  systemInstruction:
                    parts:
                      - text: >-
                          You are a math tutor. Answer with exactly one equation
                          and no other text.
              Thinking Summary:
                summary: Thinking Summary
                value:
                  contents:
                    - parts:
                        - text: >-
                            What is the 10th Fibonacci number when F(0)=0 and
                            F(1)=1? Briefly verify the result.
                  generationConfig:
                    maxOutputTokens: 4096
                    thinkingConfig:
                      thinkingLevel: MEDIUM
                      includeThoughts: true
              Google Search:
                summary: Google Search
                value:
                  contents:
                    - parts:
                        - text: >-
                            Use Google Search to find the winner and final score
                            of the UEFA EURO 2024 final. Cite your sources.
                  tools:
                    - googleSearch: {}
                  generationConfig:
                    maxOutputTokens: 2048
              JSON Mode:
                summary: JSON Mode
                value:
                  contents:
                    - parts:
                        - text: >-
                            Return a JSON array of 3 planets with name and
                            average_distance_from_sun_au.
                  generationConfig:
                    responseMimeType: application/json
                    responseSchema:
                      type: ARRAY
                      items:
                        type: OBJECT
                        properties:
                          name:
                            type: STRING
                            description: Name of the planet.
                          average_distance_from_sun_au:
                            type: NUMBER
                            description: >-
                              Average distance from the Sun, in astronomical
                              units.
                        required:
                          - name
                          - average_distance_from_sun_au
              Multi-turn Chat:
                summary: Multi-turn Chat
                value:
                  contents:
                    - role: user
                      parts:
                        - text: I have 2 dogs.
                    - role: model
                      parts:
                        - text: I will remember that you have 2 dogs.
                    - role: user
                      parts:
                        - text: How many dog paws are in my house?
              Thinking Level:
                summary: Thinking Level
                value:
                  contents:
                    - parts:
                        - text: How does quantum computing work?
                  generationConfig:
                    thinkingConfig:
                      thinkingLevel: LOW
              Inline Video:
                summary: Inline Video
                value:
                  contents:
                    - role: user
                      parts:
                        - inlineData:
                            mimeType: video/mp4
                            data: <base64-encoded-mp4>
                        - text: Analyze this video and list the key scenes.
                  generationConfig:
                    maxOutputTokens: 2048
                    thinkingConfig:
                      thinkingLevel: LOW
                description: >-
                  Replace `<base64-encoded-mp4>` with the base64 contents of
                  your local MP4 file.
              Public Video URL:
                summary: Public Video URL
                value:
                  contents:
                    - role: user
                      parts:
                        - fileData:
                            mimeType: video/mp4
                            fileUri: >-
                              https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4
                        - text: Analyze this video and list the key scenes.
                  generationConfig:
                    maxOutputTokens: 2048
                    thinkingConfig:
                      thinkingLevel: LOW
      responses:
        '200':
          description: >-
            Successful response. For streaming requests, the response is a
            stream of SSE events, each containing a `GenerateContentResponse`
            JSON object prefixed with `data: `.
          content:
            application/json:
              schema:
                type: object
                properties:
                  candidates:
                    type: array
                    description: The generated response candidates.
                    items:
                      type: object
                      properties:
                        content:
                          type: object
                          description: The generated content.
                          properties:
                            role:
                              type: string
                              description: Always `model` for generated responses.
                            parts:
                              type: array
                              description: The content parts of the response.
                              items:
                                type: object
                                properties:
                                  text:
                                    type: string
                                    description: Generated text content.
                                  functionCall:
                                    type: object
                                    description: >-
                                      A function call request from the model
                                      (when using function calling tools).
                                    properties:
                                      name:
                                        type: string
                                        description: >-
                                          Name of the function the model wants to
                                          call.
                                      args:
                                        type: object
                                        description: Function arguments as a JSON object.
                                      id:
                                        type: string
                                        description: >-
                                          Identifier of the function call. If the
                                          model returns an ID, copy the same ID
                                          into the corresponding function
                                          response.
                                  inlineData:
                                    type: object
                                    description: >-
                                      Inline binary data (e.g., generated
                                      images).
                                    properties:
                                      mimeType:
                                        type: string
                                        description: >-
                                          MIME type of the inline data, such as
                                          `image/png`.
                                      data:
                                        type: string
                                        description: Base64-encoded bytes of the inline data.
                                  thought:
                                    type: boolean
                                    description: >-
                                      True when this text part is a thinking
                                      summary requested with `includeThoughts`.
                                  thoughtSignature:
                                    type: string
                                    description: >-
                                      Opaque signature returned in a model
                                      content part. Preserve the signature and
                                      the complete part when sending
                                      conversation history or tool results.
                        finishReason:
                          type: string
                          description: The reason the model stopped generating tokens.
                          enum:
                            - STOP
                            - MAX_TOKENS
                            - SAFETY
                            - RECITATION
                            - LANGUAGE
                            - OTHER
                            - BLOCKLIST
                            - PROHIBITED_CONTENT
                            - SPII
                            - MALFORMED_FUNCTION_CALL
                        safetyRatings:
                          type: array
                          description: Safety ratings for this candidate.
                          items:
                            type: object
                            properties:
                              category:
                                type: string
                                description: Safety category this rating applies to.
                              probability:
                                type: string
                                description: >-
                                  Probability level for harmful content in this
                                  category, such as `NEGLIGIBLE` or `HIGH`.
                              blocked:
                                type: boolean
                                description: Whether content was blocked for this category.
                        citationMetadata:
                          type: object
                          description: Citation information for model-generated content.
                          properties:
                            citationSources:
                              type: array
                              items:
                                type: object
                                properties:
                                  startIndex:
                                    type: integer
                                    description: >-
                                      Start byte index of the cited span in the
                                      output.
                                  endIndex:
                                    type: integer
                                    description: >-
                                      End byte index of the cited span in the
                                      output.
                                  uri:
                                    type: string
                                    description: URI of the cited source.
                                  license:
                                    type: string
                                    description: License of the cited source when known.
                              description: Sources cited for the generated content.
                        tokenCount:
                          type: integer
                          description: Token count for this candidate.
                        avgLogprobs:
                          type: number
                          description: Average log probability score of this candidate.
                        groundingMetadata:
                          type: object
                          description: >-
                            Grounding metadata when Google Search or other
                            grounding tools are used.
                          properties:
                            groundingChunks:
                              type: array
                              items:
                                type: object
                                properties:
                                  web:
                                    type: object
                                    properties:
                                      uri:
                                        type: string
                                        description: URI of the grounding source.
                                      title:
                                        type: string
                                        description: Title of the grounding source page.
                                    description: A web source used for grounding.
                              description: >-
                                Web sources that ground the response when Google
                                Search grounding runs.
                            groundingSupports:
                              type: array
                              items:
                                type: object
                                properties:
                                  groundingChunkIndices:
                                    type: array
                                    items:
                                      type: integer
                                    description: >-
                                      Indexes into `groundingChunks` that
                                      support this segment.
                                  confidenceScores:
                                    type: array
                                    items:
                                      type: number
                                    description: >-
                                      Support confidence per grounding chunk,
                                      between 0 and 1.
                                  segment:
                                    type: object
                                    properties:
                                      startIndex:
                                        type: integer
                                        description: Start byte index of the segment.
                                      endIndex:
                                        type: integer
                                        description: End byte index of the segment.
                                      text:
                                        type: string
                                        description: Text of the segment.
                                    description: >-
                                      The output text segment this support entry
                                      covers.
                              description: >-
                                Mapping between output text segments and the
                                grounding chunks that support them.
                            webSearchQueries:
                              type: array
                              items:
                                type: string
                              description: Search queries the model issued for grounding.
                        index:
                          type: integer
                          description: >-
                            Index of this candidate in the list of response
                            candidates.
                  promptFeedback:
                    type: object
                    description: >-
                      Feedback on the prompt, including safety blocking
                      information.
                    properties:
                      blockReason:
                        type: string
                        description: If set, the prompt was blocked.
                        enum:
                          - SAFETY
                          - OTHER
                          - BLOCKLIST
                          - PROHIBITED_CONTENT
                      safetyRatings:
                        type: array
                        items:
                          type: object
                          properties:
                            category:
                              type: string
                              description: Safety category this rating applies to.
                            probability:
                              type: string
                              description: >-
                                Probability level for harmful content in this
                                category.
                            blocked:
                              type: boolean
                              description: >-
                                Whether the prompt was blocked for this
                                category.
                        description: Safety ratings for the prompt.
                  usageMetadata:
                    type: object
                    description: Token usage statistics for the request.
                    properties:
                      promptTokenCount:
                        type: integer
                        description: Number of tokens in the prompt.
                      candidatesTokenCount:
                        type: integer
                        description: Number of tokens across all generated candidates.
                      totalTokenCount:
                        type: integer
                        description: Total token count (prompt + candidates + thinking).
                      trafficType:
                        type: string
                        description: >-
                          The traffic type used for processing (e.g.,
                          `ON_DEMAND`).
                      thoughtsTokenCount:
                        type: integer
                        description: >-
                          Number of tokens used for the model's internal
                          thinking process.
                      promptTokensDetails:
                        type: array
                        description: Token count breakdown by input modality.
                        items:
                          type: object
                          properties:
                            modality:
                              type: string
                              description: >-
                                Input modality this entry counts, such as `TEXT`
                                or `VIDEO`.
                            tokenCount:
                              type: integer
                              description: Prompt tokens for this modality.
                      candidatesTokensDetails:
                        type: array
                        description: Token count breakdown by output modality.
                        items:
                          type: object
                          properties:
                            modality:
                              type: string
                              description: Output modality this entry counts.
                            tokenCount:
                              type: integer
                              description: Output tokens for this modality.
                  modelVersion:
                    type: string
                    description: The model version that generated this response.
                  createTime:
                    type: string
                    description: >-
                      The timestamp when this response was created (ISO 8601
                      format).
                  responseId:
                    type: string
                    description: Unique identifier for this response.
              example:
                candidates:
                  - content:
                      role: model
                      parts:
                        - text: >-
                            AI learns patterns from massive amounts of data to
                            make predictions, solve problems, and generate new
                            content. 


                            In short: **Data in → Patterns found → Smart
                            predictions out.**
                    finishReason: STOP
                usageMetadata:
                  promptTokenCount: 9
                  candidatesTokenCount: 36
                  thoughtsTokenCount: 388
                  totalTokenCount: 433
                modelVersion: gemini-3.8-flash
      x-codeSamples:
        - lang: Python
          label: Basic
          source: |
            import os
            from google import genai

            client = genai.Client(
                api_key=os.environ["COMETAPI_KEY"],
                http_options={
                    "api_version": "v1beta",
                    "base_url": "https://api.cometapi.com",
                },
            )

            response = client.models.generate_content(
                model="gemini-3.8-flash",
                contents='Explain how AI works in a few words',
            )

            print(response.text)
        - lang: Python
          label: System Instruction
          source: |
            import os
            from google import genai
            from google.genai import types

            client = genai.Client(
                api_key=os.environ["COMETAPI_KEY"],
                http_options={
                    "api_version": "v1beta",
                    "base_url": "https://api.cometapi.com",
                },
            )

            response = client.models.generate_content(
                model="gemini-3.8-flash",
                contents='What is 2+2?',
                config=types.GenerateContentConfig(
                    system_instruction=(
                        "You are a math tutor. Answer with exactly one equation "
                        "and no other text."
                    ),
                ),
            )

            print(response.text)
        - lang: Python
          label: Thinking Summary
          source: |
            import os
            from google import genai
            from google.genai import types

            client = genai.Client(
                api_key=os.environ["COMETAPI_KEY"],
                http_options={
                    "api_version": "v1beta",
                    "base_url": "https://api.cometapi.com",
                },
            )

            response = client.models.generate_content(
                model="gemini-3.8-flash",
                contents='What is the 10th Fibonacci number when F(0)=0 and F(1)=1? Briefly verify the result.',
                config=types.GenerateContentConfig(
                    max_output_tokens=4096,
                    thinking_config=types.ThinkingConfig(
                        thinking_level="MEDIUM",
                        include_thoughts=True,
                    ),
                ),
            )

            for part in response.candidates[0].content.parts:
                if part.text:
                    label = "Thinking summary" if part.thought else "Answer"
                    print(f"{label}: {part.text}")
        - lang: Python
          label: Google Search
          source: |
            import os
            from google import genai
            from google.genai import types

            client = genai.Client(
                api_key=os.environ["COMETAPI_KEY"],
                http_options={
                    "api_version": "v1beta",
                    "base_url": "https://api.cometapi.com",
                },
            )

            response = client.models.generate_content(
                model="gemini-3.8-flash",
                contents='Use Google Search to find the winner and final score of the UEFA EURO 2024 final. Cite your sources.',
                config=types.GenerateContentConfig(
                    tools=[types.Tool(google_search=types.GoogleSearch())],
                    max_output_tokens=2048,
                ),
            )

            print(response.text)
        - lang: Python
          label: JSON Mode
          source: |
            import os
            from google import genai
            from google.genai import types

            client = genai.Client(
                api_key=os.environ["COMETAPI_KEY"],
                http_options={
                    "api_version": "v1beta",
                    "base_url": "https://api.cometapi.com",
                },
            )

            response = client.models.generate_content(
                model="gemini-3.8-flash",
                contents='Return a JSON array of 3 planets with name and average_distance_from_sun_au.',
                config=types.GenerateContentConfig(
                    response_mime_type="application/json",
                    response_schema={
                        "type": "ARRAY",
                        "items": {
                            "type": "OBJECT",
                            "properties": {
                                "name": {
                                    "type": "STRING",
                                    "description": "Name of the planet."
                                },
                                "average_distance_from_sun_au": {
                                    "type": "NUMBER",
                                    "description": "Average distance from the Sun, in astronomical units."
                                }
                            },
                            "required": [
                                "name",
                                "average_distance_from_sun_au"
                            ]
                        }
                    },
                ),
            )

            print(response.text)
        - lang: Python
          label: Streaming
          source: |
            import os
            from google import genai

            client = genai.Client(
                api_key=os.environ["COMETAPI_KEY"],
                http_options={
                    "api_version": "v1beta",
                    "base_url": "https://api.cometapi.com",
                },
            )

            response = client.models.generate_content_stream(
                model="gemini-3.8-flash",
                contents='Write a short poem about the stars',
            )

            for chunk in response:
                if chunk.text:
                    print(chunk.text, end="")
        - lang: Python
          label: Multi-turn Chat
          source: |
            import os
            from google import genai

            client = genai.Client(
                api_key=os.environ["COMETAPI_KEY"],
                http_options={
                    "api_version": "v1beta",
                    "base_url": "https://api.cometapi.com",
                },
            )

            chat = client.chats.create(model="gemini-3.8-flash")

            response = chat.send_message("I have 2 dogs.")
            print(response.text)

            response = chat.send_message("How many dog paws are in my house?")
            print(response.text)
        - lang: Python
          label: Thinking Level
          source: |
            import os
            from google import genai
            from google.genai import types

            client = genai.Client(
                api_key=os.environ["COMETAPI_KEY"],
                http_options={
                    "api_version": "v1beta",
                    "base_url": "https://api.cometapi.com",
                },
            )

            response = client.models.generate_content(
                model="gemini-3.8-flash",
                contents='How does quantum computing work?',
                config=types.GenerateContentConfig(
                    thinking_config=types.ThinkingConfig(
                        thinking_level="LOW",
                    ),
                ),
            )

            print(response.text)
        - lang: Python
          label: Inline Video
          source: |
            import os
            from google import genai
            from google.genai import types

            client = genai.Client(
                api_key=os.environ["COMETAPI_KEY"],
                http_options={
                    "api_version": "v1beta",
                    "base_url": "https://api.cometapi.com",
                },
            )

            with open("your_video.mp4", "rb") as f:
                video_bytes = f.read()

            response = client.models.generate_content(
                model="gemini-3.8-flash",
                contents=[
                    types.Part.from_bytes(data=video_bytes, mime_type="video/mp4"),
                    "Analyze this video and list the key scenes.",
                ],
                config=types.GenerateContentConfig(
                    max_output_tokens=2048,
                    thinking_config=types.ThinkingConfig(
                        thinking_level="LOW",
                    ),
                ),
            )

            print(response.text)
        - lang: Python
          label: Public Video URL
          source: |
            import os
            from google import genai
            from google.genai import types

            client = genai.Client(
                api_key=os.environ["COMETAPI_KEY"],
                http_options={
                    "api_version": "v1beta",
                    "base_url": "https://api.cometapi.com",
                },
            )

            response = client.models.generate_content(
                model="gemini-3.8-flash",
                contents=[
                    types.Part.from_uri(
                        file_uri=(
                            "https://interactive-examples.mdn.mozilla.net/"
                            "media/cc0-videos/flower.mp4"
                        ),
                        mime_type="video/mp4",
                    ),
                    "Analyze this video and list the key scenes.",
                ],
                config=types.GenerateContentConfig(
                    max_output_tokens=2048,
                    thinking_config=types.ThinkingConfig(
                        thinking_level="LOW",
                    ),
                ),
            )

            print(response.text)
        - lang: JavaScript
          label: Basic
          source: |
            import { GoogleGenAI } from "@google/genai";

            const ai = new GoogleGenAI({
                apiKey: process.env.COMETAPI_KEY,
                httpOptions: {
                    apiVersion: "v1beta",
                    baseUrl: "https://api.cometapi.com",
                },
            });

            const response = await ai.models.generateContent({
                "model": "gemini-3.8-flash",
                "contents": [
                    {
                        "parts": [
                            {
                                "text": "Explain how AI works in a few words"
                            }
                        ]
                    }
                ]
            });

            console.log(response.text);
        - lang: JavaScript
          label: System Instruction
          source: |
            import { GoogleGenAI } from "@google/genai";

            const ai = new GoogleGenAI({
                apiKey: process.env.COMETAPI_KEY,
                httpOptions: {
                    apiVersion: "v1beta",
                    baseUrl: "https://api.cometapi.com",
                },
            });

            const response = await ai.models.generateContent({
                "model": "gemini-3.8-flash",
                "contents": [
                    {
                        "parts": [
                            {
                                "text": "What is 2+2?"
                            }
                        ]
                    }
                ],
                "config": {
                    "systemInstruction": {
                        "parts": [
                            {
                                "text": "You are a math tutor. Answer with exactly one equation and no other text."
                            }
                        ]
                    }
                }
            });

            console.log(response.text);
        - lang: JavaScript
          label: Thinking Summary
          source: |
            import { GoogleGenAI } from "@google/genai";

            const ai = new GoogleGenAI({
                apiKey: process.env.COMETAPI_KEY,
                httpOptions: {
                    apiVersion: "v1beta",
                    baseUrl: "https://api.cometapi.com",
                },
            });

            const response = await ai.models.generateContent({
                "model": "gemini-3.8-flash",
                "contents": [
                    {
                        "parts": [
                            {
                                "text": "What is the 10th Fibonacci number when F(0)=0 and F(1)=1? Briefly verify the result."
                            }
                        ]
                    }
                ],
                "config": {
                    "maxOutputTokens": 4096,
                    "thinkingConfig": {
                        "thinkingLevel": "MEDIUM",
                        "includeThoughts": true
                    }
                }
            });

            for (const part of response.candidates[0].content.parts) {
                if (part.text) {
                    const label = part.thought ? "Thinking summary" : "Answer";
                    console.log(`${label}: ${part.text}`);
                }
            }
        - lang: JavaScript
          label: Google Search
          source: |
            import { GoogleGenAI } from "@google/genai";

            const ai = new GoogleGenAI({
                apiKey: process.env.COMETAPI_KEY,
                httpOptions: {
                    apiVersion: "v1beta",
                    baseUrl: "https://api.cometapi.com",
                },
            });

            const response = await ai.models.generateContent({
                "model": "gemini-3.8-flash",
                "contents": [
                    {
                        "parts": [
                            {
                                "text": "Use Google Search to find the winner and final score of the UEFA EURO 2024 final. Cite your sources."
                            }
                        ]
                    }
                ],
                "config": {
                    "maxOutputTokens": 2048,
                    "tools": [
                        {
                            "googleSearch": {}
                        }
                    ]
                }
            });

            console.log(response.text);
        - lang: JavaScript
          label: JSON Mode
          source: |
            import { GoogleGenAI } from "@google/genai";

            const ai = new GoogleGenAI({
                apiKey: process.env.COMETAPI_KEY,
                httpOptions: {
                    apiVersion: "v1beta",
                    baseUrl: "https://api.cometapi.com",
                },
            });

            const response = await ai.models.generateContent({
                "model": "gemini-3.8-flash",
                "contents": [
                    {
                        "parts": [
                            {
                                "text": "Return a JSON array of 3 planets with name and average_distance_from_sun_au."
                            }
                        ]
                    }
                ],
                "config": {
                    "responseMimeType": "application/json",
                    "responseSchema": {
                        "type": "ARRAY",
                        "items": {
                            "type": "OBJECT",
                            "properties": {
                                "name": {
                                    "type": "STRING",
                                    "description": "Name of the planet."
                                },
                                "average_distance_from_sun_au": {
                                    "type": "NUMBER",
                                    "description": "Average distance from the Sun, in astronomical units."
                                }
                            },
                            "required": [
                                "name",
                                "average_distance_from_sun_au"
                            ]
                        }
                    }
                }
            });

            console.log(response.text);
        - lang: JavaScript
          label: Streaming
          source: |
            import { GoogleGenAI } from "@google/genai";

            const ai = new GoogleGenAI({
                apiKey: process.env.COMETAPI_KEY,
                httpOptions: {
                    apiVersion: "v1beta",
                    baseUrl: "https://api.cometapi.com",
                },
            });

            const response = await ai.models.generateContentStream({
                "model": "gemini-3.8-flash",
                "contents": [
                    {
                        "parts": [
                            {
                                "text": "Write a short poem about the stars"
                            }
                        ]
                    }
                ]
            });

            for await (const chunk of response) {
                if (chunk.text) process.stdout.write(chunk.text);
            }
        - lang: JavaScript
          label: Multi-turn Chat
          source: >
            import { GoogleGenAI } from "@google/genai";


            const ai = new GoogleGenAI({
                apiKey: process.env.COMETAPI_KEY,
                httpOptions: {
                    apiVersion: "v1beta",
                    baseUrl: "https://api.cometapi.com",
                },
            });


            const chat = ai.chats.create({ model: "gemini-3.8-flash" });


            let response = await chat.sendMessage({ message: "I have 2 dogs."
            });

            console.log(response.text);


            response = await chat.sendMessage({
                message: "How many dog paws are in my house?",
            });

            console.log(response.text);
        - lang: JavaScript
          label: Thinking Level
          source: |
            import { GoogleGenAI } from "@google/genai";

            const ai = new GoogleGenAI({
                apiKey: process.env.COMETAPI_KEY,
                httpOptions: {
                    apiVersion: "v1beta",
                    baseUrl: "https://api.cometapi.com",
                },
            });

            const response = await ai.models.generateContent({
                "model": "gemini-3.8-flash",
                "contents": [
                    {
                        "parts": [
                            {
                                "text": "How does quantum computing work?"
                            }
                        ]
                    }
                ],
                "config": {
                    "thinkingConfig": {
                        "thinkingLevel": "LOW"
                    }
                }
            });

            console.log(response.text);
        - lang: JavaScript
          label: Inline Video
          source: |
            import fs from "node:fs";
            import { GoogleGenAI } from "@google/genai";

            const ai = new GoogleGenAI({
                apiKey: process.env.COMETAPI_KEY,
                httpOptions: {
                    apiVersion: "v1beta",
                    baseUrl: "https://api.cometapi.com",
                },
            });

            const videoBase64 = fs.readFileSync("your_video.mp4", {
                encoding: "base64",
            });

            const response = await ai.models.generateContent({
                "model": "gemini-3.8-flash",
                "contents": [
                    {
                        "role": "user",
                        "parts": [
                            {
                                "inlineData": {
                                    "mimeType": "video/mp4",
                                    "data": videoBase64
                                }
                            },
                            {
                                "text": "Analyze this video and list the key scenes."
                            }
                        ]
                    }
                ],
                "config": {
                    "maxOutputTokens": 2048,
                    "thinkingConfig": {
                        "thinkingLevel": "LOW"
                    }
                }
            });

            console.log(response.text);
        - lang: JavaScript
          label: Public Video URL
          source: |
            import { GoogleGenAI } from "@google/genai";

            const ai = new GoogleGenAI({
                apiKey: process.env.COMETAPI_KEY,
                httpOptions: {
                    apiVersion: "v1beta",
                    baseUrl: "https://api.cometapi.com",
                },
            });

            const response = await ai.models.generateContent({
                "model": "gemini-3.8-flash",
                "contents": [
                    {
                        "role": "user",
                        "parts": [
                            {
                                "fileData": {
                                    "mimeType": "video/mp4",
                                    "fileUri": "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4"
                                }
                            },
                            {
                                "text": "Analyze this video and list the key scenes."
                            }
                        ]
                    }
                ],
                "config": {
                    "maxOutputTokens": 2048,
                    "thinkingConfig": {
                        "thinkingLevel": "LOW"
                    }
                }
            });

            console.log(response.text);
        - lang: Shell
          label: Basic
          source: |
            curl \
              "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
              -H "Content-Type: application/json" \
              -H "x-goog-api-key: $COMETAPI_KEY" \
              --data-binary @- <<'EOF'
            {
              "contents": [
                {
                  "parts": [
                    {
                      "text": "Explain how AI works in a few words"
                    }
                  ]
                }
              ]
            }
            EOF
        - lang: Shell
          label: System Instruction
          source: |
            curl \
              "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
              -H "Content-Type: application/json" \
              -H "x-goog-api-key: $COMETAPI_KEY" \
              --data-binary @- <<'EOF'
            {
              "contents": [
                {
                  "parts": [
                    {
                      "text": "What is 2+2?"
                    }
                  ]
                }
              ],
              "systemInstruction": {
                "parts": [
                  {
                    "text": "You are a math tutor. Answer with exactly one equation and no other text."
                  }
                ]
              }
            }
            EOF
        - lang: Shell
          label: Thinking Summary
          source: |
            curl \
              "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
              -H "Content-Type: application/json" \
              -H "x-goog-api-key: $COMETAPI_KEY" \
              --data-binary @- <<'EOF'
            {
              "contents": [
                {
                  "parts": [
                    {
                      "text": "What is the 10th Fibonacci number when F(0)=0 and F(1)=1? Briefly verify the result."
                    }
                  ]
                }
              ],
              "generationConfig": {
                "maxOutputTokens": 4096,
                "thinkingConfig": {
                  "thinkingLevel": "MEDIUM",
                  "includeThoughts": true
                }
              }
            }
            EOF
        - lang: Shell
          label: Google Search
          source: |
            curl \
              "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
              -H "Content-Type: application/json" \
              -H "x-goog-api-key: $COMETAPI_KEY" \
              --data-binary @- <<'EOF'
            {
              "contents": [
                {
                  "parts": [
                    {
                      "text": "Use Google Search to find the winner and final score of the UEFA EURO 2024 final. Cite your sources."
                    }
                  ]
                }
              ],
              "tools": [
                {
                  "googleSearch": {}
                }
              ],
              "generationConfig": {
                "maxOutputTokens": 2048
              }
            }
            EOF
        - lang: Shell
          label: JSON Mode
          source: |
            curl \
              "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
              -H "Content-Type: application/json" \
              -H "x-goog-api-key: $COMETAPI_KEY" \
              --data-binary @- <<'EOF'
            {
              "contents": [
                {
                  "parts": [
                    {
                      "text": "Return a JSON array of 3 planets with name and average_distance_from_sun_au."
                    }
                  ]
                }
              ],
              "generationConfig": {
                "responseMimeType": "application/json",
                "responseSchema": {
                  "type": "ARRAY",
                  "items": {
                    "type": "OBJECT",
                    "properties": {
                      "name": {
                        "type": "STRING",
                        "description": "Name of the planet."
                      },
                      "average_distance_from_sun_au": {
                        "type": "NUMBER",
                        "description": "Average distance from the Sun, in astronomical units."
                      }
                    },
                    "required": [
                      "name",
                      "average_distance_from_sun_au"
                    ]
                  }
                }
              }
            }
            EOF
        - lang: Shell
          label: Streaming
          source: |
            curl \
              "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:streamGenerateContent?alt=sse" \
              -H "Content-Type: application/json" \
              -H "x-goog-api-key: $COMETAPI_KEY" \
              --no-buffer \
              --data-binary @- <<'EOF'
            {
              "contents": [
                {
                  "parts": [
                    {
                      "text": "Write a short poem about the stars"
                    }
                  ]
                }
              ]
            }
            EOF
        - lang: Shell
          label: Multi-turn Chat
          source: |
            curl \
              "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
              -H "Content-Type: application/json" \
              -H "x-goog-api-key: $COMETAPI_KEY" \
              --data-binary @- <<'EOF'
            {
              "contents": [
                {
                  "role": "user",
                  "parts": [
                    {
                      "text": "I have 2 dogs."
                    }
                  ]
                },
                {
                  "role": "model",
                  "parts": [
                    {
                      "text": "I will remember that you have 2 dogs."
                    }
                  ]
                },
                {
                  "role": "user",
                  "parts": [
                    {
                      "text": "How many dog paws are in my house?"
                    }
                  ]
                }
              ]
            }
            EOF
        - lang: Shell
          label: Thinking Level
          source: |
            curl \
              "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
              -H "Content-Type: application/json" \
              -H "x-goog-api-key: $COMETAPI_KEY" \
              --data-binary @- <<'EOF'
            {
              "contents": [
                {
                  "parts": [
                    {
                      "text": "How does quantum computing work?"
                    }
                  ]
                }
              ],
              "generationConfig": {
                "thinkingConfig": {
                  "thinkingLevel": "LOW"
                }
              }
            }
            EOF
        - lang: Shell
          label: Inline Video
          source: |
            curl \
              "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
              -H "Content-Type: application/json" \
              -H "x-goog-api-key: $COMETAPI_KEY" \
              --data-binary @- <<'EOF'
            {
              "contents": [
                {
                  "role": "user",
                  "parts": [
                    {
                      "inlineData": {
                        "mimeType": "video/mp4",
                        "data": "<base64-encoded-mp4>"
                      }
                    },
                    {
                      "text": "Analyze this video and list the key scenes."
                    }
                  ]
                }
              ],
              "generationConfig": {
                "maxOutputTokens": 2048,
                "thinkingConfig": {
                  "thinkingLevel": "LOW"
                }
              }
            }
            EOF
        - lang: Shell
          label: Public Video URL
          source: |
            curl \
              "https://api.cometapi.com/v1beta/models/gemini-3.8-flash:generateContent" \
              -H "Content-Type: application/json" \
              -H "x-goog-api-key: $COMETAPI_KEY" \
              --data-binary @- <<'EOF'
            {
              "contents": [
                {
                  "role": "user",
                  "parts": [
                    {
                      "fileData": {
                        "mimeType": "video/mp4",
                        "fileUri": "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4"
                      }
                    },
                    {
                      "text": "Analyze this video and list the key scenes."
                    }
                  ]
                }
              ],
              "generationConfig": {
                "maxOutputTokens": 2048,
                "thinkingConfig": {
                  "thinkingLevel": "LOW"
                }
              }
            }
            EOF
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-goog-api-key
      description: >-
        Your CometAPI key passed via the `x-goog-api-key` header. Bearer token
        authentication (`Authorization: Bearer $COMETAPI_KEY`) is also
        supported.

````