> ## Documentation Index
> Fetch the complete documentation index at: https://docs.weaveos.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Langfuse usage in Weave

> Connect a Langfuse project so Weave reports its model, token, session, and cost usage

[Langfuse](https://langfuse.com) is an LLM observability platform. When you connect a Langfuse project, Weave syncs the project's generations (model, token counts, cost, session, and user ID) and reports them under the **Langfuse** AI tool.

## Connect a Langfuse project

You need a Langfuse project member who can create API keys and a Weave admin to connect them.

1. In Langfuse, open **Project settings → API keys** and click **Create new API keys**. Copy the public key (`pk-lf-...`) and secret key (`sk-lf-...`).
2. In Weave, open **Data → Langfuse** and click **Connect Langfuse**.
3. Enter a connection name, the Langfuse host, and both keys, then click **Save**. The host defaults to `https://cloud.langfuse.com`; use `https://us.cloud.langfuse.com` for the US region, or your own URL for self-hosted Langfuse.

Weave checks that the keys can read the project before encrypting and storing the secret key. Connect each Langfuse project you want reported as its own connection.

After connecting:

* Weave re-reads the last 3 days of generations on every scheduled sync, so late-arriving usage is picked up. To import older history, ask Weave support for a backfill.
* If the keys are revoked, the connection shows **Action required**. Create new keys in Langfuse and use **Replace keys**.
* Disconnecting erases the stored secret key in Weave. Delete the key in Langfuse separately.

> [!NOTE]
>
> Weave reads generations through the Langfuse observations API v2. Self-hosted Langfuse must run v4 or later.

## What Weave stores

Weave stores one row per Langfuse generation: its ID, start time, model, `userId`, `sessionId`, input, output, and cache token counts, and Langfuse's calculated total cost. Weave never stores prompts, completions, or metadata.

## How usage is attributed

Langfuse's `userId` is whatever your application sends. Weave attributes a generation to a member only when its `userId` is exactly that member's email address (compared case-insensitively). To get per-person reporting, set the Langfuse `userId` to the user's work email.

Generations with any other `userId`, or none, still count toward organization-wide AI tool costs but don't appear in per-person token or session reports.

## Avoiding double counting

Langfuse often observes calls that Weave already reports from another source, such as the Weave Router, OpenRouter, the AI Gateway, or the Claude Code, Cursor, and Codex integrations. Weave keeps each source's data separate and removes the overlap at reporting time:

* A generation whose `sessionId` matches a session that another source already reports is skipped.
* A generation that matches a gateway or OpenRouter request within a few seconds, with the same output tokens and prompt size, is skipped.

Only the remaining generations are reported as Langfuse usage.

## Costs

Langfuse calculates cost from its own model price table, so Weave reports Langfuse cost with **estimated** fidelity. When Langfuse has no price for a model, Weave estimates cost from token counts for session reporting. Provider invoices, discounts, and negotiated rates are not reflected.

## Related pages

* [AI tool costs](https://docs.weaveos.com/metrics/ai-tool-costs.md): understand cost fidelity and visibility
* [OpenRouter](https://docs.weaveos.com/ai-tools/openrouter.md): the other gateway analytics integration
* [AI tools overview](https://docs.weaveos.com/ai-tools/overview.md): compare supported AI tools


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.