// STATUS: LIVE_VERIFIED — executed 2026-09-18 (exit 0 in 13.0s) // Thinking: thinkingBudget + includeThoughts on gemini-3.5-flash (thought summary part + thoughtsTokenCount), then thinkingLevel low on the same model. // Run: node --env-file=.env --experimental-strip-types examples/gemini/thinking/thinking.ts (@google/genai 2.23 reads GEMINI_API_KEY) import { GoogleGenAI } from "@google/genai"; import { appendFileSync } from "node:fs"; const ai = new GoogleGenAI({}); const MODEL = "gemini-3.5-flash"; const log = (method: string, path: string, status: number, cost: number, note: string) => appendFileSync("reports/live-requests.jsonl", JSON.stringify({ ts: new Date().toISOString().replace(/\.\d+Z$/, "Z"), provider: "gemini", method, path, status, est_cost_usd: cost, note }) + "\n"); const r = await ai.models.generateContent({ model: MODEL, contents: "What is 17*23? Reply with the number only.", config: { maxOutputTokens: 600, thinkingConfig: { thinkingBudget: 256, includeThoughts: true } } }); log("POST", "/v1beta/models/{model}:generateContent", 200, 0.0012, "example thinking/thinking.ts (budget 256)"); for (const p of r.candidates?.[0]?.content?.parts ?? []) console.log(p.thought ? "THOUGHT:" : "ANSWER:", (p.text ?? "").slice(0, 120).replace(/\n/g, " ")); console.log("thoughtsTokenCount:", r.usageMetadata?.thoughtsTokenCount, "candidates:", r.usageMetadata?.candidatesTokenCount); if (!r.text?.includes("391")) throw new Error("wrong answer"); const r2 = await ai.models.generateContent({ model: MODEL, contents: "Reply with OK.", config: { maxOutputTokens: 32, thinkingConfig: { thinkingLevel: "low" } } }); log("POST", "/v1beta/models/{model}:generateContent", 200, 0.00003, "example thinking/thinking.ts (level low)"); console.log("level low:", r2.text, r2.usageMetadata?.thoughtsTokenCount);