Summary: Langfuse is an open-source tool that records every LLM call in your app, works out what each one cost, and lets you score answers with user feedback or an LLM judge. This playbook takes one concrete case, a support chatbot that is getting expensive and sometimes answers badly, and walks through the setup that finds both problems in about a week of real traffic. The free Hobby cloud plan (50k units a month) or a free self-hosted install is enough to follow along.
The scenario: a chatbot nobody can explain
Picture a small product team that shipped a help-center chatbot a few months ago. The model bill keeps creeping up, a few customers have complained about wrong answers, and when someone asks "which conversations cost the most?" or "how often is it wrong?", nobody can answer. The provider dashboard shows total tokens, but not which feature, user or prompt produced them.
That gap is what LLM observability tools are for. The plan below uses Langfuse to answer four questions, in this order:
- What does one conversation actually cost, and which ones are outliers?
- Which answers do real users dislike?
- Can a judge model flag weak answers automatically, so you do not depend on the few users who click a button?
- How do you keep the Langfuse bill itself under control as traffic grows?
Step 1: Choose cloud or self-hosted
The instrumentation code is the same for both, so this is mainly a question of who runs the servers.
- Langfuse Cloud: sign up at cloud.langfuse.com, create a project, and create API credentials in the project settings. You get a public key (
pk-lf-...) and a secret key (sk-lf-...). Data regions are EU (https://cloud.langfuse.com), US (https://us.cloud.langfuse.com) and Japan (https://jp.cloud.langfuse.com), plus a HIPAA region. - Self-hosted: the core is MIT-licensed with unlimited usage. For a trial, clone the
langfuse/langfuserepository, update the secrets indocker-compose.yml, and rundocker compose up. The docs say the web container logs "Ready" after about two to three minutes, and the UI is then athttp://localhost:3000. There is no default admin account: click Sign up to create the first user. For a VM, the docs recommend at least 4 cores, 16 GiB of memory and around 100 GiB of storage, and they warn that the Compose setup has no high availability or backups, so use Kubernetes for serious production.
If your chat logs contain personal data, decide on the region (or self-hosting) before you send a single trace. Moving later is more work than choosing now.
Step 2: Trace every chatbot call
If the bot uses the OpenAI Python SDK, the change is one import. Install the SDK with pip install langfuse, set three environment variables, and swap the import:
LANGFUSE_SECRET_KEY="sk-lf-..." LANGFUSE_PUBLIC_KEY="pk-lf-..." LANGFUSE_BASE_URL="https://cloud.langfuse.com" # before: import openai from langfuse.openai import openai
The wrapper behaves like the normal client and records the prompt, model and output for each call. For JavaScript and TypeScript, the official route is @langfuse/openai plus @langfuse/otel: start an OpenTelemetry NodeSDK with a LangfuseSpanProcessor before any traced code runs, then wrap the client with observeOpenAI(new OpenAI()). LangChain users add a CallbackHandler instead, and the Vercel AI SDK has its own integration.
Next, attach the context you will want to filter by later. In Python, wrap the request handler in propagate_attributes() so every nested call inherits the same values:
from langfuse import observe, propagate_attributes
@observe()
def answer(user_id, chat_id, question):
with propagate_attributes(user_id=user_id,
session_id=chat_id,
tags=["support-bot"]):
return run_bot(question)
The session_id groups every turn of one chat into a single replayable conversation (it must be a US-ASCII string under 200 characters). The user_id lets you rank users by cost, and the tag lets you separate the support bot from any other LLM feature in the same project. These three fields are what turn a pile of logs into answers.
Step 3: Find the expensive conversations
You usually do not need to configure anything for cost. Langfuse ships with prices for popular OpenAI, Anthropic and Google models, and most integrations capture token usage automatically. For each generation it stores usage and cost broken down by type, such as input, output and cached tokens. If you send cost yourself, the ingested value wins over the inferred one.
After a few days of traffic, open the cost dashboard and look at cost by model, cost over time, and the top users and use cases by cost. In a support bot, the outliers are usually long sessions where the full history is re-sent on every turn, or a retrieval step that stuffs too many documents into the prompt. Open one of those sessions and you can see each turn's tokens side by side.
Two cost gotchas to check early:
- A generation shows no cost. The model name did not match any model definition, which is common with fine-tuned, self-hosted or very new models. Click the model badge on the generation, or go to Project Settings > Models, and add a definition with a regex match pattern and prices. It applies to new traces only, not old ones.
- Long-context pricing. Some models charge more above a context threshold. Langfuse supports pricing tiers with conditions on usage, model parameters or metadata, so a custom definition can mirror that.
Step 4: Capture what users think
Cost is half the story; the other half is whether answers helped. In Langfuse, feedback is stored as a score linked to a trace. The documented pattern for a web chat is:
- Have the backend return the trace ID with each answer.
- Add thumbs-up and thumbs-down buttons that send a score (for example
user-feedback, 1 or 0, type BOOLEAN) through the Langfuse browser SDK. Use a dedicated key that is only allowed to ingest scores, since it lives in the browser. - In Langfuse, filter traces by
user-feedback < 1to read the disliked answers.
You can also score from the server. A good implicit signal for support is ticket outcome: call langfuse.create_score() with 1 when the ticket closes without a human, and 0 when it is escalated. That catches unhappy users who never click anything.
Step 5: Let a judge model score answers automatically
Explicit feedback is sparse, so the next step is an LLM-as-a-Judge evaluator that scores live answers against a rubric.
- Set up an LLM Connection (the provider key the judge will use).
- Go to Evaluators, click New evaluator, and start from a Langfuse template or a blank LLM-as-a-Judge prompt.
- Write the rubric with variables such as
{{input}}and{{output}}, and pick a score type: numeric (for example helpfulness from 0 to 1), categorical labels, or boolean. - Map each variable to the observation's input, output, metadata or tool calls.
- Test it on sample observations in the right-hand panel, read the score and reasoning, and adjust until it agrees with you.
- Save, then create a rule that runs it on incoming observations.
Two details from the docs matter for a chatbot. First, observation-level evaluators are the recommended target for live data, and trace-level ones are deprecated. Second, an observation-level evaluator does not see sibling or child observations. If the judge needs the whole question and final answer, target a logical root observation that records both, using the Is Root Observation filter in the rule. Before trusting the judge, compare its scores with a small set of answers you labeled by hand; Langfuse's Score Analytics can show that agreement.
Step 6: Keep the Langfuse bill predictable
Cloud pricing is based on units: traces plus observations plus scores. Units created by Langfuse features count too, including LLM-as-a-Judge scores, annotation queues and experiments. As a rough worked example, a chat turn recorded as one trace, three observations and one judge score uses five units, so the Hobby plan's 50k monthly units would cover about 10,000 such turns. Your own count depends on how many steps your bot logs; the built-in Langfuse Usage Management dashboard shows the real totals.
Three levers keep it in check:
- Sampling: set
LANGFUSE_SAMPLE_RATE(orsample_rate) between 0 and 1. Sampling is per trace, so a dropped trace takes its observations and scores with it. In JS/TS, use an OpenTelemetry sampler such asTraceIdRatioBasedSampler(0.2). - Judge only what matters: filter the evaluator rule to the final answer observation and the
support-bottag instead of every step. - Spend alerts: on Core and above, set email alerts in the organization's Billing tab. They track your Langfuse bill (checked every 60 to 90 minutes), not your model spend.
For privacy, the Python SDK's mask_otel_spans hook can delete or rewrite span attributes before data leaves your app, which is the place to strip emails or order numbers from chat content.
Langfuse plans and two alternatives
| Option | Free tier | First paid plan | Worth knowing |
|---|---|---|---|
| Langfuse Cloud | Hobby: 50k units/month, 30 days of data access, 2 users | Core $29/month: 100k units, then $8 per 100k; 90 days of data access; unlimited users | Pro $199/month for 3 years of access and retention controls; core features can also be self-hosted free under MIT |
| LangSmith (LangChain) | Developer: $0, 1 seat, up to 5k base traces/month | Plus $39/seat/month: up to 10k base traces/month, then pay as you go | Self-hosted and hybrid deployment are listed under Enterprise (custom pricing) |
| Helicone | Hobby: 10,000 requests, 1 GB storage, 1 seat, 7-day retention | Pro $79/month: unlimited seats, alerts and reports, usage-based pricing beyond the free allowance | Includes gateway features such as caching, rate limits and fallbacks |
Prices as listed on each vendor's official pricing page on 2026-11-02. Units, traces and requests are counted differently, so compare them against your own traffic rather than side by side.
Editor's note
Good fit: teams with an LLM feature already in production who need per-user cost and a quality signal, and anyone who wants the option to self-host the whole stack for free.
Not a fit: a single prompt you run by hand a few times a week. The provider's usage page is enough there. And if you mainly want a proxy with caching and fallbacks, a gateway-first tool may suit you better.
Common errors and fixes from the official troubleshooting page:
- No traces appear. Check that the three
LANGFUSE_*variables are set, thattracing_enabledis true andsample_rateis not 0. In scripts, serverless functions and batch jobs, calllangfuse.flush()orlangfuse.shutdown()before exit, because data is sent in the background. Uselangfuse.auth_check()during setup (not in production) to test the keys. - OpenAI calls are missing. The wrapper or callback handler must be created before the API calls run.
- Steps show up at the top level instead of nested. Use context managers, call
.end()on manual observations, and make sure the parent observation is exported. Self-hosted servers need version 3.63.0 or later for the OpenTelemetry-based SDKs. - Next.js traces vanish with
@vercel/otel. Upgrade to v2 or later, or register the span processor through a manualNodeSDK.
FAQ
Is Langfuse really free?
Two ways. The Cloud Hobby plan is free with no credit card, limited to 50k units a month, 30 days of data access and 2 users. The self-hosted open-source version is free under the MIT license with unlimited usage, but you pay for and maintain the servers.
Do I have to use LangChain?
No. Langfuse has drop-in wrappers for the OpenAI SDK in Python and JS/TS, a Vercel AI SDK integration, OpenTelemetry support for other languages, and proxy-based logging through LiteLLM. LangChain is just one of many integrations.
Do LLM-as-a-Judge evaluations cost money?
Yes, in two places. The judge model runs on your own LLM Connection, so the provider bills you for those tokens, and each score it writes counts as a Langfuse unit on Cloud. Filtering the rule to final answers keeps both small.
Related on lightmind24: if you have not built the bot yet, the Dify playbook for a help-docs chatbot is a quick way to start. Teams running an internal chat UI can pair this with the Open WebUI playbook, and the OpenRouter free models guide helps once your cost data shows which calls could move to a cheaper model.
Instrument first, read a week of real conversations, and only then decide which prompt or model to change.
Images: official Langfuse documentation images and a screenshot of the langfuse.com pricing page captured by the author; see the official screenshots at the end of this post.
Last verified: 2026-11-02
Sources:
Langfuse Cloud pricing
Langfuse self-hosted pricing
Langfuse docs: Get Started with Tracing
Langfuse docs: Sessions
Langfuse docs: Token and Cost Tracking
Langfuse docs: User Feedback
Langfuse docs: LLM-as-a-Judge
Langfuse docs: Billable Units
Langfuse docs: Sampling
Langfuse docs: Spend Alerts
Langfuse docs: Masking
Langfuse docs: SDK Troubleshooting
Langfuse docs: Docker Compose deployment
LangSmith pricing
Helicone pricing
댓글
댓글 쓰기