Uploads and references
Send images, video or audio for a model to animate, edit or follow.
Models take input media through references. Each reference has a role, which says how the model
uses it, and either an upload_id or a public url:
"references": [
{ "role": "first_frame", "upload_id": "upl_01jbx9w6k3f8..." },
{ "role": "reference_image", "url": "https://example.com/style.jpg" }
]| Role | Used as |
|---|---|
first_frame, last_frame | The first or last frame of a video |
reference_image, reference_video, reference_audio | Subject, style or motion to follow |
source_image, source_video | The media to edit |
mask | The region of a source_image to edit |
Each model accepts some roles, with a maximum count per role, listed on its model page.
A role the model doesn't accept is rejected with invalid_parameters. When you leave out mode, it's
inferred from the roles.
Uploading a file
Uploading is two steps: create an upload, which returns a signed URL, then PUT the bytes to that URL
with the same Content-Type. The SDKs do both:
import { readFile } from "node:fs/promises";
import { RawFrame } from "@rawframe/sdk";
const rf = new RawFrame();
// Upload the first frame. Uploads are kept for 7 days and can be reused.
const frame = await rf.uploads.upload(await readFile("first-frame.png"), { contentType: "image/png" });
const video = await rf.generations.createAndWait({
model: "bytedance/seedance-2.5",
prompt: "The camera slowly pulls back as the scene comes to life",
references: [{ role: "first_frame", upload_id: frame.id }],
params: { duration_seconds: 5 },
});
console.log(video.mode, video.outputs?.[0]?.url);- Accepted types:
image/png,image/jpeg,image/webp,video/mp4,video/quicktime,audio/mpeg,audio/wav. Up to 200 MB. size_bytesmust be the exact size. If the uploaded file is a different size, the upload becomesrejected.sha256is optional.- The
upload_urlworks for 15 minutes and needs no API key. Don't send your key to it. - An upload is
pendinguntil its bytes arrive, thenready. Referencing a pending upload fails withupload_incomplete. - Uploads are kept for 7 days (
expires_at) and can be used by any number of generations until then. After that, references to them fail withupload_expired.
Referencing a URL
A url reference must be public HTTPS. We fetch it once when the generation starts and keep our own
copy, so the URL only needs to work for a few minutes. Private and internal addresses are refused. Use
an upload for anything that isn't publicly reachable, or that you'll reuse.