Skip to main content

Image Generation

Generate images from text prompts and edit existing images using OpenAI’s DALL-E API. Ideal for marketing, design assistants, and content creation agents.
Reuses the openai peer dependency (already present if using OpenAI models).

Quick Start

import { Agent, openai, ImageGenerationToolkit } from "@radaros/core";

const imgGen = new ImageGenerationToolkit({
  apiKey: process.env.OPENAI_API_KEY,
  model: "dall-e-3",
  quality: "hd",
});

const agent = new Agent({
  name: "creative-agent",
  model: openai("gpt-4o"),
  instructions: "Generate images based on user descriptions.",
  tools: [...imgGen.getTools()],
});

const result = await agent.run("Create an illustration of a robot reading a book in a cozy library.");

Config

apiKey
string
required
OpenAI API key. Falls back to OPENAI_API_KEY env var.
model
string
default:"dall-e-3"
DALL-E model to use (dall-e-2 or dall-e-3).
size
string
default:"1024x1024"
Default image size. Options: 256x256, 512x512, 1024x1024, 1792x1024, 1024x1792.
quality
string
default:"standard"
Image quality (standard or hd). HD is only available for DALL-E 3.

Tools

ToolDescription
image_generateGenerate an image from a text prompt. Returns URL(s) and revised prompt.
image_editEdit an existing image with a text prompt (inpainting). Provide the original image URL.

Model Comparison

FeatureDALL-E 2DALL-E 3
Sizes256x256, 512x512, 1024x10241024x1024, 1792x1024, 1024x1792
QualityStandardStandard, HD
Prompt FollowingGoodExcellent
Image EditingYesNo
Batch (n > 1)YesNo

Environment Variables

VariableDescription
OPENAI_API_KEYOpenAI API key