SDXL API provides a seamless interface for image generation and retrieval using Stable Diffusion XL integrated with Cloudflare AI Workers. This API allows users to generate and manage images in a highly efficient and scalable manner.
- Image Generation: Generate images from text prompts with customizable steps.
- Image Retrieval: Retrieve generated images and their configurations. (opt-in with R2 binding)
I recommend to use this as an Service Binding, and use Cloudflare Zero Trust to protect the Swagger UI. By this way, your other applications and still access the service with Service Binding, while the Swagger UI (and the whole API) is protected by Cloudflare Zero Trust and only you (and the one you trust) can access it.
You can use the library to interact with the service binding.
# add this to downstream worker's wrangler.toml
[[services]]
binding = "sdxl"
service = "sdxl-api-worker"
import { sdxl } from "sdxl-api";
export default {
async fetch(request, env) {
// setup the SDXL instance, bind to the service
sdxl.setup({ fetcher: env.sdxl });
// generate an image
const [image] = await sdxl.generate(
"A colorful deep space nebula on a black background.",
12,
);
// ...
},
};
Your contributions and suggestions are heartily welcome.