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.
Usage with Agent
from llama_index.tools.openai import OpenAIImageGenerationToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
image_generation_tool = OpenAIImageGenerationToolSpec(
api_key=os.environ["OPENAI_API_KEY"]
)
agent = FunctionAgent(
tools=[*image_generation_tool.to_tool_list()],
llm=OpenAI(model="gpt-4.1"),
)
print(
await agent.run(
"A pink and blue llama in a black background with the output"
)
)
Usage directly
from llama_index.tools.openai 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.
Metadata
Release files for llama-index-tools-openai-image-generation 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llama_index_tools_openai_image_generation-0.7.0.tar.gz | 5.1 kB | Without provenance | Details for llama_index_tools_openai_image_generation-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_tools_openai_image_generation-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for llama_index_tools_openai_image_generation-0.7.0-py3-none-any.whl |
Total release size: 10.2 kB
Release files / llama_index_tools_openai_image_generation-0.7.0.tar.gz
| Download URL | llama_index_tools_openai_image_generation-0.7.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26a7a413d6738ab9cb3a661ab8df3638227ce2c658113aa0e410b1c8e78608ba
|
|
BLAKE2b-256 checksum How to use checksums |
4c601ab81c4430079a86560d8816b4e78d2e5ba9ac4ab8386817193b434bf415
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / llama_index_tools_openai_image_generation-0.7.0-py3-none-any.whl
| Download URL | llama_index_tools_openai_image_generation-0.7.0-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
727c8f72e20d534d10846d583a33002d72dfeca30c7f75e110ab49c749a83343
|
|
BLAKE2b-256 checksum How to use checksums |
c83c4bd2baad3c14396af31697602fba17bf8798f29e71770c0f87dcae4c52e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for llama-index-tools-openai-image-generation 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.