SDK

SDK: file uploads

uploadFile uploads a file and returns an object you can put straight into input[].

Node.js

ts
import { readFile } from 'node:fs/promises';

const buf = await readFile('photo.png');
const fileItem = await client.uploadFile(buf, {
  filename: 'photo.png',
  type: 'image/png',
});

// ready to go straight into input[]:
await client.createTask({
  assistant_id: 1,
  input: [fileItem, textInput("What's in the photo?")],
});

Browser

Instead of a Buffer/Uint8Array, pass a File or Blob directly — for example, from an <input type="file">.

ts
const file = inputEl.files![0];
const fileItem = await client.uploadFile(file, { filename: file.name, type: file.type });

Signature

ts
uploadFile(
  file: Blob | Uint8Array,
  opts?: { filename?: string; type?: string; signal?: AbortSignal },
): Promise<FileInputItem>

Storage base URL

getStorageBase() returns the public base URL — join it with provider_data.path to get a download link for a file (for example, an image generated in output).

ts
const base = await client.getStorageBase();
const url = `${base}/${file.provider_data.path}`;
Validation rules (formats, max size ~1 GB) are the same as for the REST endpoint POST /api/files.