> For the complete documentation index, see [llms.txt](https://docs.agentipy.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.agentipy.fun/tools/create-image.md).

# Create Image

The `Create Image` tool is part of AgentiPy. Based on its name and implementation, it is used for generating images using OpenAI's DALL·E models. The tool requires an OpenAI API key to be configured within the `SolanaAgentKit`.

## Functionality

This tool is implemented in the `ImageGenerator` class.

### Key Methods:

* `create_image(agent: SolanaAgentKit, prompt: str, size: str = "1024x1024", n: int = 1)`:
  * Takes a `SolanaAgentKit` instance (which should have `openai_api_key` set), a text `prompt` for the image generation, the desired `size` (defaulting to "1024x1024"), and the number of images `n` to generate (defaulting to 1).
  * Checks if the `openai_api_key` is present in the agent's configuration.
  * Uses the `openai.Image.create` method (from the `openai` library) to request image generation based on the provided parameters.
  * Returns a dictionary containing a list of URLs for the generated images.

##

**Note:** This tool interacts with the OpenAI API and requires a valid API key. Ensure that the `openai` library is installed and that your API key has the necessary permissions and quota for image generation.

## Source Code

You can find the source code for this tool on GitHub: <https://github.com/niceberginc/agentipy/blob/main/agentipy/tools/create_image.py>
