Crate diffusion_to

Source
Expand description

§diffusion_to

diffusion_to is a library for interacting with the API for diffusion.to. This API makes it easy to create AI-generated images and download them in a base64 format to be used however is needed. All options available in the UI are available through the library, using enums where possible to prevent invalid requests from being made.

§Example

Basic usage:

let client = DiffusionClient::new(args.api_key)?;

let request = ImageRequest::new(args.prompt)
    .update_steps(args.steps.try_into()?)
    .update_model(args.model.try_into()?)
let token = client.request_image(request).await?;

// wait for up to five minutes
let image = client
    .check_and_wait(token, Some(Duration::from_secs(300)))
    .await?;

println!("{}", iamge.raw)

Modules§

prelude

Structs§

DiffusionClient
The client used to interact with the diffusion.to API
DiffusionImage
The image response returned from the API when the image is complete
ImageRequest
An image request to notify the API of the parameters of the image to create
ImageToken
A token returned from the API that is used to check the status of the image and get the image when completed

Enums§

DiffusionError
Potential errors returned from the library
ImageModel
The available image models provided through the API
ImageOrientation
The available iamge orientations provided through the API
ImageSize
The available image sizes provided through the API
ImageSteps
The available steps provided through the API

Type Aliases§

Result