Langfuse
Using OpenRouter with Langfuse
Using Langfuse
Langfuse provides observability and analytics for LLM applications. Since OpenRouter uses the OpenAI API schema, you can utilize Langfuse’s native integration with the OpenAI SDK to automatically trace and monitor your OpenRouter API calls.
Installation
Configuration
Set up your environment variables:
Environment Setup
Simple LLM Call
Since OpenRouter provides an OpenAI-compatible API, you can use the Langfuse OpenAI SDK wrapper to automatically log OpenRouter calls as generations in Langfuse:
Basic Integration
Advanced Tracing with Nested Calls
Use the @observe()
decorator to capture execution details of functions with nested LLM calls:
Nested Function Tracing
Learn More
- Langfuse OpenRouter Integration: https://langfuse.com/docs/integrations/other/openrouter
- OpenRouter Quick Start Guide: https://openrouter.ai/docs/quickstart
- Langfuse
@observe()
Decorator: https://langfuse.com/docs/sdk/python/decorators