BevylDevelopers

Quickstart

Upload a video, create a project, and download the MP4.

These steps use the TypeScript SDK. Every SDK method maps to endpoints in the API reference, so any HTTP client works.

Get an API key

Create an API key in the partner portal and store it as BEVYL_API_KEY.

No portal access yet? Request it.

Install the SDK

npm install @bevyl-ai/bevyl-sdk

Create a workspace

Pick a workspaceId for the customer. See Workspaces and brand.

import { BevylClient } from '@bevyl-ai/bevyl-sdk';

const bevyl = new BevylClient({
  apiKey: process.env.BEVYL_API_KEY!,
  workspaceId: 'customer-123',
});

await bevyl.createWorkspace({ name: 'Tasty Burgers' });
await bevyl.updateBrand({
  name: 'Tasty Burgers',
  summary: 'A neighborhood burger restaurant.',
  voiceTone: 'Warm and a little cheeky.',
});

Upload footage

import { createReadStream } from 'node:fs';
import { stat } from 'node:fs/promises';
import { Readable } from 'node:stream';

const path = 'kitchen-broll.mp4';

const upload = await bevyl.uploadVideo({
  filename: path,
  fileSize: (await stat(path)).size,
  contentType: 'video/mp4',
  body: Readable.toWeb(createReadStream(path)),
});

This helper polls each background job at the interval Bevyl asks for:

type Job = { status: string; pollIntervalMs?: number | null };

async function waitFor<T>(check: () => Promise<T>, job: (result: T) => Job) {
  for (;;) {
    const result = await check();
    const { status, pollIntervalMs } = job(result);
    if (status !== 'working') return result;
    await new Promise((resolve) => setTimeout(resolve, pollIntervalMs ?? 5000));
  }
}

const videoId = upload.video.id;
const { video } = await waitFor(
  () => bevyl.getVideoStatus({ videoId }),
  (result) => result.video,
);
if (video.status === 'failed') throw new Error(video.statusMessage);

Create a project

const voices = await bevyl.listVoices();

const project = await bevyl.createProject({
  format: 'voiceover',
  sourceVideoIds: [videoId],
  voiceoverProfileId: voices.defaultVoiceoverProfileId,
  videoIdea: 'A 15-second vertical ad for the truffle burger.',
  aspectRatio: '9:16',
});

const { generation } = await waitFor(
  () =>
    bevyl.getProjectStatus({
      projectId: project.projectId,
      runId: project.generation.runId,
    }),
  (result) => result.generation,
);
if (generation.status !== 'completed') {
  throw new Error(generation.statusMessage);
}

Export and download

const started = await bevyl.startExport({ projectId: project.projectId });

const result = await waitFor(
  () => bevyl.getExportStatus({ exportId: started.exportId }),
  (result) => result.export,
);

if (result.export.status !== 'ready') {
  throw new Error(result.export.statusMessage);
}
console.log(result.export.exportDownloadUrl);

Next steps

On this page