Gemini -> Generate Image
Readonly
Action summary
Gemini -> Generate Image
Gemini → Generate Image
Overview
This action allows you to generate an image using the Gemini API by providing a model choice and a prompt description. The function sends your image generation request to Gemini, retrieves the resulting image data, and saves it as a downloadable file.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
gemini_api_key |
text | Yes | Your Gemini API key (from settings registry). |
model |
text | Yes | The name of the Gemini model to use for image generation |
prompt |
text | Yes | The textual description for the image you wish to generate |
Function Stack
- Gemini API Request
- Submits the provided
promptto the selected image-generationmodelat:
- Submits the provided
https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={API_KEY}
- Stores the Gemini response as `gemini_api`.
- Precondition
- Ensures the request was successful with response status
200.
- Ensures the request was successful with response status
- Save Image
- Extracts image data from
gemini_api.response.result.candidates.content.parts.inlineData.data - Saves the image as
image_response.png.
- Extracts image data from
- Response
- Returns the complete Gemini API response (
gemini_api.response.result).
- Returns the complete Gemini API response (
Example Usage
Request
{
"gemini_api_key": "AIzaSyD...",
"model": "gemini-1.5-flash",
"prompt": "A futuristic city skyline at sunset in vibrant colors"
}
Response
{
"candidates": [
{
"content": {
"parts": [
{ "text": "A futuristic city skyline at sunset..." },
{ "inlineData": { "mimeType": "image/png", "data": "iVBORw0KGgoAAAANSUhEUg..." } }
]
}
}
]
// ... other response data
}
Notes
- The
modelparameter lets you choose between available Gemini image models (e.g.,gemini-1.5-flash). Ensure the selected model supports image generation. - The generated image is saved as a file (
image_response.png), which you can directly use or download. - The prompt should be clear and descriptive for best results.
- Make sure your API key has access to the relevant model and sufficient usage quota.
Troubleshooting
PERMISSION_DENIEDorINVALID_ARGUMENT: Check your API key, model name, and prompt formatting.- No image output: If
inlineData.datais empty, check your model choice and try another prompt. - Image file corrupt or unreadable: Confirm the returned data and file creation process completed successfully.
References
Version notes
2025-06-16 16:50:43
Current