feat: implement proxy input file resolution and storage

- Added `inputFiles.ts` for handling input file resolution, including validation and normalization of file types.
- Introduced `proxyFileStore.ts` for managing file storage, retrieval, and deletion with owner-based isolation.
- Created tests for proxy file storage functionality in `proxyFileStore.test.ts`.
- Developed `proxyInputFileResolver.ts` to resolve input files in OpenAI and response formats.
- Added utility functions for handling reasoning signatures in `reasoningTransport.ts` and corresponding tests.
- Enhanced shared input file transformers in `inputFile.ts` for better file handling and type inference.
This commit is contained in:
cita
2026-03-08 22:10:31 +08:00
parent ede8998244
commit 7bd3114ea0
54 changed files with 4504 additions and 164 deletions
+12 -1
View File
@@ -26,6 +26,7 @@ Metapi 暴露标准 OpenAI / Claude 兼容接口,下游客户端只需配置
| `/v1/messages` | POST | Claude Messages |
| `/v1/completions` | POST | OpenAI Completions(Legacy) |
| `/v1/embeddings` | POST | 向量嵌入 |
| `/v1/files` | POST / GET / DELETE | OpenAI Files 上传、列举、读取与删除 |
| `/v1/images/generations` | POST | 图像生成 |
| `/v1/models` | GET | 模型列表 |
@@ -52,6 +53,10 @@ Metapi 暴露标准 OpenAI / Claude 兼容接口,下游客户端只需配置
| 模型提供商 → OpenAI → API 地址 | `https://your-domain.com` |
| API Key | `PROXY_TOKEN` |
> 说明:Metapi 现在支持标准 OpenAI `/v1/files` 文件链路。
> Cherry Studio、Open WebUI 等客户端如果通过标准 OpenAI Files + `Responses` / Chat 文件块发送 PDF、Markdown、JSON、图片、音频附件,即可经由 Metapi 转发。
> 如果某个客户端版本仍使用私有附件协议而不是标准 `/v1/files`,则仍需单独适配。
### Cursor
| 配置项 | 值 |
@@ -142,7 +147,13 @@ curl -sS https://your-domain.com/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"hi"}]}'
# 3. 测试流式
# 3. 测试文件上传
curl -sS https://your-domain.com/v1/files \
-H "Authorization: Bearer <PROXY_TOKEN>" \
-F "purpose=assistants" \
-F "file=@./sample.pdf"
# 4. 测试流式
curl -sS https://your-domain.com/v1/chat/completions \
-H "Authorization: Bearer <PROXY_TOKEN>" \
-H "Content-Type: application/json" \