SiliconFlow
API手册

上传文件

上传文件

POST
/files
AuthorizationBearer <token>required

添加 Header 'Authorization: Bearer {账户 API Key}' 进行鉴权

In: header

purposestringrequired
Value in"batch"
Example"batch"
fileFile uploadrequired

要上传的文件

Formatbinary
Example"/path/to/abc.jsonl"

Response Body

成功响应

TypeScript Definitions

Use the response body type in TypeScript.

codeinteger
Example20000
messagestring
Example"Ok"
statusboolean
Exampletrue
dataobject

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"
上传文件