Skip to main content

contextmeter

contextmeter

A live meter for your LLM's context window — see exactly what's filling it.

PyPI version Python versions CI License: MIT

contextmeter demo

contextmeter is a tiny local proxy + terminal HUD. Point your LLM app at it and watch, in real time, how your context window fills up — broken down by system prompt, tool definitions, chat history, and tool outputs. It makes the invisible "tool tax" obvious: "34% of your window is tool schemas you never call."

It auto-detects the request format per call, so it works with any OpenAI-compatible API, Anthropic, and Google Gemini out of the box — no code changes, just a base-URL swap. Responses are streamed straight through.

Works with

Anything that speaks the OpenAI chat format — OpenAI, OpenRouter, Groq, Together, Mistral, DeepSeek, Fireworks, and local servers like Ollama, vLLM, and LM Studio — plus Anthropic (Claude) and Google Gemini. contextmeter figures out which format each request uses on its own (Gemini's model is even read from the request URL).

Install

uv pip install contextmeter

Use

Start the meter (provider is auto-detected; defaults to forwarding to OpenAI):

contextmeter

Then point your app's base URL at http://localhost:8765. To forward somewhere else (Anthropic, a local server, OpenRouter, …), just set --upstream:

contextmeter --upstream https://api.anthropic.com
contextmeter --upstream http://localhost:11434

--provider is optional — pass openai or anthropic only if you want to pin the format instead of letting it auto-detect.

Note: pass the host root as --upstream, not the /v1 endpoint. Your LLM client already appends the path (e.g. /v1/chat/completions), so use http://localhost:11434 — not http://localhost:11434/v1 (which would double the path to /v1/v1/...).

Why

Most developers have no idea what's eating their context window. Tool definitions alone can consume 40–60% before the first message. contextmeter shows you, live, in your terminal.

Status

Supports OpenAI-compatible, Anthropic, and Google Gemini request analysis with automatic per-request provider detection, streaming pass-through, and counting of the model's emitted tool_calls/tool_use payloads. Token counts are approximate (tiktoken-based; Anthropic and Gemini are approximated).

Roadmap: Python wrapper entry point (no proxy); pricing/limits auto-refresh; richer Textual UI.

Metadata

Release files for contextmeter 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for contextmeter 0.2.0
File Size Uploaded
contextmeter-0.2.0.tar.gz 61.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for contextmeter 0.2.0
File Interpreter ABI Platform
contextmeter-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 76.2 kB

Release files / contextmeter-0.2.0.tar.gz

Download URL contextmeter-0.2.0.tar.gz
Size 61.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fe2da124e05e6993838c93f71b90182ed00687f60b269cf01363416cfc8d2ecf
BLAKE2b-256 checksum
How to use checksums
2f75b58b88220b56fc3f96eb28074798512fa93e46a6d1c2347c9f617af6d209
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / contextmeter-0.2.0-py3-none-any.whl

Download URL contextmeter-0.2.0-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de3fee2b808ebd5f81b24a111c3df0233ee7f0e1e70aaf398183c13efc5c81b4
BLAKE2b-256 checksum
How to use checksums
51568bc016ded9fbb6bd06e5d2e695921e3150ec6ce4a681f9a7b3819a6abad3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page