API手册
上传文件
上传文件
AuthorizationBearer <token>required
添加 Header 'Authorization: Bearer {账户 API Key}' 进行鉴权
In: header
purposestringrequired
Value in
"batch"Example
"batch"fileFile uploadrequired
要上传的文件
Format
binaryExample
"/path/to/abc.jsonl"Response Body
成功响应
TypeScript Definitions
Use the response body type in TypeScript.
codeinteger
Example
20000messagestring
Example
"Ok"statusboolean
Example
truedataobject
curl --request POST \
--url https://api.siliconflow.cn/v1/files \
--header 'Authorization: Bearer YOUR_API_KEY' \
--form purpose=batch \
--form 'file=@files_example.jsonl'
import requests
url = "https://api.siliconflow.cn/v1/files"
headers = {"Authorization": "Bearer YOUR_API_KEY"}
with open("files_example.jsonl", "rb") as f:
files = {"file": ("files_example.jsonl", f)}
data = {"purpose": "batch"}
response = requests.post(url, headers=headers, data=data, files=files)
print(response.json())
{
"code": 20000,
"message": "Ok",
"status": true,
"data": {
"id": "file-jkvytbjtow",
"object": "file",
"bytes": 8509,
"createdAt": 1741685396,
"filename": "requests.jsonl",
"purpose": "batch"
}
}{
"code": 20012,
"message": "string",
"data": "string"
}"Invalid token""Forbidden""404 page not found"{
"code": 50505,
"message": "Model service overloaded. Please try again later.",
"data": "string"
}"string"