Spanlens is an open-source (MIT) LLM observability platform designed to provide comprehensive monitoring for applications utilizing OpenAI, Anthropic, and Gemini APIs. It simplifies the process of tracking every LLM call, offering insights into cost, latency, and token usage, making it an essential tool for developers and teams building and deploying AI-powered applications.
Key Features
- One-Line Integration: Observe every LLM call with minimal setup, acting as a drop-in replacement for provider SDKs.
- Cost Tracking & Optimization: Detailed per-request breakdown, daily rollups, budget alerts, and AI-driven model recommendations with dollar-figure savings.
- Agent Tracing: Visualize multi-step agent workflows as waterfall span trees, highlighting critical paths, cost attribution, and latency outliers.
- Anomaly Detection: Automatically flag significant deviations (3σ) in latency or cost against a 7-day baseline.
- PII & Injection Scanning: Regex detection for sensitive data (SSN, email) and potential injections, with auto-masking of API keys before storage.
- Evals & Experiments: LLM-as-judge scoring (0-1) for response quality and the ability to replay datasets across prompt versions and models for comparative analysis of quality, cost, and latency.
Use Cases
Spanlens is ideal for engineering teams and developers who need deep visibility into their LLM operations. It helps in proactively managing and optimizing the financial aspects of LLM usage by providing granular cost breakdowns and suggesting more efficient models, preventing unexpected bill spikes. For complex AI agents, its tracing capabilities allow for quick identification of performance bottlenecks and errors within multi-step workflows, significantly reducing debugging time.
Furthermore, Spanlens enhances application quality and security. Developers can use its Evals and Experiments features to rigorously test and compare different prompt versions and models, ensuring that new deployments are both cost-effective and deliver superior results. The built-in PII and injection scanning features provide a crucial layer of security, helping to protect sensitive user data and prevent malicious prompts from impacting the application.
Pricing Information
Spanlens operates on a freemium model. A free tier is available, supporting up to 50,000 requests per month with 14-day data retention and all core features. Self-hosting the platform is free forever, offering unlimited usage and data retention. Paid plans (Pro, Team, Enterprise) offer increased request limits, longer data retention, more seats, and advanced support options.
User Experience and Support
The platform emphasizes ease of use with a "one-line" integration approach, ensuring minimal overhead (p99 under 3ms) as ingestion happens asynchronously and never sits on the critical path. The user interface provides a unified view of all LLM activities, allowing users to move seamlessly from high-level cost charts to specific request details. Comprehensive documentation and community support are available, with higher tiers offering email and dedicated support.
Technical Details
Spanlens offers SDKs for TypeScript and Python, integrating seamlessly with popular frameworks like Next.js, Node, and Edge environments. It supports major LLM providers including OpenAI, Anthropic, Google (Gemini, Vertex), and Mistral, as well as Ollama for local LLMs. For self-hosting, it can be deployed via Docker Compose or a single binary, ensuring data privacy by keeping prompts and completions within your network. It also supports OpenTelemetry (OTLP/HTTP) for existing tracing infrastructures.
Pros and Cons
- Pros:
- Open-source (MIT) and self-hostable for data privacy and control.
- Minimal latency overhead (<3ms p99) due to async ingestion.
- Comprehensive features: cost tracking, agent tracing, PII scanning, evals, experiments, user analytics.
- Supports all major LLM providers and local LLMs (Ollama).
- Strong team collaboration features (projects, roles, audit logs).
- Cons:
- Advanced features like Evals and Experiments might require a learning curve to fully leverage.
- Self-hosting requires some technical setup (Docker/binary deployment).
- Free tier has retention and request limits (though generous for small projects).
Conclusion
Spanlens provides an indispensable, open-source solution for anyone looking to gain deep observability, optimize costs, enhance security, and improve the quality of their LLM-powered applications. Its robust feature set and flexible deployment options make it a powerful tool for both individual developers and large teams. Explore Spanlens today to transform how you monitor and manage your LLM interactions.