https://github.com/JacobLinCool/sdxl-api
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.
https://github.com/JacobLinCool/sdxl-api
cloudflare-workers stable-diffusion
Last synced: 11 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/JacobLinCool/sdxl-api
- Owner: JacobLinCool
- License: mit
- Created: 2023-11-19T20:08:34.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-29T08:06:09.000Z (over 2 years ago)
- Last Synced: 2025-05-07T05:28:57.729Z (about 1 year ago)
- Topics: cloudflare-workers, stable-diffusion
- Language: TypeScript
- Homepage:
- Size: 198 KB
- Stars: 15
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SDXL API
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.

## Features
- **Image Generation:** Generate images from text prompts with customizable steps.
- **Image Retrieval:** Retrieve generated images and their configurations. (opt-in with R2 binding)
## Usage
I recommend to use this as an [Service Binding](https://developers.cloudflare.com/workers/configuration/bindings/about-service-bindings/), 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.
### Service Binding
You can use [the library](./packages/sdxl-api/) to interact with the service binding.
```toml
# add this to downstream worker's wrangler.toml
[[services]]
binding = "sdxl"
service = "sdxl-api-worker"
```
```ts
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,
);
// ...
},
};
```
## Contributions
Your contributions and suggestions are heartily welcome.