> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentium.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Generation

> Generate and edit images via OpenAI DALL-E API.

# 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.

<Info>
  Reuses the `openai` peer dependency (already present if using OpenAI models).
</Info>

***

## Quick Start

```typescript theme={null}
import { Agent, openai, ImageGenerationToolkit } from "@agentium/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

<ParamField body="apiKey" type="string" required>
  OpenAI API key. Falls back to `OPENAI_API_KEY` env var.
</ParamField>

<ParamField body="model" type="string" default="dall-e-3">
  DALL-E model to use (`dall-e-2` or `dall-e-3`).
</ParamField>

<ParamField body="size" type="string" default="1024x1024">
  Default image size. Options: `256x256`, `512x512`, `1024x1024`, `1792x1024`, `1024x1792`.
</ParamField>

<ParamField body="quality" type="string" default="standard">
  Image quality (`standard` or `hd`). HD is only available for DALL-E 3.
</ParamField>

***

## Tools

| Tool             | Description                                                                             |
| ---------------- | --------------------------------------------------------------------------------------- |
| `image_generate` | Generate an image from a text prompt. Returns URL(s) and revised prompt.                |
| `image_edit`     | Edit an existing image with a text prompt (inpainting). Provide the original image URL. |

***

## Model Comparison

| Feature          | DALL-E 2                    | DALL-E 3                        |
| ---------------- | --------------------------- | ------------------------------- |
| Sizes            | 256x256, 512x512, 1024x1024 | 1024x1024, 1792x1024, 1024x1792 |
| Quality          | Standard                    | Standard, HD                    |
| Prompt Following | Good                        | Excellent                       |
| Image Editing    | Yes                         | No                              |
| Batch (n > 1)    | Yes                         | No                              |

***

## Environment Variables

| Variable         | Description    |
| ---------------- | -------------- |
| `OPENAI_API_KEY` | OpenAI API key |
