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

# autogen.agentchat.contrib.capabilities.generate_images.ImageGenerator

<h2 id="autogen.agentchat.contrib.capabilities.generate_images.ImageGenerator" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

  <span class="doc doc-object-name doc-class-name">ImageGenerator</span>
</h2>

```python theme={null}
ImageGenerator(*args, **kwargs)
```

This class defines an interface for image generators.<br />Concrete implementations of this protocol must provide a `generate_image` method that takes a string prompt as
input and returns a PIL Image object.<br />NOTE: Current implementation does not allow you to edit a previously existing image.

<b>Parameters:</b>

| Name       | Description |
| ---------- | ----------- |
| `*args`    |             |
| `**kwargs` |             |

### Instance Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### cache\_key

```python theme={null}
cache_key(self, prompt: str) -> str
```

Generates a unique cache key for the given prompt.<br />This key can be used to store and retrieve generated images based on the prompt.<br />

<b>Parameters:</b>

| Name     | Description                                                     |
| -------- | --------------------------------------------------------------- |
| `prompt` | A string describing the desired image.<br /><br />**Type:** str |

<b>Returns:</b>

| Type | Description                                      |
| ---- | ------------------------------------------------ |
| str  | A unique string that can be used as a cache key. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### generate\_image

```python theme={null}
generate_image(self, prompt: str) -> Image
```

Generates an image based on the provided prompt.<br />

<b>Parameters:</b>

| Name     | Description                                                     |
| -------- | --------------------------------------------------------------- |
| `prompt` | A string describing the desired image.<br /><br />**Type:** str |

<b>Returns:</b>

| Type            | Description                                          |
| --------------- | ---------------------------------------------------- |
| PIL.Image.Image | A PIL Image object representing the generated image. |

<br />
