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

# Camel.toolkits.dalle toolkit

<a id="camel.toolkits.dalle_toolkit" />

<a id="camel.toolkits.dalle_toolkit.OpenAIImageToolkit" />

## OpenAIImageToolkit

```python theme={"system"}
class OpenAIImageToolkit(BaseToolkit):
```

A class representing a toolkit for image generation using OpenAI's
DALL-E model.

<a id="camel.toolkits.dalle_toolkit.OpenAIImageToolkit.__init__" />

### **init**

```python theme={"system"}
def __init__(self, timeout: Optional[float] = None):
```

Initializes a new instance of the OpenAIImageToolkit class.

**Parameters:**

* **timeout** (Optional\[float]): The timeout value for API requests in seconds. If None, no timeout is applied. (default: :obj:`None`)

<a id="camel.toolkits.dalle_toolkit.OpenAIImageToolkit.base64_to_image" />

### base64\_to\_image

```python theme={"system"}
def base64_to_image(self, base64_string: str):
```

Converts a base64 encoded string into a PIL Image object.

**Parameters:**

* **base64\_string** (str): The base64 encoded string of the image.

**Returns:**

Optional\[Image.Image]: The PIL Image object or None if conversion
fails.

<a id="camel.toolkits.dalle_toolkit.OpenAIImageToolkit.image_path_to_base64" />

### image\_path\_to\_base64

```python theme={"system"}
def image_path_to_base64(self, image_path: str):
```

Converts the file path of an image to a Base64 encoded string.

**Parameters:**

* **image\_path** (str): The path to the image file.

**Returns:**

str: A Base64 encoded string representing the content of the image
file.

<a id="camel.toolkits.dalle_toolkit.OpenAIImageToolkit.image_to_base64" />

### image\_to\_base64

```python theme={"system"}
def image_to_base64(self, image: Image.Image):
```

Converts an image into a base64-encoded string.

This function takes an image object as input, encodes the image into a
PNG format base64 string, and returns it.
If the encoding process encounters an error, it prints the error
message and returns None.

**Parameters:**

* **image**: The image object to be encoded, supports any image format that can be saved in PNG format.

**Returns:**

str: A base64-encoded string of the image.

<a id="camel.toolkits.dalle_toolkit.OpenAIImageToolkit.get_dalle_img" />

### get\_dalle\_img

```python theme={"system"}
def get_dalle_img(self, prompt: str, image_dir: str = 'img'):
```

Generate an image using OpenAI's DALL-E model.
The generated image is saved to the specified directory.

**Parameters:**

* **prompt** (str): The text prompt based on which the image is generated.
* **image\_dir** (str): The directory to save the generated image. Defaults to 'img'.

**Returns:**

str: The path to the saved image.

<a id="camel.toolkits.dalle_toolkit.OpenAIImageToolkit.get_tools" />

### get\_tools

```python theme={"system"}
def get_tools(self):
```

**Returns:**

List\[FunctionTool]: A list of FunctionTool objects
representing the functions in the toolkit.
