@interview-sdk/adapter-gemini
v0.1.2
Published
Google Gemini provider adapter for @interview-sdk/core.
Maintainers
Readme
@interview-sdk/adapter-gemini
Google Gemini provider adapter for @interview-sdk/core, built on
@google/genai — Google's current unified SDK. The older
@google/generative-ai package reached end-of-life on 2025-11-30; this
adapter deliberately does not use it.
Install
npm install @interview-sdk/core @interview-sdk/adapter-geminiUsage
import { GeminiAdapter } from '@interview-sdk/adapter-gemini';
const adapter = new GeminiAdapter({ apiKey: process.env.GEMINI_API_KEY });
// <InterviewWidget adapter={adapter} mode="client" ... />
// or: new ServerAnswerProcessor({ questions, rubric, adapter })(AdapterRegistry from @interview-sdk/core is a separate, optional utility
for looking an adapter up by string id at runtime — most apps just pass the
adapter directly like above.)
GeminiAdapter accepts an optional model (defaults to gemini-3.5-flash;
pass gemini-3.1-pro for heavier reasoning) and an optional pre-configured
client for testing or Vertex/Enterprise mode.
Behavior
- Splits
AIMessage[]into Gemini'sconfig.systemInstruction(developer content) and thecontentsarray — Gemini uses'user'/'model'role names (not'assistant'), soassistantmessages are mapped to'model'. - Requests
responseMimeType: 'application/json'(noresponseSchema) whenresponseFormat: 'json'is set — the same reasoning as the other text adapters: our response shapes carry dynamic keys that Gemini's OpenAPI-subset schema format can't express. - Opts into retries explicitly. Unlike Claude's and OpenAI's SDKs,
@google/genaidoes not retry rate-limit/server errors by default — this adapter passeshttpOptions.retryOptions.attemptsso Gemini's baseline resilience matches the other providers before core's ownwithRetry/FailoverAdapterlayer is even involved. - Normalizes every Gemini
ApiError(a single generic class with a numeric.status, not a typed hierarchy like Claude/OpenAI) onto the sharedProvider*Errortaxonomy from@interview-sdk/coreby branching on that status code. - Context-length overflow and a deprecated/retired model id both surface as
a generic
ApiErrorwith no distinct type — context-length is detected heuristically from the message text.
Verified against
@google/[email protected], current as of 2026-07-04 — model names and the SDK
package itself have changed before (Google previously shipped
@google/generative-ai, now EOL); re-check before assuming this stays
accurate for long.
