Back to Omniroute

Langfuse Plugin

examples/plugins/langfuse/README.md

3.8.492.7 KB
Original Source

Langfuse Plugin

Emits Langfuse generation traces for every LLM completion routed through OmniRoute.

Records prompt, response, model, provider, token usage, latency, and error details to Langfuse cloud (cloud.langfuse.com or us.cloud.langfuse.com) or a self-hosted Langfuse instance.

Install

Copy the examples/plugins/langfuse/ directory to your OmniRoute plugins path, or install directly from the marketplace UI.

Configuration

Fill these fields in the plugin config panel:

KeyRequiredDefaultNotes
publicKeyYes""Langfuse public key (pk-lf-...)
secretKeyYes""Langfuse secret key (sk-lf-...)
hostNohttps://cloud.langfuse.comAlso https://us.cloud.langfuse.com or self-hosted URL
enabledNotrueSet to false to make the plugin a no-op without uninstalling
sampleRateNo1.00.1 = trace 10% of requests
flushAtNo15Events to buffer before flushing
flushIntervalNo10000Max ms between flushes
redactBodyNofalseSet true to strip prompt + completion from traces (metadata still recorded)

Get keys at cloud.langfuse.com → Settings → API keys.

What gets traced

Each LLM completion emits one Langfuse generation observation inside a per-request trace:

  • Trace: omniroute:<model> with userId, provider, requestId metadata
  • Generation: chat.completion with:
    • model — full model ID
    • modelParameterstemperature, max_tokens, top_p
    • input — messages array (redacted if redactBody: true)
    • output — assistant message (redacted if redactBody: true)
    • usage.promptTokens, usage.completionTokens, usage.totalTokens
    • startTime, endTime — for latency

Errors emit a generation with level: "ERROR" and statusMessage.

Runtime dependency

The plugin lazy-loads the langfuse npm SDK on first request. Install it in the plugin's own directory so a broken SDK cannot crash the gateway:

bash
cd examples/plugins/langfuse
npm install langfuse

Privacy

  • Prompts and completions are sent to Langfuse cloud (or your self-host) in cleartext unless redactBody: true
  • API keys are stored in the plugin config, encrypted at rest by OmniRoute
  • Set sampleRate < 1.0 to reduce data volume
  • Set enabled: false to disable without removing configuration