Generate images using Gemini
POST
https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp-image-generation:generateContent
responseModalities
: ["TEXT", "IMAGE"] in your generation configuration for text and image output with gemini-2.0-flash-exp-image-generation
. Image only is not allowed.Request Request Example
Shell
JavaScript
Java
Swift
curl --location -g --request POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp-image-generation:generateContent?key=' \
--header 'Content-Type: application/json' \
--data-raw '{
"contents": [{
"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"]}
}'
Response Response Example
{}
Request
Query Params
key
string
required
Example:
{{GEMINI_API_KEY}}
Header Params
Content-Type
string
required
Example:
application/json
Body Params application/json