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

# Gemini Audio Generation

> <ul><li>Gemini audio generation endpoint.</li><li>You can use models such as gemini-2.5-flash-preview-tts</li></ul>

<RequestExample>
  ```bash cURL theme={null} theme={null}
  curl --request POST \
    --url 'https://api.elkapi.com/v1beta/models/gemini-3.1-pro-preview:generateContent' \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
    "contents": [
      "Hello, please introduce yourself"
    ],
    "generationConfig": {
      "responseModalities": [
        "responseModalitie"
      ],
      "speechConfig": {
        "voiceConfig": {
          "prebuiltVoiceConfig": {
            "voiceName": "voiceName"
          }
        }
      }
    }
  }'
  ```

  ```python Python theme={null} theme={null}
  import requests

  url = "https://api.elkapi.com/v1beta/models/gemini-3.1-pro-preview:generateContent"
  headers = {
      "Authorization": "Bearer <token>"
  }
  headers["Content-Type"] = "application/json"
  payload = {
      "contents": [
          "Hello, please introduce yourself"
      ],
      "generationConfig": {
          "responseModalities": [
              "responseModalitie"
          ],
          "speechConfig": {
              "voiceConfig": {
                  "prebuiltVoiceConfig": {
                      "voiceName": "voiceName"
                  }
              }
          }
      }
  }

  response = requests.request("POST", url, headers=headers, json=payload)
  print(response.json())
  ```

  ```javascript JavaScript theme={null} theme={null}
  const url = "https://api.elkapi.com/v1beta/models/gemini-3.1-pro-preview:generateContent";

  const headers = {
    "Authorization": "Bearer <token>"
  };
  headers["Content-Type"] = "application/json";
  const payload = {
    "contents": [
      "Hello, please introduce yourself"
    ],
    "generationConfig": {
      "responseModalities": [
        "responseModalitie"
      ],
      "speechConfig": {
        "voiceConfig": {
          "prebuiltVoiceConfig": {
            "voiceName": "voiceName"
          }
        }
      }
    }
  };

  const response = await fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(payload)
  });

  console.log(await response.json());
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null} theme={null}
  {
    "candidates": [
      {
        "content": "Hello, please introduce yourself",
        "finishReason": "finishReason",
        "safetyRatings": [
          {}
        ]
      }
    ],
    "usageMetadata": {
      "promptTokenCount": 1,
      "candidatesTokenCount": 1,
      "totalTokenCount": 1
    }
  }
  ```
</ResponseExample>

## Authorizations

<ParamField header="Authorization" type="string" required>
  All endpoints require Bearer Token authentication.

  Add it to the request headers:

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Path Parameters

<ParamField path="model" type="string" required default="gemini-3.1-pro-preview">
  Model name

  Example: `gemini-3.1-pro-preview`
</ParamField>

## Body

<ParamField body="contents" type="array<object>" required>
  <ParamField body="contents.parts" type="array<object>">
    <ParamField body="contents.parts.text" type="string" />
  </ParamField>
</ParamField>

<ParamField body="generationConfig" type="object" required>
  <ParamField body="generationConfig.responseModalities" type="array<string>" required />

  <ParamField body="generationConfig.speechConfig" type="object" required>
    <ParamField body="generationConfig.speechConfig.voiceConfig" type="object" required>
      <ParamField body="generationConfig.speechConfig.voiceConfig.prebuiltVoiceConfig" type="object" required />
    </ParamField>
  </ParamField>
</ParamField>

## Response

<ResponseField name="candidates" type="array<object>">
  <ResponseField name="candidates.content" type="object">
    <ResponseField name="candidates.content.role" type="string" />

    <ResponseField name="candidates.content.parts" type="array<object>" />
  </ResponseField>

  <ResponseField name="candidates.finishReason" type="string" />

  <ResponseField name="candidates.safetyRatings" type="array<object>" />
</ResponseField>

<ResponseField name="usageMetadata" type="object">
  <ResponseField name="usageMetadata.promptTokenCount" type="integer" />

  <ResponseField name="usageMetadata.candidatesTokenCount" type="integer" />

  <ResponseField name="usageMetadata.totalTokenCount" type="integer" />
</ResponseField>
