import {genkit} from 'genkit';
import {googleAI} from '@genkit-ai/google-genai';

export function createAi(apiKey?: string) {
  const normalizedApiKey = String(apiKey || '').trim();

  return genkit({
    plugins: [normalizedApiKey ? googleAI({ apiKey: normalizedApiKey }) : googleAI()],
    model: 'googleai/gemini-2.5-flash',
  });
}

export const ai = genkit({
  plugins: [googleAI()],
  model: 'googleai/gemini-2.5-flash',
});
