Skill 4.1.1

Develop token efficiency systems to reduce FM costs while maintaining effectiveness (for example, by using token estimation and tracking, context window optimization, response size controls, prompt compression, context pruning, response limiting)

Key Concepts

Token estimation before a call (with the CountTokens API where available, or a tokeniser or ratio-based estimate) lets the application trim inputs to budget. Tracking uses the usage field in every response and the InputTokenCount and OutputTokenCount metrics, broken down by application, feature and user, often through application inference profiles with cost allocation tags.

Context window optimisation sends only what the model needs: fewer, reranked chunks; context pruning drops or summarises old conversation turns; prompt compression removes redundant instructions and examples. Response size controls set maxTokens, ask for concise formats and use stop sequences. Output tokens usually cost more than input tokens, so limiting response length has a large effect.