API 参考
创建 File Upload
上传一个本地文件、远程 HTTPS URL 或 base64 来源,并获得临时 URL。
上传一个本地文件、远程 HTTPS URL 或 base64 来源,并获得临时 URL。
端点
- 基础 URL
https://runapi.ai- API 版本
v1- 身份验证
Authorization: Bearer YOUR_API_KEY
02
JSON 请求体请求
只能在列出的请求位置发送值。
application/json - Base64 source4 个字段
file_namestring
可选
Optional filename for the created File Upload.
sourceobject
必填
Base64-encoded source bytes.
source.datastring
必填
Base64 data
source.typestring
必填
Selects the base64 source representation.
application/json - URL source4 个字段
file_namestring
可选
Optional filename for the created File Upload.
sourceobject
必填
Remote HTTPS source to download.
source.typestring
必填
Selects the URL source representation.
source.urlstring
必填
Public HTTPS URL to download.
multipart/form-data2 个字段
filestring
必填
Local file bytes to upload.
file_namestring
可选
Optional filename for the created File Upload.
03
HTTP 201成功响应
POST /api/v1/files
JSON
{
"created_at": "2026-07-27T10:00:00.000Z",
"expires_at": "2026-07-27T11:00:00.000Z",
"file_name": "mask.png",
"mime_type": "image/png",
"size_bytes": 204800,
"url": "https://file.runapi.ai/temp/user-uploads/mask.png"
}
04
HTTP 401错误响应 (401)
JSON
{
"error": {
"code": "authentication_required",
"message": "Authentication required"
}
}
05
HTTP 403错误响应 (403)
JSON
{
"error": {
"code": "standard_api_key_required",
"message": "Standard API key required"
}
}
06
HTTP 400错误响应 (400)
JSON
{
"error": {
"code": "invalid_source",
"message": "Only HTTPS URLs are allowed"
}
}
07
HTTP 408错误响应 (408)
JSON
{
"error": {
"code": "invalid_source",
"message": "Download timeout"
}
}
08
HTTP 413错误响应 (413)
JSON
{
"error": {
"code": "file_too_large",
"message": "File size exceeds the maximum allowed size"
}
}
09
HTTP 415错误响应 (415)
JSON
{
"error": {
"code": "unsupported_media_type",
"message": "This content type is not supported"
}
}
10
HTTP 422错误响应 (422)
JSON
{
"error": {
"code": "upload_failed",
"message": "File upload failed. Please try again."
}
}
11
HTTP 429错误响应 (429)
JSON
{
"error": {
"code": "rate_limited",
"message": "Too many file uploads for this account. Please retry later."
}
}
12
cURL 示例
CURL
curl -X POST https://runapi.ai/api/v1/files \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"source":{"type":"url","url":"https://cdn.runapi.ai/public/samples/mask.png"},"file_name":"mask.png"}'
13