This repository is archived and no longer maintained. All features have been migrated to separate repositories.
My personal Cloudflare Workers API repository
Please Fork this repository, manually create the wrangler.toml file, and add the following content:
name = "api"
main = "dist/index.js"
compatibility_date = "2024-04-05"
assets = { directory = "public" }
[vars]
KEY = "VALUE"
# See Environment Variables
# Only used for counting visits, can be omitted
[[d1_databases]]
binding = "count"
database_name = "YOUR_D1_DATABASE_NAME"
database_id = "YOUR_D1_DATABASE_ID"
# Only used for FileBox, can be omitted
[[r2_buckets]]
binding = "filebox"
bucket_name = "YOUR_BUCKET_NAME"
[observability] # Optional
enabled = true # OptionalCF_USER:CloudflareuserID, forPainterLeafandCyberLeafCF_AI_API_KEY:Cloudflare AIAPIkey, forPainterLeafandCyberLeafHF_API_KEY:Hugging FaceAPIkey, forPainterLeafPAINTERLEAF_SERVER_PASSWORD:PainterLeafserver password, forPainterLeafWEATHER_API_KEY:qWeatherAPIkey, forMyHomepageFILEBOX_UPLOAD_PW: FileBox upload password, forFileBoxFILEBOX_DOWNLOAD_PW: FileBox download password, forFileBox
If you don't need to use a certain feature, it's okay not to set the corresponding environment variable.
# Install dependencies
npm i -g bun # if you haven't installed bun yet
bun i
# Login to Cloudflare
bunx wrangler login
# Deploy
bun dep| Category | Function | Path | Method | Query Parameters | Request Body | Response |
|---|---|---|---|---|---|---|
PainterLeaf |
Get model list | /painter/models |
GET |
- | - | application/json |
PainterLeaf |
Generate image | /painter/generate |
POST |
- | prompt: prompt wordsmodel: model nameIf img2img: image: Array.from(uint8Array) |
image/png |
PainterLeaf |
Translate prompt words | /painter/translate |
POST |
- | text: textsource_lang: source languagetarget_lang: target language |
application/json |
MyHomepage |
qWeather | /weather |
GET |
location: longitude,latitude |
- | application/json |
PainterLeaf |
Generate text from image | /painter/genprompt |
POST |
- | image: Array.from(uint8Array) |
application/json |
PainterLeaf |
Generate text from image with llama3.2 vision |
/painter/genprompt/v4 |
POST |
- | image: Array.from(uint8Array) |
application/json |
Others |
Count visits | /count |
GET |
- | - | text/javascript |
Others |
Count visits | /count |
POST |
- | hostname: domain nameunique: whether to count as unique visitors |
application/json |
FileBox |
Upload file | /filebox/upload |
POST |
- | key: pickup codefilename: file namepassword: upload passwordfile: base64 encoded file |
application/json |
FileBox |
Download file | /filebox/download |
POST |
- | key: pickup codepassword: download passwordshouldDelete: whether to delete the filefiletype: file or text |
application/json |
Others |
Return my avatar | /avatar.jpg |
GET |
- | - | image/jpeg |
Others |
Return public avatar | /public_avatar.png |
GET |
- | - | image/png |
CyberLeaf |
Chat | /being/chat |
POST |
- | messages: { role: string, content: string }[] |
application/json |
CyberLeaf |
Test Connection | /being/test |
POST |
- | msg: 'ping' |
msg: 'pong' |