Skip to main content

Crate kavel

Crate kavel 

Source
Expand description

Generate and edit images from Rust with no API key and no account.

This crate calls the anonymous tier of Kavel, which meters its free allowance against a client id the crate invents rather than an account you register, so a program using it runs on a machine with nothing configured.

let img = kavel::generate("a paper boat at sunrise", &kavel::Options::default())?;
println!("{}", img.url);

Measured against the running service: a signed-out caller is granted 15 credits, one generated image costs 5 and one edit costs 15, so the crate mints a fresh client id per call. A ceiling of 30 credits per IP per day sits above that. Free output is 1K and watermarked.

Structs§

Image
One finished picture.
Options
Tunes a single call. Options::default() is a square image with a six minute deadline.

Enums§

Error
Everything that can go wrong, split by what the caller should do next.

Constants§

ANON_GRANT
Credit balance a signed-out caller starts with.
BASE_URL
The service this crate talks to.
COST_EDIT
What one edit costs: the whole grant, so one edit per client id.
COST_TEXT_TO_IMAGE
What one generated image costs, so the grant pays for three.
IP_DAILY_CEILING
Credits one machine may spend per day regardless of client ids.
MODEL_EDIT
The free image-to-image engine.
MODEL_GENERATE
The free text-to-image engine.

Functions§

anon_id
A fresh client id. The grant pays for three images or one edit, so a reused id walls partway through a loop for reasons the caller cannot see.
credits
What a client id has left. Costs nothing to call. None asks about a fresh id.
edit
Rewrite an existing image. source_url must be a public http(s) url and instruction says what to change.
generate
Turn a prompt into a new image.
parse_submit
Interpret the submit response. The quota wall answers HTTP 200 with code 0, so it can only be recognised by a field.