File Upload API

Upload images, video, audio, and documents by URL or base64. Files are auto-organized by type and returned as CDN URLs.

Upload a file

POST /v1/files/upload — upload a file for processing. Supports both URL downloads and direct base64 uploads. Files are automatically organized by type:

CategoryStorage pathExtensions
Imagesassets/image/.jpg, .jpeg, .png, .gif, .webp, .bmp, .svg
Videosassets/video/.mp4, .avi, .mov, .wmv, .flv, .webm, .mkv
Audioassets/audio/.mp3, .wav, .flac, .aac, .ogg, .m4a
Documentsassets/docs/.pdf, .doc, .docx, .txt, .ppt, .pptx, .xls, .xlsx, .csv

Method 1: URL upload

Download a file from a publicly accessible URL.

ParameterTypeDescription
file_urlstringURL of the file to download.
file_typestringOne of auto, image, video, audio, document.
import requests

resp = requests.post(
    "https://api.bithuman.ai/v1/files/upload",
    headers={"Content-Type": "application/json", "api-secret": "YOUR_API_SECRET"},
    json={"file_url": "https://example.com/presentation.pdf", "file_type": "auto"},
)
print(resp.json())

Method 2: direct upload

Upload base64-encoded file data directly.

ParameterTypeDescription
file_datastringBase64-encoded file data.
file_namestringOriginal filename with extension.
file_typestringOne of auto, image, video, audio, document.
import base64, requests

with open("document.pdf", "rb") as f:
    file_data = base64.b64encode(f.read()).decode("utf-8")

resp = requests.post(
    "https://api.bithuman.ai/v1/files/upload",
    headers={"Content-Type": "application/json", "api-secret": "YOUR_API_SECRET"},
    json={"file_data": file_data, "file_name": "document.pdf", "file_type": "auto"},
)
print(resp.json())

Response

Both methods return the same shape:

{
  "success": true,
  "message": "File uploaded successfully",
  "data": {
    "file_url": "https://cdn.bithuman.ai/assets/docs/20250115_103000_abc12345.pdf",
    "original_source": "https://example.com/document.pdf",
    "file_type": "auto",
    "file_size": 1024000,
    "mime_type": "application/pdf",
    "asset_category": "docs",
    "uploaded_at": "2026-05-15T10:30:00Z"
  }
}

Use the returned file_url as the image, video, or audio input to agent generation.

Size limits

CategoryMax size
Images10 MB
Videos100 MB
Audio50 MB
Documents10 MB

Exceeding a limit returns HTTP 413.

URL vs. direct upload

MethodBest forProsCons
URL uploadExternal files, cloud storageNo request-size limit, efficientRequires a publicly accessible URL
Direct uploadLocal files, form uploadsWorks with any file sourceLimited by request size

Error codes

HTTPCodeMeaning
400DOWNLOAD_FAILEDCould not download the URL — ensure it’s publicly accessible.
401UNAUTHORIZEDInvalid API secret.
413FILE_TOO_LARGEFile exceeds the size limit for its category.
415UNSUPPORTED_TYPEFile type not supported. Supported: JPEG, PNG, WebP, MP4, WAV, MP3, OGG.
500INTERNAL_ERRORServer-side error.

See the full error reference and the interactive API reference.