Skip to main content
POST
/
v1beta
/
models
/
{model}
:generateContent
gemini-3-pro-image-preview (text to image)
curl --request POST \
  --url https://api.example.com/v1beta/models/{model}:generateContent
Gemini’s official format for the text to image API.
curl --location 'https://gptproto.com/v1beta/models/gemini-3-pro-image-preview:generateContent' \
--header 'Authorization: sk-***********' \
--header 'Content-Type: application/json' \
--data '{
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "Hi, can you create a 3d rendered image of a pig with wings and a top hat flying over a happy futuristic scifi city with lots of greenery?"
                }
            ]
        }
    ],
    "generationConfig": {
        "responseModalities": [
            "TEXT",
            "IMAGE"
        ],
        "imageConfig": {
            "aspectRatio": "16:9",
            "imageSize": "1K"
        }
    }
}'
{
  "error": {
    "message": "Invalid signature",
    "type": "401"
  }
}

Path Parameters

Parameters

ParameterTypeRequiredDefaultDescription
contentsarray✅ Yes-An array of content objects representing the generation prompt. The role of the message sender. Typically "user". Optional for single-turn requests.
partsarray✅ Yes-An array of parts that make up the message content. Text prompt for image generation.
generationConfigobject❌ No-Configuration for the image generation behavior. Response modalities. For image generation, use ["TEXT", "IMAGE"].
imageConfigobject❌ No-Image-specific configuration. Aspect ratio for the generated image. Examples: "16:9", "1:1", "9:16".