import { AICapabilities, AIInterface, AIMessage, AIModel, AIResponse, ChatOptions, CompletionOptions, EmbeddingOptions, EmbeddingResponse, GeminiOptions, ImageDescriptionOptions, ImageEmbeddingOptions, ImageGenerationOptions, ImageGenerationResponse, MessageOptions, TTSOptions, TTSResponse, VideoGenerationJob, VideoGenerationOptions, VideoGenerationResult, VideoGenerationStatusResult, Voice, VoiceCloneOptions, VoiceDesignOptions, VoiceListOptions } from '../types'; export declare class GeminiProvider implements AIInterface { private options; private client; private operationCtor?; constructor(options: GeminiOptions); private initializeClientSync; private ensureClient; /** * Build the GoogleGenAI client configuration based on provided options. * Supports both Google AI Studio (apiKey only) and Vertex AI (projectId + location). */ private buildClientConfig; chat(messages: AIMessage[], options?: ChatOptions): Promise; complete(prompt: string, options?: CompletionOptions): Promise; /** * Simple message interface for single-turn interactions with optional history * * @param text - The message text to send * @param options - Configuration options including history, model, etc. * @returns Promise resolving to the response content string * * @example * ```typescript * // Simple usage * const response = await provider.message('Hello!'); * * // With history * const response = await provider.message('What was my question?', { * history: [ * { role: 'user', content: 'What is 2+2?' }, * { role: 'assistant', content: '4' } * ] * }); * ``` */ message(text: string, options?: MessageOptions): Promise; /** * Generate embeddings for text using Gemini embedding models * @param text - Single text string or array of texts to embed * @param options - Optional configuration for embeddings * @returns Promise resolving to embeddings response * * @example * ```typescript * const embedding = await provider.embed('Hello world'); * const embeddings = await provider.embed(['Text 1', 'Text 2']); * ``` */ embed(text: string | string[], options?: EmbeddingOptions): Promise; /** * Decode an image input (URL, base64 data URL, or Buffer) to raw bytes. * Shared by the chat/vision inline-data format and the video-generation * `imageBytes` format, which use different wrapper shapes around the same * base64 payload. * @private */ private decodeImageInput; /** * Convert an image to Gemini's inline-data format, used by chat/vision * `contents` parts (`generateContent`, `embedContent`). * @param image - Image as URL, base64 data URL, or Buffer * @returns Gemini inline data format * @private */ private imageToGeminiFormat; /** * Convert a reference image to the shape `generateVideos`'s `image` * parameter expects: `{ imageBytes, mimeType }` (or `{ gcsUri }` for a * `gs://` URI in Vertex AI mode). This is a different shape than * {@link imageToGeminiFormat}'s `{ inlineData: {...} }` — the SDK's video * converters read `imageBytes`/`mimeType`/`gcsUri` directly and silently * drop anything else, which previously caused image-to-video requests to * convert to `{}` and fall back to text-to-video. * @private */ private imageToGeminiVideoFormat; /** * Generate a text description of an image * @param image - Image as URL, base64 data URL, or Buffer * @param prompt - Custom prompt for description (optional) * @param options - Optional configuration * @returns Promise resolving to the description string * * @example * ```typescript * const description = await provider.describeImage('https://example.com/image.jpg'); * ``` */ describeImage(image: string | Buffer, prompt?: string, options?: ImageDescriptionOptions): Promise; /** * Generate embeddings for an image using native multimodal embeddings * @param image - Image as URL, base64 data URL, or Buffer * @param options - Optional configuration for image embeddings * @returns Promise resolving to embeddings response * * @example * ```typescript * const embedding = await provider.embedImage('https://example.com/image.jpg'); * ``` */ embedImage(image: string | Buffer, options?: ImageEmbeddingOptions): Promise; /** * Generate an image from a text prompt using Imagen 3 * @param prompt - Text description of the image to generate * @param options - Optional configuration for image generation * @returns Promise resolving to generated image(s) * * @example * ```typescript * const result = await provider.generateImage('A sunset over mountains'); * fs.writeFileSync('image.png', result.images[0].data); * ``` */ generateImage(prompt: string, options?: ImageGenerationOptions): Promise; /** * Submit an asynchronous video-generation job using Veo. * * Uses the same `@google/genai` client and credentials as {@link generateImage}. * Returns a serializable handle immediately; the render itself runs as a * long-running operation that callers poll via {@link getVideoGenerationJob}. * * @param options - Prompt, reference image(s), and generation parameters * @returns Promise resolving to a serializable job handle * * @example * ```typescript * const job = await provider.submitVideoGenerationJob({ * prompt: 'A neon hologram of a cat driving at top speed', * durationSeconds: 8, * }); * ``` */ submitVideoGenerationJob(options: VideoGenerationOptions): Promise; /** * Build a real `GenerateVideosOperation` instance for polling, and assert * the handle is being resumed against a provider configured in the same * mode (Google AI Studio vs. Vertex AI) it was submitted in. * @private */ private buildVideoOperation; /** * A handle submitted in Vertex AI mode cannot be resumed against a * provider configured for Google AI Studio (or vice versa): the SDK * routes `operations.getVideosOperation` based on how *this* client was * constructed, not how the job was submitted, so a mode mismatch would * otherwise surface as a confusing 404 deep in the SDK. * @private */ private assertResumeModeMatches; /** * Poll the status of a Veo video-generation job. * * On success, `result` carries the provider's `url` (a `files/*:download` * resource the caller cannot fetch directly without this provider's API * key) plus `mimeType`, but not `data` — call * {@link fetchVideoGenerationResult} to download the bytes. * * @param handle - The job handle returned by {@link submitVideoGenerationJob} * @returns Promise resolving to the current status, and result once succeeded */ getVideoGenerationJob(handle: VideoGenerationJob): Promise; /** * Fetch the result of a completed Veo video-generation job, downloading * the rendered bytes with this provider's API key (the `uri` Gemini * returns is a `files/*:download` resource that requires the same * credentials this provider already holds; a bare consumer cannot fetch * it directly). * * @param handle - The job handle returned by {@link submitVideoGenerationJob} * @returns Promise resolving to the generated video's bytes and metadata * @throws {AIError} When the job has not succeeded yet */ fetchVideoGenerationResult(handle: VideoGenerationJob): Promise; /** * Download a generated video's bytes via `ai.files.download`, which * resolves the `files/*:download` resource with this provider's API key * (matching Google's own documented usage pattern). The SDK's `download` * method only writes to a filesystem path, so this round-trips through a * temporary file and reads it back into memory. * @private */ private downloadGeneratedVideo; /** * Cancel an in-flight Veo video-generation job. * * **The Gemini API has no cancel endpoint for video-generation * operations.** The generativelanguage v1beta discovery document only * defines `batches.cancel` (unrelated to video jobs); there is no * `models.operations.cancel`. This always throws — cancellation of a * Veo render is unsupported by the provider itself, not merely by this * client. Callers must treat cancellation as best-effort across all * video-generation providers and tolerate this failure (e.g. by simply * discarding the handle and not billing for further polling). * * @param handle - The job handle returned by {@link submitVideoGenerationJob} * @throws {AIError} Always — cancellation is unsupported by the Gemini API */ cancelVideoGenerationJob(handle: VideoGenerationJob): Promise; /** * Cheap auth-shaped check for Veo access: lists models with a page size * of 1. Callers on a hot path must cache the result themselves. * * @returns Promise resolving to true when access looks valid */ validateVideoGenerationAccess(): Promise; private mapVideoOperation; stream(messages: AIMessage[], options?: ChatOptions): AsyncIterable; countTokens(text: string): Promise; getModels(): Promise; getCapabilities(): Promise; synthesizeSpeech(_text: string, _options?: TTSOptions): Promise; streamSpeech(_text: string, _options?: TTSOptions): AsyncIterable; cloneVoice(_options: VoiceCloneOptions): Promise; designVoice(_options: VoiceDesignOptions): Promise; getVoices(_options?: VoiceListOptions): Promise; private mapToolChoice; private buildGenerateContentConfig; private mapFinishReason; private messagesToGeminiFormat; private stripMarkdownCodeBlock; private mapError; } //# sourceMappingURL=gemini.d.ts.map