API quickstart
Use the Boltgen API to generate videos and request 15-second livestream segments with prepaid credits.
Integrate from the OpenAPI 3.1 schema for the public developer API.
1. Create an API key
Sign in, open Account, and create a key. Copy it when it appears; keep it on your server and store it as BOLTGEN_API_KEY.
2. Generate a video
Set BOLTGEN_IDEMPOTENCY_KEY to a unique value for each new video. If submission times out, retry with the same key and request body.
The cURL example uses jq. The TypeScript example runs on Node.js 24 or later.
# Requires jq. Set BOLTGEN_API_KEY and BOLTGEN_IDEMPOTENCY_KEY first.
job=$(curl --fail-with-body --silent --show-error --max-time 30 \
"https://boltgen.app/v1/videos" \
-H "Authorization: Bearer $BOLTGEN_API_KEY" \
-H "Idempotency-Key: $BOLTGEN_IDEMPOTENCY_KEY" \
-H "Content-Type: application/json" \
--data '{"prompt":"A quiet city street at dusk. The camera slowly moves forward.","upscale":false,"durationSeconds":15,"resolution":"480x864"}') || { printf '%s\n' "$job" >&2; exit 1; }
JOB_ID=$(printf '%s' "$job" | jq -er '.id') || exit 1
printf 'Job ID: %s\n' "$JOB_ID"
# Repeat this status request while the job is in progress.
curl --fail-with-body --silent --show-error --max-time 30 \
"https://boltgen.app/v1/videos/$JOB_ID" \
-H "Authorization: Bearer $BOLTGEN_API_KEY"// Save as video.ts and run: node video.ts
const { BOLTGEN_API_KEY, BOLTGEN_IDEMPOTENCY_KEY } = process.env;
if (!BOLTGEN_API_KEY || !BOLTGEN_IDEMPOTENCY_KEY) {
throw new Error("Set BOLTGEN_API_KEY and BOLTGEN_IDEMPOTENCY_KEY.");
}
const baseUrl = "https://boltgen.app";
const authorization = "Bearer " + BOLTGEN_API_KEY;
const submitHeaders = {
Authorization: authorization,
"Content-Type": "application/json",
"Idempotency-Key": BOLTGEN_IDEMPOTENCY_KEY,
};
async function request<T>(path: string, options: RequestInit): Promise<T> {
const response = await fetch(baseUrl + path, {
...options,
signal: AbortSignal.timeout(30_000),
});
if (!response.ok) {
throw new Error("HTTP " + response.status + ": " + await response.text());
}
return response.json() as Promise<T>;
}
async function main() {
const job = await request<{ id: string }>("/v1/videos", {
method: "POST",
headers: submitHeaders,
body: JSON.stringify({
"prompt": "A quiet city street at dusk. The camera slowly moves forward.",
"upscale": false,
"durationSeconds": 15,
"resolution": "480x864"
}),
});
console.log("Job ID:", job.id);
for (let attempt = 0; attempt < 60; attempt++) {
const result = await request<{ status: string; playbackUrl?: string }>(
"/v1/videos/" + encodeURIComponent(job.id),
{ headers: { Authorization: authorization } },
);
if (["succeeded", "failed", "cancelled", "held"].includes(result.status)) {
console.log(result);
return;
}
await new Promise<void>((resolve) => setTimeout(resolve, 5_000));
}
console.log("Still in progress. Check the same job ID later:", job.id);
}
main().catch((error: unknown) => {
console.error(error);
process.exitCode = 1;
});Poll the same job ID every few seconds while the job is in progress. Stop when it succeeds, fails, or is cancelled. If it is held for review, pause polling and check the same job later.
3. Livestream request format
Create a stream, then request its 15-second segments one at a time. The first segment starts from text; each later segment uses the previous published segment’s final frame as its opening frame. Prompt edits apply to segments that have not started yet. Each segment is a generation job, charged from available prepaid credits and admitted while the worker is ready.
curl -X POST "https://boltgen.app/v1/streams" \
-H "Authorization: Bearer $BOLTGEN_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: replace-with-a-unique-key" \
--data '{
"prompt": "A quiet city street at dusk. The camera slowly moves forward.",
"upscale": false,
"resolution": "480x864"
}'curl -X POST "https://boltgen.app/v1/streams/<stream-id>/segments" \
-H "Authorization: Bearer $BOLTGEN_API_KEY" \
-H "Content-Type: application/json" \
--data '{"sequence":1}'Poll the returned jobId at /v1/videos/<job-id>. Once it succeeds, the verified clip appears on the returned watchUrl. Request sequence 2 only after sequence 1 has published. Stop with PATCH /v1/streams/<stream-id> and {"status":"stopped"}. A stream drains its active segment and then stops; exhausted credits or worker capacity prevent another segment.
4. Poll a video and retrieve its result
A successful video request returns a job ID. Poll it with the same API key; the status response includes an expiring signed playback URL after completion.
{ "id": "<job-id>", "status": "running" }
{ "id": "<job-id>", "status": "succeeded", "playbackUrl": "https://…", "expiresInSeconds": 900 }A queued job can report workerStarting: true while the generator starts. Upscale jobs can report upscaling. A held job is awaiting review, and its credits remain reserved. Pause automatic polling and check the same job again later.
Starting images
Upload a PNG, JPEG, or WebP image up to 2 MB with the same API key, then pass the returned owner-scoped key as startingImageKey.
curl -X POST "https://boltgen.app/v1/video-start-images" \ -H "Authorization: Bearer $BOLTGEN_API_KEY" \ -F "image=@start-frame.png"
Request fields
prompt: required, 1–4,000 characters.upscale: optional boolean; defaults tofalse.durationSeconds: video only; integer from 5 to 15, defaults to 15.resolution: optional initial video size. The default is480x864. The wide 480p preset (864x480) upscales to1296x720with SoL.512x288and448x256upscale to1184x666.512x320upscales to1152x720, and the vertical presets (480x864,352x640, and256x448) upscale to720x1296with SoL.seed: optional integer from 0 to 2,147,483,647.startingImageKey: optional owner-scoped key returned byPOST /v1/video-start-images.
See video pricing for per-second rates. Each credit is one cent. A native 480p, 15-second request encodes about 15.17 seconds and reserves 5 credits. The final debit uses the verified output duration.
Use Authorization: Bearer $BOLTGEN_API_KEY on API requests. To create a video or a stream, also send a unique Idempotency-Key. Livestreams use fixed 15-second segments.
4. Track and recover submissions
Use GET /v1/videos/{id} for video status and GET /v1/streams/{id} for stream state, the latest published sequence, and playback availability. Use the watch URL from stream creation for playback.
If a submission times out before returning an ID, send its original Idempotency-Key toGET /v1/videos/lookup or GET /v1/streams/lookup. A 404 may mean the original request is still being committed. Keep the original key when retrying.
Accounts can arrange signed HTTPS delivery of video.succeeded and video.failed events. The OpenAPI document describes the payload and signature headers.