Skip to main content

litellm-doctor

CLI llm for OpenAI-compatible gateways (LiteLLM and similar): list models, ping, local token estimates, needle context test, stepped context bench.

Setup

git clone git@github.com:hewimetall/litellm-doctor.git
cd litellm-doctor
cp .env.example .env   # set OPENAI_API_KEY (+ optional OPENAI_BASE_URL)
uv sync

.env:

OPENAI_BASE_URL=http://localhost:4000/v1
OPENAI_API_KEY=sk-...

Default base URL if unset: http://localhost:4000/v1.
Auth: Authorization: Bearer $OPENAI_API_KEY.

Vendored tokenizer files ship in the repo under tiktoken_cache/ (no download required for --mode openai).

Commands

Command Purpose
llm list GET /models
llm info [MODEL] GET /model/info (max_in / max_out / mode / input types / key)
llm ping MODEL single chat/completions
llm pings parallel ping of all models (-j)
llm tokens TEXT local token count
llm context MODEL one needle test at a given size
llm bench MODEL size sweep: est vs usage vs OK/FAIL

Examples

uv run llm list
uv run llm info
uv run llm info --json          # includes input_types + supports_* flags
uv run llm ping gpt-4o-mini
uv run llm pings -j 8 --timeout 5

uv run llm tokens "hello world"
uv run llm tokens - --mode openai < prompt.txt

uv run llm context my-model -n 32000
uv run llm context my-model -n 32000 --mode openai --no-random

uv run llm bench my-model
uv run llm bench my-model --start 1000 --stop 64000 --step 8000
uv run llm bench my-model --no-random --json

Common flags: --timeout, --max-tokens, --json (where supported).

Tokenizer (--mode)

Mode How it counts Network
opencode (default) chars / 4 (OpenCode-style) none
openai local tiktoken + chatml overhead none (vendored files only)

Model → encoding for --mode openai: see MODEL_ENCODING in src/helpers/tokenize.py
(default cl100k_base; o200k_base for gpt-4o / o3 / …). Unknown model names fall back to cl100k_base.

Vendored encodings

Committed in-repo (safe to git push):

  • tiktoken_cache/cl100k_base.tiktoken
  • tiktoken_cache/o200k_base.tiktoken

Source of the pin script (optional refresh): GitHub niieani/gpt-tokenizer raw data — not openaipublic.blob.core.windows.net.

bash scripts/pin_tiktoken.sh   # refresh from GitHub if needed

Runtime loads BPE from disk (load_tiktoken_bpe(path)). tiktoken.get_encoding() is not used, so OpenAI CDN is never contacted.

context / bench: prompt shape

Single user message:

[bust=<hex>]          # only when --random (default)
SECRET=NEEDLE-42
<padding>
Find SECRET= in this message. Reply with the SECRET value only.
Flag Behavior
--random (default) bust= + random pad — avoids KV / prefix-cache hits
--no-random no bust=, stable lorem ipsum — prefix may cache

Step success: HTTP 200 and reply contains NEEDLE-42.

bench defaults

  • sizes: 1000 … 128000, step 8000
  • max_tokens=16, timeout=30
  • columns: target, est, usage (prompt_tokens), ms, status, recall
  • summary: max_ok_target, first_fail_target, meta max_input_tokens

Releases

Push a tag v* (e.g. v0.1.0) to run .github/workflows/release.yml:

Artifact Platforms
llm binary (PyInstaller one-file) linux-x86_64, windows-x86_64, macos-x86_64, macos-aarch64
Docker image ghcr.io/hewimetall/litellm-doctor (Python runtime — not a packaged binary)
PyPI package pip install lite-llm-doctor (sdist + wheel; version = tag without v)

Manual workflow_dispatch builds artifacts / validates the image without publishing a GitHub Release, pushing to GHCR, or uploading to PyPI.

PyPI uses Trusted Publishing (OIDC) from this workflow — no API token in repo secrets. Register the publisher on PyPI with workflow release.yml and Environment name left empty (Any).

docker pull ghcr.io/hewimetall/litellm-doctor:latest
docker run --rm -e OPENAI_API_KEY -e OPENAI_BASE_URL ghcr.io/hewimetall/litellm-doctor:latest list

Layout

src/helpers/llm.py          # CLI
src/helpers/tokenize.py     # token estimates + needle_prompt
src/helpers/paths.py        # data/.env roots (dev, wheel, frozen)
scripts/pin_tiktoken.sh     # optional refresh from GitHub
tiktoken_cache/*.tiktoken   # vendored encodings (in git)
.github/workflows/release.yml
Dockerfile                  # GHCR runtime image
.env                        # secrets — gitignored
.env.example                # template

Metadata

Release files for lite-llm-doctor 0.1.2

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

Source distribution (sdist)

Source distribution for lite-llm-doctor 0.1.2
File Size Uploaded Provenance Actions
lite_llm_doctor-0.1.2.tar.gz 2.5 MB With provenance Details for lite_llm_doctor-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lite-llm-doctor 0.1.2
File Interpreter ABI Platform Actions
lite_llm_doctor-0.1.2-py3-none-any.whl Python 3 none any Details for lite_llm_doctor-0.1.2-py3-none-any.whl

Total release size: 5.0 MB

Release files / lite_llm_doctor-0.1.2.tar.gz

Download URL lite_llm_doctor-0.1.2.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
24f71607a916b0492d9fd87c5967791b9630b5dda5a3b0b64b3c5cd11a19f8f8
BLAKE2b-256 checksum
How to use checksums
5fc0e48db77745604a755cec441f4da28bbc0f4afdcd11528e91dfd357e99176
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 19, 2026.

Transparency log

Release files / lite_llm_doctor-0.1.2-py3-none-any.whl

Download URL lite_llm_doctor-0.1.2-py3-none-any.whl
Size 2.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
3fbe292618128b44b72637962d8d8287326a1e68d2ab49bb142f29da4cddf75f
BLAKE2b-256 checksum
How to use checksums
c99d1c329e203a40a0335b61f1de97fc8d03df77d553f9b7f42d38137d1ce615
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 19, 2026.

Transparency log

Security for lite-llm-doctor 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lite_llm_doctor-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files Full provenance

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