跳转到内容
EN

Align asset

Code Mode: praxis.media.libraries.assets.align.create

HTTP: POST /media/v1/libraries/{library_id}/assets/{asset_id}/align

Align two recordings by their sound and learn how they line up, without producing an asset. The route names the source asset; the body names the reference to compare against it. Both must be audio or a video, of the same library; anything else is refused with REFERENCE_TYPE_MISMATCH before a job exists. The call is an analysis: it decides and charges nothing else, bills per second of input, and stores no asset — the completed job carries the answer in result, offset_seconds saying how many seconds later the reference starts (so a caller holding both recordings knows which one to slide) and confidence how sure the correlation is. The analysis is idempotent on the source, the reference and the parameters: asking again with the same pair answers the completed job and its result instead of analysing and charging again. A max_offset_seconds caps how far apart the two may be; alignment needs an alignment model from the platform model catalogue, and with none published the request is refused with OPERATION_NOT_SUPPORTED, 尚未上架. Send Idempotency-Key, or idempotency_key in the body, to retry without analysing twice. The response is 202 with a queued Job whose operation is align; poll GET /media/v1/libraries/{library_id}/jobs/{job_id} until it is completed or failed, then read result. Example: POST /media/v1/libraries/lib_example/assets/9dfa312ef9bc4b00816339b598b1152c/align with {“reference_asset_id”:“3f2a9c1e5b7d4e6f8a0b1c2d3e4f5a6b”,“max_offset_seconds”:30}.

签名

praxis.media.libraries.assets.align.create(args:{path:{library_id:string;asset_id:string};headers?:{"Idempotency-Key"?:string};body:{/** Asset to align against the one the route names. */ reference_asset_id:string;/** Largest offset to search for, in seconds; omit it to let the model search its full range. */ max_offset_seconds?:number;/** Stable key so a retried request reuses the same job instead of analysing and charging again; reusing it with different content is rejected. e.g. "align-interview-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}}>;

参数

名称位置类型必填说明
library_idpathstring是Library ID returned by creation.
asset_idpathstring是32-character asset ID.
Idempotency-Keyheaderstring否Stable 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.

请求体

必填内容类型说明
是application/json

响应

状态码内容类型说明
202application/jsonThe alignment job is queued. Poll GET /media/v1/libraries/{library_id}/jobs/{job_id} until its status is completed or failed; a completed job carries the answer in result as offset_seconds and confidence, so a caller holding both recordings knows which one to slide. No asset is stored and nothing is overwritten. An alignment with the same source, reference and params answers the job already completed instead of analysing and charging again.
400application/jsonREFERENCE_TYPE_MISMATCH: the source asset or the reference asset is not an audio or video asset; both must be one of the two. INVALID_PARAMS: reference_asset_id is missing, max_offset_seconds is zero or negative, or the request names an alignment model the generation capabilities do not offer. OPERATION_NOT_SUPPORTED: the platform has published no alignment model, so the request is refused with the model field named. Correct the reported field; nothing was analysed and nothing was charged.
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: the source or the reference asset is missing, deleted or belongs to another library, or the addressed library was not found; verify the identifiers with libraries and assets. A reference asset that cannot be reached answers the same way, never as a hint that it exists elsewhere.
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.