Skip to content

Commit f1c7ab6

Browse files
committed
refactor: OpenAI-only /v1 API
1 parent e16d81a commit f1c7ab6

46 files changed

Lines changed: 1530 additions & 5444 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@ batch generation, and one-click deployment to Cloudflare Pages.
2121
## Features
2222

2323
- **Multiple AI Providers** - Gitee AI, HuggingFace Spaces, ModelScope
24-
- **Image-to-Video** - Generate videos from images (Gitee AI)
2524
- **Dark Mode UI** - Gradio-style with frosted glass effects
2625
- **Flexible Sizing** - Multiple aspect ratios (1:1, 16:9, 9:16, 4:3, etc.)
27-
- **4x Upscaling** - RealESRGAN integration
2826
- **Secure Storage** - API keys encrypted with AES-256-GCM
2927
- **Token Rotation** - Multiple API keys with automatic failover on rate limits
3028
- **History (Lightweight)** - Stores metadata (URL + params) in localStorage with 24h TTL
3129
- **Flow Mode** - Visual canvas for batch generation (experimental)
3230
- Images are referenced by remote URLs (no blob caching)
33-
- Flow state is persisted locally; downloads use a proxy endpoint for CORS-safe fetches
31+
- Flow state is persisted locally
3432

3533
## Token Rotation
3634

@@ -92,20 +90,30 @@ Open `http://localhost:5173`
9290

9391
## API Usage
9492

95-
After deployment, you can call the API directly:
93+
After deployment, you can call the OpenAI-format API directly:
9694

9795
```bash
98-
curl -X POST https://your-project.pages.dev/api/generate \
96+
curl -X POST https://your-project.pages.dev/v1/images/generations \
9997
-H "Content-Type: application/json" \
100-
-H "X-API-Key: your-gitee-api-key" \
101-
-d '{"prompt": "a cute cat", "width": 1024, "height": 1024}'
98+
-H "Authorization: Bearer gitee:your-gitee-api-key" \
99+
-d '{
100+
"model": "gitee/z-image-turbo",
101+
"prompt": "a cute cat",
102+
"size": "1024x1024",
103+
"steps": 9,
104+
"n": 1,
105+
"response_format": "url"
106+
}'
102107
```
103108

104109
Notes:
105110

106111
- The API returns the **raw provider image URL** (e.g. HuggingFace Space `gradio_api/file=...`).
107112
- Some provider URLs are **temporary** (HF Space files often expire around 24 hours).
108-
- For CORS-safe downloads, use the built-in proxy endpoint: `GET /api/proxy-image?url=...`.
113+
- Provider routing is via the `model` prefix:
114+
- `gitee/...` -> Gitee AI (`Authorization: Bearer gitee:...`)
115+
- `ms/...` -> ModelScope (`Authorization: Bearer ms:...`)
116+
- no prefix -> HuggingFace (token optional; `Authorization: Bearer <token>` or `Authorization: Bearer hf:<token>`)
109117

110118
📖 **[Full API Reference](./docs/en/API.md)** - Providers, parameters, code examples
111119

README.zh.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
## 功能特性
2222

2323
- **多 AI 提供商** - Gitee AI、HuggingFace Spaces、ModelScope
24-
- **图片转视频** - 从图片生成视频 (Gitee AI)
2524
- **深色模式 UI** - Gradio 风格毛玻璃效果
2625
- **灵活尺寸** - 多种宽高比 (1:1, 16:9, 9:16, 4:3 等)
27-
- **4x 放大** - RealESRGAN 集成
2826
- **安全存储** - API Key 使用 AES-256-GCM 加密
2927
- **Token 轮询** - 多 API Key 自动切换,遇到限流自动换用下一个
3028
- **历史记录(轻量)** - 仅存元数据(URL + 参数)到 localStorage,24 小时自动过期清理
@@ -98,7 +96,31 @@ pnpm dev:web
9896

9997
- 接口返回的是**原始图片 URL**(例如 HuggingFace Space 的 `gradio_api/file=...`)。
10098
- 部分 URL 是**临时文件**(HF Space 通常 24 小时左右会失效)。
101-
- 如需绕过 CORS 下载,可使用代理接口:`GET /api/proxy-image?url=...`
99+
100+
## API 使用
101+
102+
部署后可直接调用 OpenAI 格式 API:
103+
104+
```bash
105+
curl -X POST https://your-project.pages.dev/v1/images/generations \
106+
-H "Content-Type: application/json" \
107+
-H "Authorization: Bearer gitee:your-gitee-api-key" \
108+
-d '{
109+
"model": "gitee/z-image-turbo",
110+
"prompt": "a cute cat",
111+
"size": "1024x1024",
112+
"steps": 9,
113+
"n": 1,
114+
"response_format": "url"
115+
}'
116+
```
117+
118+
说明:
119+
120+
- Provider 路由通过 `model` 前缀区分:
121+
- `gitee/...` -> Gitee AI(`Authorization: Bearer gitee:...`
122+
- `ms/...` -> ModelScope(`Authorization: Bearer ms:...`
123+
- 无前缀 -> HuggingFace(可选 token;`Authorization: Bearer <token>``Authorization: Bearer hf:<token>`
102124

103125
## 安全性
104126

0 commit comments

Comments
 (0)