2025-04-29 07:25:14 +00:00
# LobeChat Cloudflare Workers AI Image Generation Plugin
2024-12-18 22:28:36 +00:00
2025-04-29 07:25:14 +00:00
This is a LobeChat plugin that generates high-quality images using the `@cf/black-forest-labs/flux-1-schnell` model from [Cloudflare Workers AI ](https://developers.cloudflare.com/workers-ai/ ).
2024-12-18 22:28:36 +00:00
2025-04-29 07:25:14 +00:00
## Features
- Generate high-quality images using Cloudflare's Flux-1-Schnell model
- Request proxying through Cloudflare Worker for simplified authentication
- Generate and view images directly in LobeChat conversations
2025-04-28 10:38:21 +00:00
2025-04-29 07:25:14 +00:00
## Setup Steps
2025-04-28 10:38:21 +00:00
2025-04-29 07:25:14 +00:00
1. Set up Cloudflare Worker
- Deploy the provided Worker code to Cloudflare Workers
- Configure the following environment variables (Secrets) in your Worker settings:
- `WORKER_API_KEY` : Set a secure API key for client authentication
- `CLOUDFLARE_API_TOKEN` : Your Cloudflare API token
- `CLOUDFLARE_ACCOUNT_ID` : Your Cloudflare account ID
2025-04-28 10:38:21 +00:00
2025-04-29 07:25:14 +00:00
2. Configure the plugin in LobeChat
2025-04-28 10:53:59 +00:00
- Add this plugin to LobeChat
2025-04-29 07:25:14 +00:00
- In the configuration page:
- Configure your Worker API key as `WORKER_API_KEY`
- Ensure the Worker URL is correctly configured
## Authentication and Parameters
This plugin uses the following configuration to access your Cloudflare Worker:
- Worker API key: Used as the X-Api-Key request header
- You only need to provide the image description (prompt) when using this plugin
- The Worker automatically calls the Cloudflare AI API using the configured credentials
## Usage Instructions
1. In the chat, request to generate an image, for example:
- "Draw a cat standing on a mountain top"
- "Generate a beach sunset landscape"
2025-04-28 10:38:21 +00:00
2025-04-29 07:25:14 +00:00
2. Supported parameters:
- prompt: Image description (required, maximum 2048 characters)
- steps: Number of diffusion steps (optional, default 4, maximum 8)
Example: "Generate an image of an astronaut riding a horse, using 8 diffusion steps"
2025-04-28 10:38:21 +00:00
2025-04-29 07:25:14 +00:00
## API Format Example
2025-04-28 10:38:21 +00:00
2025-04-29 07:25:14 +00:00
```bash
curl https://schnell-worker.foryoung365.workers.dev \
-X POST \
-H "X-Api-Key: < YOUR_WORKER_API_KEY > " \
-d '{ "prompt": "cyberpunk cat", "steps": 8 }'
```
2025-04-28 10:38:21 +00:00
2025-04-28 10:53:59 +00:00
## Limitations
2025-04-28 10:38:21 +00:00
2025-04-29 07:25:14 +00:00
- There may be usage limitations based on your Cloudflare account type
- The Flux-1-Schnell model has its own capability range; not all prompts will produce ideal results
- Higher diffusion steps take longer to generate but may produce higher quality
2025-04-28 10:38:21 +00:00
2025-04-28 10:53:59 +00:00
## Privacy
2025-04-28 10:38:21 +00:00
2025-04-29 07:25:14 +00:00
- Your prompt text is sent to the Cloudflare AI API through the Worker
2025-04-28 10:53:59 +00:00
- This plugin does not collect or store your personal data
2025-04-29 07:25:14 +00:00
- Generated images are returned directly to your browser through the Worker
2025-04-28 10:38:21 +00:00
2025-04-29 07:25:14 +00:00
`(Not affiliated with any of the above entities)`