Python 88.3%
TypeScript 7.6%
Shell 4.1%
1// Interactions API with @google/genai: create, chain with previousInteractionId, stream events, delete.2// STATUS: LIVE_VERIFIED 2026-09-18 — `node --env-file=.env --experimental-strip-types examples/gemini/interactions/interactions.ts` (gemini-3.5-flash-lite, < $0.001).3import { GoogleGenAI } from "@google/genai";4import { logRequest } from "../../shared/tool-loop/log.ts";56const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });7const MODEL = "gemini-3.5-flash-lite";8// NOTE: the Interactions SDK surface passes the wire format through (snake_case) — camelCase → 400 "Unknown parameter 'generationConfig'. Did you mean 'generation_config'?"9const first: any = await ai.interactions.create({ model: MODEL, input: "Reply with OK.", generation_config: { max_output_tokens: 16 } } as any);10logRequest("gemini", "POST", "/v1beta/interactions", 200, 0.0001, "interactions.ts create");11console.log("create:", first.id, first.status, first.steps.map((s: any) => s.type));1213const stream: any = await ai.interactions.create({ model: MODEL, input: "Reply with OK.", previous_interaction_id: first.id, stream: true, generation_config: { max_output_tokens: 16 } } as any);14const types: string[] = []; let last: any;15for await (const ev of stream) { types.push(ev.event_type ?? ev.eventType); last = ev; }16logRequest("gemini", "POST", "/v1beta/interactions", 200, 0.0001, "interactions.ts stream");17console.log("stream events:", types.join(" → "));1819const got: any = await ai.interactions.get(first.id); // positional id (an object is stringified → 400 "Invalid interaction name")20logRequest("gemini", "GET", "/v1beta/interactions/{id}", 200, 0, "interactions.ts get");21console.log("get:", got.status, "usage:", got.usage?.total_tokens);22for (const id of [first.id, last?.interaction?.id].filter(Boolean)) {23 await ai.interactions.delete(id);24 logRequest("gemini", "DELETE", "/v1beta/interactions/{id}", 200, 0, "interactions.ts delete");25}26console.log("deleted");27