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

# Reconocimiento multimedia de 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`).

Esta página usa la misma operación `generateContent` que [Generar contenido (Gemini)](/es/api-reference/chat/generate-content), con el playground de arriba rellenado previamente para chat de texto plano. Las notas a continuación describen los campos multimodales nativos de Gemini que puede agregar a `contents[].parts` para analizar imágenes, audio, video o medios mixtos en una sola solicitud.

<Note>
  Cada part puede incluir datos inline (bytes codificados en base64 más un tipo MIME) junto con instrucciones de texto, lo que permite que el modelo razone entre modalidades en una sola llamada.
</Note>

### Campos de solicitud nativos de Gemini

Los campos genéricos `contents` y `generationConfig` que se muestran en el playground aceptan la siguiente forma anidada para reconocimiento multimodal:

| Campo                                    | Tipo   | Obligatorio | Descripción                                                                        |
| ---------------------------------------- | ------ | ----------- | ---------------------------------------------------------------------------------- |
| `contents[].role`                        | string | No          | Rol del turno, por ejemplo `user`.                                                 |
| `contents[].parts`                       | array  | Sí          | Lista ordenada de parts de contenido (texto y/o medios inline).                    |
| `contents[].parts[].text`                | string | No          | Instrucción de texto o pregunta para el modelo.                                    |
| `contents[].parts[].inlineData`          | object | No          | Carga multimedia inline para comprensión de imagen, audio o video.                 |
| `contents[].parts[].inlineData.mimeType` | string | No          | Tipo MIME de los datos inline, por ejemplo `image/jpeg`, `audio/mp3`, `video/mp4`. |
| `contents[].parts[].inlineData.data`     | string | No          | Bytes multimedia codificados en base64.                                            |

<Tip>
  Puede mezclar varias parts en un solo turno; por ejemplo, una part `text` con una instrucción seguida de una o más parts `inlineData` que contengan el medio a analizar.
</Tip>

### Ejemplo: analizar una imagen

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

### Campos de respuesta

La respuesta sigue la forma estándar de `generateContent`. Los campos más relevantes para el reconocimiento multimedia son:

<ResponseField name="candidates" type="array">
  Respuestas candidatas devueltas por el modelo.

  <Expandable title="candidate properties">
    <ResponseField name="content" type="object">
      Objeto de contenido generado.

      <Expandable title="content properties">
        <ResponseField name="role" type="string">
          Rol devuelto en el bloque de contenido generado, normalmente `model`.
        </ResponseField>

        <ResponseField name="parts" type="array">
          Parts de contenido devueltas, normalmente texto que describe el medio analizado.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="finishReason" type="string">
      Cadena de motivo de finalización, por ejemplo `STOP`.
    </ResponseField>

    <ResponseField name="safetyRatings" type="array">
      Resultados de evaluación de seguridad.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="usageMetadata" type="object">
  Metadatos de contabilidad de tokens, incluido `promptTokenCount`, `candidatesTokenCount` y `totalTokenCount`. Los medios inline (imágenes, audio, video) consumen tokens del prompt además de cualquier part de texto.
</ResponseField>

### Ejemplo de respuesta

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

````