Skip to main content

Langfuse pass-through

The /langfuse route forwards Langfuse public API paths, such as /api/public/ingestion, /api/public/scores and /api/public/prompts, to Langfuse. The Langfuse SDK authenticates with HTTP Basic auth made of a public key and a secret key. Through the gateway, the virtual key goes in the secret key field and any value in the public key field. The gateway authenticates the virtual key, replaces the pair with its own Langfuse keys, or with the team's Langfuse keys when the team has its own Langfuse logging configured, and forwards the request.

This route is for applications that trace themselves with the Langfuse SDK. To send the gateway's own request logs to Langfuse, use the Langfuse logging integration instead.

A real-world scenario​

An agent team instruments its application with the Langfuse SDK. The company has one Langfuse project and does not want its secret key in every service. The services set the Langfuse host to the gateway's /langfuse route and use their virtual key as the secret key. Langfuse credentials live only on the gateway, and a team with its own Langfuse project gets its traces routed there through team logging settings.

Before you start​

The gateway needs Langfuse credentials, from the environment or from a team's logging settings.

VariablePurpose
LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEYThe Langfuse keys the gateway sends upstream.
LANGFUSE_HOSTOptional. Changes the upstream address from Langfuse Cloud, for a self-hosted Langfuse.

Steps​

  1. Set LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY in the gateway environment and restart. For a team with its own Langfuse project, open /ui/teams, click the team, open the Settings tab and add Langfuse under the team's logging settings with its langfuse_public_key, langfuse_secret_key and, for self-hosting, langfuse_host.

  2. Issue a virtual key on /ui/api-keys with + Create New Key, then Create Key.

  3. Call Langfuse through the gateway. With curl, pass the virtual key as the Basic auth password.

    curl "http://localhost:4000/langfuse/api/public/prompts?limit=5" \
    -u "anything:$SPANWAY_API_KEY"
  4. With the Langfuse SDK, set the host to http://localhost:4000/langfuse, the secret key to the virtual key and the public key to any value.

Expected result​

Langfuse's own response, with its status code and headers. For an ingestion batch:

{"successes": [{"id": "evt_1", "status": 201}], "errors": []}

Each call is attributed to the virtual key in the gateway's spend logs with no cost, since Langfuse bills by plan rather than by call.

Errors​

StatusMessageWhat it means and how to fix it
401Authentication Error, Invalid proxy server token passedThe secret key field does not hold a valid virtual key.
401Send the virtual key as the password of HTTP Basic auth.The request has no Authorization header, or it is not Basic auth, such as a Bearer token or a malformed Basic value.
403Key/team denied access to passthrough route /langfuse/...The key or team lists the route in denied_passthrough_routes. The message goes on with Matched <pattern> in denied_passthrough_routes, naming the pattern to remove from the key or team.
400Invalid Langfuse endpoint pathThe path carries control characters, backslashes or .. segments. Use a plain Langfuse API path.
400Dynamic Langfuse hosts must include dynamic Langfuse credentialsThe team's logging settings set langfuse_host without the team's keys. Add both keys or remove the host.
400Invalid Langfuse host: ...The team's langfuse_host points at a private or disallowed address.
401 from LangfuseUnauthorizedThe gateway forwarded the call with no usable Langfuse keys. Set the environment variables or the team's keys.

Pass-through endpoints lists every built-in route. The Langfuse integration sends the gateway's own request logs to Langfuse, and team logging explains per-team Langfuse settings.