4.1.1 · Lesson 1 of 16
Token Efficiency Systems & Prompt Compression
Minimize prompt and completion token counts to reduce pay-per-token API charges without degrading output quality.
WHAT
Minimize prompt and completion token counts to reduce pay-per-token API charges without degrading output quality.
WHY
LLM API pricing scales linearly with input/output token volume. Unoptimized system prompts, repetitive context, and long completions inflate cost.
HOW
- Context Pruning & Prompt Compression: Strip redundant fluff and extract only critical entities/summaries before the context window.
- Response Size Controls: Set
maxTokensto bound completion length. - Structured Formatting: Enforce JSON or concise bullets to avoid verbose intros.
Key points
- Context pruning / prompt compression
- maxTokens bounding
- Structured concise outputs
- Strip conversational filler
- Token cost scales with volume
Exam focus
LLM pricing scales with input/output tokens — compress context, bound maxTokens, and enforce concise structured outputs.