Lightweight LLM call logger for OpenAI/Anthropic
Project description
LLM Debugger
LLM Debugger is a lightweight, local-first tool for inspecting and understanding how your application interacts with large language models like OpenAI GPT-4 or Anthropic Claude.
It helps you:
- Log and inspect each model call with request/response metadata
- View differences between turns in a conversation
- Visualize tool calls, tool responses, and system prompts
- Compare prompt strategies and debug session behavior
Ideal for developers building agent workflows, chat interfaces, or prompt-based systems.
✨ Features
- ⚡ One-line setup – Start logging with a simple wrapper around your OpenAI client
- 🧠 Automatic session tracking – No manual session IDs or state management required
- 📀 Local-first logging – Stores structured logs as JSON on your machine
- 🔍 Rich session insights – Context diffs, tool call/response blocks, and system prompt visibility
- ⏱️ Latency + metadata capture – Track timing, models, and more with every call
- 🧹 Framework-agnostic – Works with any Python codebase
- 🛡️ Privacy-first – Fully offline, no account or server required
- 🌐 Simple UI – Static frontend served locally; no build step needed for end users
- 👐 Open source (MIT) – Lightweight, auditable, and easy to extend
📦 Installation
🔹 Installation Options
Option 1: From PyPI (Recommended for most users)
Install the prebuilt package if you just want to use the tool:
pip install llm_debugger
Option 2: From GitHub (Latest version)
Install directly from GitHub:
pip install git+https://github.com/akhalsa/llm_debugger.git
Option 3: Local Copy (For direct integration or customization)
Clone the repository and install:
# Clone the repo
git clone https://github.com/akhalsa/llm_debugger.git
# Install from the local copy
pip install ./llm_debugger
Note: All installation methods include pre-compiled frontend files. No Node.js or frontend build steps are required for basic usage. The static files (HTML, CSS, JS) are packaged with the library, so the debugger UI works out of the box.
🔸 Development Setup (Only for contributors)
If you want to modify the logger or UI code:
-
Prerequisites:
- Python ≥ 3.8
- Node.js & npm (only needed for UI development)
-
Setup:
git clone https://github.com/akhalsa/llm_debugger.git cd llm_debugger # Optional: Create a virtual environment python3 -m venv venv source venv/bin/activate # Install in development mode pip install -e .
-
Frontend Development (only if modifying the UI):
cd llm_logger/front_end npm install npx tsc # Compiles TypeScript to ../static
🚀 Usage
1. Wrap Your OpenAI Client
from dotenv import load_dotenv
import openai
import os
from llm_logger import wrap_openai
load_dotenv()
api_key = os.getenv("OPENAI_API_KEY")
openai_client = wrap_openai(
openai.OpenAI(api_key=api_key),
logging_account_id="my_project"
)
Then use openai_client as normal:
response = openai_client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What's the capital of France?"}
]
)
This writes logs to .llm_logger/logs/.
2. Launch the Log Viewer
Option A: Standalone Mode
Run the debugger UI as a standalone service:
# Default port (8000)
llm_logger
# Or specify a custom port
llm_logger -p 8000
Then open in your browser:
http://localhost:8000/static/index.html
Option B: Alongside Your Application
You can run the debugger UI alongside your application in the same process or in a separate process:
Same Process (using FastAPI):
from fastapi import FastAPI
import uvicorn
from llm_logger.server import app as debugger_app
# Your main application
app = FastAPI()
# Mount the debugger UI at /debugger
app.mount("/debugger", debugger_app)
# Run your application
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=5000)
Separate Process (e.g., in Docker):
# Start your main application
uvicorn your_app:app --host 0.0.0.0 --port 5000 &
# Start the debugger UI on a different port
llm_logger -p 8000 &
# Wait for both processes
wait
Option C: Docker Environment
If you're using Docker, you can include the debugger UI in your Dockerfile without requiring Node.js:
FROM python:3.9-slim
WORKDIR /app
# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy your application code
COPY . .
# Expose ports for both your app and the debugger
EXPOSE 5000 8000
# Start both services
CMD ["bash", "-c", "uvicorn your_app:app --host 0.0.0.0 --port 5000 & llm_logger -p 8000 & wait"]
🛠️ Roadmap Ideas
- Replay conversation with inline visualization
- Claude and other model support
- UI analytics and filters
- Exportable reports and session sharing
- Plugin hooks and configuration options
📬 Feedback
Found a bug or have a feature request? Open an issue.
📜 License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_logger-0.1.1.tar.gz.
File metadata
- Download URL: llm_logger-0.1.1.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
072fd529651bba63b9939b45bad9eddbf164ab1afa2e7c93499499ead7530ca5
|
|
| MD5 |
fe6cfbd74adb31da02a95a39ccc106dc
|
|
| BLAKE2b-256 |
fd998545c01dd34206f8b8b4bc7516f95483b8d217ce00de4dbf5441d38e4cbb
|
File details
Details for the file llm_logger-0.1.1-py3-none-any.whl.
File metadata
- Download URL: llm_logger-0.1.1-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfaecfb2c3d4d665383160923f8b0c3589ec3e959f3478a9947002c115cabe06
|
|
| MD5 |
727b69e3c9e10ff82cbc075323cc537f
|
|
| BLAKE2b-256 |
aa3b493ec0130d8d28300614431b3c7db20c5c54f2f06ef7b38e824b74a592df
|