Skip to content
中文

Generate video

Code Mode: praxis.media.videos.generate

HTTP: POST /media/v1/libraries/{library_id}/videos/generations

Generate videos into a library: from a prompt, from frames, from reference pictures or videos, or by editing an existing video. {library_id} also accepts default, the organization’s default library. mode picks the anchor: text (prompt only); image (animates first_frame); first_last (between first_frame and last_frame); reference (1 to 9 references: pictures with role subject or style keep a person, product or look consistent, and video assets with role video give the camera and motion to follow; an element id expands into its pictures and description); edit (keeps the video named by source, at least 4 s, and changes what the prompt says, such as replacing its person with a subject picture; the output is as long as the source). Frames and references are assets of the same library; in the prompt call them @video1 and @image1, @image2… in request order. Read GET /media/v1/generation/capabilities first: a model takes only the modes it lists. To draw several takes of one shot and keep the best, send n (1 to 4); 480p is the cheapest way to compare takes. Charges are per output second at the model API prices and appear in the Job’s usage; a job with an input video is metered on input plus output seconds, so it costs more than the output length suggests (a 5 s edit of a 5 s source bills about 6 s); a refused or failed output costs nothing, and so does a request refused before the job starts. A real human face in a source or reference is refused by the model with CONTENT_REJECTED. Refused before any charge: output gif (OPERATION_NOT_SUPPORTED), negative_prompt, references outside reference and edit, and an unknown mode. The response is 202 with a queued Job; poll GET /media/v1/libraries/{library_id}/jobs/{job_id} for each output’s asset and viewer_url, give viewer_url to the person and tell them usage. Send Idempotency-Key, or idempotency_key in the body, to retry without generating and charging twice.

Signature

praxis.media.videos.generate(args:{path:{library_id:string};headers?:{"Idempotency-Key"?:string};body:{/** Text prompt describing the video to generate; the video model receives it unchanged. e.g. "A red kite above a calm sea at sunrise" */ prompt:string;/** What the video must not contain. */ negative_prompt?:string;/** Name the produced videos carry in the library; when n is above 1 the second and later get " 2", " 3" and so on. e.g. "Lighthouse shot 7" */ display_name?:string;/** What the video is anchored to. e.g. "text" */ mode:"text"|"image"|"first_last"|"reference"|"edit";/** Video to edit; required by mode edit and refused by every other mode. */ source?:string;/** Asset to use as the opening frame; required by mode image and first_last. */ first_frame?:string;/** Asset to use as the closing frame; required by mode first_last. */ last_frame?:string;/** Existing assets the model may use, each an object {"asset_id": "<asset id>", "role": "subject"} naming the asset and the role it plays; in the prompt they are @ */ references?:Array<{asset_id:string;role:"edit_target"|"style"|"structure"|"subject"|"video"|"voice";/** How strongly the reference asset influenced the result, from 0 to 1 on the Stability scale. */ strength?:number;/** Video generation, mode reference only: the voice this picture’s subject speaks with. */ voice_asset_id?:string}>;/** Requested video length in seconds; refused with mode edit, whose output is as long as its source. e.g. 8 */ duration_seconds?:number;/** Requested output resolution, validated against the chosen model. e.g. "1080p" */ resolution?:"480p"|"720p"|"1080p"|"4k";/** Output aspect ratio written as width:height; defaults to 16:9. e.g. "16:9" */ aspect_ratio?:string;/** True to generate an audio track with the video. e.g. true */ generate_audio?:boolean;/** Container of the produced video; defaults to mp4. e.g. "mp4" */ output?:"mp4"|"gif";/** Videos to generate in one job, from 1 to 4; defaults to 1. */ n?:number;/** Seed for reproducible sampling, on models that take one; omit it to let the model choose. */ seed?:number;/** Model with video-generation capability; omit it to use the library default video model. e.g. "wan2.7-t2v" */ model?:string;tier?:"economy"|"balanced"|"quality";/** Folder the produced asset is filed under; when omitted it is 生成/YYYY-MM-DD, the UTC date the job was created. */ asset_folder?:string;/** Understanding behavior for the produced asset; defaults to auto. e.g. "auto" */ understanding?:"auto"|"skip";/** Stable key so a retried request reuses the same job instead of generating and charging again; reusing it with different content is rejected. e.g. "kite-sunrise-video-1" */ idempotency_key?:string}}):Promise<{/** Job identifier: job_ followed by 32 lowercase hexadecimal characters. pattern: ^job_[0-9a-f]{32}$ e.g. "job_b562f087623c4756b43813e3dce670ba" */ id:string;/** Identifier of the library the job runs in; the produced assets land here. */ library_id:string;/** Batch operation: tag adds labels, untag removes labels, set_context replaces custom metadata, move changes asset_folder, and delete removes selected assets. */ action:"tag"|"untag"|"set_context"|"move"|"delete"|"reprocess"|"generate";/** Where the job is. */ status:"queued"|"in_progress"|"running"|"completed"|"completed_with_errors"|"failed"|"cancelled"|"canceled";/** Category of media this job produces. */ type?:"image"|"video"|"speech"|"music"|"sound_effect"|"voice";/** The operation this job performs: generate for a plain text-to-image or text-to-video job, or the edit operation an image edit applied to its source asset. */ operation?:"generate"|"clone"|"tag"|"untag"|"set_context"|"move"|"delete"|"reprocess"|"variations"|"upscale"|"outpaint"|"inpaint"|"erase"|"replace_object"|"recolor"|"remove_background"|"replace_background"|"to_video"|"extend"|"edit"|"lip_sync"|"frame"|"to_gif"|"voice_change"|"resynthesize";/** Asset this job edits, present on an image edit job and omitted on generation jobs. */ source_asset_id?:string;/** Fraction of this job already processed, from 0 to 1. */ progress?:number;/** Why a queued generation job has not started yet. */ queue_reason?:"concurrency"|"provider_throttled"|"provider_queue";/** Present while the job waits for a slot (queue_reason concurrency): its place in line among the waiting jobs of its type in this library, 1 for the next to start */ queue_position?:number;/** Generation job: number of outputs requested (images or videos; text segments for speech). */ total:number;/** Number of outputs or items successfully processed; failed ones are counted separately. */ done:number;/** Number of outputs or items that could not be produced or processed. */ failed:number;/** Always present, including an empty array before any item failure or when all items succeed. */ failures:Array<{/** Identifier supplied for the failed item; it may identify a missing asset. */ asset_id?:string;/** Zero-based output index for a failed video-generation item. */ index?:number;/** Domain error code explaining the individual item failure. */ code:"LIBRARY_NOT_FOUND"|"ASSET_NOT_FOUND"|"WORK_NOT_FOUND"|"REVISION_CONFLICT"|"JOB_NOT_FOUND"|"UNDERSTANDING_NOT_FOUND"|"ASSET_VERSION_CHANGED"|"LIBRARY_INVALID_STATE"|"INVALID_PARAMS"|"INVALID_EXPRESSION"|"UNSUPPORTED"|"NOT_IMPLEMENTED"|"FILE_TOO_LARGE"|"FILE_EMPTY"|"FILE_NOT_READY"|"UNSUPPORTED_MEDIA"|"FETCH_FAILED"|"LIMIT_EXCEEDED"|"CHUNK_INVALID"|"RATE_LIMITED"|"CAPACITY"|"UPSTREAM_FAILED"|"CONTENT_REJECTED"|"GENERATION_FAILED"|"BINDING_READ_ONLY"|"OPERATION_NOT_SUPPORTED"|"MODEL_PENDING"|"REFERENCE_TYPE_MISMATCH"|"CONSENT_REQUIRED"|"LIBRARY_IS_DEFAULT"|"JOB_INVALID_STATE"|"VOICE_TRAINING"|"INSUFFICIENT_BALANCE";/** The upstream model service’s finer reason for this failure, such as MODEL_PROTOCOL_LINE_UNAVAILABLE or VOICE_SAMPLE_REJECTED. */ detail_code?:string;/** Request id of the model call that failed, the same id shown in the model request log, so the failure can be traced there. */ model_request_id?:string;/** The model service’s own words for this failure, for a person to read, for example why moderation refused an input. */ message?:string}>;/** Generation intent recorded on the earliest video jobs; newer generation jobs describe themselves with type and operation instead. */ intent?:string;/** Model that produced the outputs of a generation job; omitted for batch jobs. */ model?:string;/** The performance tier that actually served this job’s model, present only when the request named a tier instead of a model. */ tier?:"economy"|"balanced"|"quality";/** Per-output results of a generation job, in index order: one entry per requested image or video, and one per text segment for speech. */ outputs?:Array<{/** Zero-based position of this output in the requested count. */ index:number;/** State of this requested output. */ status:"pending"|"succeeded"|"failed";/** Short-lived signed URL for previewing this output; read the Job again to obtain a fresh URL. */ preview_url?:string;/** Seed for this output, when the model returned one; it may be absent. */ seed?:number|null;/** Present only on a job written before ADR-094 §2, when outputs were candidates with a retention window. */ expires_at?:string;/** Library asset identifier for this output once the library has stored it. */ asset_id?:string;/** Console page that shows this output in the media library, present once asset_id is. */ viewer_url?:string}>;/** What this job has been charged, as US dollars in a decimal string with six decimals, for example 0.042300. */ usage?:{/** US dollars as a decimal string with six decimals, for example 0.042300; never a floating-point number. */ amount:string;/** Currency code for amount; USD. */ currency:string};/** Time the job was created, in UTC. */ created_at:string;/** Time the job reached a terminal status, or null while queued or running. */ finished_at:string|null;/** Automation run (its root run) that started this job. */ pipeline_run_id?:string;/** Generation jobs only: the elements the job’s request expanded, each with the version read when the job was created; absent when none were. */ elements?:Array<{/** Element asset the generation expanded, in the same library as the output. */ asset_id:string;/** Element version read when the job was created. */ version:number;/** Kind of element. */ material_type:"character"|"product"|"scene"|"brand"}>;/** Present on a completed align job: how the two recordings line up, with offset_seconds and confidence. */ result?:{/** How many seconds later the reference asset starts, relative to the source asset the route named; positive means the reference comes later, so a caller holding b */ offset_seconds:number;/** How sure the alignment is, from 0 to 1; a low value means the two recordings share little to correlate. */ confidence:number}}>;

Parameters

NameInTypeRequiredDescription
library_idpathstringyesLibrary ID returned by creation.
Idempotency-KeyheaderstringnoStable key for retrying the same request without creating or charging for another job; reusing it with different request content is rejected. Send it here or as idempotency_key in the body, never both with different values.

Request body

RequiredContent typesDescription
yesapplication/json

Responses

StatusContent typesDescription
202application/jsonThe job is queued. Poll GET /media/v1/libraries/{library_id}/jobs/{job_id} until its status is completed or failed; the produced videos are stored in the library as they finish, with nothing to save and nothing to expire.
400application/jsonOPERATION_NOT_SUPPORTED: output gif was requested, or negative_prompt was sent; this release produces mp4 only. INVALID_PARAMS also covers references sent with a mode other than reference, more than 9 pictures after elements are expanded, a reference list of brands alone, and the same element named twice. INVALID_PARAMS: prompt or mode is missing, mode is not one of text, image, first_last or reference, n is outside 1–4, or another field is out of range. REFERENCE_TYPE_MISMATCH: a frame names an asset of this library that is not an image or a sticker. Select a supported mode and correct the reported field.
402application/jsonINSUFFICIENT_BALANCE: the organization balance cannot cover the estimated cost of this generation or edit; top up and resubmit. Nothing was generated and nothing was charged for this request.
403application/jsonThis credential has read-only access to the library; use a write-capable binding for mutations.
404application/jsonASSET_NOT_FOUND: a frame names an asset that is missing, deleted or belongs to another library, or the addressed library was not found; verify the identifiers with libraries and assets.
409application/jsonMODEL_PENDING or JOB_INVALID_STATE: the chosen model is not ready for this library, or the job cannot start from its current state; wait for the model to become available, or start a new job rather than resuming this one.
413application/jsonThe file exceeds an input limit; provide a smaller source file.
415application/jsonThis media format is unsupported; provide a supported format.
422application/jsonCONTENT_REJECTED: the provider refused the prompt or the source image under its content policy; change the prompt or the source before retrying. Nothing was generated and nothing was charged.
429application/jsonRATE_LIMITED: this library already has its maximum number of running jobs of this type and 50 more waiting, or the provider is throttling requests; Retry-After gives the seconds to wait before retrying. Below that a job past the running limit is accepted and waits (queue_reason concurrency) instead of being refused.
501application/jsonThe requested operation is unsupported; choose a supported method.
502application/jsonRequest failed; see the error code reference.
503application/jsonHistorical projections are still being initialized, or library storage is temporarily unavailable; retry shortly and check failureSummary counts_complete.