← All tools

Vision & Media

Image Generation

Create images from a text prompt.

image_generate

Overview

Turns a text description into an actual image, using OpenAI's DALL·E models. Tell it what you want — 'a minimalist product hero for a climate-tech launch' — and it renders the picture for the agent to deliver or hand off to another step.

How it works

Calls the OpenAI Images API to generate images from a text prompt. Supports DALL-E 2, DALL-E 3, and gpt-image-1 with size, quality, style, and count options. Returns either a hosted URL or base64 bytes, and can optionally save the result to a local file path.

Example

When a user asks:

Create a minimalist hero image for our climate-tech launch.

the agent calls the tool:

image_generate(prompt="Minimalist hero image, climate-tech product, soft gradient", model="dall-e-3", size="1792x1024")

and gets back: a URL to the generated image (or base64 bytes), plus metadata.

Configuration

Set these before calling the tool. Values marked required must be present or the tool call will fail.

OPENAI_API_KEY required

OpenAI API key. Also exposed as swarmai.tools.image.api-key.

swarmai.tools.image.base-url optional

Override the base URL for OpenAI-compatible providers (Azure OpenAI, gateway proxies).

Use it in a workflow

Wire this tool into a SwarmAI crew. Use the YAML DSL for declarative workflows, or the Java builder API when you want full programmatic control.

YAML DSL

# creative-gen.yaml
name: creative-gen-crew
process: SEQUENTIAL

agents:
  - id: designer
    role: Creative Generator
    goal: Produce marketing images from campaign briefs
    tools:
      - image_generate

tasks:
  - id: creative-gen-task
    agent: designer
    description: Generate a minimalist hero image for the Q4 climate-tech launch, 1792x1024.

Java

import ai.intelliswarm.swarmai.agent.Agent;
import ai.intelliswarm.swarmai.task.Task;
import ai.intelliswarm.swarmai.swarm.Swarm;
import ai.intelliswarm.swarmai.swarm.SwarmOutput;
import ai.intelliswarm.swarmai.process.ProcessType;
import ai.intelliswarm.swarmai.tool.vision.ImageGenerationTool;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;

@Autowired ChatClient chatClient;
@Autowired ImageGenerationTool imageGenerationTool;

Agent designer = Agent.builder()
    .role("Creative Generator")
    .goal("Produce marketing images from campaign briefs")
    .chatClient(chatClient)
    .tool(imageGenerationTool)
    .build();

Task designerTask = Task.builder()
    .description("Generate a minimalist hero image for the Q4 climate-tech launch, 1792x1024.")
    .agent(designer)
    .build();

SwarmOutput result = Swarm.builder()
    .agent(designer)
    .task(designerTask)
    .process(ProcessType.SEQUENTIAL)
    .build()
    .kickoff();

What it's good for

Real scenarios where agents put this tool to work.

Generate marketing creatives or hero images from a campaign brief
Produce diagram or illustration variants for reports and slide decks
Create product visualizations from feature descriptions for design review
Quick concept images inside a broader content-generation crew

Source

Implementation lives at swarmai-tools/src/main/java/ai/intelliswarm/swarmai/tool/vision/ImageGenerationTool.java in the swarm-ai repository.

Open image_generate on GitHub →