Skip to main content
POST
/
v1
/
models
/
{model}
:generateContent
Generate content (Gemini)
curl --request POST \
  --url https://api.dgrid.ai/v1/models/{model}:generateContent \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Hello from DGrid."
        }
      ]
    }
  ]
}
'
{
  "candidates": [
    {
      "content": {
        "role": "<string>",
        "parts": [
          {}
        ]
      },
      "finishReason": "<string>",
      "safetyRatings": [
        {}
      ]
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 123,
    "candidatesTokenCount": 123,
    "totalTokenCount": 123
  }
}
This page uses the same generateContent operation as Generate content (Gemini), 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.
Set generationConfig.responseModalities to ["AUDIO"] to request audio output, and configure generationConfig.speechConfig.voiceConfig.prebuiltVoiceConfig.voiceName to choose a prebuilt voice for generated speech.

Gemini-native request fields

FieldTypeRequiredDescription
generationConfig.responseModalitiesarrayYesRequested response modalities, e.g. ["AUDIO"].
generationConfig.speechConfigobjectNoSpeech configuration object.
generationConfig.speechConfig.voiceConfigobjectNoVoice configuration wrapper.
generationConfig.speechConfig.voiceConfig.prebuiltVoiceConfigobjectNoPrebuilt voice settings.
generationConfig.speechConfig.voiceConfig.prebuiltVoiceConfig.voiceNamestringNoPrebuilt voice preset name, e.g. Kore.
Use a text-to-speech-capable model such as gemini-2.5-flash-preview-tts in the model path parameter when requesting audio output.

Example: requesting speech audio

{
  "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:
candidates
array
Candidate responses returned by the model.
usageMetadata
object
Token accounting, including promptTokenCount, candidatesTokenCount, and totalTokenCount.
promptFeedback
object
Prompt blocking feedback when applicable.

Example response

200
{
  "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
  }
}

Authorizations

Authorization
string
header
required

Your DGrid API key. All endpoints use Authorization: Bearer <DGRID_API_KEY>.

Path Parameters

model
string
required

Target model ID, such as gemini-1.5-pro.

Body

application/json
contents
object[]

Input content array with role and parts.

generationConfig
object

Generation configuration.

Response

Generated content candidates.

candidates
object[]

Candidate responses returned by the model.

usageMetadata
object

Token accounting metadata.