Generate images with Cloudflare Workers AI's flux-1-schnell model
Go to file
foryoung365 12b53764ea 更新 manifest.json,移除 API 认证信息,添加 openapi 地址和插件标识符,以简化配置和增强可读性。 2025-04-29 18:59:41 +08:00
public 更新 manifest.json,移除 API 认证信息,添加 openapi 地址和插件标识符,以简化配置和增强可读性。 2025-04-29 18:59:41 +08:00
src 更新 README.md、manifest.json、openapi.json、plugin.json 文件,将插件重构为基于 Cloudflare Workers AI 的图像生成插件,修改设置步骤、认证方式和限制信息,更新 API 参数和描述以支持图像生成。 2025-04-29 15:25:14 +08:00
.gitignore Initial commit 2024-03-25 22:17:45 -04:00
LICENSE Create LICENSE 2024-12-18 14:29:10 -08:00
README.md 更新 README.md、manifest.json、openapi.json、plugin.json 文件,将插件重构为基于 Cloudflare Workers AI 的图像生成插件,修改设置步骤、认证方式和限制信息,更新 API 参数和描述以支持图像生成。 2025-04-29 15:25:14 +08:00
README_CN.md 更新 README.md、manifest.json、openapi.json、plugin.json 文件,将插件重构为基于 Cloudflare Workers AI 的图像生成插件,修改设置步骤、认证方式和限制信息,更新 API 参数和描述以支持图像生成。 2025-04-29 15:25:14 +08:00

README.md

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

  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
  2. 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

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"
  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"

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)