/** * Google Gemini API compatible types for the /v1beta/models/* endpoints * These match the official Gemini REST format to enable drop-in replacement * * Hand-written rather than re-exported from @google/genai: that package * models responses as classes with computed getters (`.text`, * `.functionCalls`), which a plain wire object can't satisfy, and the * SDK package must stay free of provider dependencies. */ /** Gemini names the assistant turn `model`, and has no `system` role — * system text travels in the separate `systemInstruction` field. */ export type GeminiRole = 'user' | 'model'; export interface GeminiBlob { mimeType: string; data: string; } export interface GeminiFileData { mimeType?: string; fileUri: string; } export interface GeminiFunctionCall { id?: string; name: string; args: Record; } export interface GeminiFunctionResponse { id?: string; name: string; response: Record; } /** * A part is a union in spirit but an open bag on the wire — Gemini * sends one populated field per part, and `thought` / `thoughtSignature` * ride alongside the payload field rather than replacing it. */ export interface GeminiPart { text?: string; inlineData?: GeminiBlob; fileData?: GeminiFileData; functionCall?: GeminiFunctionCall; functionResponse?: GeminiFunctionResponse; /** Marks the part as reasoning output rather than answer text. */ thought?: boolean; /** Opaque token Gemini 3.x requires echoed back on the next turn. */ thoughtSignature?: string; } export interface GeminiContent { role?: GeminiRole; parts: GeminiPart[]; } export interface GeminiFunctionDeclaration { name: string; description?: string; parameters?: Record; parametersJsonSchema?: Record; } export interface GeminiTool { functionDeclarations?: GeminiFunctionDeclaration[]; [key: string]: unknown; } export type GeminiFunctionCallingMode = 'AUTO' | 'ANY' | 'NONE' | 'VALIDATED'; export interface GeminiToolConfig { functionCallingConfig?: { mode?: GeminiFunctionCallingMode; allowedFunctionNames?: string[]; }; } export interface GeminiSafetySetting { category: string; threshold: string; } export interface GeminiThinkingConfig { includeThoughts?: boolean; thinkingBudget?: number; } export interface GeminiGenerationConfig { temperature?: number; topP?: number; topK?: number; candidateCount?: number; maxOutputTokens?: number; stopSequences?: string[]; responseMimeType?: string; responseSchema?: Record; responseJsonSchema?: Record; seed?: number; presencePenalty?: number; frequencyPenalty?: number; thinkingConfig?: GeminiThinkingConfig; } export interface GeminiGenerateContentRequest { contents: GeminiContent[]; systemInstruction?: GeminiContent | { parts: GeminiPart[]; }; tools?: GeminiTool[]; toolConfig?: GeminiToolConfig; safetySettings?: GeminiSafetySetting[]; generationConfig?: GeminiGenerationConfig; cachedContent?: string; } /** * countTokens accepts either a bare `contents` array or a nested * `generateContentRequest`. The official SDKs send the nested form when * tools or a system instruction are in play. */ export interface GeminiCountTokensRequest { contents?: GeminiContent[]; generateContentRequest?: GeminiGenerateContentRequest & { model?: string; }; } export interface GeminiCountTokensResponse { totalTokens: number; } export type GeminiFinishReason = 'STOP' | 'MAX_TOKENS' | 'SAFETY' | 'RECITATION' | 'MALFORMED_FUNCTION_CALL' | 'OTHER'; export interface GeminiSafetyRating { category: string; probability: string; blocked?: boolean; } export interface GeminiCandidate { content?: GeminiContent; finishReason?: GeminiFinishReason; index?: number; safetyRatings?: GeminiSafetyRating[]; } export interface GeminiUsageMetadata { promptTokenCount?: number; candidatesTokenCount?: number; totalTokenCount?: number; cachedContentTokenCount?: number; thoughtsTokenCount?: number; } export interface GeminiPromptFeedback { blockReason?: string; safetyRatings?: GeminiSafetyRating[]; } export interface GeminiGenerateContentResponse { candidates: GeminiCandidate[]; usageMetadata?: GeminiUsageMetadata; modelVersion?: string; responseId?: string; promptFeedback?: GeminiPromptFeedback; } /** * Google's canonical RPC status codes, as surfaced in the REST error * envelope's `status` field. */ export type GeminiRpcStatus = 'INVALID_ARGUMENT' | 'FAILED_PRECONDITION' | 'UNAUTHENTICATED' | 'PERMISSION_DENIED' | 'NOT_FOUND' | 'RESOURCE_EXHAUSTED' | 'INTERNAL' | 'UNAVAILABLE' | 'DEADLINE_EXCEEDED' | 'UNKNOWN'; export interface GeminiError { error: { code: number; message: string; status: GeminiRpcStatus; details?: unknown[]; }; } //# sourceMappingURL=gemini-format.d.ts.map