How to Upload Files (API)
API reference for uploading files to WaveSpeedAI.
Endpoint
POST https://api.wavespeed.ai/api/v3/uploadRequest
curl --location --request POST 'https://api.wavespeed.ai/api/v3/upload' \
--header 'Authorization: Bearer ${WAVESPEED_API_KEY}' \
--form 'file=@"/path/to/file.png"'Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | Yes | File to upload (multipart/form-data) |
Supported Formats
| Type | Formats | Max Size |
|---|---|---|
| Images | JPG, JPEG, PNG, WebP, GIF, BMP, TIFF | 20 MB |
| Videos | MP4, AVI, MOV, WMV, FLV, WebM, MKV, 3GP, OGV | 100 MB |
| Audio | MP3, WAV, OGG, AAC, FLAC, WebM, M4A, Opus | 50 MB |
Response
{
"code": 200,
"message": "success",
"data": {
"url": "https://cdn.wavespeed.ai/uploads/abc123.png"
}
}Response Fields
| Field | Type | Description |
|---|---|---|
data.url | string | URL to the uploaded file |
Python Example
import os
import requests
api_key = os.environ.get("WAVESPEED_API_KEY")
def upload_file(file_path):
with open(file_path, 'rb') as f:
response = requests.post(
"https://api.wavespeed.ai/api/v3/upload",
headers={"Authorization": f"Bearer {api_key}"},
files={"file": f}
)
return response.json()["data"]["url"]
# Upload an image
url = upload_file("/path/to/image.png")
print(url)JavaScript Example
async function uploadFile(file) {
const apiKey = process.env.WAVESPEED_API_KEY;
const formData = new FormData();
formData.append('file', file);
const response = await fetch('https://api.wavespeed.ai/api/v3/upload', {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`
},
body: formData
});
const data = await response.json();
return data.data.url;
}Error Responses
| Code | Description |
|---|---|
| 400 | Invalid file or format not supported |
| 401 | Invalid API key |
| 413 | File too large |
Retention
Uploaded files are stored for 7 days and then automatically deleted.
Related Pages
- How to Upload Files — General guide
- How to Submit Task