Routing Langfuse traces through Azure API Management

Put telemetry egress under gateway control by exposing self-hosted Langfuse's OTLP endpoint through Azure API Management, with protocol limits, outbound authentication and private network design planned up front.

On this page

Why teams put Azure API Management in front of Langfuse traces

Azure API Management can expose the OpenTelemetry endpoint of a self-hosted Langfuse as a gateway URL, so applications send traces to the gateway and the gateway forwards them to Langfuse at /api/public/otel. Teams choose this pattern when many applications across the estate send LLM traces to one Langfuse instance and the security team wants that egress logged, throttled and authenticated at a single point. The supported method is OTLP over HTTP, with payloads in protobuf or JSON. Langfuse does not accept gRPC, so any collector or SDK exporter in the path must be set to HTTP. Authentication is Basic Auth built from project API keys, which the gateway or the calling service must present in the expected form.

The gateway changes who holds the keys and where traffic is observed. With a gateway in place, the public key and secret key for each Langfuse project can be stored as named values or secrets in Azure API Management and injected by an outbound policy, so application teams never handle the Langfuse credentials directly. Your gateway logs then record each export request, its source and its volume, which is useful evidence when the security team asks where telemetry leaves the estate. Confirm with your Azure API Management tier and policy features which named value and secret options apply to your region and deployment model before you design the key rotation process. The gateway does not change what Langfuse stores, how traces are processed by the Langfuse Worker, or which retention and masking settings apply inside Langfuse.

What you need in place before configuring Azure API Management

Six items must be settled before the gateway is configured: the Langfuse deployment, the project keys, the Azure tier and network mode, the certificate, the network path and the exporter in each application. Each one depends on a decision owned by a different team, so confirm them in writing before the build starts.

A reachable self-hosted Langfuse

Confirm which Langfuse version the instance runs and that its Web container answers at the host you plan to expose. Ask the Langfuse owner whether the deployment is a single VM or a production cluster, since that determines how much traffic the gateway can safely forward. Record the version now, because upgrade guides can change how ingestion behaves.

Self-hosting docs

Project API keys for the target project

Create a public and secret key pair for the Langfuse project that will receive these traces. The gateway uses Basic Auth built from these keys, so the owner of the Langfuse project should decide who holds the secret key and where it is stored. Use one project per team or environment if you need separate trace boundaries.

Azure API Management tier and network mode

Confirm with the Azure team which API Management tier and network mode are approved for your subscription, and whether the gateway can reach the Langfuse host privately. Do not assume features from another tier. Ask for the written limits and any network injection requirements before you design routes.

TLS certificate for the gateway hostname

Choose the public or internal hostname that applications will call and obtain a certificate that matches it. Confirm with your certificate authority or internal PKI team who renews it and how the renewal reaches the gateway. An expired certificate stops all trace export at once, so track its expiry date alongside the Langfuse upgrade calendar.

Network path from gateway to Langfuse Web

Open a route from the gateway to the Langfuse Web container on the port your deployment exposes, and confirm that the ingestion path is not blocked by a firewall or proxy. Worker containers process events asynchronously, so the gateway needs a path to Web only. Confirm this with your network team and test it before any application depends on it.

OTLP over HTTP exporter in each application

Check that each application's OpenTelemetry exporter can send OTLP over HTTP with protobuf or JSON. Langfuse does not accept gRPC, so an exporter configured for gRPC will fail silently against the gateway. Ask each application owner to confirm the exporter type and the header format they will use for Basic Auth.

Langfuse Azure guide

How a trace travels from application to Langfuse through the gateway

The path starts in an instrumented application or framework exporter that sends OTLP over HTTP to the gateway. Azure API Management then applies its outbound policy, adding the project's Basic Auth credential before forwarding to Langfuse Web at /api/public/otel. Langfuse Worker and the data stores sit behind Web, inside the Langfuse network. Check that the gateway is the only path to that endpoint and that the credential is injected by policy, not held by applications.

Trace hops from application exporter through the gateway into Langfuse.

How the gateway changes telemetry egress control

Putting Azure API Management in front of the Langfuse OTLP endpoint gives the platform team one controlled outbound path for telemetry. Services that emit traces send them to a gateway URL instead of directly to Langfuse at /api/public/otel, so the gateway becomes the single place where the Basic Auth credential built from project API keys is applied. Application teams no longer need to hold Langfuse keys in each service's configuration, and rotating or revoking a key becomes a change to the gateway rather than a change to every deployed application. Because every trace passes through one hop, the gateway's own logs also show which services send telemetry and when, which gives the team a clear record of trace sources.

The new hop adds trade-offs that should be planned before go-live. Trace ingestion now depends on the gateway being available, so its health, capacity and failure behavior become part of the Langfuse operating picture. The gateway policy, including how it forwards the Authorization header and the target path, is a configuration point that must be kept in source control, reviewed and versioned like any other infrastructure. Two kinds of mismatch surface at this hop: protocol and payload limits. Langfuse accepts OTLP over HTTP with protobuf or JSON, and gRPC is not supported, so exporters configured for gRPC will fail at the gateway or be rejected by the backend. Large trace batches may also hit size limits on either side. Confirm the supported OTLP payload limits and the gateway's request size settings in a test environment with production-like trace volumes before routing live traffic.

Which OTLP transports the gateway must carry for Langfuse

Langfuse accepts OTLP traces over HTTP with protobuf encoding at its /api/public/otel endpoint. This is the transport to standardize on when the gateway sits in front of Langfuse, because it is the encoding most OpenTelemetry SDKs and collectors use by default for HTTP exports. The gateway must forward the request body unchanged and must not expect JSON.

  • Exporter setting: confirm that the exporter's protocol is http/protobuf in each framework or SDK you use, since some default to a different value.
  • Endpoint path: the exporter should post to the gateway URL that forwards to /api/public/otel, not to a bare host.
  • Content type: the gateway API definition should allow the application/x-protobuf content type and must not reject or rewrite it.
  • Body size: check the gateway's request body limit against your largest expected trace batch.
  • Authentication header: the Basic Auth header built from the project keys must pass through to Langfuse without being stripped.

Confirm the exact default in your SDK version before you publish the gateway route.

Configure the gateway route to Langfuse in six steps

This sequence turns Azure API Management into the single egress point for OTLP traces, so applications send telemetry to the gateway and the gateway adds the Langfuse project credentials. Each step ends with a check you can run before moving to the next.

  1. Create or select the gateway API

    Platform or integration engineers create a new API in Azure API Management, or select an existing one reserved for telemetry, and give it a base path that applications will call. Keep it separate from business APIs so telemetry policies, logging and access rules do not affect other traffic. Confirm the API's backend and gateway hostname are in the networks you have approved. Check: the API appears in the gateway's API list and its test console opens without errors.

  2. Define the operation for the Langfuse OTLP path

    Add an operation that forwards requests to the Langfuse OTLP path at /api/public/otel on your self-hosted Langfuse host, using the base URL of that instance. Langfuse accepts OTLP over HTTP with protobuf or JSON, and gRPC is not supported, so the operation must accept the HTTP trace request shape applications will send. Confirm the exact operation template and path mapping against current Azure API Management and Langfuse documentation. Check: a test request sent through the gateway's test console reaches the Langfuse host and returns a response from the Langfuse endpoint rather than a gateway error.

  3. Add the outbound Basic Auth policy

    Create a named value or secret in the gateway's secret store for the Langfuse project public key and secret key, then write an outbound policy that builds a Basic Auth header from them. Langfuse authenticates OTLP requests with Basic Auth using project API keys, so the gateway becomes the only place these keys are stored and applications never see them. Confirm the policy syntax, the encoding of the header and how secret values are referenced against current Azure documentation. Check: a request made without any credentials from the test client reaches Langfuse, and the outbound header does not appear in any response returned to the caller.

  4. Restrict inbound access to approved identities

    Limit who can call the gateway operation by applying an inbound policy or access control that accepts only approved application identities, such as managed identities, subscription keys issued per application, or client certificates, as your security team chooses. Remove any default access that lets unknown callers send traces through the route. Because the gateway now holds the Langfuse keys, this step decides who can write data into your projects. Check: a call from an identity not on the approved list is rejected at the gateway, and a call from an approved identity is accepted.

  5. Point one test application at the gateway

    Choose one non-production application instrumented with OpenTelemetry and set its OTLP exporter endpoint to the gateway URL for the new API, using HTTP with protobuf or JSON. Configure the approved identity the application uses to reach the gateway, and leave any Langfuse keys out of the application configuration. Send a few traces that include a model call and a nested span so the structure is visible later. Check: the application exports without export errors in its logs, and the gateway's request log shows the calls arriving from the expected identity.

  6. Verify the trace in the correct project

    Open the Langfuse project that the gateway's keys belong to and locate the traces sent by the test application. Confirm that spans, attributes and timing match what the application produced, and that the trace is filed under the expected project and not another one. Then revoke or rotate the test keys if they were temporary, and record the gateway configuration, key names and approved identities in your change record. Check: the trace is visible in the intended project with its full span tree, and a second project's trace list does not contain it.

How credentials and trace fields map across the gateway

This table traces each field that crosses the gateway, from the caller's identity to the Langfuse project that stores the trace. Read it row by row to see which party sets each value and where the gateway must avoid altering it. The main takeaway is that the Langfuse keys decide the project, so the gateway must map each caller to exactly one key pair.

FieldGateway handlingLangfuse destinationOwner
Langfuse public and secret keysStore in APIM named values or Key Vault, never in the caller's request; build the Basic Auth header in an outbound policyBasic Auth header on the request to /api/public/otelPlatform team
Inbound client identityValidate the caller's APIM subscription key or token before any Langfuse credential is attachedNot forwarded to Langfuse; used only for gateway access and logsGateway admin
Client to key pair mappingOne subscription per application or team, each tied to a single Langfuse key pairDetermines the Langfuse project receiving the tracesPlatform team with application owners
OTLP pathExpose a gateway route that forwards the OTLP path to /api/public/otel without rewriting the trace pathLangfuse OTLP ingestion endpointGateway admin
Content typeAllow application/x-protobuf and application/json; reject other types and gRPC callsLangfuse accepts OTLP over HTTP with protobuf or JSON onlyGateway admin
Trace payloadPass the request body unchanged; avoid body transformation policies that could drop spans or attributesSpans grouped into traces within the target projectApplication team
Project boundaryNever route one subscription's key pair to another project's caller; review key mapping on every changeTraces stay in the project that owns the key pairSecurity and platform leads

Security controls for the gateway route

The gateway route sits between your applications and Langfuse, so it carries the project keys, the trace payloads and the network path. The six controls below cover who can send telemetry, how credentials and traffic are protected, and how access is logged without copying personal data into logs.

Keep project keys in the gateway

Langfuse accepts OTLP with Basic Auth built from project API keys, so whoever holds the keys can write traces into the project. Store the public and secret keys in the Azure API Management secret store, or in Key Vault referenced by the gateway, and keep them out of application configuration files and container images. Ask who can read named values in the gateway, and confirm that the applications only receive their own gateway credential.

Langfuse gateway docs

Restrict which applications call the route

A gateway that forwards any request to Langfuse turns it into an open ingestion point. Require a subscription key or another caller credential at the gateway, issue one per application or team, and reject calls that lack it. Confirm that each credential can be revoked without changing the Langfuse project keys, so a leaked application key does not expose the Langfuse account.

Encrypt both hops

Traces often contain prompts, completions and user identifiers, so both legs need TLS: from clients to the gateway, and from the gateway to the Langfuse host. Confirm the certificate chain for your private Langfuse hostname is trusted by the gateway, because a backend that fails certificate validation tends to show up as dropped spans rather than a clear error. Disable plain HTTP on the public listener.

Keep Langfuse off the public internet

If your design requires it, expose the Langfuse endpoint only on a private network path, such as a private endpoint or an internal load balancer reachable from the gateway's virtual network. Plan the DNS records and routing so the gateway resolves the private name, and test the path from each application subnet. Confirm which teams need direct UI access, since that access path is separate from the telemetry route.

Log access, not trace content

Gateway logs are useful for audits and troubleshooting, but they should record caller, route, status code, timing and size rather than request bodies. Turn off body logging for the telemetry API, and confirm that diagnostic settings do not capture headers that contain credentials. Use your own data classification to decide which fields may appear in logs and how long they are kept.

Rotate project keys on a planned cutover

Rotating a Langfuse project key changes the credential that the gateway uses, so rotation should be scheduled rather than improvised. Create the new key pair, add it to the gateway secret store, test a canary application, then retire the old key and confirm that no caller still uses it. Record the owner and the date of each rotation so that an incident response team can trace which key was active at any time.

Common failures when Azure API Management forwards traces

This table pairs each common failure with its likely cause and a concrete check. Work through it in order when traces do not reach the Langfuse project you expect. Most failures come down to the exporter protocol, the key pair, or the host the application still points at.

SymptomLikely causeFix
401 Unauthorized from LangfuseBasic Auth header missing from the gateway policy, or the public and secret keys are reversed or from another environmentConfirm the policy sends Basic Auth built from the project public key and secret key, then test with a single request before re-enabling the application.
Traces sent but never appearExporter configured for gRPC, which Langfuse does not acceptSet the exporter to OTLP over HTTP with protobuf or JSON and confirm the gateway route forwards HTTP to /api/public/otel.
Traces appear in the wrong projectPublic and secret keys from different projects were combined in the gateway named values or policyCheck each key pair against the project it was created in, and keep separate gateway configurations per environment or project.
Timeouts or dropped spans on large batchesRequest body or duration limits at the gateway or upstream, often triggered by large prompts or long batchesLower the batch size in the exporter, review gateway timeout settings, and test with a representative large trace before go-live.
TLS handshake or certificate errorsIncomplete certificate chain on the gateway hostname, or a private CA not trusted by the application hostInspect the chain presented by the gateway hostname, install missing intermediate certificates, and confirm the CA bundle on the sending host.
No traces at all after cutoverApplication exporter still points at the previous host or an old endpoint pathSearch configuration and environment variables for the old host, update the OTLP endpoint to the gateway URL, and restart the service.

Questions buyers ask before routing Langfuse traces through a gateway

What drives the cost of routing Langfuse traces through Azure API Management?

The cost depends on the gateway tier and network design, the number of applications sending traces, how often project keys are rotated, and how much testing the route needs before it carries production telemetry. A one-time build covers the gateway instance, the inbound and outbound policies, private networking and the test plan. Recurring costs include Azure consumption for the gateway tier you choose, key rotation work and changes when new applications join. Ask for a written quote that splits these components, states what is one-time and what recurs, and lists the Azure resources the quote assumes you already own. DeployOpen does not publish a price list, so the quote follows from the written scope.

How long does it take to configure and test one gateway route?

Duration depends mostly on how fast network changes are approved, not on the policy work itself. A single route involves creating the API in Azure API Management, adding the policy that forwards requests to the Langfuse OTLP endpoint, setting up outbound authentication from project API keys, and running a test application end to end. If the Langfuse host is on a private network, the approval of firewall rules, private DNS and routing changes often sets the schedule. Ask the proposal to name the approval steps, the owner of each, and the test evidence delivered at the end of the route.

What does our team need to provide before the engagement starts?

Plan to provide four things: Azure access with rights to create or change the API Management instance and its networking, administrative access to the self-hosted Langfuse project that will receive traces, a test application that already emits OpenTelemetry traces, and written approval for the network changes your change board requires. Without the test application, the team cannot confirm that traces arrive with the expected attributes. Without network approvals early, the route can stall even when the configuration is ready. Ask the proposal to list these inputs and the person who owns each one.

Can an internal platform team build this without outside help?

Yes, if the team already runs Azure API Management, understands OTLP over HTTP and can operate a self-hosted Langfuse instance. The Langfuse documentation for Azure API Management describes the pattern: services send OTLP traces to a gateway URL, and the gateway forwards them to Langfuse at /api/public/otel with Basic Auth from project API keys. The harder parts are private network design, secret handling for keys, and proving that the policies do not drop or alter traces. A partner is most useful when the team lacks one of those skills or when the change needs to be finished inside a fixed window.

Can the gateway enforce limits for each application?

Azure API Management can apply policies such as rate limits and quotas, but whether they fit telemetry depends on how each application authenticates and what you want to limit. Per-application limits usually require each application or team to have a distinct identity or subscription key at the gateway, and the policy must read that identity reliably. Confirm the exact policy types and the tier you need in the Azure documentation and in your own tenant before promising per-application enforcement. Also confirm the behavior when a limit is hit, because dropped spans are a loss of trace data that the owning team should accept in writing.

What should we check on the protocol side before routing traces?

Check that every sending application uses OTLP over HTTP with either protobuf or JSON, because Langfuse does not accept gRPC. Confirm that the instrumentation library or collector in each service exports to the gateway URL rather than directly to Langfuse, and that Basic Auth credentials come from project API keys stored in a secret store, not in code. Verify request size and timeout settings on the gateway against your largest trace payloads, since large prompt and completion bodies can fail at the edge. Ask the proposal to include a test plan that covers each protocol and each sending application.

How DeployOpen scopes and delivers gateway-routed Langfuse tracing

DeployOpen plans, builds and hands over the Azure API Management route in front of a self-hosted Langfuse OTLP endpoint, inside your own Azure and network setup. Each step is agreed in writing before work starts, so the gateway policy, network path and project keys are defined before any service is switched over.

How we scope

  • We confirm which services will send OTLP traces and which Langfuse project each one writes to.
  • We define the Azure API Management tier, network model and private connectivity to your Langfuse host.
  • The written scope lists policies, keys handling, test cases and handover items before work begins.

How we build

  • We configure the gateway route to /api/public/otel and confirm HTTP protobuf or JSON, since gRPC is not supported.
  • We implement outbound authentication so project API keys are injected by the gateway, not held by client applications.
  • We test each sending service end to end and verify traces arrive in the intended Langfuse project.

How we hand over

  • You receive the gateway configuration, policy definitions, network diagram and a runbook for key rotation.
  • We walk your platform and security teams through the route, the test results and the known limits.
  • Every change is documented so your team can review it against your own security and change controls.

How we support

  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
  • Ongoing support, upgrades and continuous testing are available as a retainer for the gateway and Langfuse stack.
  • We can retest the route after Langfuse upgrades or gateway policy changes to confirm tracing still works.

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.