Skip to content

Gemini Image Generator

Gemini Image Generator is a tool that lets you create new images by describing what you want. You give it a prompt, choose how many pictures you need, and pick a style or aspect ratio. The component talks to Google’s Gemini AI to produce the images, which you can then use in your dashboards, reports, or any other part of your workflow.

How it Works

When you run the component, it sends a request to the Google Gemini API.

  • Prompt – A text description of the image you want (up to 4,000 characters).
  • Image Files – Optional reference images that Gemini can use as a starting point.
  • Aspect Ratio – The shape of the image (e.g., 1:1, 3:4, 4:3, 9:16, 16:9).
  • Number of Images – How many variations you want.
  • Image Model – The specific Gemini model you want to use.

Gemini processes the request and returns one or more image files. The component then outputs these files as binary data, ready to be attached to other components or displayed in the dashboard.

Inputs

Mapping Mode

This component has a special mode called “Mapping Mode”. When you enable this mode using the toggle switch, an additional input called “Mapping Data” is activated, and each input field offers you three different ways to provide data:

  • Fixed: You type the value directly into the field.
  • Mapped: You connect the output of another component to use its result as the value.
  • Javascript: You write Javascript code to dynamically calculate the value.

This flexibility allows you to create more dynamic and connected workflows.

Input Fields

  • Image Files: A list of image files (URL or File Id) that Gemini can use as reference material for generation.
  • Aspect Ratio: The shape of the image. Choose one of the following values: 1:1, 3:4, 4:3, 9:16, or 16:9.
  • Mapping Mode: Toggle to enable batch processing of multiple data records.
  • Image Model: The name of the Gemini model you want to use.
  • Number of Images: How many images you want Gemini to generate.
  • Prompt: A text description of the desired image(s). The maximum length is 4,000 characters.
  • Tool Name: The name of the tool that will be used when this component is connected as a tool.
  • Tool Description: A detailed description of what this tool does.
  • Tools arguments metadata: Defines the arguments metadata for the tools.

Credential – This component requires a Google Gemini API credential.

  1. First, create a credential named “Google Gemini API” in the Nappai credentials section and provide your Google API Key.
  2. Then, select that credential in the component’s “Credential” field.
    (The credential fields themselves are not listed in the input section.)

Outputs

  • Image: Binary data produced by Gemini (method: generate_image_file).
  • Tool: A tool object that can be used by agents (method: to_toolkit).

Usage Example

  1. Add the Gemini Image Generator to your workflow.
  2. Set the Prompt to “A serene mountain landscape at sunrise, with mist over the valley.”
  3. Choose Aspect Ratio 16:9 for a wide‑screen view.
  4. Set Number of Images to 3 to get a few variations.
  5. Select the Google Gemini API credential you created earlier.
  6. Run the workflow.
  7. The component will output three image files that you can display in a gallery or attach to a report.
  • Text to Image Generator – Another image‑creation tool that uses different AI models.
  • Image Resizer – Adjusts the size of images produced by any generator.
  • Image Optimizer – Compresses images to reduce file size without losing quality.

Tips and Best Practices

  • Keep prompts clear and specific; longer, detailed prompts often yield better results.
  • Use the “Mapping Mode” to generate images for many records at once, saving time.
  • Choose an aspect ratio that matches where the image will be displayed (e.g., 9:16 for mobile stories).
  • Limit the number of images to what you actually need; generating many images can increase costs.
  • If you need reference images, upload them first and provide their URLs or File IDs.

Security Considerations

  • The component uses a Google Gemini API key, so keep that key secure and never expose it in public workflows.
  • Only grant the credential to trusted users or roles within your Nappai environment.
  • Review Google’s usage policies to ensure compliance with data handling and privacy requirements.