Skip to main content

Real-time observability dashboard for LLM applications. Track prompts, tokens, costs, and latency. One-line integration.

Project description

📡 LLM Radar

PyPI Python Version License: MIT

Real-time observability dashboard for LLM applications. Track every prompt, token count, cost, and latency across OpenAI and Anthropic — with one line of code.

from llm_radar import LLMRadar
radar = LLMRadar(app)  # that's it

Dashboard → http://localhost:8000/__llm_radar


Installation

pip install llm-radar

With provider SDKs:

pip install "llm-radar[openai]"       # + openai
pip install "llm-radar[anthropic]"    # + anthropic
pip install "llm-radar[all]"          # + both

Quick Start

OpenAI

from fastapi import FastAPI
from llm_radar import LLMRadar
import openai

app = FastAPI()
radar = LLMRadar(app)          # intercepts all openai calls automatically

client = openai.OpenAI()

@app.get("/chat")
async def chat(message: str):
    response = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": message}],
    )
    return {"reply": response.choices[0].message.content}

Anthropic

from fastapi import FastAPI
from llm_radar import LLMRadar
import anthropic

app = FastAPI()
radar = LLMRadar(app)

client = anthropic.Anthropic()

@app.get("/summarize")
async def summarize(text: str):
    response = client.messages.create(
        model="claude-haiku-4-5-20251001",
        max_tokens=256,
        messages=[{"role": "user", "content": text}],
    )
    return {"summary": response.content[0].text}

Use with fastapi-radar

llm-radar works alongside fastapi-radar — one app, two dashboards.

from fastapi import FastAPI
from fastapi_radar import Radar
from llm_radar import LLMRadarPlugin

app = FastAPI()

radar = Radar(app)               # HTTP + SQL monitoring → /__radar/
llm   = LLMRadarPlugin(app)      # LLM monitoring       → /__llm_radar

What Gets Tracked

Signal Captured
Prompt preview ✅ First 500 chars of last user message
Response preview ✅ First 500 chars of response
Input tokens
Output tokens
Cost (USD) ✅ Auto-calculated from current pricing
Latency (ms) ✅ End-to-end wall time
Model name
Provider ✅ openai / anthropic
Errors ✅ With message
Async calls

Configuration

radar = LLMRadar(
    app,
    dashboard_path="/__llm_radar",   # Custom path
    max_calls=1000,                   # Max records to keep
    retention_hours=24,               # Data retention window
    db_path="/var/data/llm",          # Custom DB location
    auth_dependency=my_auth_fn,       # Optional FastAPI dependency
    track_openai=True,
    track_anthropic=True,
)

Securing the Dashboard

from fastapi import Depends, HTTPException
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials

security = HTTPBearer()

def verify_token(creds: HTTPAuthorizationCredentials = Depends(security)):
    if creds.credentials != "your-secret-token":
        raise HTTPException(status_code=401, detail="Unauthorized")

radar = LLMRadar(app, auth_dependency=verify_token)

Supported Models & Pricing

Auto-detects cost for:

  • OpenAI: gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-3.5-turbo, o1, o3-mini, o4-mini
  • Anthropic: claude-opus-4, claude-sonnet-4, claude-haiku-4, claude-3.5-sonnet, claude-3-opus

Unrecognized models record 0 cost (no crash).


Contributing

git clone https://github.com/ganeshmandakapu/llm-radar
cd llm-radar
pip install -e ".[dev]"

License

MIT — Ganesh Mandakapu

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

llm_radar-0.1.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

llm_radar-0.1.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file llm_radar-0.1.0.tar.gz.

File metadata

  • Download URL: llm_radar-0.1.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llm_radar-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d8d57333cdd8a4fef9d67c162ccaf0f9f7669fda8be2d94592ffa3948a25fcbe
MD5 32d454e7caa8e513e483ad5ff62e59f0
BLAKE2b-256 bfee221381e3afccb24ae865637ab10e00e4b95e0649d4f691aa4c6c526a75c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_radar-0.1.0.tar.gz:

Publisher: publish.yml on GaneshMandakapu/llm-radar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llm_radar-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: llm_radar-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llm_radar-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1f4e728b24da882d28eeebd1a9e36f525de7cd0f8e7b21b73d204e843ec7050
MD5 d8dafd7973bbb1190cef80e8b9e9cbe9
BLAKE2b-256 c7c7557d5264a304e11ccb8581c17e79fc067ce081d02fe3d820c6199f2ddf0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_radar-0.1.0-py3-none-any.whl:

Publisher: publish.yml on GaneshMandakapu/llm-radar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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