import type * as ElevenLabs from "../api"; import { FlowsClient as GeneratedFlowsClient } from "../api/resources/flows/client/Client"; import { ImageClient as GeneratedImageClient } from "../api/resources/flows/resources/image/client/Client"; import { TemplatesClient as GeneratedTemplatesClient } from "../api/resources/flows/resources/templates/client/Client"; import { RunsClient as GeneratedRunsClient } from "../api/resources/flows/resources/templates/resources/runs/client/Client"; import { TextToSpeechClient as GeneratedTextToSpeechClient } from "../api/resources/flows/resources/textToSpeech/client/Client"; import { VideoClient as GeneratedVideoClient } from "../api/resources/flows/resources/video/client/Client"; import type { BaseRequestOptions } from "../BaseClient"; import { ElevenLabsError } from "../errors"; export declare namespace FlowsWait { /** * Options for `createAndWait`. Everything besides the wait options below is passed * through as request options to the create call and every status check. * * Between status checks `createAndWait` waits for the number of seconds in the server's * `Retry-After` header, never less than `minPollIntervalInSeconds`. A `failed` result is * returned, not thrown, so check `status`. It is meant for scripts and quickstarts: in * production, set `webhook` on the `create` request and handle the webhook event instead * of holding a process open. * * Throws `FlowsWaitTimeoutError` if `waitTimeoutInSeconds` runs out first. */ interface Options extends BaseRequestOptions { /** * Seconds to wait in total before throwing `FlowsWaitTimeoutError`, which carries the * generation or run id so you can resume with `get`. Waits indefinitely when omitted * or `Infinity`; must be at least 0 when set. * Not to be confused with `timeoutInSeconds`, which limits each HTTP request. */ waitTimeoutInSeconds?: number; /** * The shortest wait between status checks, in seconds. Also used when the server * sends no `Retry-After` header. Defaults to 3; must be finite and at least 0.5. */ minPollIntervalInSeconds?: number; } } /** * Thrown by `createAndWait` when a generation or template run is still unfinished after * `waitTimeoutInSeconds`. The work keeps running on the server: resume waiting by calling * `get` with `id` (and `templateId` for a template run), or let a webhook deliver the result. */ export declare class FlowsWaitTimeoutError extends ElevenLabsError { readonly id: string; readonly templateId: string | undefined; readonly waitTimeoutInSeconds: number; readonly lastResponse: { status: string; }; constructor(args: { id: string; templateId?: string; waitTimeoutInSeconds: number; lastResponse: { status: string; }; }); } /** Milliseconds to wait before the next GET: the server's `Retry-After`, never below the minimum, plus jitter. */ export declare function pollDelayMs(headers: Headers, minIntervalSeconds: number): number; /** @internal Indirection so tests can replace the wait between status checks. */ export declare const pollTimer: { sleep(ms: number): Promise; }; /** What `createAndWait` returns for a generation: always `completed` or `failed`, never in progress. */ export type TerminalMediaGenerationResponse = ElevenLabs.MediaGenerationResponse.Completed | ElevenLabs.MediaGenerationResponse.Failed; export declare class FlowsImageClient extends GeneratedImageClient { /** * Start an image generation and wait until it is `completed` or `failed`, then return the final generation. * A `failed` generation is returned, not thrown. In production, use a `webhook` instead; * see {@link FlowsWait.Options} for polling, timeouts and webhooks. * @throws {FlowsWaitTimeoutError} when `waitTimeoutInSeconds` elapses first. * * @example * const generation = await client.flows.image.createAndWait({ * modelId: "bytedance-seedream-5-lite", * prompt: "A corgi in a tiny lifeguard chair on a sunlit beach at golden hour, photorealistic", * }); */ createAndWait(request: ElevenLabs.ImageGenerationRequest, options?: FlowsWait.Options): Promise; } export declare class FlowsVideoClient extends GeneratedVideoClient { /** * Start a video generation and wait until it is `completed` or `failed`, then return the final generation. * A `failed` generation is returned, not thrown. In production, use a `webhook` instead; * see {@link FlowsWait.Options} for polling, timeouts and webhooks. * @throws {FlowsWaitTimeoutError} when `waitTimeoutInSeconds` elapses first. */ createAndWait(request: ElevenLabs.VideoGenerationRequest, options?: FlowsWait.Options): Promise; } export declare class FlowsTextToSpeechClient extends GeneratedTextToSpeechClient { /** * Start a text-to-speech generation and wait until it is `completed` or `failed`, then return the final generation. * A `failed` generation is returned, not thrown. In production, use a `webhook` instead; * see {@link FlowsWait.Options} for polling, timeouts and webhooks. * @throws {FlowsWaitTimeoutError} when `waitTimeoutInSeconds` elapses first. */ createAndWait(request: ElevenLabs.TextToSpeechGenerationRequest, options?: FlowsWait.Options): Promise; } export declare class FlowsTemplateRunsClient extends GeneratedRunsClient { /** * Start a run of a flows template and wait until its `status` is `completed` or `failed`, then return the final run. * A `failed` run is returned, not thrown; each output also has its own `status`. In production, * handle the `flows_template_run` webhook instead; see {@link FlowsWait.Options} for polling and timeouts. * @throws {FlowsWaitTimeoutError} when `waitTimeoutInSeconds` elapses first. * * @example * const run = await client.flows.templates.runs.createAndWait("template_id", { * inputs: { prompt: "a corgi on a surfboard" }, * }); */ createAndWait(templateId: string, request: ElevenLabs.flows.templates.TemplateRunCreateRequest, options?: FlowsWait.Options): Promise; } export declare class FlowsTemplatesClient extends GeneratedTemplatesClient { get runs(): FlowsTemplateRunsClient; } /** * Extends the generated flows client with `createAndWait` helpers on `image`, `video`, * `textToSpeech` and `templates.runs`. */ export declare class Flows extends GeneratedFlowsClient { get video(): FlowsVideoClient; get image(): FlowsImageClient; get textToSpeech(): FlowsTextToSpeechClient; get templates(): FlowsTemplatesClient; }