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

# Gemini Media Recognition

> Gemini-native generateContent interface for text chat, multimodal media recognition (images, audio, video), speech synthesis, and image generation with structured parts. Use `generationConfig` to request specific response modalities such as speech (`speechConfig`) or images (`imageConfig`).

This page uses the same `generateContent` operation as [Generate content (Gemini)](/api-reference/chat/generate-content), with the playground above pre-filled for plain text chat. The notes below describe the Gemini-native multimodal fields you can add to `contents[].parts` to analyze images, audio, video, or mixed media in a single request.

<Note>
  Each part can carry inline data (base64-encoded bytes plus a MIME type) alongside text instructions, letting the model reason across modalities in one call.
</Note>

### Gemini-native request fields

The generic `contents` and `generationConfig` fields shown in the playground accept the following nested shape for multimodal recognition:

| Field                                    | Type   | Required | Description                                                                |
| ---------------------------------------- | ------ | -------- | -------------------------------------------------------------------------- |
| `contents[].role`                        | string | No       | Role of the turn, e.g. `user`.                                             |
| `contents[].parts`                       | array  | Yes      | Ordered list of content parts (text and/or inline media).                  |
| `contents[].parts[].text`                | string | No       | Text instruction or question for the model.                                |
| `contents[].parts[].inlineData`          | object | No       | Inline media payload for image, audio, or video understanding.             |
| `contents[].parts[].inlineData.mimeType` | string | No       | MIME type of the inline data, e.g. `image/jpeg`, `audio/mp3`, `video/mp4`. |
| `contents[].parts[].inlineData.data`     | string | No       | Base64-encoded media bytes.                                                |

<Tip>
  You can mix multiple parts in a single turn — for example a `text` part with an instruction followed by one or more `inlineData` parts containing the media to analyze.
</Tip>

### Example: analyzing an image

```json theme={null}
{
  "contents": [
    {
      "role": "user",
      "parts": [
        { "text": "Describe what is happening in this image." },
        {
          "inlineData": {
            "mimeType": "image/jpeg",
            "data": "<base64-encoded-image-bytes>"
          }
        }
      ]
    }
  ]
}
```

### Response fields

The response follows the standard `generateContent` shape. The fields most relevant to media recognition are:

<ResponseField name="candidates" type="array">
  Candidate responses returned by the model.

  <Expandable title="candidate properties">
    <ResponseField name="content" type="object">
      Generated content object.

      <Expandable title="content properties">
        <ResponseField name="role" type="string">
          Role returned in the generated content block, typically `model`.
        </ResponseField>

        <ResponseField name="parts" type="array">
          Returned content parts, typically text describing the analyzed media.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="finishReason" type="string">
      Finish reason string, e.g. `STOP`.
    </ResponseField>

    <ResponseField name="safetyRatings" type="array">
      Safety evaluation results.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="usageMetadata" type="object">
  Token accounting metadata, including `promptTokenCount`, `candidatesTokenCount`, and `totalTokenCount`. Inline media (images, audio, video) consumes prompt tokens in addition to any text parts.
</ResponseField>

### Example response

```json 200 theme={null}
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          { "text": "The image shows a golden retriever sitting on a grassy lawn." }
        ]
      },
      "finishReason": "STOP",
      "safetyRatings": []
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 264,
    "candidatesTokenCount": 18,
    "totalTokenCount": 282
  }
}
```


## OpenAPI

````yaml api-reference/openapi.json POST /v1/models/{model}:generateContent
openapi: 3.1.0
info:
  title: DGrid AI Gateway API
  description: >-
    A single, unified API to access 200+ leading AI models. OpenAI-, Claude-,
    and Gemini-compatible endpoints for chat, completions, embeddings, images,
    audio, and moderations.
  version: 1.0.0
  contact:
    name: DGrid AI
    url: https://dgrid.ai
servers:
  - url: https://api.dgrid.ai
    description: DGrid AI Gateway
security:
  - bearerAuth: []
paths:
  /v1/models/{model}:generateContent:
    post:
      tags:
        - Chat
      summary: Generate content (Gemini)
      description: >-
        Gemini-native generateContent interface for text chat, multimodal media
        recognition (images, audio, video), speech synthesis, and image
        generation with structured parts. Use `generationConfig` to request
        specific response modalities such as speech (`speechConfig`) or images
        (`imageConfig`).
      operationId: generateContent
      parameters:
        - name: model
          in: path
          required: true
          schema:
            type: string
          description: Target model ID, such as `gemini-1.5-pro`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                contents:
                  type: array
                  description: Input content array with role and parts.
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        description: Content role.
                      parts:
                        type: array
                        description: Content parts (text, inline data, media).
                        items:
                          type: object
                generationConfig:
                  type: object
                  description: Generation configuration.
                  properties:
                    responseModalities:
                      type: array
                      items:
                        type: string
                      description: >-
                        Requested response modalities, such as `TEXT`, `AUDIO`,
                        or `IMAGE`.
                    speechConfig:
                      type: object
                      description: Speech configuration for audio output.
                      properties:
                        voiceConfig:
                          type: object
                          properties:
                            prebuiltVoiceConfig:
                              type: object
                              properties:
                                voiceName:
                                  type: string
                                  description: Voice preset name.
                    imageConfig:
                      type: object
                      description: Image configuration for image output.
                      properties:
                        aspectRatio:
                          type: string
                          description: Aspect ratio.
                        imageSize:
                          type: string
                          description: Image size.
            example:
              contents:
                - role: user
                  parts:
                    - text: Hello from DGrid.
      responses:
        '200':
          description: Generated content candidates.
          content:
            application/json:
              schema:
                type: object
                properties:
                  candidates:
                    type: array
                    description: Candidate responses returned by the model.
                    items:
                      type: object
                      properties:
                        content:
                          type: object
                          description: Generated content object.
                          properties:
                            role:
                              type: string
                              description: Role in the generated content block.
                            parts:
                              type: array
                              description: Returned content parts.
                              items:
                                type: object
                        finishReason:
                          type: string
                          description: Finish reason string.
                        safetyRatings:
                          type: array
                          description: Safety evaluation results.
                          items:
                            type: object
                  usageMetadata:
                    type: object
                    description: Token accounting metadata.
                    properties:
                      promptTokenCount:
                        type: integer
                      candidatesTokenCount:
                        type: integer
                      totalTokenCount:
                        type: integer
        '400':
          $ref: '#/components/responses/BadRequest'
components:
  responses:
    BadRequest:
      description: Invalid request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            param:
              type: string
            code:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your DGrid API key. All endpoints use `Authorization: Bearer
        <DGRID_API_KEY>`.

````