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

# Reconnaissance média Gemini

> 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`).

Cette page utilise la même opération `generateContent` que [Générer du contenu (Gemini)](/fr/api-reference/chat/generate-content), avec le playground ci-dessus prérempli pour un chat en texte brut. Les notes ci-dessous décrivent les champs multimodaux natifs Gemini que vous pouvez ajouter à `contents[].parts` pour analyser des images, de l'audio, de la vidéo ou des médias mixtes dans une seule requête.

<Note>
  Chaque part peut transporter des données inline (octets encodés en base64 plus un type MIME) en plus d'instructions textuelles, ce qui permet au modèle de raisonner sur plusieurs modalités en un seul appel.
</Note>

### Champs de requête natifs Gemini

Les champs génériques `contents` et `generationConfig` affichés dans le playground acceptent la forme imbriquée suivante pour la reconnaissance multimodale :

| Champ                                    | Type   | Requis | Description                                                                       |
| ---------------------------------------- | ------ | ------ | --------------------------------------------------------------------------------- |
| `contents[].role`                        | string | Non    | Rôle du tour, par exemple `user`.                                                 |
| `contents[].parts`                       | array  | Oui    | Liste ordonnée des parts de contenu (texte et/ou média inline).                   |
| `contents[].parts[].text`                | string | Non    | Instruction textuelle ou question pour le modèle.                                 |
| `contents[].parts[].inlineData`          | object | Non    | Charge utile média inline pour la compréhension d'image, d'audio ou de vidéo.     |
| `contents[].parts[].inlineData.mimeType` | string | Non    | Type MIME des données inline, par exemple `image/jpeg`, `audio/mp3`, `video/mp4`. |
| `contents[].parts[].inlineData.data`     | string | Non    | Octets média encodés en base64.                                                   |

<Tip>
  Vous pouvez mélanger plusieurs parts dans un même tour, par exemple une part `text` contenant l'instruction, suivie d'une ou plusieurs parts `inlineData` contenant les médias à analyser.
</Tip>

### Exemple : analyser une 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>"
          }
        }
      ]
    }
  ]
}
```

### Champs de réponse

La réponse suit la forme standard `generateContent`. Les champs les plus pertinents pour la reconnaissance média sont :

<ResponseField name="candidates" type="array">
  Réponses candidates renvoyées par le modèle.

  <Expandable title="candidate properties">
    <ResponseField name="content" type="object">
      Objet de contenu généré.

      <Expandable title="content properties">
        <ResponseField name="role" type="string">
          Rôle renvoyé dans le bloc de contenu généré, généralement `model`.
        </ResponseField>

        <ResponseField name="parts" type="array">
          Parts de contenu renvoyées, généralement du texte décrivant le média analysé.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="finishReason" type="string">
      Chaîne indiquant la raison de fin, par exemple `STOP`.
    </ResponseField>

    <ResponseField name="safetyRatings" type="array">
      Résultats d'évaluation de sécurité.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="usageMetadata" type="object">
  Métadonnées de comptabilité des tokens, notamment `promptTokenCount`, `candidatesTokenCount` et `totalTokenCount`. Les médias inline (images, audio, vidéo) consomment des tokens de prompt en plus des éventuelles parts textuelles.
</ResponseField>

### Exemple de réponse

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

````