/** * Native Google Gemini API (/v1beta/models/{model}:generateContent, streaming via * :streamGenerateContent?alt=sse) — wire types and provider implementation. */ import type { ChatMessageDto, UpstreamErrorDto, ChatStreamPieceDto, ChatResponseDto, ProviderResponseDto, ProviderStreamEventDto } from '../protocol.js'; import { AIProvider, type ChatRequestOpts } from '../aiProvider.js'; export type GeminiRole = 'user' | 'model' | 'system'; export interface GeminiTextPart { text: string; /** When true, this part is a thought summary (reasoning), not answer text. */ thought?: boolean; } export interface GeminiContent { role: GeminiRole; parts: GeminiTextPart[]; } export interface GeminiGoogleSearchTool { google_search: Record; } export type GeminiTool = GeminiGoogleSearchTool; export type GeminiThinkingLevel = 'minimal' | 'low' | 'medium' | 'high'; export interface GeminiThinkingConfig { /** Surface thought summaries as `thought` parts in the response. */ includeThoughts?: boolean; /** Token budget for thinking; -1 = dynamic (model self-regulates depth). */ thinkingBudget?: number; /** Semantic depth dial for Gemini 3.x+; replaces numeric budgets. */ thinkingLevel?: GeminiThinkingLevel; } export interface GeminiGenerationConfig { temperature?: number; topP?: number; topK?: number; maxOutputTokens?: number; stopSequences?: string[]; candidateCount?: number; thinkingConfig?: GeminiThinkingConfig; } export type GeminiFinishReason = 'FINISH_REASON_UNSPECIFIED' | 'STOP' | 'MAX_TOKENS' | 'SAFETY' | 'RECITATION' | 'LANGUAGE' | 'OTHER'; export interface GeminiCandidate { content: GeminiContent; finishReason?: GeminiFinishReason; } export interface GeminiPromptFeedback { blockReason?: string; } export interface GeminiResponseDto extends ProviderResponseDto { candidates?: GeminiCandidate[]; promptFeedback?: GeminiPromptFeedback; } export type GeminiSseEventDto = GeminiResponseDto; /** Request payload for native Gemini API */ interface GeminiRequestPayload { contents: GeminiContent[]; systemInstruction?: GeminiContent; tools?: GeminiTool[]; generationConfig?: GeminiGenerationConfig; } export declare class GeminiProvider extends AIProvider { protected readonly providerName = "Gemini"; readonly defaultBaseUrl = "https://generativelanguage.googleapis.com"; readonly path = "/v1beta/models"; private readonly budgetMap; getPath(model: string, stream: boolean): string; buildHeaders(apiKey: string): Record; buildPayload(messages: ChatMessageDto[], model: string, opts: ChatRequestOpts, _stream: boolean): GeminiRequestPayload; parseError(errorText: string, status: number): UpstreamErrorDto; parseNonStreamingResponse(json: ProviderResponseDto): ChatResponseDto; protected parseProviderStreamChunk(json: ProviderStreamEventDto): ChatStreamPieceDto | null; /** Major.minor from a versioned model name (`gemini-3.5-flash` → 3.5); null for aliases. */ private geminiVersion; /** Dial → level, clamped to the family's supported enum: `minimal` is 3.5+; earlier 3.x floors at * `low`. (gemini-3-pro-preview's low|high-only enum would need a wider clamp, but Google retired * the model — 404 verified 2026-07-15.) */ private thinkingLevelFor; private isGeminiResponse; /** Split a candidate's parts into answer text and thought (reasoning) summaries — Gemini marks * thought parts with `thought: true`. Returns the `{ text?, reasoning? }` stream-piece shape. */ private extractParts; private checkGeminiError; } export {}; //# sourceMappingURL=gemini.d.ts.map