agentai-image
Image generation and editing for AgentAI.
ImageGeneratorgenerates and edits images from your code.- With the
toolboxfeature (on by default),GenerateImageToolBoxgives an agent thegenerate_imageandedit_imagetools, with a required filenamethat is passed to the storage. The model gets the image, or only its metadata as JSON.ReadMediaToolBoxlets the model read a stored file by its ID. - Images are saved in any
MediaStorage(MediaRead+MediaSave,MemoryStorage) fromagentai_image::storage, re-exported fromagentai-core. - TLS features as in
agentai:rustls-ring(default),rustls-aws-lc,native-tls,system-proxy.
use ImageGenerator;
// The provider comes from the model name, the API key from `OPENAI_API_KEY`
let generator = new?.with_size;
let response = generator.generate.await?;
Providers live in agentai_image::provider. provider::openai speaks the OpenAI image API and
any API compatible with it (OPENAI_BASE_URL, or a base URL set in code); provider::openrouter
speaks the OpenRouter image API (openrouter::<model>, key from OPENROUTER_API_KEY).
provider::list_models("openai" | "openrouter") lists the image models a server offers. See the
image_generator, image_tools and list_models examples.