Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.reactor.inc/llms.txt

Use this file to discover all available pages before exploring further.

Some models accept file inputs alongside regular parameters. The SDK handles file uploads in two steps: upload the file to get a reference, then pass that reference into a command.
  1. Upload the file with uploadFile() to get a FileRef.
  2. Pass the FileRef into sendCommand() as a regular parameter.

Uploading a file

Call uploadFile() with a File or Blob. It returns a FileRef you can pass into sendCommand(), alongside regular arguments. The example below uses Helios’s set_image command. The commands and file parameters a model accepts vary by model, so check your model’s reference for what it expects.
File upload flow: your app calls uploadFile() to get a presigned PUT URL and a FileRef from Reactor, PUTs the file bytes directly to object storage, then sends the FileRef in a command to the model, which fetches the bytes from storage itself.
const input = document.querySelector("input[type=file]") as HTMLInputElement;
const file = input.files![0];

const ref = await reactor.uploadFile(file);
await reactor.sendCommand("set_image", { image: ref });
uploadFile() can only be called when the connection status is "ready". Upload URLs expire after 15 minutes. For more information, see Rate Limits.

The FileRef type

uploadFile() returns a FileRef with metadata about the uploaded file. You never construct one directly.
class FileRef {
  readonly uploadId: string;   // Upload identifier
  readonly name: string;       // Filename
  readonly mimeType: string;   // MIME type (e.g. "image/jpeg")
  readonly size: number;       // File size in bytes
}

Custom filename

By default, uploadFile() uses the file’s name. Blob objects default to "upload". Override it with the name option.
const ref = await reactor.uploadFile(blob, { name: "style-reference.png" });

Complete example

For a full image-to-video walkthrough that uploads a reference image and conditions the first frame on it, see Helios’s image-to-video example.