@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
93 lines (92 loc) • 4.41 kB
TypeScript
import { type AIProviderName } from "../../constants/enums.js";
import { BaseProvider } from "../../core/baseProvider.js";
import type { EmbedInput, ZodUnknownSchema, EnhancedGenerateResult, TextGenerationOptions, StreamOptions, StreamResult } from "../../types/index.js";
import type { LanguageModel, Schema } from "../../types/index.js";
export declare class GoogleAIStudioProvider extends BaseProvider {
private credentials?;
constructor(modelName?: string, sdk?: unknown, credentials?: {
apiKey?: string;
baseURL?: string;
});
getProviderName(): AIProviderName;
getDefaultModel(): string;
/**
* AI SDK model instance — no longer used.
* All models are routed through native @google/genai SDK directly.
*/
getAISDKModel(): LanguageModel;
protected formatProviderError(error: unknown): Error;
/**
* Overrides the BaseProvider's image generation method to implement it for Google AI.
* This method calls the Google AI API to generate an image from a prompt.
* @param options The generation options containing the prompt.
* @returns A promise that resolves to the generation result, including the image data.
*/
protected executeImageGeneration(options: TextGenerationOptions): Promise<EnhancedGenerateResult>;
/**
* Detect image MIME type from buffer
*/
private detectImageType;
/**
* Estimate token count from text using centralized estimation with provider multipliers
*/
private estimateTokenCount;
/**
* Run the file preprocessing this provider's native paths depend on.
*
* AI Studio overrides both `generate()` and `executeStream()` and routes
* straight to the native SDK, so neither reaches
* `buildMultimodalMessagesArray` — the place that turns `input.files` into
* text, images, PDFs and `nativeAudioFiles`. `BaseProvider.stream()` does
* build messages, but onto a throwaway clone whose result is discarded, so
* the real `options.input` came through untouched.
*
* The consequence was asymmetric and easy to miss: `generate()` did this
* inline and worked, while `stream()` silently dropped every attached file —
* not just audio, but the metadata summary too. Vertex hit the identical bug
* (#1258) and solved it with exactly this shape, called from both entry
* points.
*/
private preprocessNativeFileInput;
protected executeStream(options: StreamOptions, analysisSchema?: ZodUnknownSchema | Schema<unknown>): Promise<StreamResult>;
/**
* Execute stream using native @google/genai SDK
* Uses @google/genai directly for all Gemini models (2.0, 2.5, 3.x)
*/
private executeNativeGemini3Stream;
/**
* Execute generate using native @google/genai SDK for Gemini 3 models
* This bypasses @ai-sdk/google to properly handle thought_signature
*/
private executeNativeGemini3Generate;
/**
* Override generate to route Gemini 3 models with tools to native SDK
*/
generate(optionsOrPrompt: TextGenerationOptions | string): Promise<EnhancedGenerateResult | null>;
/**
* Emit `generation:end` so the Pipeline B observability listener creates
* a `model.generation` span for native Google AI Studio generate calls.
* Without this hand-off the native path silently disappears from
* Pipeline B exporters (Langfuse, custom OTEL collectors).
*/
private emitPipelineBGenerationEvent;
private executeAudioStreamViaGeminiLive;
protected getDefaultEmbeddingModel(): string;
/**
* Generate embeddings for text using Google AI Studio embedding models
* @param input - The text to embed (string or EmbedInput)
* @param modelName - The embedding model to use (default: gemini-embedding-001)
* @returns Promise resolving to the embedding vector
*/
embed(input: string | EmbedInput, modelName?: string): Promise<number[]>;
/**
* Generate embeddings for multiple texts in a single batch
* @param texts - The texts to embed
* @param modelName - The embedding model to use (default: gemini-embedding-001)
* @returns Promise resolving to an array of embedding vectors
*/
embedMany(texts: string[], modelName?: string): Promise<number[][]>;
private getApiKey;
private getBaseURL;
}
export default GoogleAIStudioProvider;