Model chooser / Analyse spreadsheets and numbers / Recurring
A reporting pipeline turns questions into queries and query results into a short narrative, many times a week. Gemini 3.8 Flash is Google's "most intelligent workhorse", sits in the low cost tier, and ranks level with Opus 5 on LMArena.
Why Gemini 3.8 Flash
How to use it
Gemini API, TypeScript
Edit the parts in capitals, then run it.
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({}); // reads GEMINI_API_KEY
const interaction = await ai.interactions.create({
model: "gemini-3.8-flash",
input: `Schema:\nPASTE SCHEMA\n\nMetric definitions:\nPASTE DEFINITIONS\n\nQuestion: Which acquisition channel had the best 90-day retention last quarter?`,
response_format: {
type: "text",
mime_type: "application/json",
schema: {
type: "object",
properties: {
sql: { type: "string", description: "One read-only SELECT query" },
assumptions: { type: "array", items: { type: "string" } },
},
required: ["sql", "assumptions"],
},
},
});
const { sql, assumptions } = JSON.parse(interaction.output_text);
// run sql on a READ-ONLY connection, then send the rows back for the narrative
Alternatives that also work
Pick it when the narrative quality matters as much as the query, such as a report that goes to the board.
Pick it when volume is high and you want MIT-licensed weights with a cheap hosted API as a fallback.
Pick it when the warehouse cannot be reached from a third-party API. Apache 2.0, one GPU.
Watch out for
Sources
Checked . Models change monthly; we re-check this page when they do.
Wiring it into a workflow that runs every week, with evals, fallbacks and a cost you can predict, is the work. Fifteen minutes, no deck.