Using Langfuse
Langfuse provides observability and analytics for LLM applications. Since OpenRouter uses the OpenAI API schema, you can use Langfuse’s native integration with the OpenAI SDK to automatically trace and monitor your OpenRouter API calls.Installation
Configuration
Set up your environment variables: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:Output
Advanced Tracing with Nested Calls
Use the@observe() decorator to capture execution details of functions with nested LLM calls:
Output
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