Skip to main content
Looking to auto-instrument without client code? Check out OpenRouter Broadcast to automatically send traces to Langfuse.

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

The Python example uses @observe() to capture a parent trace and its LLM calls. The TypeScript, Go, and cURL tabs show the same two requests without Langfuse instrumentation.
Output

Learn More