import { GoogleGenAI } from "@google/genai";
const DEFAULT_MODEL = "gemini-2.5-flash-lite";
async function callGemini(opts, apiKey) {
  const client = new GoogleGenAI({ apiKey });
  const model = opts.modelOverride ?? DEFAULT_MODEL;
  const start = Date.now();
  const response = await client.models.generateContent({
    model,
    contents: opts.prompt,
    config: {
      responseMimeType: "application/json",
      responseJsonSchema: opts.jsonSchema,
      abortSignal: opts.signal
    }
  });
  const text = response.text;
  if (!text) {
    throw new Error("gemini: empty text in response");
  }
  let values;
  try {
    values = JSON.parse(text);
  } catch (e) {
    throw new Error(`gemini: invalid JSON in response: ${e.message}`);
  }
  return {
    values,
    provider: "gemini",
    model,
    cached: false,
    latencyMs: Date.now() - start
  };
}
export {
  callGemini
};
//# sourceMappingURL=gemini.js.map