openrouter-context-optimization
Installation
SKILL.md
OpenRouter Context Optimization
Overview
OpenRouter models have varying context windows (4K to 1M+ tokens). Since pricing is per-token, stuffing unnecessary context wastes money and can degrade output quality. This skill covers context window lookup, token estimation, conversation trimming, chunking strategies, and Anthropic prompt caching for large contexts.
Prerequisites
- An OpenRouter API key (
sk-or-v1-...) exported asOPENROUTER_API_KEY— see theopenrouter-install-authskill for setup - Python 3.8+ with the OpenAI SDK and
requestsfor model-metadata lookup;tiktokenfor exact token counting per the references curlandjqto query context windows and pricing from/api/v1/models- Node.js 18+ if you use the TypeScript context-budget calculator in the references