Back to news
ReleaseGemini9 min read

Read a year of customer email with Gemini 4 Neon.

Load a year of support mail from an IaGenify mailbox into one long context and ask Gemini 4 Neon for the ten insights that matter — with the messages that prove them.

geminineonlong-contextmailsdktutorial

Support inboxes hold a year of product feedback that nobody reads end to end, and summaries of samples miss the pattern that only shows across hundreds of messages. With a context of a million tokens, Gemini 4 Neon can read the whole year at once. This tutorial pulls the mail from an IaGenify mailbox, builds one long input and asks for insights with the evidence behind each one.

Collect the year

messages.list() pages through a folder, newest first. Its cursor is a date, so mail arriving while you read does not shift the pages. A summary has no body, so each message is read with messages.get().

import { IaGenify } from "iagenify";

const api = new IaGenify({ apiKey: process.env.IAGENIFY_API_KEY });
const box = await api.mail.get("[email protected]");
const since = new Date("2026-01-01");
const mails = [];

let cursor = null;
collect: do {
  const page = await box.messages.list({ folder: "inbox", limit: 100, cursor });
  for (const summary of page.messages) {
    if (new Date(summary.receivedAt) < since) break collect;
    const message = await box.messages.get(summary.id);
    mails.push(`[${summary.id}] ${summary.receivedAt} — ${message.subject}\n${message.text}`);
  }
  cursor = page.nextCursor;
} while (cursor);

Estimate before you send

Roughly four characters make a token. Measure the corpus first: past a million tokens the request is refused before anything is charged, and well below it you know what the call will cost.

const corpus = mails.join("\n\n---\n\n");
const tokens = Math.ceil(corpus.length / 4);
const [neon] = (await api.catalogue()).filter((row) => row.model === "gemini-4-neon");
console.log(tokens, "tokens ≈", Math.ceil((tokens / 1e6) * neon.creditsInput), "credits of input");

Ask for insights with evidence

const turn = await api.models.turn({
  model: "gemini-4-neon",
  system: "You analyse customer email for a product team. Every insight cites the message ids that show it.",
  messages: [{
    role: "user",
    content: `${corpus}\n\nList the ten most important product insights from this year of support email. For each: one sentence, how often it appears, and three message ids that show it.`,
  }],
  maxOutputTokens: 8000,
});

console.log(turn.message.content, turn.usage.credits);

The message ids turn each insight into something you can open and check. Read a few of them before you act on a finding.

What it costs

Neon is billed 750 credits per million input tokens and 3,750 per million output tokens, and one credit is one US cent. A year that fills 400,000 tokens costs about 300 credits of input, so run it once a quarter rather than on every message.

References

Frequently asked questions

Why not summarise the email in batches?

Batches only see their own slice. A pattern spread across hundreds of messages shows up when the model reads them together.

Can I use another mailbox provider?

This example reads an IaGenify mailbox through the SDK. Mail from elsewhere can be passed as text in the same way.

Back to news