/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { GoogleGenAI, HttpOptions } from '@google/genai'; import { GoogleLLMVariant } from '../utils/variant_utils.js'; import { BaseLlm } from './base_llm.js'; import { BaseLlmConnection } from './base_llm_connection.js'; import { LlmRequest } from './llm_request.js'; import { LlmResponse } from './llm_response.js'; /** * The parameters for creating a Gemini instance. */ export interface GeminiParams { /** * The name of the model to use. Defaults to 'gemini-2.5-flash'. */ model?: string; /** * The API key to use for the Gemini API. If not provided, it will look for * the GOOGLE_GENAI_API_KEY, GOOGLE_API_KEY or GEMINI_API_KEY environment * variable, in that order. */ apiKey?: string; /** * Whether to use Vertex AI. If true, `project`, `location` * should be provided. */ vertexai?: boolean; /** * The Vertex AI project ID. Required if `vertexai` is true. */ project?: string; /** * The Vertex AI location. Required if `vertexai` is true. */ location?: string; /** * Headers to merge with internally crafted headers. */ headers?: Record; /** * Whether to use the Interactions API for stateful conversations. */ useInteractionsApi?: boolean; } declare const GEMINI_MODEL_SYMBOL: unique symbol; /** * Type guard to check if an object is an instance of Gemini. * @param obj The object to check. * @returns True if the object is an instance of Gemini, false otherwise. */ export declare function isGemini(obj: unknown): obj is Gemini; /** * Integration for Gemini models. */ export declare class Gemini extends BaseLlm { readonly [GEMINI_MODEL_SYMBOL] = true; private readonly apiKey?; protected readonly vertexai: boolean; private readonly project?; private readonly location?; private readonly headers?; readonly useInteractionsApi: boolean; /** * @param params The parameters for creating a Gemini instance. */ constructor({ model, apiKey, vertexai, project, location, headers, useInteractionsApi, }: GeminiParams); /** * A list of model name patterns that are supported by this LLM. * * @returns A list of supported models. */ static readonly supportedModels: Array; private _apiClient?; private _apiBackend?; private _trackingHeaders?; private _liveApiVersion?; private _liveApiClient?; /** * Sends a request to the Gemini model. * * @param llmRequest LlmRequest, the request to send to the Gemini model. * @param stream bool = false, whether to do streaming call. * @yields LlmResponse: The model response. */ generateContentAsync(llmRequest: LlmRequest, stream?: boolean, abortSignal?: AbortSignal): AsyncGenerator; protected getHttpOptions(): HttpOptions; get apiClient(): GoogleGenAI; get apiBackend(): GoogleLLMVariant; get liveApiVersion(): string; protected getLiveHttpOptions(): HttpOptions; get liveApiClient(): GoogleGenAI; /** * Connects to the Gemini model and returns an llm connection. * * @param llmRequest LlmRequest, the request to send to the Gemini model. * @returns BaseLlmConnection, the connection to the Gemini model. */ connect(llmRequest: LlmRequest): Promise; private preprocessRequest; } export declare function geminiInitParams({ model, vertexai, project, location, apiKey, }: GeminiParams): GeminiParams; export {};