Skip to content

Image Generation

POST https://www.kkiai.com/v1beta/models/{modeName}:generateContent

Official Documentation: https://ai.google.dev/gemini-api/docs/image-generation?hl=zh-cn

Request Parameters

Authorization

Add the Authorization parameter to the Header. Its value is the Token concatenated after Bearer.

Example: Authorization: Bearer ********************

Path Parameters

Parameter NameTypeRequiredDescription
modeNamestringRequiredModel name: gemini-2.5-flash-image gemini-2.5-flash-image-preview gemini-3-pro-image-preview gemini-3.1-flash-image-preview

Query Parameters

Parameter NameTypeRequiredDescriptionExample
keystringRequired{{YOUR_API_KEY}}

Header Parameters

Parameter NameTypeRequiredDescriptionExample
Content-TypestringRequiredapplication/json

Body Parameters (application/json)

Parameter NameTypeRequiredDescription
contentsarray[object]Required
  └ partsarray[object]Required
generationConfigobjectOptional
  └ responseModalitiesarray[string]OptionalResponse modalities: Text、Image Default: ["Text", "Image"]
  └ imageConfigobjectOptional

Request Example

json
{
  "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": [
      "IMAGE"
    ]
  }
}

cURL Example

bash
curl --location -g --request POST 'https://www.kkiai.com/v1beta/models/gemini-2.5-flash-image-preview:generateContent?key=' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "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": [
      "IMAGE"
    ]
  }
}'

Response

🟢 200 Success

Response Example

json
{}