Gateway API 文档

OpenAI 兼容
POST/openai/v1/files

Files 上传(仅 Batch)

上传 OpenAI-compatible Batch JSONL,**仅支持 purpose=batch**。Gateway 校验每行唯一 custom_id 和已发布 body.model,将 model 改写为 LiteLLM model_name,并固化请求时人民币价格快照。文件归属绑定到当前账户。

需要认证

请求参数

参数类型必填说明
purposestring必填文件用途,**本网关仅允许 "batch"**。
filefile必填文件二进制(JSONL,每行一条 {custom_id, method, url, body} 请求对象)。上传体上限默认 512MB。

调用示例

typescript
import OpenAI from "openai"
import fs from "node:fs"

const client = new OpenAI({ baseURL: "https://llmapi.memene.cn/openai/v1", apiKey: "gw_memene_<keyId>_<secret>" })

// 仅支持 purpose="batch",上传 JSONL(每行一条 {custom_id, method, url, body})
const file = await client.files.create({
  file: fs.createReadStream("requests.jsonl"),
  purpose: "batch",
})
console.log(file.id)

响应示例

json
{
  "id": "file-abc123",
  "object": "file",
  "bytes": 120000,
  "created_at": 1700000000,
  "filename": "requests.jsonl",
  "purpose": "batch"
}

注意:配套端点(均做归属隔离,越权返回 404): - `GET /openai/v1/files` 列出本账户上传的 Batch 文件。 - `GET /openai/v1/files/{id}` 查询文件元信息。 - `GET /openai/v1/files/{id}/content` 流式下载 Batch 结果。 - `DELETE /openai/v1/files/{id}` 删除文件。 这是 LiteLLM OpenAI-compatible Files 协议,不限制 JSONL 中的模型来自某个 Provider;每行模型必须已绑定 LiteLLM。管理操作不单独计费。