Skip to main content
POST
Gemini generateContent
Use a Gemini image-generation model to create images from text prompts. Image generation and editing both return through generateContent.
  • Use gemini-2.5-flash-image and declare IMAGE in generationConfig.responseModalities
  • Generated images usually appear in candidates[].content.parts[].inlineData with a MIME type and Base64 data
  • To provide a reference image, use inlineData in parts, or upload it to the Files API and use fileData

Authorizations

x-goog-api-key
string
header
required

Path Parameters

model
string
required

Gemini model name.

Example:

"gemini-2.5-flash-image"

Body

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

Response

Successful Gemini content response

candidates
object[]
usageMetadata
object