> For the complete documentation index, see [llms.txt](https://docs.agenticflow.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.agenticflow.ai/reference/nodes/openai_generate_image.md).

# Generate Image

**Action ID:** `openai_generate_image`

## Description

Generate an image using text-to-image models. This node supports both DALL-E 3 and DALL-E 2 models with customizable resolutions and quality settings. DALL-E 3 offers superior image quality while DALL-E 2 provides faster generations with more resolution options.

## Provider

**OpenAI**

## Connection

| Name              | Description                                        | Required | Category |
| ----------------- | -------------------------------------------------- | :------: | -------- |
| OpenAI Connection | The OpenAI connection to use for image generation. |     ✓    | openai   |

## Input Parameters

| Name       | Type     | Required | Default   | Description                                                                          |
| ---------- | -------- | :------: | --------- | ------------------------------------------------------------------------------------ |
| model      | dropdown |     -    | dall-e-3  | The model which will generate the image. Options: dall-e-3, dall-e-2                 |
| prompt     | string   |     ✓    | -         | The text prompt to generate an image from.                                           |
| resolution | dropdown |     -    | 1024x1024 | The resolution to generate the image in. Available options depend on selected model. |
| quality    | dropdown |     -    | standard  | Standard is faster, HD has better details.                                           |

<details>

<summary>View JSON Schema</summary>

```json
{
  "description": "Generate Image node input.",
  "properties": {
    "model": {
      "default": "dall-e-3",
      "description": "The model which will generate the image.",
      "title": "Model",
      "type": "string"
    },
    "prompt": {
      "description": "The text prompt to generate an image from.",
      "title": "Prompt",
      "type": "string"
    },
    "resolution": {
      "default": "1024x1024",
      "description": "The resolution to generate the image in.",
      "enum": [
        "1024x1024",
        "1024x1792",
        "1792x1024"
      ],
      "title": "Resolution",
      "type": "string"
    },
    "quality": {
      "default": "standard",
      "description": "Standard is faster, HD has better details.",
      "enum": [
        "standard",
        "hd"
      ],
      "title": "Quality",
      "type": "string"
    }
  },
  "required": [
    "prompt"
  ],
  "title": "GenerateImageInput",
  "type": "object"
}
```

</details>

## Output Parameters

| Name    | Type    | Description                                                    |
| ------- | ------- | -------------------------------------------------------------- |
| created | integer | Unix timestamp when the image was created.                     |
| data    | array   | Array of generated image objects containing URLs and metadata. |

<details>

<summary>View JSON Schema</summary>

```json
{
  "description": "Generate Image node output.",
  "properties": {
    "created": {
      "title": "Created",
      "type": "integer"
    },
    "data": {
      "items": {},
      "title": "Data",
      "type": "array"
    }
  },
  "title": "GenerateImageOutput",
  "type": "object"
}
```

</details>

## How It Works

This node sends your text prompt to OpenAI's image generation API along with your specified model, resolution, and quality settings. The model interprets your prompt and generates a new image from scratch. DALL-E 3 produces higher-quality, more detailed images but supports a more limited set of resolutions (1024x1024, 1024x1792, 1792x1024). DALL-E 2 is faster and offers more resolution options (1024x1024, 512x512, 256x256) but with generally lower quality. The response includes the generated image URL and metadata.

## Usage Examples

### Example 1: High-Quality Portrait

**Input:**

```
model: "dall-e-3"
prompt: "A serene portrait of a woman with flowing auburn hair in a sunlit garden, soft lighting, photorealistic style"
resolution: "1024x1024"
quality: "hd"
```

**Output:**

```
created: 1699564800
data: [
  {
    "url": "https://oaidalleapiprodscus.blob.core.windows.net/...",
    "revised_prompt": "A serene portrait of a woman with flowing auburn hair..."
  }
]
```

### Example 2: Vertical Mobile Image

**Input:**

```
model: "dall-e-3"
prompt: "A vibrant sunset over mountains, abstract watercolor style"
resolution: "1024x1792"
quality: "standard"
```

**Output:**

```
created: 1699564900
data: [
  {
    "url": "https://oaidalleapiprodscus.blob.core.windows.net/...",
    "revised_prompt": "A vibrant sunset over mountains..."
  }
]
```

### Example 3: Quick Generation with DALL-E 2

**Input:**

```
model: "dall-e-2"
prompt: "A cute robot made of recycled materials"
resolution: "512x512"
quality: "standard"
```

**Output:**

```
created: 1699565000
data: [
  {
    "url": "https://oaidalleapiprodscus.blob.core.windows.net/...",
    "revised_prompt": "A cute robot made of recycled materials"
  }
]
```

## Common Use Cases

* **Content Creation**: Generate images for articles, social media posts, or marketing materials
* **Visual Mockups**: Create quick visual prototypes and mockups during design phase
* **Illustration Generation**: Generate custom illustrations for books, presentations, or educational content
* **Product Visualization**: Create images of products in different scenarios or contexts
* **Concept Art**: Generate concept art for games, films, or creative projects
* **Marketing Assets**: Create unique visuals for advertising campaigns
* **Batch Image Generation**: Generate multiple variations of images for testing

## Error Handling

| Error Type           | Cause                                          | Solution                                                                                     |
| -------------------- | ---------------------------------------------- | -------------------------------------------------------------------------------------------- |
| Invalid Prompt       | Prompt contains prohibited content or is empty | Review prompt against OpenAI usage policies and ensure it's descriptive                      |
| Model Not Available  | Selected model doesn't exist                   | Verify model name (dall-e-2 or dall-e-3)                                                     |
| Invalid Resolution   | Resolution not supported by selected model     | Use 1024x1024, 1024x1792, 1792x1024 for DALL-E 3 or 1024x1024, 512x512, 256x256 for DALL-E 2 |
| Rate Limit Exceeded  | Too many requests in a short time              | Implement delays between requests or upgrade plan                                            |
| Authentication Error | Invalid or missing API key                     | Verify OpenAI connection is properly configured                                              |
| Insufficient Credits | Account has insufficient API credits           | Add credits to your OpenAI account                                                           |
| Timeout Error        | Request took too long to process               | Try again or use a faster model variant                                                      |

## Notes

* **Model Selection**: DALL-E 3 provides superior quality but costs more and supports fewer resolutions. Choose DALL-E 2 for faster, cost-effective generations.
* **Resolution Trade-offs**: Larger resolutions (1024x1792, 1792x1024) take longer to generate and cost more.
* **Quality Settings**: HD quality produces more detailed images but increases generation time and cost.
* **Prompt Engineering**: Write descriptive, detailed prompts for better results. Include style preferences (photorealistic, watercolor, etc.).
* **Revised Prompts**: DALL-E 3 may revise your prompt for safety and clarity. Check the revised\_prompt in the response.
* **Image URLs**: Generated image URLs are temporary. Download or store them if you need long-term access.
* **Costs**: Each image generation request incurs API costs. Budget accordingly for high-volume usage.
