How to Upload Files

How to Upload Files (API)

API reference for uploading files to WaveSpeedAI.

Endpoint

POST https://api.wavespeed.ai/api/v3/upload

Request

curl --location --request POST 'https://api.wavespeed.ai/api/v3/upload' \
--header 'Authorization: Bearer ${WAVESPEED_API_KEY}' \
--form 'file=@"/path/to/file.png"'

Parameters

ParameterTypeRequiredDescription
filefileYesFile to upload (multipart/form-data)

Supported Formats

TypeFormatsMax Size
ImagesJPG, JPEG, PNG, WebP, GIF, BMP, TIFF20 MB
VideosMP4, AVI, MOV, WMV, FLV, WebM, MKV, 3GP, OGV100 MB
AudioMP3, WAV, OGG, AAC, FLAC, WebM, M4A, Opus50 MB

Response

{
  "code": 200,
  "message": "success",
  "data": {
    "url": "https://cdn.wavespeed.ai/uploads/abc123.png"
  }
}

Response Fields

FieldTypeDescription
data.urlstringURL 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

CodeDescription
400Invalid file or format not supported
401Invalid API key
413File too large

Retention

Uploaded files are stored for 7 days and then automatically deleted.

© 2025 WaveSpeedAI. All rights reserved.