Skip to main content
POST
/
v1beta
/
models
/
{model}
:generateContent
Gemini generateContent
curl --request POST \
  --url http://sandbox.mintlify.com/v1beta/models/{model}:generateContent \
  --header 'Content-Type: application/json' \
  --header 'x-goog-api-key: <api-key>' \
  --data '
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "请总结这段内容"
        }
      ]
    }
  ]
}
'
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "这里是总结结果。"
          }
        ]
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 24,
    "candidatesTokenCount": 36,
    "totalTokenCount": 60
  }
}
Gemini’s official docs use the same generateContent family for image understanding, image generation, and image editing.
  • Images can be passed as inlineData or via the Files API
  • Small assets are commonly sent inline, while larger or reusable assets are better handled through Files API references
  • This path is suitable for image QA, OCR-assisted analysis, UI understanding, and multimodal reasoning
  • Native image generation and image editing still use generateContent
  • Text and generated images both come back through candidates[].content.parts[]
  • Google’s official docs note that generated images include a SynthID watermark

Authorizations

x-goog-api-key
string
header
required

Path Parameters

model
string
required

Gemini model name.

Example:

"gemini-2.5-pro"

Body

application/json
contents
object[]
required
systemInstruction
object
generationConfig
object
safetySettings
object[]
tools
object[]

Response

Successful Gemini content response

candidates
object[]
usageMetadata
object