UNPKG

@fishjam-cloud/js-server-sdk

Version:
63 lines (60 loc) 2.47 kB
import { GoogleGenAIOptions, GoogleGenAI } from '@google/genai'; /** * Creates a GoogleGenAI client. * * This module is a separate entry point (`@fishjam-cloud/js-server-sdk/gemini`), * so `@google/genai` is only loaded when the consumer imports this module. * * Does not verify the API key against Google — use {@link createClientAndValidate} * or call {@link checkCredentials} afterwards for that. * * @param options Configuration for the GoogleGenAI client. * @returns A GoogleGenAI instance. */ declare const createClient: (options: GoogleGenAIOptions) => GoogleGenAI; /** * Verifies the API key by making a single lightweight authenticated call * (`models.list`). Resolves on success; throws if the call fails — either * because the key was rejected or because the request itself failed (e.g. * network/connectivity). The original error is preserved as `cause`. * * Note: this catches the common cases (invalid / unauthorized / wrong-project / * region-blocked keys). It does not guarantee the key can use a specific Live * native-audio model — such model-specific rejections still surface only via the * `live.connect` session callbacks (`onerror`/`onclose`). * * @param client A GoogleGenAI instance, e.g. from {@link createClient}. */ declare const checkCredentials: (client: GoogleGenAI) => Promise<void>; /** * Creates a GoogleGenAI client and verifies the API key before returning it, * so misconfiguration fails fast. * * Throws if the key is rejected (see {@link checkCredentials}). * * @param options Configuration for the GoogleGenAI client. * @returns A validated GoogleGenAI instance. */ declare const createClientAndValidate: (options: GoogleGenAIOptions) => Promise<GoogleGenAI>; /** * Predefined audio settings for the agent's output track, * configured for Gemini's 24kHz audio output. */ declare const geminiOutputAudioSettings: { readonly encoding: "pcm16"; readonly channels: 1; readonly sampleRate: 24000; }; /** * Predefined audio settings for subscribing to room audio, * configured for Gemini's 16kHz audio input. */ declare const geminiInputAudioSettings: { readonly audioFormat: "pcm16"; readonly audioSampleRate: 16000; }; /** * The MIME type for the audio data sent to Gemini. */ declare const inputMimeType: "audio/pcm;rate=16000"; export { checkCredentials, createClient, createClientAndValidate, geminiInputAudioSettings, geminiOutputAudioSettings, inputMimeType };