Overview
Offline, deterministic context packaging for Gemini. Compile any text into a verified PDF artifact (gemini-context-pack-v1 canonicalization), send it as a single inlineData: application/pdf part, and compare reported input tokens without hosted services or API keys at build time.
- TypeScript ESM,
node >=18,bun >=1 - Bundled OFL fonts (no runtime CDN)
- Verifiable: SHA-256 over canonical source, independent
pdfjs-distextraction
README (English) — README (한국어) — Architecture (A–J) — Validation Methodology — Responsible Use — Accounting and Claims
Install — GitHub Release tarball (no registry)
gh release download v0.1.0 --repo ianlyoo/GeminiContextPack --pattern "gemini-context-pack-*.tgz"
npm install ./gemini-context-pack-0.1.0.tgz
Alternative: npm pack then npm install ./gemini-context-pack-0.1.0.tgz
git clone https://github.com/ianlyoo/GeminiContextPack.git
cd GeminiContextPack
bun install --frozen-lockfile
bun run build
echo "hello world — deterministic example" > input.txt
node ./dist/cli.js compile --input input.txt --output out.pdf
node ./dist/cli.js inspect --pdf out.pdf
node ./dist/cli.js verify --pdf out.pdf --source input.txt
Benchmark: reported input tokens in measured workloads
Qualified evidence only. See evidence/results.json and evidence/manifest.json for traceability. No cost or invoice claim is made.
| Target | Plain prompt_token_count | PDF prompt_token_count | PDF details (TEXT+IMAGE) | Ratio PDF/Plain | Reduction |
|---|---|---|---|---|---|
| 5000 | 5419 | 402 | 136 + 266 | 0.074 | 0.926 |
| 20000 | 20704 | 402 | 136 + 266 | 0.019 | 0.981 |
| 50000 | 51393 | 402 | 136 + 266 | 0.008 | 0.992 |
Limitations adjacent to benchmark (must be read with every number): Synthetic corpus, seed 42 deterministic lorem-style text with payload (not natural language); one run per condition (no statistical distribution); model gemini-2.5-flash primary with MEDIA_RESOLUTION_LOW (MEDIUM/HIGH variants exist as 532/1092 image tokens in raw); provider-reported input tokens only (usage.prompt_token_count); cache/wrapper/retrieval differ between plain and PDF (see raw evidence/raw/*.json); retrieval is substring match; no invoice data and no dollar cost is reported here; policy, model behavior, pricing, and tokenization may change.
Do not extrapolate beyond synthetic seed 42, single-run, gemini-2.5-flash/LOW setup. Reported input tokens are not an invoice. Every numeric field traces to raw evidence SHA and jsonPath — verify locally with bun run evidence:verify and bun run bench:offline -- --out /tmp/offline.json.
TypeScript API
import { compileContextWithBundledFonts } from "gemini-context-pack/node";
import { verifyContextPdf } from "gemini-context-pack";
import { toGeminiInlinePart } from "gemini-context-pack/gemini";
const source = "hello world — deterministic example";
const artifact = await compileContextWithBundledFonts(source);
const report = await verifyContextPdf(artifact.pdfBytes, source);
const part = toGeminiInlinePart(artifact);
// part = { inlineData: { mimeType: "application/pdf", data: "<base64>" } }
Project links
License and ownership
Owner: ianlyoo — License: Apache-2.0 — Version: 0.1.0 — Language: TypeScript
Not an official Google product. Not affiliated with Google. Gemini API behavior, pricing, and tokenization may change.