2.5 KiB
2.5 KiB
LobeChat Cloudflare Workers AI Image Generation Plugin
This is a LobeChat plugin that generates high-quality images using the @cf/black-forest-labs/flux-1-schnell
model from Cloudflare Workers AI.
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
Setup Steps
-
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 authenticationCLOUDFLARE_API_TOKEN
: Your Cloudflare API tokenCLOUDFLARE_ACCOUNT_ID
: Your Cloudflare account ID
-
Configure the plugin in LobeChat
- Add this plugin to LobeChat
- In the configuration page:
- Configure your Worker API key as
WORKER_API_KEY
- Ensure the Worker URL is correctly configured
- Configure your Worker API key as
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
-
In the chat, request to generate an image, for example:
- "Draw a cat standing on a mountain top"
- "Generate a beach sunset landscape"
-
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"
API Format Example
curl https://schnell-worker.foryoung365.workers.dev \
-X POST \
-H "X-Api-Key: <YOUR_WORKER_API_KEY>" \
-d '{ "prompt": "cyberpunk cat", "steps": 8 }'
Limitations
- 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
Privacy
- Your prompt text is sent to the Cloudflare AI API through the Worker
- This plugin does not collect or store your personal data
- Generated images are returned directly to your browser through the Worker
(Not affiliated with any of the above entities)