{"openapi":"3.1.0","info":{"title":"LongStories API","version":"2026-10-15","description":"Make videos from code. Guides and examples: https://longstories.ai/resources/api.md\n\nKeep the same characters in every video: The API does not remember the characters of your last video. Each create request uses exactly the characters it sends in `characters`. Leave `characters` out and the video makes new characters from your prompt, so they look different every time. The universe's cast is not added for you. To keep a cast: save each character once (on [your characters page](https://longstories.ai/characters) or with `POST /api/v1/characters`), read their ids with `GET /api/v1/characters`, and send the same ids in every create request. A saved character keeps its look and its voice. An object such as `{ \"name\": \"Luna\", \"description\": \"A wise owl\" }` only describes a character for that one video. It is not saved and does not carry over. If you send two saved characters with the same name, the video uses the first one. A universe set to \"Only its cast\" refuses characters that are not in its cast (`universe_cast_only`).\n\nMake a video from a song or a narration: Upload the audio with `POST /api/v1/voiceover/upload`. Then call create with `voiceoverKey` and `voiceoverDuration` set to the `voiceoverKey` and `duration` the upload returned. For a song, add `\"audioKind\": \"song\"`; its lyrics are transcribed from the audio. `voiceoverDuration` is required with `voiceoverKey`. A request without it, or with a value 1 second or more away from the upload, is refused.\n\nUse your own script: Send `userScript` instead of `prompt` to skip script writing. The script must be in the LongStories script format, with scenes, shots and `@Handles`; see the [scripting guide](https://longstories.ai/resources/scripting-guide). A script in another form is refused with `needs_canonical_rewrite` before any credit is used. A `@Handle` in a script does not select a saved character by itself. Send the character ids in `characters`, and write each one in the script with its `mentionHandle` from `GET /api/v1/characters` (for example `@CatBoy`). A `@Handle` that matches none of them becomes a new character.\n\nVersions: The API has dated versions. Send the `LongStories-Version` header to choose one; we recommend sending it on every request, so your integration never changes under you. Without the header, a call uses the newest version that existed on the day your API key was created. An answer to an authenticated call names the version it used in its `LongStories-Version` header. An older version keeps working: the API converts its requests to the newest format. Adding a field or an endpoint does not make a new version; renaming, removing or changing the meaning of something does."},"servers":[{"url":"https://longstories.ai"}],"security":[{"apiKey":[]}],"paths":{"/api/v1/universe/{slug}/create":{"post":{"operationId":"create","summary":"Create a video","description":"Start a video in a universe. Answers at once with a run id; poll the status endpoint for the video.\n\nRate limit: 100 per minute per key, shared with estimate and status.\n\nSend one of `prompt`, `userScript` or `voiceoverKey`.\n\nAdd an `Idempotency-Key` header (up to 256 characters) to retry safely. For a fixed-price request, a retry with the same key and body returns the same video and does not charge again; the same key with a different body is refused.\n\nYour account makes one video at a time through the API. A second request is accepted and waits as `QUEUED` until the first one ends.","parameters":[{"name":"slug","in":"path","required":true,"schema":{"type":"string"},"description":"The universe's slug: the last part of its address, `https://longstories.ai/universes/{slug}`. Public universes and your own."},{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","maxLength":256}},{"$ref":"#/components/parameters/ApiVersion"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UniverseVideoRequest"}}}},"responses":{"200":{"description":"Success, inside `{ data, requestId }`.","content":{"application/json":{"example":{"data":{"requestId":"run_06gje4epb3crc9jna7kod5el01","status":"QUEUED","estimatedDuration":600000,"estimatedCredits":299},"requestId":"3f2c9a4e-0b7d-4c55-9a52-5a1d2f6e8b10"}}}},"400":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/universe/status":{"get":{"operationId":"status","summary":"Check a video","description":"The state of a video you started. Poll it every 30 seconds until `isCompleted` is true.\n\nRate limit: 100 per minute per key, shared with create and estimate.\n\n`status` is one of `WAITING_FOR_DEPLOY`, `QUEUED`, `EXECUTING`, `REATTEMPTING`, `FROZEN`, `COMPLETED`, `CANCELED`, `FAILED`, `CRASHED`, `INTERRUPTED`, `SYSTEM_FAILURE`, `TIMED_OUT`, `DELAYED`, `EXPIRED`.\n\nWhen `isSuccess` is true, `output.url` is the video file and `output.projectId` is the project in your library.\n\nA video usually takes 5 to 20 minutes, longer for long or `ultra` videos.","parameters":[{"name":"requestId","in":"query","required":true,"schema":{"type":"string"},"description":"The `data.requestId` of the create response. It starts with `run_`."},{"$ref":"#/components/parameters/ApiVersion"}],"responses":{"200":{"description":"Success, inside `{ data, requestId }`.","content":{"application/json":{"example":{"data":{"status":"COMPLETED","isCompleted":true,"isSuccess":true,"output":{"url":"https://.../out.mp4","size":21267933,"projectId":"1917b8a2-498f-40b7-8097-fef38030eec1"},"error":null,"creditsUsed":299},"requestId":"..."}}}},"400":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/universe/{slug}/estimate":{"post":{"operationId":"estimate","summary":"Price a video","description":"The credits a create request would cost, without starting it. Same body as create.\n\nRate limit: 100 per minute per key, shared with create and status.\n\nSend exactly the body you will send to create (see its fields above).","parameters":[{"name":"slug","in":"path","required":true,"schema":{"type":"string"},"description":"The universe's slug: the last part of its address, `https://longstories.ai/universes/{slug}`. Public universes and your own."},{"$ref":"#/components/parameters/ApiVersion"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UniverseVideoRequest"}}}},"responses":{"200":{"description":"Success, inside `{ data, requestId }`.","content":{"application/json":{"example":{"data":{"estimatedDuration":60000,"estimatedCredits":262},"requestId":"..."}}}},"400":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/characters":{"get":{"operationId":"characters-list","summary":"List your characters","description":"Your saved characters, newest first (up to 100), with the `id` to send in `characters`.\n\nRate limit: 30 per minute per key.\n\nA character's id is also the last part of its address: `https://longstories.ai/characters/{id}`.","parameters":[{"$ref":"#/components/parameters/ApiVersion"}],"responses":{"200":{"description":"Success, inside `{ data, requestId }`.","content":{"application/json":{"example":{"data":{"characters":[{"id":"80d3a3c9-3673-46c3-8fab-47d3acf5b72d","name":"Cat Boy","mentionHandle":"CatBoy","description":"A brave young hero","appearance":"...","clothing":"...","personality":"","speech":"","characterPrompt":"...","imageUrl":"https://...","createdAt":"2026-07-16T19:04:11.263687+00:00"}]},"requestId":"..."}}}},"400":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"characters-create","summary":"Save a character","description":"Save a character from text (JSON) or from a photo (multipart, field `image`). Use the returned `id` in `characters`.\n\nRate limit: 30 per minute per key.\n\nYour plan's character limit applies.","parameters":[{"$ref":"#/components/parameters/ApiVersion"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"The character's name."},"description":{"type":"string","description":"Who the character is."},"appearance":{"type":"string","description":"How the character looks."},"clothing":{"type":"string","description":"What the character wears."},"personality":{"type":"string","description":"How the character behaves."},"speech":{"type":"string","description":"How the character talks."}},"required":["name","description"]}},"multipart/form-data":{"schema":{"type":"object","properties":{"image":{"type":"string","format":"binary","description":"A JPEG, PNG or WebP photo up to 25 MB. Each person in it becomes a saved character."}},"required":["image"]}}}},"responses":{"200":{"description":"Success, inside `{ data, requestId }`.","content":{"application/json":{"example":{"data":{"characters":[{"id":"80d3a3c9-3673-46c3-8fab-47d3acf5b72d","name":"Cat Boy","...":"..."}]},"requestId":"..."}}}},"400":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/voiceover/upload":{"post":{"operationId":"voiceover-upload","summary":"Upload a narration or a song","description":"Upload audio for a video to follow. Send the returned `voiceoverKey` and `duration` to create.\n\nRate limit: 10 per minute per key.\n\nThe request needs a `Content-Length` header; curl and most HTTP clients add it.","parameters":[{"$ref":"#/components/parameters/ApiVersion"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary","description":"MP3, WAV, M4A, AAC, OGG, OPUS, FLAC or WebM, up to 128 MB. Your plan's audio length limit applies."},"originalName":{"type":"string","description":"A file name to keep with the upload."}},"required":["file"]}}}},"responses":{"200":{"description":"Success, inside `{ data, requestId }`.","content":{"application/json":{"example":{"data":{"voiceoverKey":"video-creation/voiceovers/af7df29397ac3e5dd647430f15789e3c.mp3","duration":26.832,"originalName":"my-song.mp3"},"requestId":"..."}}}},"400":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/music/upload":{"post":{"operationId":"music-upload","summary":"Upload background music","description":"Upload your own track. Send the returned `musicSlug` as `musicConfig.musicSlug` in any later video.\n\nRate limit: 10 per minute per key.","parameters":[{"$ref":"#/components/parameters/ApiVersion"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary","description":"Same formats and size limit as the narration upload."},"title":{"type":"string","description":"The track's title. Default: the file name."}},"required":["file"]}}}},"responses":{"200":{"description":"Success, inside `{ data, requestId }`.","content":{"application/json":{"example":{"data":{"musicSlug":"user_abc123","title":"My Track","duration":187},"requestId":"..."}}}},"400":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/music":{"get":{"operationId":"music-list","summary":"List music","description":"The music catalog and your uploaded tracks, with the `musicSlug` to send in `musicConfig`.\n\nRate limit: 30 per minute per key.","parameters":[{"$ref":"#/components/parameters/ApiVersion"}],"responses":{"200":{"description":"Success, inside `{ data, requestId }`.","content":{"application/json":{"example":{"data":{"catalog":[{"musicSlug":"temple_of_treasures","title":"Temple of Treasures","duration":180,"category":"adventure","tags":["epic"]}],"customTracks":[{"musicSlug":"user_abc123","title":"My Track","duration":187}]},"requestId":"..."}}}},"400":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/music/{musicSlug}":{"delete":{"operationId":"music-delete","summary":"Delete an uploaded track","description":"Delete one of your uploaded tracks. Catalog tracks cannot be deleted.\n\nRate limit: 30 per minute per key.","parameters":[{"name":"musicSlug","in":"path","required":true,"schema":{"type":"string"},"description":"The `musicSlug` the upload returned."},{"$ref":"#/components/parameters/ApiVersion"}],"responses":{"200":{"description":"Success, inside `{ data, requestId }`.","content":{"application/json":{"example":{"data":{"deleted":true,"musicSlug":"user_abc123"},"requestId":"..."}}}},"400":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error. `error.details` says what to fix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"apiKey":{"type":"apiKey","in":"header","name":"x-api-key"}},"parameters":{"ApiVersion":{"name":"LongStories-Version","in":"header","required":false,"schema":{"type":"string","example":"2026-10-15"},"description":"The dated API version. Send it on every request."}},"schemas":{"UniverseVideoRequest":{"type":"object","properties":{"prompt":{"description":"What the video is about. Required unless you send `userScript` or `voiceoverKey`.","type":"string","minLength":1},"duration":{"default":"60","description":"Target length in seconds, as a string. \"15\", \"30\", \"60\", \"180\", \"300\" and \"600\" have a fixed price; other values get an approximate price. A script or uploaded audio sets its own length.","type":"string","pattern":"^\\d+$"},"animation":{"description":"Old switch: `false` makes a video without animation. Prefer `animationPreset`; if you send both, they must agree.","default":true,"type":"boolean"},"animationPreset":{"description":"Animation quality: `static` (storyboard, no animation), `mini`, `fast`, `pro` or `ultra`. Omit it to use the universe's default.","type":"string","enum":["static","mini","fast","pro","ultra"]},"imagePreset":{"description":"Storyboard images, for `animationPreset: \"static\"` only: `basic` (cheaper) or `advanced` (default). `legacy` works only for accounts created before 16 September 2026. Animated presets ignore it.","type":"string","enum":["basic","advanced","legacy"]},"language":{"description":"Language code such as \"en\" or \"es\". Omit it and the language is detected from the prompt.","type":"string","minLength":2,"maxLength":5},"characters":{"description":"The characters of this video. Each item is either the id of a saved character (from `GET /api/v1/characters`), which keeps its look and voice, or an object `{ name, description, appearance?, clothing? }` that describes a character for this video only (it is not saved). If you leave this field out, the video makes new characters from your prompt, and the universe's cast is not added for you. To keep the same characters across videos, send the same ids on every request.","type":"array","items":{"anyOf":[{"type":"object","properties":{"name":{"type":"string","minLength":1},"description":{"type":"string","minLength":1},"appearance":{"type":"string"},"clothing":{"type":"string"}},"required":["name","description"]},{"type":"string","minLength":1}]}},"visualStyleId":{"description":"A visual style of the universe. Omit it to use the universe's default style behavior.","type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"},"preferAiStyle":{"description":"A hint to let AI choose the style. It does not override a universe whose default is AI style; send `visualStyleId` to force a style.","type":"boolean"},"removeWatermark":{"default":false,"description":"Remove the watermark. Your plan must include watermark removal; without it the request still succeeds and the watermark stays.","type":"boolean"},"videoFormat":{"description":"Aspect ratio. Omit it to use the universe's setting.","type":"string","enum":["9:16","16:9"]},"captions":{"description":"Captions on or off. Omit it to use the universe's setting.","type":"boolean"},"captionsStyle":{"description":"Caption look. Previews: https://longstories.ai/resources/captions","type":"string","enum":["default","minimal","neon","cinematic","fancy","tiktok","highlight","gradient","intellectual","vida","manuscripts","subtitle","modern","bounce","popcorn","typewriter","handwritten","karaoke","retro","gaming"]},"captionsPosition":{"description":"Caption placement.","type":"string","enum":["center","bottom","top"]},"userScript":{"description":"Your own script in LongStories script format, so no script is written for you. Cannot be sent with `voiceoverKey`. A script that is not in the format is refused with `needs_canonical_rewrite`.","type":"string"},"voiceoverKey":{"description":"The `voiceoverKey` from `POST /api/v1/voiceover/upload`: a narration or a song the video follows. Cannot be sent with `userScript`.","type":"string"},"voiceoverDuration":{"description":"Required with `voiceoverKey`: the `duration` the upload returned, in seconds. A value 1 second or more away from the uploaded audio is refused.","type":"number"},"audioKind":{"description":"What the uploaded audio is: `voiceover` (default) or `song`. Requires `voiceoverKey`.","type":"string","enum":["voiceover","song"]},"songPerformance":{"description":"Songs only: whether characters sing on camera and who leads.","type":"object","properties":{"singOnCamera":{"type":"boolean"},"leadSingerCharacterId":{"anyOf":[{"type":"string","minLength":1},{"type":"null"}]}},"required":["singOnCamera"],"additionalProperties":false},"audioTranscript":{"description":"The exact spoken words of an uploaded voiceover, used for captions and timing. Requires `voiceoverKey`. Not for songs: their lyrics are transcribed from the audio.","type":"string"},"musicConfig":{"description":"Background music under the narration: `{ musicSlug, volume?, loop?, enabled? }`. `musicSlug` is a catalog track or one from `POST /api/v1/music/upload`. `{ \"enabled\": false }` turns off the universe's default music. Volume 0 to 1 (default 0.3).","type":"object","properties":{"enabled":{"type":"boolean"},"musicSlug":{"type":"string"},"volume":{"type":"number","minimum":0,"maximum":1},"loop":{"type":"boolean"}}}},"additionalProperties":false},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"requestId":{"type":"string"},"details":{"type":"object"},"docs":{"type":"string"}},"required":["code","message"]}}}}}}