Skip to main content

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

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

contextmeter-0.2.0.tar.gz (61.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

contextmeter-0.2.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file contextmeter-0.2.0.tar.gz.

File metadata

  • Download URL: contextmeter-0.2.0.tar.gz
  • Upload date:
  • Size: 61.7 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for contextmeter-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fe2da124e05e6993838c93f71b90182ed00687f60b269cf01363416cfc8d2ecf
MD5 b19d877522fee010a687f10ed9b2d8cd
BLAKE2b-256 2f75b58b88220b56fc3f96eb28074798512fa93e46a6d1c2347c9f617af6d209

See more details on using hashes here.

File details

Details for the file contextmeter-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: contextmeter-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for contextmeter-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de3fee2b808ebd5f81b24a111c3df0233ee7f0e1e70aaf398183c13efc5c81b4
MD5 b7c8799b9130838b3139a902a1123feb
BLAKE2b-256 51568bc016ded9fbb6bd06e5d2e695921e3150ec6ce4a681f9a7b3819a6abad3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page