ACTIONS
  • Home
  • My Actions
  • My Projects
  • My Packages
Gemini -> Generate Image
Readonly
Gemini → Generate Image

Action summary

Gemini -> Generate Image

Xano / Google Gemini

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

  1. Gemini API Request
    • Submits the provided prompt to the selected image-generation model at:
https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={API_KEY}
- Stores the Gemini response as `gemini_api`.
  1. Precondition
    • Ensures the request was successful with response status 200.
  2. Save Image
    • Extracts image data from gemini_api.response.result.candidates.content.parts.inlineData.data
    • Saves the image as image_response.png.
  3. Response
    • Returns the complete Gemini API response (gemini_api.response.result).

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 model parameter 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_DENIED or INVALID_ARGUMENT: Check your API key, model name, and prompt formatting.
  • No image output: If inlineData.data is 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

  • Gemini API: Image Generation
  • Gemini API Documentation

Version notes

2025-06-16 16:50:43
Current
2025-06-30T11:09:30.000+00:00