Use when integrating Gemini AI models in Supabase Edge Functions or Deno — Gemini 3.1 flash-lite, thinking levels, URL Context, Google Search grounding, structured output, function calling, image generation via generateContent. Use for AI enrichment, DNA scoring, product linking, and analysis tasks. Do NOT use for CopilotKit/Mastra client-side AI (use mastra/copilotkit), OpenAI/Anthropic direct integration, or Interactions API through MVP.
Use when integrating Gemini AI models in Supabase Edge Functions or Deno — Gemini 3.1 flash-lite, thinking levels, URL Context, Google Search grounding, structured output, function calling, image generation via generateContent. Use for AI enrichment, DNA scoring, product linking, and analysis tasks. Do NOT use for CopilotKit/Mastra client-side AI (use mastra/copilotkit), OpenAI/Anthropic direct integration, or Interactions API through MVP.
Gemini AI Integration (iPix)
Build AI features using Gemini via generateContent() only — nevergenerateImages().
Decision:gemini-3.1-flash-lite is the approved default everywhere. Override via GEMINI_MODEL env (allowlist: gemini-3.5-flash, gemini-3.1-pro-preview).
config: {
tools: [{ functionDeclarations: [searchMercurProducts, linkAssetToProduct] }],
}
// Execute calls server-side; return functionResponse with matching id + name (3.5 strict)// Append full candidate content to preserve thought signatures
Multimodal / Asset DNA (AI-010)
Pass Cloudinary delivery URL in prompt (optimized w_2048,f_auto) or inlineData for small tests:
contents: [
{ text: "Score this asset against brand DNA rubric: ..." },
{ text: `Image URL: ${secureUrl}` },
],
config: {
tools: [{ urlContext: {} }], // optional for brand guidelines URLresponseMimeType: "application/json",
responseSchema: assetDnaSchema,
}
Image Generation (Phase 2 — AI-016)
const response = await ai.models.generateContent({
model: "gemini-3.1-flash-image-preview",
contents: prompt,
config: {
responseModalities: ["IMAGE"],
imageConfig: { aspectRatio: "16:9" },
},
});
for (const part of response.candidates?.[0]?.content?.parts ?? []) {
if (part.inlineData?.mimeType?.startsWith("image/")) {
const base64 = part.inlineData.data;
}
}
Thought Signatures
Required for function calling + image edit chains. SDKs preserve signatures when you append full response.candidates[0].content to history.