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

# Native Gemini Format

> 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 fields you can add to `generationConfig` to request audio understanding or generation with structured parts.

<Note>
  Set `generationConfig.responseModalities` to `["AUDIO"]` to request audio output, and configure `generationConfig.speechConfig.voiceConfig.prebuiltVoiceConfig.voiceName` to choose a prebuilt voice for generated speech.
</Note>

### Gemini-native request fields

| Field                                                                     | Type   | Required | Description                                      |
| ------------------------------------------------------------------------- | ------ | -------- | ------------------------------------------------ |
| `generationConfig.responseModalities`                                     | array  | Yes      | Requested response modalities, e.g. `["AUDIO"]`. |
| `generationConfig.speechConfig`                                           | object | No       | Speech configuration object.                     |
| `generationConfig.speechConfig.voiceConfig`                               | object | No       | Voice configuration wrapper.                     |
| `generationConfig.speechConfig.voiceConfig.prebuiltVoiceConfig`           | object | No       | Prebuilt voice settings.                         |
| `generationConfig.speechConfig.voiceConfig.prebuiltVoiceConfig.voiceName` | string | No       | Prebuilt voice preset name, e.g. `Kore`.         |

<Tip>
  Use a text-to-speech-capable model such as `gemini-2.5-flash-preview-tts` in the `model` path parameter when requesting audio output.
</Tip>

### Example: requesting speech audio

```json theme={null}
{
  "contents": [
    {
      "role": "user",
      "parts": [
        { "text": "Say cheerfully: Have a wonderful day!" }
      ]
    }
  ],
  "generationConfig": {
    "responseModalities": ["AUDIO"],
    "speechConfig": {
      "voiceConfig": {
        "prebuiltVoiceConfig": {
          "voiceName": "Kore"
        }
      }
    }
  }
}
```

### Response fields

The response follows the standard `generateContent` shape. When audio output is requested, the returned `parts` contain inline audio data instead of text:

<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 parts. For audio output, each part contains an `inlineData` object with `mimeType` (e.g. `audio/L16;codec=pcm;rate=24000`) and base64-encoded `data`.
        </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, including `promptTokenCount`, `candidatesTokenCount`, and `totalTokenCount`.
</ResponseField>

<ResponseField name="promptFeedback" type="object">
  Prompt blocking feedback when applicable.
</ResponseField>

### Example response

```json 200 theme={null}
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "inlineData": {
              "mimeType": "audio/L16;codec=pcm;rate=24000",
              "data": "<base64-encoded-audio-bytes>"
            }
          }
        ]
      },
      "finishReason": "STOP",
      "safetyRatings": []
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 10,
    "candidatesTokenCount": 0,
    "totalTokenCount": 10
  }
}
```


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

````