上传文件
multipart 上传图片/视频/音频,返回公网 url。
POST
/
v1
/
files
上传文件
curl --request POST \
--url https://sigrunai.com/v1/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file=@example-fileimport requests
url = "https://sigrunai.com/v1/files"
files = { "file": ("example-file", open("example-file", "rb")) }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://sigrunai.com/v1/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sigrunai.com/v1/files"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"code": 20000,
"msg": "<string>",
"data": {
"url": "<string>",
"name": "<string>",
"media_type": "image",
"bytes": 123
}
}上传图片、视频或音频参考素材,返回可在创建任务时使用的公网
成功响应示例:
url。
鉴权
Authorization: Bearer <你的 API Key>
请求
multipart/form-data,字段名必须为 file。
| 限制 | 说明 |
|---|---|
| 大小 | 最大 32MB |
| 图片 | .jpg .jpeg .png .webp .gif .bmp .avif .heic .heif |
| 视频 | .mp4 .mov .webm .mkv .avi .m4v |
| 音频 | .mp3 .wav .m4a .aac .ogg .flac .opus |
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
url | string | 公网可访问地址,可填入 images / videos / audios |
name | string | 原始文件名 |
media_type | string | image / video / audio |
bytes | int | 文件字节数 |
示例
curl -X POST 'https://sigrunai.com/v1/files' \
-H 'Authorization: Bearer sk_xxx' \
-F 'file=@./ref.png'
{
"code": 20000,
"msg": "ok",
"data": {
"url": "https://cdn.sigrunai.com/openapi/files/xxxxxxxx.png",
"name": "ref.png",
"media_type": "image",
"bytes": 123456
}
}
最后修改于 2026年10月15日
⌘I
上传文件
curl --request POST \
--url https://sigrunai.com/v1/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file=@example-fileimport requests
url = "https://sigrunai.com/v1/files"
files = { "file": ("example-file", open("example-file", "rb")) }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://sigrunai.com/v1/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sigrunai.com/v1/files"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"code": 20000,
"msg": "<string>",
"data": {
"url": "<string>",
"name": "<string>",
"media_type": "image",
"bytes": 123
}
}