LiteLLM with Langfuse for traces and prompt logs

Connect a self-hosted LiteLLM gateway to Langfuse for traces and prompt logs, choosing the langfuse_otel preset or the SDK callback and attaching metadata that makes traces useful.

On this page

How LiteLLM sends traces and prompt logs to Langfuse

A platform team running a self-hosted LiteLLM gateway usually needs one place where it can see each request's trace, the prompt and response content (if the team chooses to store it), latency, token usage and cost, grouped by key, team and model. LiteLLM can send this data to Langfuse in two ways: through the langfuse_otel preset, which uses OpenTelemetry v2, or through the langfuse SDK callback. LiteLLM's Langfuse documentation recommends the langfuse_otel preset for Langfuse v3 and v4. The SDK callback requires Langfuse Python SDK v4 (langfuse>=4.7,<5) and exports through LiteLLM's OpenTelemetry pipeline, so the Langfuse version and the Python dependency set on the gateway should be confirmed before choosing it.

Langfuse stores the traces, observations, prompts and evaluation data, and it is the system the team's engineers and reviewers query. The gateway contributes what Langfuse cannot see on its own: which virtual key and team made the call, which model and provider route served it, retries and fallbacks, and the cost computed from LiteLLM's pricing data. Those fields only appear in Langfuse if the gateway attaches them as metadata, so the team should decide early which keys, team names and tags to pass and which content to omit. Both export paths rely on the same LiteLLM settings for keys and endpoints, so the decision is mainly about version alignment and where the data is allowed to go. The method described here comes from LiteLLM's Langfuse integration documentation, which should be checked against the release in use before rollout.

What you need before connecting LiteLLM to Langfuse

The Langfuse connection depends on versions and infrastructure on both sides: the LiteLLM proxy line, its database and cache, and a Langfuse deployment with its own data stores. Work through these cards before choosing between the OpenTelemetry preset and the SDK callback, because each path depends on the same foundations.

LiteLLM version line

Pick a release from the four most recent stable minor versions that LiteLLM supports for both open source and Enterprise deployments. The current release shown in the supplied facts is v1.105.1, published October 14, 2026, but versions move quickly. Confirm the latest stable minor on the releases page before you pin the image, and record the tag you deploy so the Langfuse integration can be tested against the same build.

LiteLLM releases

PostgreSQL for the proxy

Virtual keys, budgets and spend records require PostgreSQL, which LiteLLM names as its primary supported database. Confirm that the proxy database is reachable from every gateway pod and that its backups cover spend history, since Langfuse traces will not replace the gateway's own accounting. Size the instance for the number of keys and log writes you expect, and plan connection limits before scaling out.

Redis for multi-instance proxies

Once more than one proxy instance runs, LiteLLM requires Redis 7.0 or newer for shared rate limits, router state and cache. A single-instance test can skip it, but a production gateway with horizontal scaling cannot. Confirm the Redis version, its persistence settings and its network path from each proxy pod, because a stale or unreachable cache changes rate limit and routing behavior across the fleet.

Langfuse deployment and host

Decide whether Langfuse runs self-hosted in your infrastructure or on Langfuse Cloud, and record the host that the gateway will call. A self-hosted instance needs a public or internal hostname that the LiteLLM pods can resolve and reach over TLS. Langfuse v4 needs ClickHouse 25.12 or later (26.4 recommended), PostgreSQL 15 or later and Redis 7.0 or later, so check these against your Langfuse stack before connecting anything.

Langfuse self-hosting

Langfuse project API keys

Create a Langfuse project for the gateway and generate its public and secret API keys there, scoped to that project only. Store both values in your secret manager and inject them into the LiteLLM deployment, never in the config file committed to version control. Separate projects for development and production keep test traces out of production dashboards and make key rotation contained to one environment.

SDK pin for the callback path

If you use the langfuse SDK callback instead of the langfuse_otel preset, pin the Python SDK to langfuse>=4.7,<5 in the LiteLLM image. The callback requires Langfuse Python SDK v4 and exports through LiteLLM's OpenTelemetry pipeline. Record the pinned version in your build manifest and rerun a test request after every LiteLLM upgrade, since the callback and SDK must stay compatible.

Egress from gateway to Langfuse

Confirm that the gateway's network policy allows outbound HTTPS from the LiteLLM pods to the Langfuse host, and that any egress proxy, DNS rule or firewall lets the request through. Blocked egress usually shows up as missing traces rather than an obvious error, so test with one request before rollout. If prompts contain personal data, agree with your security team which fields leave the boundary before enabling the integration.

langfuse_otel preset or the SDK callback: which to choose

LiteLLM offers two ways to send proxy traffic to Langfuse. The langfuse_otel preset sends traces through OpenTelemetry v2, and LiteLLM recommends it for Langfuse v3 and v4. The langfuse SDK callback uses the Langfuse Python SDK, requires SDK v4 (langfuse>=4.7,<5), and still exports through LiteLLM's OpenTelemetry pipeline. Both paths produce traces for the same gateway, so the decision mainly affects dependencies, upgrade work and how much control your engineers have over the Langfuse client.

  • Preset path: the starting point LiteLLM recommends for Langfuse v3 and v4 deployments.
  • Callback path: adds the Langfuse SDK to the proxy image and pins it to a version range.
  • Shared pipeline: both routes use LiteLLM's OpenTelemetry export, so the overall trace structure is similar.
  • Decision inputs: your Langfuse server version, how often you upgrade client libraries and who owns the proxy image.

Before reading further, confirm which Langfuse server version you run, because that narrows the choice.

Configuration sequence for the Langfuse integration

This sequence takes LiteLLM from an unconnected proxy to a verified Langfuse trace in the correct project, with credentials kept out of the configuration file. Each step ends with a check so the team knows it can move on.

  1. Confirm Langfuse reachability and version

    Confirm that the LiteLLM proxy host can reach the Langfuse endpoint over the network path you have approved, whether that is a self-hosted instance in your infrastructure or Langfuse Cloud. Confirm the Langfuse version against the integration path you plan to use: the langfuse_otel preset is the recommended route for Langfuse v3 and v4, while the SDK callback requires Langfuse Python SDK v4 (langfuse>=4.7,<5). Check the LiteLLM release you run against the LiteLLM Langfuse documentation. Done when a request from the proxy host to the Langfuse health endpoint succeeds and the version pair is written down.

  2. Create project keys in the target Langfuse project

    A Langfuse administrator creates a public and secret key pair inside the Langfuse project that should receive LiteLLM traces. Use one project per environment or per governed team so that traces from different workloads do not mix. Record which project the keys belong to, since the keys define where traces land. Done when the key pair exists in the intended project and nowhere else, and the owner of the project is named in the change record.

  3. Store the keys in the secret manager

    Place the Langfuse public and secret keys in your secret manager, such as the one that already holds LITELLM_MASTER_KEY, and inject them into the proxy as environment variables at runtime. Do not write the keys into the proxy configuration file or commit them to version control. Restrict read access to the proxy's service identity. Done when the proxy container or pod starts with the variables present, and a search of the config repository for the key strings returns nothing.

  4. Choose the preset or the SDK callback

    Decide between the langfuse_otel preset and the langfuse SDK callback before editing the configuration. LiteLLM recommends the OpenTelemetry preset for Langfuse v3 and v4, and the SDK callback exports through the same OpenTelemetry pipeline but depends on the Langfuse Python SDK pin. Record the choice, the Langfuse version it targets and the LiteLLM release, because changing it later alters how trace fields are mapped. Done when the decision is written in the change record with the reason, and the team has confirmed the selected path against the current LiteLLM documentation for its release.

  5. Set the callback in the proxy configuration

    Add the chosen Langfuse callback to the LiteLLM proxy configuration, referencing the injected environment variables for the host and keys rather than literal values. Set the callback at the level your design requires, and confirm the configuration key names against the release you run. Apply the change through your normal configuration-as-code process and restart or roll the proxy. Done when the proxy starts without configuration errors and its logs show the Langfuse callback initialized.

  6. Send a test request through a virtual key

    Create a dedicated test virtual key restricted to one approved model, then send a short request through the proxy using that key. Attach metadata such as a team name, environment and a request identifier so the trace can be found later. Using a virtual key rather than the master key ensures the trace carries the key and team attribution you will rely on in production. Done when the request returns a successful response to the caller.

  7. Confirm the trace in the correct project

    Open the Langfuse project that owns the keys and locate the trace by the request identifier you attached. Check that the trace shows the expected model, the latency, the input and output token counts, and the metadata you sent. Confirm it does not appear in any other project. If the trace is missing, check the proxy logs for export errors and the key pair before changing the configuration. Done when the trace is visible in the correct project with all expected fields populated.

How a request becomes a Langfuse trace

The request starts at a client that calls the LiteLLM proxy with a virtual key. The LiteLLM router picks a deployment and forwards the call to the model provider. On the way out, LiteLLM exports trace data either through its OpenTelemetry pipeline (the langfuse_otel preset) or through the Langfuse SDK callback. Check which path your version uses, and confirm that Langfuse Web and Langfuse Worker, with their stores, sit inside the boundary you intend to cross.

Request path from client to model provider and into self-hosted Langfuse storage.

Which metadata to attach so traces answer real questions

Attach metadata that answers the questions someone will ask later: which team sent the call, which person or service account made it, which key was used, which model group served it, and which environment it ran in. Use stable, named values for these fields, such as a team slug, a key alias from your key register, and a fixed environment name like prod or staging. Free text such as a developer's name typed into a request tag makes filters inconsistent, so the same team appears under three spellings and cost or access reviews miss records. Session identifiers are useful for following a multi-turn conversation, but generate them with a consistent format and avoid putting user names or email addresses into them.

Metadata also decides who can see what. Traces in Langfuse carry the fields you send with them, and anyone with access to a project can read them. A user identifier or a free-text tag can expose personal data to people who only needed the latency view. Review the metadata list together with the prompt-logging decision, and confirm which roles in your Langfuse project can read traces. Project-level RBAC and data masking are listed as Enterprise license features in the Langfuse self-hosting documentation, so confirm your edition before relying on them. Check the current field names for your LiteLLM version in the LiteLLM Langfuse documentation.

After the first test call, check the trace and the generation separately. At trace level, confirm the team, environment, session identifier and tags appear once, spelled exactly as your register defines them. At generation level, confirm the model name, the model group, the provider route, input and output token counts, the cost, and the latency are present and match the LiteLLM spend log for the same request. Also confirm that no secret, such as a provider key or bearer token, appears in any metadata or header field. Record the results in your test notes so the field list is approved before callers are moved onto the gateway.

Which LiteLLM fields map to Langfuse traces, observations and users

This table compares each LiteLLM request field with the Langfuse trace, observation, user, session or tag field it lands in, and notes whether the mapping depends on the chosen method. Read it before building dashboards or filters, because some fields only appear with one integration path and others depend on the running Langfuse and LiteLLM versions. Confirm each mapping in a test environment before relying on it for review or investigations.

LiteLLM fieldLangfuse targetDepends on method or versionWhat to confirm
Request ID and call typeObservation or trace ID, used to correlate callsYes: the langfuse_otel preset and the SDK callback may differ in ID handlingSearch one test call end to end in Langfuse and match it to the LiteLLM log line
Virtual key, key alias and user IDUser ID or metadata on the trace, depending on the methodYes: user fields are read from metadata keys the callback recognizesWhether the key alias or hashed key is shown, and that raw keys never appear in traces
Team ID and team aliasTrace tag or metadata field for filtering by teamYes: team values must be passed as metadata to appear as tagsThat team filters in the Langfuse UI return the expected traces
Model name and deploymentObservation model field and model parametersMostly stable, but the provider-prefixed name may differ from the requested aliasWhether the model shown is the requested alias, the routed deployment or both
Input and output contentObservation input and outputYes: content capture can be switched off per integration or per teamWhether bodies are stored, and how server-side masking is configured on the Langfuse side
Token usageObservation usage details (input, output and total tokens)Depends on the provider returning usage and on the mapping in the running releaseThat totals match the provider bill for a sample of calls
CostObservation cost details, if the callback sends itYes: cost may be calculated by LiteLLM, by Langfuse from model prices, or not sentWhich system is the source of truth and how custom model prices are configured
Session and custom tagsTrace session ID and tags, set through metadataYes: session IDs must be passed by the caller in the request metadataThat the calling application sends a stable session identifier
Errors and statusObservation level and status messageYes: failed calls and retries may appear as separate observationsHow timeouts, provider errors and retries are represented in your version

Security settings for prompt logs in Langfuse

Prompt logs are often the most sensitive data a LiteLLM gateway produces, so the controls below decide what reaches Langfuse and who can read it. Set them before the first production trace is sent, and review them together with your retention and access model.

Store the master and project keys in a secret manager

The LiteLLM LITELLM_MASTER_KEY, which must start with sk-, and the Langfuse public and secret project keys both grant access that should not sit in config files or container images. Load them from a secret manager at runtime, rotate them on a schedule you document, and restrict which workloads can read them. Confirm that your secret manager's audit trail records reads of these values.

LiteLLM production guide

Decide what prompt content leaves the gateway

Prompts and responses can contain personal data, credentials and confidential business information. Decide whether Langfuse receives full content, metadata only, or masked content, and make that choice per team or project where your policy differs. Masking should run before export so that sensitive text never reaches the trace store, and you should test it with realistic sample prompts.

Use Enterprise RBAC and project scoping

Self-hosted Langfuse project-level RBAC roles are an Enterprise license feature. Without them, your review is limited to what the open source edition provides, so confirm which access model your team needs before you design projects. Create one Langfuse project per team or data classification, and grant each group only the roles it needs so that one team cannot browse another team's prompts.

Set retention on both sides

Langfuse data retention policies are an Enterprise license feature, and LiteLLM keeps its own spend and request logs in PostgreSQL and any callbacks you configure. Retention must be set in both places, because deleting traces in Langfuse does not remove copies held by LiteLLM logs or object storage archives. Write one retention schedule that covers every store and check it against your privacy obligations.

Enable audit logs and server-side masking

Audit logs record who viewed or changed traces, prompts and settings, and server-side data masking applies redaction inside Langfuse itself. Both are Enterprise license features. Confirm the license covers the features you need before you rely on them, and test that audit events reach your SIEM or log store.

Langfuse license key docs

Connect SSO and remove shared logins

Langfuse supports several authentication and SSO options for self-hosted deployments, and SCIM provisioning is part of the Enterprise feature set. Connect the Langfuse UI to your identity provider so that joiners, movers and leavers are handled in one place, and disable local accounts used for setup. Review group-to-project mapping after each identity change.

Langfuse SSO docs

Why traces are missing, duplicated or incomplete

This table lists the failures teams most often hit when sending LiteLLM traffic to Langfuse, with the likely cause and the fix for each. Read it when traces are absent, doubled or missing fields, and check the rows in order, since a wrong key or SDK range blocks everything else.

Symptom or failureLikely causeFix
No traces appear at allWrong or missing Langfuse public and secret keys in the LiteLLM environment, or keys issued for a different project or hostConfirm the keys and host in the LiteLLM config and environment, then send one test request and check the matching project in the Langfuse UI
Callback loads but nothing exportsLangfuse Python SDK outside the langfuse>=4.7,<5 range required by the SDK callbackPin the SDK to a version inside that range in the LiteLLM image, then rebuild and redeploy the proxy
Errors or empty spans after setupThe langfuse_otel preset used against a Langfuse version that does not match the OpenTelemetry v2 pathCheck the Langfuse version against the LiteLLM Langfuse docs, and switch to the preset or SDK callback that matches your version
Traces never leave the gatewayEgress blocked from the LiteLLM network to the Langfuse host, often by a proxy, firewall or private endpoint ruleAllow outbound HTTPS to the Langfuse host from the proxy pods or VMs, and test the connection from the same network namespace
Traces fail after a v4 upgradeClickHouse below 25.12, PostgreSQL below 15 or Redis below 7.0 when moving to Langfuse v4Upgrade ClickHouse, PostgreSQL and Redis or Valkey to the v4 guide minimums before the Langfuse upgrade starts
Traces lack user, team or key contextMissing metadata in requests, such as user, team, session or environment tagsSet a consistent metadata schema at the gateway or in each client, and test that each field appears on a sample trace
Duplicate traces for one callCallback enabled in more than one place, or the same Langfuse exporter registered twice in the config or SDKKeep one Langfuse callback path per proxy, remove duplicate entries, and restart so only one exporter loads
Historic backfill fails or stallsDisk pressure in ClickHouse, since the v3 to v4 guide advises about 3x disk headroom when backfillingMeasure free disk before the backfill, add headroom or run it in batches, and monitor disk during the run

Questions teams ask before connecting LiteLLM to Langfuse

How much does it cost to connect LiteLLM to Langfuse?

The Langfuse software has no license fee for core features, since they are MIT licensed and available without limits in the open source version. The costs are infrastructure (Langfuse Web, Langfuse Worker, PostgreSQL, ClickHouse, Redis or Valkey and S3-compatible storage), one-time engineering to deploy and wire the integration, and recurring operations such as upgrades, backups and monitoring. Trace volume, retention period, number of environments and whether you need high availability drive infrastructure size and cost. A Self-Hosted Enterprise subscription is custom priced, so request a quote that separates one-time build work from recurring support and shows the infrastructure assumptions behind it.

How long does a LiteLLM to Langfuse integration take?

The sources do not give a fixed duration, so the timing has to come from your scope. Wiring one LiteLLM instance to one Langfuse project is the smallest case. Timing grows with each environment (development, staging, production), the Langfuse topology you choose, the metadata design that tags traces by team and application, and any Langfuse major version upgrade that must happen first. Ask for a written milestone plan that lists each environment and the decisions still open, then check it against your change calendar and security review dates.

Can our own team connect LiteLLM to Langfuse without a partner?

A team that already runs Kubernetes or Docker, PostgreSQL and object storage can wire the LiteLLM side itself, since the callback or preset is configuration on the proxy. The harder work is running Langfuse: ClickHouse sizing and backups, Redis, worker scaling and upgrades. Langfuse documents Docker Compose on a single VM for testing, without high availability, and Kubernetes with Helm or Terraform for production on AWS, Azure and GCP. Decide whether your team owns those operations for the long term, and confirm that someone can carry the on-call and upgrade duties before you start.

What does our team need to provide for the integration?

Plan to provide access and decisions before work starts. You will need a deployed LiteLLM proxy with configuration access, the Langfuse project and API keys for each environment, and accounts or clusters where Langfuse will run. Langfuse also needs PostgreSQL, ClickHouse, Redis or Valkey and an S3-compatible bucket, so confirm who provisions each one. Network paths from LiteLLM to Langfuse must be open, and your security team should approve secret storage for the keys. Decide the metadata and personal data rules, and name who approves them. DeployOpen works inside your infrastructure under a written, fixed scope.

What do Langfuse Enterprise features add over open source?

Langfuse states that all core features and APIs are available in the MIT-licensed open source version without limits, and self-hosted deployments run the same codebase as Langfuse Cloud. A Langfuse Enterprise license key unlocks features such as project-level RBAC roles, protected prompt labels, data retention policies, audit logs, server-side data masking, UI customization, organization creators, the org management API with SCIM and the instance management API. The self-hosted pricing page adds a named support engineer, solutions architect access and a support SLA to the Enterprise plan. Choose Enterprise only if your controls require one of these features, such as audit logs or server-side masking.

When must we upgrade Langfuse to v4 before connecting LiteLLM?

Upgrade to v4 first when you want the observations-first data model from the start, or when your chosen LiteLLM path requires a newer Langfuse setup. The v3 to v4 guide requires ClickHouse 25.12 or later (26.4 recommended), PostgreSQL 15 or later and Redis 7.0 or later. Backfilling historic data needs about 3x ClickHouse disk headroom, so plan storage before migrating. LiteLLM's Langfuse callback requires Langfuse Python SDK v4 (langfuse>=4.7,<5). Confirm with LiteLLM and Langfuse whether your path needs a v4 server, because the sources do not state that requirement for the preset. Follow the dedicated major upgrade guide and do not treat it as a routine update.

Should we use the langfuse_otel preset or the SDK callback?

LiteLLM recommends the langfuse_otel preset in OpenTelemetry v2 for Langfuse v3 and v4. The langfuse SDK callback requires Langfuse Python SDK v4 (langfuse>=4.7,<5) and sends data through LiteLLM's OpenTelemetry pipeline. Choose the preset if your platform team already runs OpenTelemetry collectors and wants one export path for several backends. Choose the SDK callback if your team depends on Langfuse SDK features and accepts the v4 SDK pin. Test both against a staging Langfuse project and compare the traces each produces before you standardize.

Which metadata should LiteLLM attach for useful Langfuse traces?

Decide metadata before rollout, because it is hard to backfill. Useful traces usually carry the environment, the team or cost center, the application or product name, the key or service account that made the call, and the model group used. These fields let you filter traces by owner and find spend or latency problems quickly. Confirm the exact metadata keys in the LiteLLM Langfuse documentation for your version. Do not attach personal data, customer identifiers or secrets to metadata, and decide whether prompt and response bodies are sent at all. Agree this design with the teams that will read the traces.

How DeployOpen scopes and delivers this integration

DeployOpen runs the LiteLLM to Langfuse integration inside your own infrastructure, as a fixed-scope engagement. Before work starts, scope, deliverables and timelines are agreed in writing, and the quote follows from that written scope. The scope usually settles the decisions that shape the work: whether Langfuse is self-hosted or cloud, which Langfuse and ClickHouse versions are in use, whether the langfuse_otel preset or the SDK callback is used, which metadata fields must appear on every trace, and who may see prompt and response content in Langfuse. Those answers determine how much configuration, testing and access review the engagement contains, so the more of them you settle before the scoping call, the more precise the quote can be.

The typical handover has four parts. First, the configuration: the LiteLLM settings for the chosen callback, the Langfuse keys and host values held in your secret manager, the metadata conventions, and the Langfuse project and role setup. Second, a runbook that covers how to check that traces arrive, how to rotate keys, what to do when Langfuse Web or Worker falls behind, and how to plan a Langfuse major upgrade. Third, test evidence: traces from representative calls, including failed calls and calls that use each team's key, with the results recorded. Fourth, a retest after any fixes, so you can see that the problems found in the first pass are closed. An optional retainer can then cover upgrades to supported LiteLLM and Langfuse releases and periodic re-checks of the integration.

How DeployOpen works on this

DeployOpen scopes, builds, tests and hands over the connection between a self-hosted LiteLLM gateway and Langfuse, inside the infrastructure you control. The work covers the choice between the OpenTelemetry preset and the SDK callback, the Langfuse deployment it sends to, and the metadata that makes traces useful to your teams.

How we scope

  • Written scope fixes the Langfuse target, self-hosted or cloud, before any configuration starts
  • We confirm the Langfuse major version and the LiteLLM release line so the exporter choice matches
  • Scope records which prompt and response fields may be sent, and who approves that data flow

How we build

  • We configure the langfuse_otel preset or the SDK callback and test traces end to end
  • We attach agreed metadata such as team, key, model and environment to each request
  • We check Langfuse Web, Worker, PostgreSQL, ClickHouse, Redis or Valkey and blob storage sizing against expected traffic

How we hand over

  • Deliverables include a configuration record, a test report and a runbook for trace-gap triage
  • We document the upgrade path for Langfuse v3 to v4 and the ClickHouse headroom it needs
  • Your engineers receive a walkthrough of the trace model and the metadata conventions

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing
  • Ongoing support, upgrades and continuous testing are available as a retainer
  • Retainers can cover Langfuse and LiteLLM version changes that affect exporter behavior

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.