Docs index: /llms.txt · every page as Markdown: add .md

‹ API reference

Files

Upload images, video, audio and documents by URL or base64.

Upload a file

POST /v1/files/upload uploadFile

Upload a file for processing. Supports both URL downloads and direct base64 uploads. Each file belongs to one category:

CategoryExtensions
Images.jpg, .jpeg, .png, .gif, .webp, .bmp
Videos.mp4, .avi, .mov, .wmv, .flv, .webm, .mkv
Audio.mp3, .wav, .flac, .aac, .ogg, .m4a
Documents.pdf, .doc, .docx, .txt, .rtf, .ppt, .pptx, .xls, .xlsx, .csv

The category comes from the file’s own bytes: bytes from a different category than file_type (for example an image sent as document) return 415. Within a category the name is stored as sent.

Uploaded files are stored privately. SVG is not accepted, and neither are HTML or any text file carrying a script: a browser that opens one runs the script inside it.

Method 1: URL upload

Download a file from a publicly accessible URL.

ParameterTypeDescription
file_urlstringPublic URL of the file. Without file_name, its last path segment is the filename.
file_namestringOptional. The filename to store, with a supported extension; required when the URL’s last path segment has none (signed or query URLs).
file_typestringOptional, default auto: a cross-check against the file’s bytes, never an override. One of auto, image, video, audio, document, pdf. Any other value returns 400.

Note The Python examples below use requests, which is not in the standard library. Install it in a virtual environment first: python3 -m venv .venv && . .venv/bin/activate && pip install requests, or use curl / urllib instead.

Method 2: direct upload

Upload base64-encoded file data directly.

ParameterTypeDescription
file_datastringBase64-encoded file data.
file_namestringOriginal filename. The extension is required and must be a supported one.
file_typestringOne of auto, image, video, audio, document, pdf. Any other value returns 400.

Response

Both methods return the same shape:

file_url is a signed link that expires after 7 days (url_expires_in is the lifetime in seconds: 604800). To use a file later, pass its file_id instead: agent generation and video generation accept either file_id or a URL, for files your own account uploaded. (Agent creation is image-only: video files upload fine, but video is not a creation input.)

An expired link returns 410 MEDIA_URL_EXPIRED; a file that belongs to another account returns 403 MEDIA_NOT_ACCESSIBLE.

curl

curl -X POST https://api.bithuman.ai/v1/files/upload \
  -H "api-secret: $BITHUMAN_API_SECRET" -H "Content-Type: application/json" \
  -d '{"file_url": "https://example.com/presentation.pdf", "file_type": "auto"}'

Python

import os, requests

resp = requests.post(
    "https://api.bithuman.ai/v1/files/upload",
    headers={"api-secret": os.environ["BITHUMAN_API_SECRET"]},
    json={
        "file_url": "https://example.com/presentation.pdf",
        "file_type": "auto",
    },
)
print(resp.json())

Node

const resp = await fetch("https://api.bithuman.ai/v1/files/upload", {
  method: "POST",
  headers: {
    "api-secret": process.env.BITHUMAN_API_SECRET,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ file_url: "https://example.com/presentation.pdf", file_type: "auto" }),
});
console.log(await resp.json());
# Setup, once: python3 -m venv .venv && . .venv/bin/activate && pip install requests
import os
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": os.environ["BITHUMAN_API_SECRET"]},
    json={"file_data": file_data, "file_name": "document.pdf", "file_type": "auto"},
)
print(resp.json())
{
  "success": true,
  "message": "File uploaded successfully",
  "data": {
    "file_id": "3f2b9c14-8a7e-4d21-9f10-2c5b6e0a11dd",
    "file_url": "https://.../storage/v1/object/sign/agent-media/YOUR_USER_ID/assets/docs/20260515_103000_document.pdf?token=...",
    "url_expires_in": 604800,
    "original_source": "https://example.com/document.pdf",
    "file_type": "docs",
    "file_size": 1024000,
    "mime_type": "application/pdf",
    "asset_category": "docs",
    "uploaded_at": "2026-05-15T10:30:00Z"
  }
}

Size limits

CategoryMax size
Images10 MB
Videos100 MB
Audio25 MB
Documents25 MB

Exceeding a limit returns HTTP 413 with code FILE_TOO_LARGE. The category is read from the file itself, so the limit that applies is the one for what the file actually is.

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.
400MISSING_PARAMNeither file_url nor file_data was sent.
400VALIDATION_ERRORfile_data was not valid base64, both file_url and file_data were sent, or file_type was not one of the six values above.
401UNAUTHORIZEDInvalid API secret.
410MEDIA_URL_EXPIREDOn an endpoint that takes an uploaded file: the signed file_url has expired. Pass the file_id, or upload again.
403MEDIA_NOT_ACCESSIBLEOn an endpoint that takes an uploaded file: the file belongs to another account.
413FILE_TOO_LARGEFile exceeds the size limit for its category.
415UNSUPPORTED_TYPEThe bytes are not a supported type, they contradict file_type, the filename extension is not one of those listed above, or the file would run in a browser.
429RATE_LIMITEDToo many requests — wait Retry-After seconds. See Rate limits.
500INTERNAL_ERRORServer-side error.

See the full error reference and the interactive API reference.