ctxlen
The context limits of any LLM: always fresh, works offline, three functions
Downloads & Community Adoption
Health & Engineering Analysis (5 Pillars)
1. Governance & Community50 / 200 ▾
2. PEP Metadata & Packaging200 / 200 ▾
3. Security & Supply Chain200 / 200 ▾
4. Documentation, SEO & Ecosystem60 / 200 ▾
5. Engineering, CI & Quality165 / 200 ▾
Official Documentation & Usage Guide — ctxlen
Show full original documentation (English README) ▾
ctxlen 📏
A super minimal-dependency, always-fresh, project to look up the context limits (input and output tokens) of LLMs. 🤔
- 🔄 New models checked every 6 hours, and your install picks them up within the hour: no upgrade needed.
- 🪶 Just httpx and certifi as dependencies, and it still works offline, with the numbers it shipped with.
- 🧰 Just three functions.
Install
uv add ctxlen
Or with pip:
pip install ctxlen
Usage
Ask for a model's whole context window:
import ctxlen
ctxlen.ctxlen("claude-opus-5-5") # 1_000_000
ctxlen.ctxlen("gpt-6-sol") # 1_050_000
You can also put the provider in front, like litellm does:
ctxlen.ctxlen("anthropic/claude-sonnet-5-5") # 1_000_000
ctxlen.ctxlen("openai/gpt-6-luna") # 1_050_000
Or ask for the input and output limits on their own:
ctxlen.max_input("gpt-6-sol") # 922_000
ctxlen.max_output("gpt-6-sol") # 128_000
The numbers come from litellm and models.dev; their notices are in LICENSE.
Offline
ctxlen.ctxlen("gpt-6-sol", live=False) uses only the numbers that came with your version, and CTXLEN_OFFLINE=1 does that for the whole process. ctxlen asks GitHub for fresh numbers at most once an hour and keeps them in ~/.cache/ctxlen/.