Skip to content

Langfuse

OpenGateLLM supports Langfuse for LLM observability: as soon as this dependency is configured, every model-forward request is traced in Langfuse, failures included.

Langfuse comes in addition to the PostgreSQL usage table, never instead of it. PostgreSQL keeps recording the consumption of successful requests and still serves GET /v1/usage (and the Playground Usage page).

Each model-forward request (chat completions, embeddings, OCR, rerank, audio transcriptions) becomes a Langfuse generation observation:

Field Content
Name Endpoint slug, for example chat-completions or embeddings
Model Router name
User Authenticated numeric user ID
Metadata Full endpoint path, router ID and name, user email, key ID and name, provider ID and model name, HTTP status
Usage Prompt tokens, completion tokens, cached prompt tokens
Cost Request cost
Time to first token Set on streaming chat as completion_start_time
Errors Failed inferences are marked ERROR with the domain error name

Prompts and completions are not sent to Langfuse.

A stream that fails after answering 200 (the provider breaks mid-stream) is marked ERROR in Langfuse, while its PostgreSQL usage row keeps status 200 and the tokens already delivered: the client received them, so they are billed.

Langfuse PostgreSQL usage table
Requests recorded All model-forward requests, failures included Successful requests only
Purpose Observability: what happened to each request Consumption: tokens, cost and environmental impacts
Serves GET /v1/usage No Yes

At startup, OpenGateLLM authenticates against the Langfuse server. If authentication fails, a warning is logged and requests are still served; a trace that cannot be sent is logged and never fails the request.

Add Langfuse to the dependencies section of your config.yml file. Check the Langfuse section in the configuration file documentation for more details.

Example:

dependencies:
[...]
langfuse:
public_key: ${LANGFUSE_PUBLIC_KEY}
secret_key: ${LANGFUSE_SECRET_KEY}
base_url: http://localhost:3000

Create the API keys in your Langfuse project settings. base_url should point at your self-hosted Langfuse instance or at Langfuse Cloud.

Extra attributes are forwarded to the Langfuse Python SDK.

Configuration file documentation Inference monitoring