Text to Image Tool
This tool allows Agents to use the OpenAI Image endpoint to generate and create variations of images.
Usage
This tool has more extensive example usage documented in a Jupyter notebook here
Another example showcases retrieval augmentation over a knowledge corpus with text-to-image. Notebook.
from llama_index.tools.text_to_image import TextToImageToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
openai.api_key = "sk-your-key"
tool_spec = TextToImageToolSpec()
# OR
tool_spec = TextToImageToolSpec(api_key="sk-your-key")
agent = FunctionAgent(
tools=tool_spec.to_tool_list(),
llm=OpenAI(model="gpt-4.1"),
)
# Context to store chat history
from llama_index.core.workflow import Context
ctx = Context(agent)
print(
await agent.run(
"show 2 images of a beautiful beach with a palm tree at sunset",
ctx=ctx,
)
)
print(await agent.run("make the second image higher quality", ctx=ctx))
generate_images: Generate images from a prompt, specifying the number of images and resolution
show_images: Show the images using matplot, useful for Jupyter notebooks
generate_image_variation: Generate a variation of an image given a URL.
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-text-to-image 0.6.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 | |
|---|---|---|---|---|
| llama_index_tools_text_to_image-0.6.0.tar.gz | 4.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llama_index_tools_text_to_image-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.7 kB
Release files / llama_index_tools_text_to_image-0.6.0.tar.gz
| Download URL | llama_index_tools_text_to_image-0.6.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
666f997a837d28854e287c2e2f0dc4064c12370220a19f4af643b1d677741444
|
|
BLAKE2b-256 checksum How to use checksums |
a9c8439cdf316c91207af9f525607b8d0d6dcb2aaa27161b91b1b385479f21af
|
| 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_text_to_image-0.6.0-py3-none-any.whl
| Download URL | llama_index_tools_text_to_image-0.6.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f95458111ccad2ce96d9f4c5153f4b954b728071a7b8d33cd71c556f836e4b4
|
|
BLAKE2b-256 checksum How to use checksums |
cc53530acb5ebc22cc04c527a1cbb53d75e0785d4cd42f3490f83e2dad19cb04
|
| 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-text-to-image 0.6.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.