{T}
TokenMath.net
Developer Knowledge HubTechnical Architecture Guides

AI Token & LLM Cost Engineering Guides

Deep-dive technical documentation written for engineers architecting, evaluating, and scaling production AI systems. No fluff—just equations, code examples, and verified benchmarks.

Fundamentals

How AI Tokenization Works: BPE vs SentencePiece

An engineer's breakdown of Byte-Pair Encoding, byte fallbacks, subword vocabularies, and why character counts never equal token counts.

7 min readRead Guide →
Conversion

Tokens vs Words: The Definitive Conversion Guide

Exact conversion rules for natural English prose, source code indentation, JSON payloads, and multi-page PDF documents.

5 min readRead Guide →
Multimodal

Multimodal Vision Token Math: OpenAI 512px Tiles, Claude & Gemini

Detailed tiling formulas, patch dimensions, and video frame-per-second token costs across OpenAI, Anthropic, and Google.

8 min readRead Guide →
Reasoning

The Engineer's Guide to Reasoning Tokens: o3, o3-pro & Claude Thinking

How invisible chain-of-thought tokens are billed at output rates, managing reasoning_effort, and preventing runaway costs.

9 min readRead Guide →
High-Throughput

Batch API Processing: 50% Discounts, Queues & Evaluation Architecture

Cut token costs in half using asynchronous JSONL queues. 24-hour SLAs, retry semantics, and stacking with prompt caching.

7 min readRead Guide →
Optimization

Prompt Caching Economics: How KV Caching Saves Up to 90%

Deep dive into Key-Value attention cache reuse, write-cache amortizations, TTL lifetimes, and breakeven hit-rate formulas.

8 min readRead Guide →
Economics

LLM API Pricing Explained: Input vs Output & Reasoning Tokens

Why generation tokens cost 3x-5x more than input tokens, how internal chain-of-thought tokens are billed, and how to compute blended rates.

6 min readRead Guide →
Architecture

RAG Cost Architecture: Ingestion, Chunking & Vector Retrieval

A complete economic blueprint for Retrieval-Augmented Generation: embedding corpus costs, vector database searches, and top-k context sizing.

9 min readRead Guide →
Agentic AI

AI Agent Cost Modeling: Loops, Tool Calls & Context Bloat

How multi-turn autonomous loops compound token consumption exponentially, and how prompt caching mitigates ballooning agent expenses.

8 min readRead Guide →
Infrastructure

Managed API vs Self-Hosted GPU TCO: The 50M–150M Token Threshold

The definitive Total Cost of Ownership equation: H100 hourly rates, vLLM throughput, and the 30% idle compute tax.

9 min readRead Guide →