import { type TregAuth } from './treg-client.js'; export declare const REAPI_SEEDANCE_MODEL = "doubao-seedance-2.5-face"; export declare const REAPI_TREG_SUBMIT_ENDPOINT_ID = "reapi.video-gen.seedance-2-5.unrestricted"; export declare const REAPI_TREG_TASK_ENDPOINT_ID = "reapi.tasks.get"; export declare const REAPI_DIRECT_BASE_URL = "https://reapi.ai/api/v1"; /** Reference audio and reference video are each capped at 30 s combined (docs/seedance-2-5). */ export declare const REAPI_MAX_AUDIO_SECONDS_COMBINED = 30; export declare const REAPI_MAX_VIDEO_SECONDS_COMBINED = 30; /** Each reference clip and audio track must be 2–30 s on its own. */ export declare const REAPI_MIN_REFERENCE_SECONDS = 2; export type ReapiResolution = '480p' | '720p' | '1080p'; export type ReapiSize = 'adaptive' | '16:9' | '9:16' | '1:1' | '4:3' | '3:4' | '21:9'; export type ReapiFrameRole = 'first_frame' | 'last_frame' | 'reference_image'; export type ReapiFetchLike = (input: string, init?: { method?: string; headers?: Record; body?: string | Uint8Array; }) => Promise<{ ok: boolean; status: number; text: () => Promise; json: () => Promise; headers?: { get(name: string): string | null; }; }>; /** Where a call goes and what it carries for auth. Chosen by the caller, never inferred. */ export type ReapiTransportTarget = { kind: 'treg'; auth: TregAuth; } | { kind: 'direct'; apiKey: string; baseUrl?: string; }; export interface ReapiSubmitBodyInput { prompt: string; /** Whole seconds, 4–30. Never -1: auto length reserves 30 s of credit. */ duration: number; resolution: ReapiResolution; size: ReapiSize; /** Plain reference images (`@image1..N` in send order). Exclusive with `imageWithRoles`. */ imageUrls?: string[]; /** First/last frame stills. Exclusive with `imageUrls`; forces `size:'adaptive'`. */ imageWithRoles?: Array<{ url: string; role: ReapiFrameRole; }>; /** Reference clips (`@video1..N`); BILLED on top of the output. */ videoUrls?: string[]; /** Reference audio (`@audio1..N`); free; drives the generated speech. */ audioUrls?: string[]; generateAudio?: boolean; /** Default true here: the last frame is free and seeds chain-from-prev. */ returnLastFrame?: boolean; seed?: number; } /** * Build the JSON body for `POST /videos/generations`, enforcing every rule the * docs check at submit so a violation fails here (free) rather than there: * • `prompt` is required on the unmoderated route in every mode; * • `duration` is a whole second 4–30; * • `image_urls` and `image_with_roles` never travel together (HTTP 400 code 20003); * • at most one `first_frame` and one `last_frame`, a last frame needs a first * frame, frame roles never share an array with `reference_image`; * • a frame role forces `size:'adaptive'`; * • the per-kind reference caps. */ export declare function buildReapiSubmitBody(input: ReapiSubmitBodyInput): Record; export declare function reapiSubmitEndpoint(target: ReapiTransportTarget): string; export declare function reapiTaskEndpoint(target: ReapiTransportTarget, taskId: string): string; export declare function reapiAuthHeaders(target: ReapiTransportTarget): Record; export type ReapiPollStatus = 'pending' | 'completed' | 'failed'; /** `processing` (and anything unknown) is pending; only `completed`/`failed` are terminal. */ export declare function mapReapiStatus(raw: string): ReapiPollStatus; export interface ReapiTaskView { taskId: string | null; status: ReapiPollStatus; videoUrl: string | null; lastFrameUrl: string | null; /** Credits the task settled at (1 credit = $0.001), when reported. */ credits: number | null; error: string | null; raw: Record; } /** Parse the shared submit/poll envelope. Tolerates a missing `output`/`usage`. */ export declare function parseReapiTaskResponse(json: unknown): ReapiTaskView; /** 1 credit = $0.001. */ export declare function reapiCreditsToUsd(credits: number): number; /** * A create that did not come back with a usable task id, carrying what the * caller needs to decide whether the vendor might still have taken (and billed) * the job. `kind` says which way the create ended: * • `http` — the provider/relay answered with a non-2xx. * • `no-task-id` — a 2xx whose body carried no id: the task may exist under * an id we never learned, which on reAPI is unrecoverable. * • `refused` — a 2xx that came back already `failed`: the vendor said no * (and refunds it); `taskId` names it when one was given. */ export declare class ReapiCreateError extends Error { readonly kind: 'http' | 'no-task-id' | 'refused'; readonly status?: number; readonly bodyText?: string; readonly taskId?: string; /** The answer itself said nothing was billed (treg 402 out of balance, 503 saturated). */ readonly retrySafe: boolean; constructor(message: string, init: { kind: 'http' | 'no-task-id' | 'refused'; status?: number; bodyText?: string; taskId?: string; retrySafe?: boolean; }); } /** * Whether a failed create might still have created (and billed) a task. * * A 4xx is the vendor saying no before it queued anything, and treg's own * "nothing was billed" answers (402 out of balance, 503 `treg_saturated`) say * the relay never reached reAPI. Everything else — a network error, a timeout, * a 5xx from a gateway sitting in front of a queue that may have taken the job, * a 2xx with no id — is a LOST ANSWER, and on this route it is terminal: reAPI * publishes no endpoint that lists tasks, so nothing can look the task up later. * 408 (the request timed out server-side) and 499 (the client went away) are the * two 4xx that say nothing about whether the body was processed. */ export declare function isAmbiguousReapiCreateError(error: unknown): boolean; export declare function submitReapiJob(input: { target: ReapiTransportTarget; body: Record; fetchImpl?: ReapiFetchLike; }): Promise<{ taskId: string; raw: Record; }>; export declare function pollReapiJob(input: { target: ReapiTransportTarget; taskId: string; fetchImpl?: ReapiFetchLike; }): Promise; //# sourceMappingURL=reapi-seedance.d.ts.map