# OpenAI Image Generation Tool
This tool allows Agents to generate images using OpenAI's DALL-E model. To see more and get started, visit https://openai.com/blog/dall-e/
## Usage
This tool has a more extensive example usage documented in a Jupyter notebook [here](https://github.com/emptycrown/llama-hub/tree/main/llama_hub/tools/notebooks/openai_image_generation.ipynb)
### Usage with Agent
```python
from llama_index.tools.openai.image_generation import (
OpenAIImageGenerationToolSpec,
)
image_generation_tool = OpenAIImageGenerationToolSpec(
api_key=os.environ["OPENAI_API_KEY"]
)
agent = OpenAIAgent.from_tools(
[*image_generation_tool.to_tool_list()],
verbose=True,
)
response = agent.query(
"A pink and blue llama in a black background with the output"
)
print(response)
```
### Usage directly
```python
from llama_index.tools.openai.image_generation import (
OpenAIImageGenerationToolSpec,
)
image_generation_tool = OpenAIImageGenerationToolSpec(
api_key=os.environ["OPENAI_API_KEY"]
)
image_data = image_generation_tool.image_generation(
text="A pink and blue llama with a black background",
response_format="b64_json",
)
image_bytes = base64.b64decode(image_data)
img = Image.open(BytesIO(image_bytes))
display(img)
```
`image_generation`: Takes an text input and generates an image
This loader is designed to be used as a way to load data as a Tool in a Agent. See [here](https://github.com/emptycrown/llama-hub/tree/main) for examples.
Raw data
{
"_id": null,
"home_page": "",
"name": "llama-index-tools-openai-image-generation",
"maintainer": "manelferreira_",
"docs_url": null,
"requires_python": ">=3.8.1,<4.0",
"maintainer_email": "",
"keywords": "cv,gpt-3,image,openai,vision",
"author": "Your Name",
"author_email": "you@example.com",
"download_url": "https://files.pythonhosted.org/packages/34/4e/8781d43b12128ecba8227436d79db1c59219fcd1378c3d76869e57b5e10a/llama_index_tools_openai_image_generation-0.1.3.tar.gz",
"platform": null,
"description": "# OpenAI Image Generation Tool\n\nThis tool allows Agents to generate images using OpenAI's DALL-E model. To see more and get started, visit https://openai.com/blog/dall-e/\n\n## Usage\n\nThis tool has a more extensive example usage documented in a Jupyter notebook [here](https://github.com/emptycrown/llama-hub/tree/main/llama_hub/tools/notebooks/openai_image_generation.ipynb)\n\n### Usage with Agent\n\n```python\nfrom llama_index.tools.openai.image_generation import (\n OpenAIImageGenerationToolSpec,\n)\n\nimage_generation_tool = OpenAIImageGenerationToolSpec(\n api_key=os.environ[\"OPENAI_API_KEY\"]\n)\n\nagent = OpenAIAgent.from_tools(\n [*image_generation_tool.to_tool_list()],\n verbose=True,\n)\n\nresponse = agent.query(\n \"A pink and blue llama in a black background with the output\"\n)\n\nprint(response)\n```\n\n### Usage directly\n\n```python\nfrom llama_index.tools.openai.image_generation import (\n OpenAIImageGenerationToolSpec,\n)\n\nimage_generation_tool = OpenAIImageGenerationToolSpec(\n api_key=os.environ[\"OPENAI_API_KEY\"]\n)\n\nimage_data = image_generation_tool.image_generation(\n text=\"A pink and blue llama with a black background\",\n response_format=\"b64_json\",\n)\n\nimage_bytes = base64.b64decode(image_data)\n\nimg = Image.open(BytesIO(image_bytes))\n\ndisplay(img)\n```\n\n`image_generation`: Takes an text input and generates an image\n\nThis loader is designed to be used as a way to load data as a Tool in a Agent. See [here](https://github.com/emptycrown/llama-hub/tree/main) for examples.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "llama-index tools openai_image_generation integration",
"version": "0.1.3",
"project_urls": null,
"split_keywords": [
"cv",
"gpt-3",
"image",
"openai",
"vision"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ab3c2a843e030666e08f0bba55aa626930ff74af23a9b7d8e4ef90c96a80283c",
"md5": "c7446a4d2a00d9c752412fbacfe21ca9",
"sha256": "961129630fd5190f2a9f0c20b9f99eb9507d34cd68999de02f363da6a3acb298"
},
"downloads": -1,
"filename": "llama_index_tools_openai_image_generation-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c7446a4d2a00d9c752412fbacfe21ca9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8.1,<4.0",
"size": 3623,
"upload_time": "2024-02-21T22:23:43",
"upload_time_iso_8601": "2024-02-21T22:23:43.818340Z",
"url": "https://files.pythonhosted.org/packages/ab/3c/2a843e030666e08f0bba55aa626930ff74af23a9b7d8e4ef90c96a80283c/llama_index_tools_openai_image_generation-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "344e8781d43b12128ecba8227436d79db1c59219fcd1378c3d76869e57b5e10a",
"md5": "b6931f3b10fba8da641f7506ea25af7f",
"sha256": "aab9b34774136d37caa8b6b0f8da4eb8c4eea31b7b190e0a57c2d339b6e4c2c6"
},
"downloads": -1,
"filename": "llama_index_tools_openai_image_generation-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "b6931f3b10fba8da641f7506ea25af7f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.1,<4.0",
"size": 3034,
"upload_time": "2024-02-21T22:23:45",
"upload_time_iso_8601": "2024-02-21T22:23:45.569577Z",
"url": "https://files.pythonhosted.org/packages/34/4e/8781d43b12128ecba8227436d79db1c59219fcd1378c3d76869e57b5e10a/llama_index_tools_openai_image_generation-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-21 22:23:45",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "llama-index-tools-openai-image-generation"
}