RelayDanceRelayDance
HomeModelsPricingDocsGuides
Get API Key →

Docs / Core Concepts / Upload Files

Upload Files

Reference media in video tasks is passed by URL. If your source file is local, upload it first: POST /v1/files returns a signed url you can drop into metadata.content[]. Files already on a public URL can be used directly without uploading.

#Endpoint

POST/v1/files

Send the file as multipart/form-data with the field name file, and your API key as Authorization: Bearer sk-.... The optional purpose field is accepted and returned unchanged, so the OpenAI SDK's files.create works as it is.

#cURL

terminalbash
curl https://relaydance.com/v1/files \
  -H "Authorization: Bearer $RELAYDANCE_API_KEY" \
  -F "[email protected]"

#Python

upload.pypython
import os, requests

with open("photo.png", "rb") as f:
    resp = requests.post(
        "https://relaydance.com/v1/files",
        headers={"Authorization": f"Bearer {os.environ['RELAYDANCE_API_KEY']}"},
        files={"file": f},
        timeout=300,
    )
resp.raise_for_status()
uploaded = resp.json()
print(uploaded["id"])
print(uploaded["url"])

#OpenAI SDK

upload_sdk.pypython
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["RELAYDANCE_API_KEY"],
    base_url="https://relaydance.com/v1",
)

with open("photo.png", "rb") as f:
    uploaded = client.files.create(file=f, purpose="user_data")
print(uploaded.id)
print(uploaded.url)

#Node.js

upload.tstypescript
import { readFileSync } from "node:fs";

const form = new FormData();
form.append("file", new Blob([readFileSync("photo.png")]), "photo.png");

const res = await fetch("https://relaydance.com/v1/files", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.RELAYDANCE_API_KEY}` },
  body: form,
});
if (!res.ok) throw new Error(`upload failed: ${res.status} ${await res.text()}`);
const uploaded = await res.json();
console.log(uploaded.id);
console.log(uploaded.url);

#Response

response.jsonjson
{
  "id": "file-0123456789abcdef0123456789abcdef-png",
  "object": "file",
  "bytes": 482113,
  "created_at": 1794710000,
  "filename": "photo.png",
  "purpose": "user_data",
  "status": "processed",
  "content_type": "image/png",
  "md5": "0123456789abcdef0123456789abcdef",
  "url": "https://...",
  "source_url": "https://...",
  "expires_in": 21600,
  "url_expires_at": 1794731600,
  "exists": false
}
FieldDescription
idFile identifier. Keep it if you want a fresh link later
urlSigned link to the uploaded file. This is what goes into metadata.content[]. Valid for expires_in seconds (6 hours); source_url is the same link
bytes, content_type, md5Size, detected type and MD5 of what was stored
existstrue when you uploaded the same file before: it is not stored twice

Getting a fresh link

The link expires after 6 hours; the file itself stays. GET /v1/files/{id} returns the same object with a new url, so you never need to upload a file twice.

terminalbash
curl https://relaydance.com/v1/files/FILE_ID \
  -H "Authorization: Bearer $RELAYDANCE_API_KEY"

#Limits

  • Types: jpg, jpeg, png, webp, gif, mp4, mov, webm, mp3, wav. Images are recognised by their content, so a wrong extension is corrected and a file that is not really an image is refused.
  • Size: images up to 10 MB, audio up to 20 MB, video up to 47 MB through this endpoint. Larger videos (up to 100 MB) use the two-step upload below.
  • Rate: 120 uploads per hour per account. Beyond that the endpoint answers 429.
  • The request carries your API key, so send it from your server, never from browser code.

#Larger videos: two-step upload

For videos between 47 MB and 100 MB, ask for a one-time upload URL and send the file straight to storage with HTTP PUT. The endpoint is GET https://pay.relaydance.com/api/upload-url (note the host), with the query parameters ext (file extension) and, optionally, md5. The response contains upload_url (valid 15 minutes), the content_type to send with the PUT, and source_url (valid 6 hours) for metadata.content[]. Files of any accepted type can go this way.

terminalbash
FILE=clip.mp4
MD5=$(md5sum "$FILE" | cut -d' ' -f1)

# 1) Ask for a one-time upload URL
RESP=$(curl -s "https://pay.relaydance.com/api/upload-url?ext=mp4&md5=$MD5" \
  -H "Authorization: Bearer $RELAYDANCE_API_KEY")

# 2) Upload the file (skipped when the same file was uploaded before)
if [ "$(echo "$RESP" | jq -r '.exists')" != "true" ]; then
  curl -s -X PUT "$(echo "$RESP" | jq -r '.upload_url')" \
    -H "Content-Type: $(echo "$RESP" | jq -r '.content_type')" \
    --data-binary "@$FILE"
fi

# 3) This URL goes into metadata.content[]
echo "$RESP" | jq -r '.source_url'

#Using the URL in a video task

Put the returned url into a metadata.content[] entry and cite it in the prompt as @image1:

img2video.pypython
import os, requests

BASE = "https://relaydance.com/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['RELAYDANCE_API_KEY']}"}

# 1) Upload the source image
with open("product.jpg", "rb") as f:
    upload = requests.post(f"{BASE}/files", headers=HEADERS, files={"file": f}, timeout=300)
upload.raise_for_status()
image_url = upload.json()["url"]

# 2) Submit the video task with the image as a reference
resp = requests.post(
    f"{BASE}/video/generations",
    headers={**HEADERS, "Content-Type": "application/json"},
    json={
        "model": "doubao-seedance-2-0-720p",
        "prompt": "@image1 rotates slowly on a marble pedestal, studio lighting",
        "seconds": "5",
        "metadata": {
            "ratio": "16:9",
            "resolution": "720p",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {"url": image_url},
                    "role": "reference_image",
                }
            ],
        },
    },
)
print(resp.json()["task_id"])
See Video Generation for the content[] schema and limits (up to 9 reference images, 3 videos, 3 audio tracks), and Image-to-Video for the end-to-end example.