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.3.0.tar.gz (21.1 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.3.0-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llm_radar-0.3.0.tar.gz
  • Upload date:
  • Size: 21.1 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.3.0.tar.gz
Algorithm Hash digest
SHA256 281bde4f21234a250cb532416ddfbe3a00e837cb5f126f804dbf25ea9653cdd0
MD5 5f7a1f59c121bb13da470c6d55741bad
BLAKE2b-256 013a116dac718201b7030cc56224c86163ac0abdfa2a5685459e970c2c2caa02

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_radar-0.3.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.3.0-py3-none-any.whl.

File metadata

  • Download URL: llm_radar-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 28.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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0b031756be98cb3091bc0315db801b8560b1541383d998a4f61eb2d710eab5b
MD5 37f5256b2397120471376838d30dbfab
BLAKE2b-256 47e9abbc1a52f3cfadf092241c69bdeebc46345764169f4dbd619e19796b98a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_radar-0.3.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