OpenClaw Inspector: LLM API Traffic Monitor
Real-time API traffic inspector for OpenClaw agents—monitor LLM token usage, costs, and API requests live with a web dashboard.
Originally published:
Real-Time API Traffic Inspection for LLM Agents
OpenClaw Inspector is a transparent proxy and debugging tool that sits between OpenClaw and LLM providers, capturing every API request and response in real time. It solves a critical visibility problem: when building with LLM agents, you're often blind to token consumption, API costs, and the exact data flowing to external providers. This tool changes that by exposing token usage, cost breakdowns, message flow, and system prompts through a live web dashboard.
Built as a zero-dependency standalone reverse proxy, OpenClaw Inspector works with any LLM provider—Anthropic, OpenAI, BytePlus, Ollama, Groq, Mistral, xAI, Google, OpenRouter, and DeepSeek—without requiring modifications to OpenClaw's internal code. It automatically patches your OpenClaw configuration to route traffic through its local proxy, then restores the original configuration when disabled, with built-in safeguards against misconfiguration.
Key Features
- One-Click Interception — Automatically patches
openclaw.jsonto route API traffic through the inspector proxy; no manual configuration required - Universal Provider Support — Works with Anthropic, OpenAI, BytePlus, Ollama, Groq, Mistral, xAI, Google, OpenRouter, DeepSeek, and custom providers
- Real-Time Web Dashboard — WebSocket-powered live view of every request, response, token count, and estimated cost
- Accurate Token Tracking — Extracts token counts from response headers and streaming (SSE) events with precise accounting
- Cost Breakdown — Per-request and aggregate cost estimation based on built-in pricing for 50+ models, with custom pricing overrides
- Message Inspector — Collapsible view of system prompts, tool definitions, thinking blocks, and full conversation history
- Persistent History — Daily usage statistics saved to disk; survives restarts and provides historical cost tracking
- CLI Tools — Access stats, history, pricing, provider list, and status from the command line with JSON export for scripting
- Autostart Support — Install as a system service (launchd on macOS, systemd on Linux) to run on login or boot with automatic restart on crash
Getting Started
Installation (recommended):
npx oc-inspector
Starts the inspector daemon in the background on localhost:3000 with an interactive web dashboard. The terminal remains free for other work. No installation or dependencies required.
Enable Interception: Click the "Enable" button in the web UI (or run oc-inspector enable). The inspector automatically backs up your openclaw.json, rewrites each provider's baseUrl to route through the proxy, and restarts the OpenClaw gateway.
View Traffic: The dashboard displays API requests and responses in real time as your agents run. Inspect token usage, costs, system prompts, tool calls, and thinking blocks for any request.
Disable When Done: Click "Disable" (or run oc-inspector disable) to restore the original configuration and remove the proxy route.
Use Cases
- Token Leak Detection — Identify which conversations, models, or providers consume unexpected tokens and unnecessary costs
- Agent Behavior Debugging — Inspect actual API requests, responses, and tool calls to understand agent decision-making
- Cost Tracking & Optimization — View daily cost breakdowns by model and provider; find opportunities to reduce spending
- System Prompt Inspection — See exactly what OpenClaw sends to each provider, including tool definitions and context
- Compliance & Audit — Maintain persistent history of all API traffic for compliance, cost allocation, or performance analysis
Who It's For
AI/ML Engineers & Agents Developers: Anyone building with OpenClaw who needs visibility into LLM API traffic, token consumption, and costs in production or development environments.
DevOps & Platform Teams: Teams managing shared OpenClaw deployments across multiple agents or applications who need cost allocation and usage monitoring.
Product Managers & Business Stakeholders: Non-technical users can view the dashboard to understand API spending trends, cost drivers, and ROI of LLM-powered features.
Configuration & Customization
OpenClaw Inspector ships with built-in pricing for 50+ popular models across major providers. You can override or extend pricing by editing ~/.openclaw/.inspector.json:
{
"pricing": {
"my-custom-model": {
"input": 0.003,
"output": 0.015,
"cacheRead": 0.0003
}
}
}
Prices are specified in USD per 1 million tokens. Custom pricing overrides built-in values, allowing you to model internal pricing, discounted rates, or non-standard models.
CLI Commands
Beyond the web dashboard, OpenClaw Inspector provides command-line tools for automation and scripting:
oc-inspector start— Start as a background daemon (default)oc-inspector stop— Stop the running daemonoc-inspector enable/disable— Toggle interception without restartingoc-inspector stats— View live token and cost statistics (supports--jsonflag)oc-inspector history --days 30— Show usage history over the past N daysoc-inspector pricing— Display model pricing table (built-in + custom overrides)oc-inspector install— Set up autostart on login/boot
How It Works
OpenClaw Inspector operates as a standalone reverse proxy with no dependencies on OpenClaw internals. When enabled, it rewrites provider baseUrls in openclaw.json to route all API traffic through its local proxy on port 3000 (default). The proxy intercepts requests and responses, extracts token counts from headers and streaming events, calculates costs using configurable pricing tables, and logs everything to a persistent database. The web dashboard connects via WebSocket for real-time updates, while CLI tools provide programmatic access to stats, history, and configuration. When disabled, the original openclaw.json is restored and the gateway is restarted, returning traffic to direct provider endpoints.
Resources
- GitHub Repository: kshidenko/openclaw-inspector
- Documentation: See
README.mdandAGENTS.mdin the repository for detailed setup and examples - License: MIT — free for personal and commercial use
Source: GitHub repository (kshidenko/openclaw-inspector), last updated February 2026.
Original Source
https://github.com/kshidenko/openclaw-inspector
Last updated: