中文 | English
My personal 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"
[vars]
KEY = "VALUE"
# See Environment Variables
# Only used for counting visits, can be omitted
[[kv_namespaces]]
binding = "count"
id = "YOUR_KV_NAMESPACE_ID"
# Only used for FileBox, can be omitted
[[r2_buckets]]
binding = "filebox"
bucket_name = "YOUR_BUCKET_NAME"
CF_USER
:Cloudflare
userID
, forPainterLeaf
andCounselorLeaf
CF_AI_API_KEY
:Cloudflare AI
API
key, forPainterLeaf
andCounselorLeaf
HF_API_KEY
:Hugging Face
API
key, forPainterLeaf
WEATHER_API_KEY
:qWeather
API
key, forMyHomepage
FILEBOX_UPLOAD_PW
: FileBox upload password, forFileBox
FILEBOX_DOWNLOAD_PW
: FileBox download password, forFileBox
FILE0_SECRET_KEY
:File0
secret key, 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
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 (Beijing) | /weather |
GET |
location : longitude,latitude |
- | application/json |
CounselorLeaf |
Chat | /counselor/chat |
POST |
- | messages : message list, excluding system messages |
application/json |
PainterLeaf |
Generate text from image | /painter/genprompt |
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 |
Others |
Show README | / |
GET |
- | - | text/html |
FileBox |
Upload file | /filebox/upload/ws |
Get->WebSocket |
- | - | - |
FileBox |
Download file | /filebox/download/ws |
Get->WebSocket |
- | - | - |
FileBox |
Get File0 Token |
/filebox/file0 |
POST |
- | type: 'upload' | 'download' password : upload/download passwordfilename : file namekey : access code |
application/json { fileToken, keyToken, filename? } |