Langfuse and LiteLLM proxy integration

Connect a self-hosted LiteLLM proxy to a self-hosted Langfuse so every routed model call is traced centrally, without changing each application.

On this page

How the Langfuse and LiteLLM proxy integration captures every model call

When many applications send model requests through one self-hosted LiteLLM gateway, the platform team needs token, cost and latency data in self-hosted Langfuse without editing each application. The supported method for this is the LiteLLM Proxy callback, langfuse_otel, enabled in litellm_config.yaml and configured with the Langfuse public and secret keys, LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY, plus LANGFUSE_OTEL_HOST pointing at your own Langfuse endpoint. This is a different path from the LiteLLM SDK, which runs inside application code, and from the Langfuse OpenAI SDK wrapper, which each application imports. Choose the proxy callback when the gateway is the one place every call already passes through, and confirm the exact callback and variable names against the Langfuse LiteLLM Proxy integration docs for the versions you run.

Per Langfuse, the proxy integration captures token usage, cost and latency for every LLM call routed through the proxy, across the providers LiteLLM fronts. That gives the platform team a central view of spend and performance by model and provider. It does not replace application-level context. The gateway sees model requests, not which end user, customer, tenant or conversation produced them, so user and session attributes still have to be supplied by the calling application, for example through metadata fields that LiteLLM forwards, and you should test that they arrive in traces before relying on them for chargeback or investigation.

Several responsibilities stay with your team. You own the Langfuse deployment, its PostgreSQL, ClickHouse, Redis or Valkey and blob storage, and the network path from the LiteLLM proxy to the Langfuse host, including TLS and firewall rules. You own key issuance and rotation, keeping the LiteLLM master key in a secret manager, and deciding what prompt and completion content may be stored in traces, since that content can contain personal data. Before go-live, confirm with your LiteLLM and Langfuse versions that the callback is supported, run test calls through each model route, and check that cost figures match the pricing your organization expects for models you host or price yourself.

What you need before connecting LiteLLM to Langfuse

The integration touches three systems: the self-hosted Langfuse instance that receives traces, the LiteLLM proxy that emits them, and the network and certificates between them. Confirm each piece before changing any proxy configuration, because most failed connections trace back to a version mismatch, a blocked route or an untrusted certificate.

Current Langfuse v4 instance

Run a self-hosted Langfuse on the v4 line and check the newest release on the Langfuse releases page before you start, since the page listed v4.63.0 as published October 16, 2026. If you also send traces from Python or JS/TS SDKs, the SDK floor is v4.59.0 or later, so confirm your Langfuse version meets it. A v3 instance needs its own upgrade plan first, because the v3 to v4 guide requires ClickHouse 25.12 or later, PostgreSQL 15 or later and Redis 7.0 or later.

Langfuse releases

Supported LiteLLM proxy version

Pin the LiteLLM proxy to a release inside the vendor's supported window, which covers the four most recent stable minor versions for open source and Enterprise deployments. Check the BerriAI releases page for the current tag before you choose one, and record the chosen version in your change record. The langfuse_otel callback is configured in litellm_config.yaml, so every proxy replica in your fleet should run the same version.

LiteLLM releases

PostgreSQL for the proxy

Provision PostgreSQL as the proxy's database. It is the primary supported database for LiteLLM, and virtual keys, budgets and spend tracking depend on it. Keep this database separate from the Langfuse PostgreSQL instance so that a restore or upgrade in one does not affect the other. Ask your database team who owns backups and point-in-time recovery for it.

Redis 7.0 or newer for scale

A single proxy instance can run without Redis, but once more than one proxy instance runs, LiteLLM needs Redis 7.0 or newer for shared rate limits, router state and cache. Decide early whether your rollout will be multi-instance, because adding Redis after the fact means changing the deployment and retesting rate limits. Confirm the Redis version your platform team supports and that replicas can reach it.

Langfuse project keys and secrets

Create a Langfuse project for proxy traces and generate its public and secret keys. These map to LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY on the proxy. Store both in your secret manager and not in litellm_config.yaml, and also keep LITELLM_MASTER_KEY in that manager, since it must start with sk-. Decide who may rotate the keys and how the change is recorded.

Network path and TLS trust

Confirm the proxy can reach the Langfuse OTEL endpoint at /api/public/otel over the network path you intend to use, and set LANGFUSE_OTEL_HOST to your own instance rather than a public host. If Langfuse sits behind an internal certificate authority, the proxy's container or host must trust that CA chain, or the export will fail on certificate validation. Test the path with a simple request from the proxy host before enabling the callback.

Langfuse LiteLLM docs

Configure the LiteLLM proxy to send traces to Langfuse

This sequence connects a running LiteLLM proxy to your self-hosted Langfuse so that every request routed through the gateway produces a trace with model, token usage, cost and latency. Each step ends with a check you can run before moving on.

  1. Create a Langfuse project and API keys

    In the self-hosted Langfuse UI, an administrator creates a project dedicated to the LiteLLM gateway and generates a public and secret key pair for it. Keeping the gateway in its own project makes its traces easy to find and lets you scope access later. Done means the key pair is visible once in the project settings and copied into your password manager or secret manager, because the secret key is not shown again after you leave the page.

  2. Store the Langfuse settings in the proxy secret store

    The platform team adds LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY and LANGFUSE_OTEL_HOST to the secret store that feeds the proxy, such as your Kubernetes secret, Vault or cloud secret manager, and never to the litellm_config.yaml file or source control. LANGFUSE_OTEL_HOST points at your own Langfuse address so that traces stay inside your infrastructure. Done means the variables resolve inside the running proxy container, which you can confirm by checking the environment of the pod or process without printing the secret value.

  3. Enable the langfuse_otel callback

    The gateway owner adds the langfuse_otel callback to the litellm_config.yaml file under the callbacks setting, so the proxy exports each LLM call it handles. This change is a configuration edit and does not touch the applications that call the gateway. Done means the file validates against your review process and the callback name appears exactly as the Langfuse documentation spells it, with the change committed to your configuration repository.

  4. Restart or roll the proxy

    The operator restarts the proxy process or performs a rolling update of its deployment so the new environment variables and callback configuration load. In a multi-instance setup, roll the instances one at a time so requests keep flowing through the healthy ones. Done means every proxy instance reports healthy after the restart and the startup logs show no error about the Langfuse callback or its credentials.

  5. Send a test request through a virtual key

    A tester sends one chat completion request through the proxy using a virtual key created for testing, with a model you have already approved for the gateway. Using a virtual key instead of the master key confirms that the path your applications use is covered. Done means the request returns a normal model response and the proxy logs show the call completed without an error from the callback.

  6. Confirm the trace in Langfuse

    The tester opens the Langfuse project and finds the trace created by the test request, then checks that it records the model name, input and output token counts, the calculated cost and the request latency. If cost is missing, confirm that the model has a price entry in Langfuse, since cost is derived from token usage and model pricing. Done means all four fields appear on the trace and match what the provider returned for that call.

  7. Repeat the check for each model and team

    Before you rely on the gateway for central tracing, the team sends one test request per model family and per team virtual key that will carry production traffic. This shows whether any provider, model alias or key produces incomplete traces, such as missing usage data. Done means every route you intend to use appears in Langfuse with the expected fields, and any gaps are logged as open issues against the specific model or key.

How a request flows from application to Langfuse through the gateway

The request starts at an application that calls the LiteLLM proxy with its own virtual key, not a Langfuse key. The proxy forwards the call to a model provider and, through the langfuse_otel callback, exports trace data over OTLP to your self-hosted Langfuse Web endpoint. Only the proxy holds the Langfuse credentials, and everything stays inside the customer network boundary except the model provider call. Check that the application environment contains no Langfuse keys and that the export host resolves to your own deployment.

Only the proxy holds Langfuse credentials and exports traces to your own host.

Which LiteLLM request fields appear in Langfuse traces

This table maps the data a LiteLLM proxy handles for each request to the Langfuse trace, observation and user or session fields it may populate. Read the Source column first: fields marked as client-dependent only appear when applications send metadata, and fields marked to confirm should be checked against the Langfuse LiteLLM integration page and a test trace in your own instance before you rely on them for chargeback or reporting.

FieldWhere it lands in LangfuseSourceConfirm before relying on it
Model nameObservation model field, used for grouping and pricingCaptured by the LiteLLM proxy for each routed callConfirm that the name matches the model price entry you expect
ProviderObservation metadata, identifying the upstream provider such as OpenAI, Anthropic or BedrockLiteLLM routes to more than 100 providersConfirm the exact attribute name in a test trace
Prompt and completion tokensObservation usage details used for token totals and costLangfuse states token usage is captured for every routed callConfirm both input and output counts appear for streaming responses
CostObservation cost, calculated from model pricingLangfuse states cost is captured through the proxyConfirm whether cost comes from LiteLLM pricing or Langfuse model definitions, and check custom or private models
LatencyObservation start and end timesLangfuse states latency is captured through the proxyConfirm how retries and failovers appear as separate or merged observations
Virtual key or team metadataTrace or observation metadata, if the proxy forwards itDepends on LiteLLM key and team configurationConfirm which key and team identifiers are forwarded and whether any are hashed or omitted
User identifierTrace user ID, which enables per-user filteringDepends on the client sending a user field or metadataConfirm the request field name the integration reads and test with a known user
Session identifierTrace session ID, which groups related callsDepends on the client sending session metadataConfirm whether the proxy passes session metadata through unchanged
Prompt and completion contentObservation input and outputCaptured as part of the routed requestConfirm content logging settings and masking before enabling broadly

Securing the gateway-to-Langfuse path

Once LiteLLM forwards every request's telemetry to Langfuse, the proxy and the trace store become one trust path. The cards below cover the credentials, content, network and access controls that decide who can see prompts, spend and user data, and which settings need an Enterprise license key.

Store master and Langfuse keys in a secret manager

The LiteLLM proxy holds LITELLM_MASTER_KEY, which must start with sk-, and the Langfuse public and secret keys used by the langfuse_otel callback. Keep all three in a secret manager your organization already audits, inject them at runtime, and rotate them on a schedule you can prove. Check that no value appears in litellm_config.yaml, container images or CI logs.

LiteLLM production guide

Scope traces to approved projects

Each Langfuse project has its own keys, so the keys LiteLLM uses determine where its traces land. Give the proxy keys for one dedicated project rather than a shared project used by other teams. Confirm which project receives gateway traffic and who holds project-level access in your Langfuse instance.

Decide what content gets captured

Prompts and completions carry personal data, source code and customer records, so decide whether the gateway logs full content, metadata only or a masked subset before go-live. Test a sample request end to end and inspect the stored trace. Where your data handling rules require it, confirm whether Enterprise server-side data masking is needed.

Limit the network path to Langfuse

Allow the proxy to reach the Langfuse host on its OTEL endpoint and nothing else on that network segment. Set LANGFUSE_OTEL_HOST to an internal address that uses TLS, and block direct egress from application workloads to the trace store. Verify the route with a test request and a failed connection from a workload that should not have access.

Set virtual key budgets and model limits

Virtual keys support per-key, per-user and per-team budgets, TPM and RPM limits, temporary budget increases and restriction to specific models. Use them so a leaked application key cannot spend without limit or reach models it was never approved for. Virtual keys need a PostgreSQL database, so include that store in your backup and access review.

LiteLLM virtual keys docs

Plan Enterprise features before rollout

SSO, SCIM, JWT authentication with identity provider tokens, audit logs and organization and team RBAC sit behind a LiteLLM Enterprise license once you exceed the free SSO limit. Langfuse also gates RBAC roles, audit logs and data masking behind its Enterprise license key. Ask both vendors for current terms and decide early which controls your audit scope requires.

Free LiteLLM SSO limit
5 users
LiteLLM Enterprise docs

Why traces are missing or incomplete after setup

This table lists the failures that most often leave LiteLLM proxy traces absent or partial in a self-hosted Langfuse, with the likely cause and the fix for each. Work through the rows in order, because a missing key or callback hides every later check. Most gaps come from configuration rather than from Langfuse itself.

SymptomLikely causeFix
No traces appear at allLANGFUSE_PUBLIC_KEY or LANGFUSE_SECRET_KEY is missing, mistyped, or belongs to a different project than the one you are viewingSet both variables on the proxy container, confirm the keys were created in the target project, and restart the proxy so it reads them
No traces appear and the proxy logs show connection errorsLANGFUSE_OTEL_HOST points at the wrong base URL, or at an address the proxy container cannot reachSet the host to the base URL of your Langfuse web service, then test reachability from inside the proxy container, not from your workstation
Traces arrive but with errors about a path or endpointLANGFUSE_OTEL_HOST includes a path such as the OTEL endpoint, so the path is appended twiceUse the base URL only and let the integration append the OpenTelemetry path, as Langfuse's LiteLLM documentation describes
No traces appear and the config file looks correctThe langfuse_otel callback is not listed under the litellm_settings callbacks in litellm_config.yaml, or the config file mounted is not the one the proxy loadsEnable the langfuse_otel callback in the mounted config file, confirm the path passed to the proxy at startup, and check the startup log for the callback
Proxy fails to send to a Langfuse on an internal certificate authorityThe proxy container does not trust the private CA that signed the Langfuse certificate, so TLS handshakes failAdd your internal CA certificate to the proxy image or mount it into the trust store, then confirm the handshake succeeds before blaming the keys
Virtual key creation or key-based requests fail, and no per-key traces are recordedThe proxy runs without PostgreSQL, which virtual keys require, so key-level identity is not storedAttach a PostgreSQL database to the proxy, run its migrations, and confirm virtual keys work before validating traces
Traces appear, but without user or session attributesThe calling applications do not send user or session identifiers through the proxy request, so the proxy has nothing to attachPass the user and session identifiers in the request metadata from each application, then confirm they show on a test trace
Some requests are logged and others are notRequests are reaching a different proxy instance or model route that does not load the callback, or applications bypass the proxy and call providers directlyConfirm every replica loads the same config, and check that applications point their base URL at the proxy rather than at a provider
Cost or token fields are empty for some modelsThe model is not priced in Langfuse, or the provider response did not include usage dataCheck the model name against Langfuse's model pricing, add a custom price for private models, and test one request per model

Running the integration as the proxy scales

Once more than one LiteLLM proxy replica serves traffic, shared state needs a Redis 7.0 or newer instance. LiteLLM's production guide ties Redis to shared rate limits, router state and cache, and PostgreSQL remains the primary supported database, which virtual keys and budgets require. Without shared Redis, replicas can disagree about how much a key or team has spent or how many requests it has sent, so the Langfuse callback will still fire, but the budget and limit decisions behind those traces will not be consistent. On Kubernetes, LiteLLM recommends one Uvicorn worker per pod and scaling horizontally by adding pods, so size the pod count and the per-pod CPU and memory (the guide suggests 1 vCPU and 4 GiB per worker as a starting point) against your measured request rate rather than running several workers inside one container.

Tracing load grows with the same traffic. Every request routed through the proxy becomes Langfuse ingestion work, which the Langfuse Worker processes asynchronously. Langfuse recommends scaling worker containers on CPU load and, under heavy ingestion, splitting langfuse-web into separate ingestion and user interface deployments. Ask your platform team to watch worker CPU, queue backlog and ClickHouse write behavior during a load test that matches your peak traffic, and confirm the sizing with the Langfuse scaling guide for your Langfuse version before production. Plan the ClickHouse and PostgreSQL capacity from that test as well, since the Langfuse data stores take the sustained write load.

Spend data arrives on a different clock from traces. LiteLLM batches spend updates to the database every 60 seconds at scale, so the budget totals, spend counters and key-level usage you see in the LiteLLM database can lag the requests by up to that interval. Langfuse traces for the same calls are sent through the OTEL callback and typically appear sooner, so a dashboard built on one source can disagree briefly with the other. Document this in your runbook, tell finance and FinOps teams which source is authoritative for chargeback, and confirm with your LiteLLM version how the batching interval is configured before you rely on it for reporting.

Questions teams ask before connecting LiteLLM to Langfuse

What drives the cost of connecting LiteLLM to a self-hosted Langfuse?

The cost follows the number of moving parts you need to wire together, more than any single product line. The main drivers are how many LiteLLM proxy instances run, how many applications and teams send traffic through them, how credentials and the master key are stored and rotated, and how much Langfuse infrastructure you must size for the expected trace volume. Langfuse itself is MIT licensed for core features, so software licensing is not the main line item. Your costs are infrastructure (PostgreSQL, ClickHouse, Redis or Valkey and blob storage), the engineering time to configure the callback and secrets, and any retainer for ongoing upgrades. Ask any partner for a quote that separates one-time setup from recurring operations and lists each proxy, application and environment in scope.

How long does a LiteLLM to Langfuse integration take?

The duration depends mainly on how ready your existing infrastructure is, not on the callback configuration itself, which is a small change in the proxy settings. If a self-hosted Langfuse is already running with its data stores sized and backed up, and the LiteLLM proxy already has a PostgreSQL database and a secret manager, the remaining work is mostly configuration, testing and rollout. If Langfuse still needs to be deployed, or the proxy runs without shared state, the timeline grows accordingly. Confirm the status of each prerequisite with your team before asking for a schedule, and agree the timeline in writing as part of a fixed scope.

What must our team provide before the work starts?

Plan for access, network paths, credentials and named owners before any configuration begins. Specifically, you need:

  • Administrative access to the LiteLLM proxy deployment and its configuration file, plus the environment where it runs
  • A reachable self-hosted Langfuse endpoint from the proxy network, with its project public and secret keys issued to you
  • Network rules that allow the proxy to reach the Langfuse OTEL endpoint and, if used, the model providers
  • An owner for the LITELLM_MASTER_KEY and Langfuse keys in your secret manager
  • A named contact for security approvals and a named owner for the Langfuse instance after go-live

Missing owners are the most common reason integrations stall, so settle them early.

Can our internal platform team do this integration without a partner?

Yes, many platform teams can complete the callback setup themselves, because the change is documented by Langfuse and LiteLLM and involves setting the Langfuse credentials, pointing the OTEL host at your endpoint and enabling the langfuse_otel callback in the configuration file. The harder parts are usually around the surrounding system: keeping keys out of configuration files, confirming that traces contain the fields you need, sizing ClickHouse for the added volume, and testing failover when more than one proxy instance runs. If your team already runs PostgreSQL, Redis and Kubernetes well, the internal path is realistic for a single proxy. Choose a partner when the scope spans several proxies, regulated evidence requirements or a tight deadline.

What breaks most often when LiteLLM sends traces to Langfuse?

The most common issues are configuration mismatches rather than product defects. Check that the Langfuse host is reachable from every proxy instance, that the public and secret keys belong to the correct project, and that the OTEL host points at your self-hosted endpoint rather than a cloud address. Trace volume can also expose capacity limits in ClickHouse or the Langfuse worker, so watch ingestion lag after rollout. With more than one proxy instance, confirm that Redis 7.0 or newer is in place for shared router state, because LiteLLM's production guide calls it out for that setup. Test each model provider path, since a failing provider can look like a tracing gap.

Do we need a Langfuse Enterprise license if we add SSO or SCIM?

Yes, for SSO-related features on the Langfuse side, you need to check the license terms. Langfuse's core features and APIs are available in the MIT-licensed open source version, and the LiteLLM callback does not require an Enterprise key. Langfuse lists the org management API with SCIM as a feature that needs an Enterprise license key, and its authentication documentation covers SSO providers such as Okta, Entra ID and Keycloak. Separately, LiteLLM's admin UI SSO is free for up to 5 users from v1.76.0, and an LiteLLM Enterprise license is needed beyond that, along with SCIM. Confirm each product's current terms with the vendor before you commit, since the two licenses are independent.

How do we keep LiteLLM and Langfuse secrets safe during the integration?

Keep the LITELLM_MASTER_KEY and the Langfuse public and secret keys in a secret manager, not in plain configuration files or source control. LiteLLM's production guidance recommends the secret manager approach for the master key, and that key must start with sk-. Give each environment its own Langfuse project keys so you can rotate or revoke them independently, and restrict who can read the proxy configuration. Review what gets logged, since trace payloads can contain prompts and user data. Data masking on the Langfuse side is an Enterprise feature, so decide earlier whether masking must happen in the applications instead.

How DeployOpen scopes and delivers the LiteLLM and Langfuse integration

DeployOpen plans, implements, hardens, documents and supports self-hosted open-source platforms inside your own infrastructure. For this integration, we scope the LiteLLM proxy and the self-hosted Langfuse instance together, so callbacks, credentials, networking and data handling are agreed before any configuration changes are made.

How we scope

  • We inventory the LiteLLM proxy deployment, its model providers, and which applications route calls through it today.
  • We confirm the self-hosted Langfuse host, OTEL endpoint reachability and the trace data your teams are allowed to store.
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts, and a quote follows from that scope.

How we build

  • We configure the langfuse_otel callback in litellm_config.yaml and set Langfuse keys and LANGFUSE_OTEL_HOST through your secret manager.
  • We verify that token usage, cost and latency appear in Langfuse for representative models, teams and virtual keys.
  • We test failure paths, including Langfuse being unreachable, so you know whether request handling is affected before go-live.

How we hand over

  • You receive the written configuration, a record of the keys and secrets used, and the network paths the integration depends on.
  • We document how to add a model, rotate Langfuse keys and confirm that new proxy deployments keep sending traces.
  • Findings from testing are delivered with the fixes applied and a retest record, so your security team can review the setup.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers for both the LiteLLM proxy and Langfuse.
  • We can plan LiteLLM and Langfuse version changes, including checking release notes and SDK compatibility before upgrades.
  • Retainer scope, response expectations and any service levels are confirmed in writing, so you know what is covered before you sign.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.