import type { RequestOptions, RunRequest, RunResponse } from "./types.js"; /** Flexible media input: base64 string, raw Buffer, or a file path to read. */ export type MediaInput = string | Buffer | { path: string; }; /** * Save base64-encoded media to a file. * * When `mimeType` is provided the correct extension is appended automatically * (e.g. `"image/jpeg"` → `.jpeg`). Returns the final file path used. * * @example * ```typescript * const result = await opper.generateImage({ prompt: "A sunset" }); * const path = saveMedia(result.data.image, "./media/sunset", result.data.mime_type); * // → "./media/sunset.jpeg" * * // Or with an explicit extension — mimeType is ignored: * saveMedia(result.data.image, "./media/sunset.png"); * ``` */ export declare function saveMedia(base64: string, filePath: string, mimeType?: string): string; /** * Response from a media method, with a `.save()` helper to write the output to a file. * * @example * ```typescript * const result = await opper.generateImage({ prompt: "A sunset" }); * result.save("./sunset"); // → "./sunset.jpeg" (extension auto-appended) * result.data.image; // still a plain base64 string * ``` */ export interface MediaResponse extends RunResponse { /** Save the media output to a file. Returns the final file path (with extension). */ save(filePath: string): string; } /** Wrap a RunResponse with a .save() method that knows which field to write. */ export declare function mediaResponse(response: RunResponse, base64Field: keyof T, mimeField?: keyof T): MediaResponse; /** Options shared by all media methods. */ export interface MediaBaseOptions { /** Model to use, e.g. `"openai/dall-e-3"` or `"pruna/p-image"`. */ readonly model?: string; /** Instructions for the function. */ readonly instructions?: string; /** Parent span ID for tracing/observability. */ readonly parent_span_id?: string; } /** Options for `generateImage()`. */ export interface GenerateImageOptions extends MediaBaseOptions { /** Text description of the image to generate (or edits to apply when a reference image is provided). */ readonly prompt: string; /** Optional reference image — base64 string, Buffer, or `{ path }` to a file. */ readonly reference_image?: MediaInput; /** Image size, e.g. `"1024x1024"`, `"1792x1024"`. */ readonly size?: string; /** Image quality: `"standard"`, `"hd"`, `"high"`, `"medium"`, `"low"`. */ readonly quality?: string; /** Image style: `"vivid"`, `"natural"` (DALL-E 3). */ readonly style?: string; /** Number of images to generate (default 1). */ readonly n?: number; /** Requested output MIME type, e.g. `"image/webp"`. */ readonly mime_type?: string; } /** Options for `generateVideo()`. */ export interface GenerateVideoOptions extends MediaBaseOptions { /** Text description of the video to generate. */ readonly prompt: string; /** Base64 image (or Buffer / `{ path }`) to use as first frame. */ readonly source_image?: MediaInput; /** Base64 video (or Buffer / `{ path }`) to use as reference. */ readonly source_video?: MediaInput; /** Base64 reference images for style. */ readonly ref_images?: MediaInput[]; /** Output aspect ratio, e.g. `"16:9"`, `"1:1"`. */ readonly aspect_ratio?: string; /** Output resolution, e.g. `"720p"`. */ readonly resolution?: string; /** Number of frames (controls duration). */ readonly frame_num?: number; /** Frames per second. */ readonly fps?: number; /** Generation speed hint. */ readonly speed_mode?: string; /** Seed for reproducibility. */ readonly seed?: number; /** Requested output MIME type, e.g. `"video/webm"`. */ readonly mime_type?: string; } /** Options for `textToSpeech()`. */ export interface TextToSpeechOptions extends MediaBaseOptions { /** Text to convert to speech. */ readonly text: string; /** Voice to use, e.g. `"alloy"`. */ readonly voice?: string; } /** Options for `transcribe()`. */ export interface SpeechToTextOptions extends MediaBaseOptions { /** Base64 audio data, Buffer, or `{ path }` to the audio file. */ readonly audio: MediaInput; /** ISO-639-1 language hint, e.g. `"en"`. */ readonly language?: string; /** Context to guide transcription. */ readonly prompt?: string; } /** Result from `generateImage()`. */ export interface GeneratedImage { readonly image: string; readonly mime_type: string; } /** Result from `generateVideo()`. */ export interface GeneratedVideo { readonly video: string; readonly mime_type: string; } /** Result from `textToSpeech()`. */ export interface GeneratedSpeech { readonly audio: string; } /** Result from `transcribe()`. */ export interface Transcription { readonly text: string; readonly language: string; } /** * Disambiguate the overloaded (name?, options, requestOptions?) pattern. * Returns `[name, options, requestOptions]`. */ export declare function resolveMediaArgs(defaultName: string, first: string | T, second?: T | RequestOptions, third?: RequestOptions): [string, T, RequestOptions | undefined]; export declare function buildGenerateImageRequest(opts: GenerateImageOptions): RunRequest; export declare function buildGenerateVideoRequest(opts: GenerateVideoOptions): RunRequest; export declare function buildTextToSpeechRequest(opts: TextToSpeechOptions): RunRequest; export declare function buildSpeechToTextRequest(opts: SpeechToTextOptions): RunRequest;