// STATUS: UNVERIFIED (ACCOUNT_RESTRICTED) — REST create returned 400 FAILED_PRECONDITION "Precondition check failed." on // 2026-09-18 (free-tier key; Batch API has no free tier). Paid key: BATCH_STATE_PENDING → RUNNING → SUCCEEDED. // Run: node --env-file=.env --experimental-strip-types examples/gemini/batch/batch-inline.ts import { GoogleGenAI } from "@google/genai"; const ai = new GoogleGenAI({}); const req = { contents: [{ role: "user", parts: [{ text: "Reply with OK." }] }], config: { maxOutputTokens: 8 } }; let job = await ai.batches.create({ model: "gemini-3.5-flash-lite", src: [req, req], config: { displayName: "atlas-example" } }); console.log("created", job.name, job.state); const terminal = new Set(["JOB_STATE_SUCCEEDED", "JOB_STATE_FAILED", "JOB_STATE_CANCELLED", "JOB_STATE_EXPIRED"]); const t0 = Date.now(); while (!terminal.has(String(job.state)) && Date.now() - t0 < 300_000) { await new Promise((r) => setTimeout(r, 20_000)); job = await ai.batches.get({ name: job.name! }); console.log(`t+${Math.round((Date.now() - t0) / 1000)}s`, job.state); } for (const r of job.dest?.inlinedResponses ?? []) console.log(JSON.stringify(r.metadata), r.response?.text ?? JSON.stringify(r.error)); if (job.dest?.fileName) console.log("responses file:", job.dest.fileName); await ai.batches.delete({ name: job.name! });