Upload a file
Upload a file to the file service.
Endpoint
POST https://api.stepfun.ai/v1/files
Request body
-
purposestringrequired
Upload intent. Onlystorageis supported for file uploads (image/video understanding, voice cloning, etc.). -
urlstringoptional
Remote file URL. Supported formats match thefilefield. If bothfileandurlare provided,filetakes precedence. -
fileFileoptional
File to upload. Each user can upload up to 1,000 files. Omit when usingurl.
storagesupported formats (max 128 MB):- Video (mp4)
- Images (jpg/jpeg, png, webp, static gif)
- Audio (mp3, wav). For voice cloning, audio length should be 5–10 seconds.
Response
Returns a single File object.
Examples
from openai import OpenAI
client = OpenAI(api_key="STEP_API_KEY", base_url="https://api.stepfun.ai/v1")
client.files.create(
file=open("productImage.png", "rb"),
purpose="storage"
)
Response
{
"id": "file-abc123",
"object": "file",
"bytes": 140,
"created_at": 1613779121,
"filename": "productImage.png",
"purpose": "storage",
"status":"processed"
}Last updated on