All files / src/providers/gemini index.ts

90.9% Statements 10/11
66.66% Branches 4/6
100% Functions 2/2
90% Lines 9/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34        63x             12x   9x 12x 12x   12x       12x     9x           63x      
import { config as globalConfig } from "../../config.js";
import { providerRegistry } from "../registry.js";
import { GeminiProvider } from "./GeminiProvider.js";
 
let registered = false;
 
/**
 * Idempotent registration of the Gemini provider.
 * Automatically called when using createLLM({ provider: 'gemini' })
 */
export function registerGeminiProvider() {
  if (registered) return;
 
  providerRegistry.register("gemini", (config) => {
    const cfg = config || globalConfig;
    const apiKey = cfg.geminiApiKey;
 
    Iif (!apiKey) {
      throw new Error("geminiApiKey is not set in config or GEMINI_API_KEY environment variable");
    }
 
    return new GeminiProvider({ apiKey });
  });
 
  registered = true;
}
 
/**
 * Alias for registerGeminiProvider for internal use.
 */
export const ensureGeminiRegistered = registerGeminiProvider;
 
export * from "./GeminiProvider.js";