
Deploy Langfuse Cost Tracking
Token and model cost dashboards for LLM apps
langfuse-web
Just deployed
Just deployed
/var/lib/postgresql/data
Redis
Just deployed
/data
ClickHouse
Just deployed
/var/lib/clickhouse
langfuse-worker
Just deployed
langfuse-bucket
Bucket
Just deployed
Deploy and Host self hosted Langfuse Cost Tracking (Open-Source LLM Cost Tracking) on Railway
Deploys self-hosted Langfuse v3 for tracking usage and USD cost of every LLM generation. Per input, output, and cached token costs are ingested or inferred from model definitions, showing spend by user, feature, and model.
About Hosting Langfuse Cost Tracking open-source software on Railway (self hosted Langfuse LLM cost tracking template)
This template runs the full Langfuse v3 stack on Railway: web UI and API, async worker, Postgres, Redis, ClickHouse, and an S3-compatible bucket. No per-trace fees: you pay Railway for compute and model tokens.
Why Deploy Langfuse Cost Tracking, the Helicone alternative on Railway (Railway Free Trial)
You get the full cost dataset without per-trace fees, which matters when finance asks who spent what. Unlike Helicone's proxy-first flow, Langfuse ingests usage directly from your SDK calls and lets you correct or override any price. Spin it up with Railway's $5 trial and keep the stack yours.
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Langfuse Cost Tracking on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Railway vs Other Hosting Providers and VPS for Langfuse Cost Tracking self hosting
Railway gives you the full managed stack; these VPS options give you raw compute.
| Provider | What You Get with Railway | What You Get with the Other Provider |
|---|---|---|
| DigitalOcean | One-click deploy of the full 6-service stack plus built-in secrets. | A single Droplet you provision and scale manually. |
| AWS | Railway manages the PaaS layer, so you skip IAM and VPC. | EC2/EKS with more control but far more setup. |
| Hetzner | Railway's managed services remove the need to patch ClickHouse and Redis. | Cheap cores, but you operate every service yourself. |
Common Use Cases for hosted Langfuse Cost Tracking
- Cost per customer: tag traces with a tenant ID, then bill each account via the Metrics API or a cost-by-user dashboard. No more hand-splitting a shared OpenAI invoice.
- Cost per feature: add a
featuretag to chat, search, and summary traces. A dashboard shows which feature eats the monthly model budget before finance asks. - Prompt change guard: compare a new system prompt against the old one. If token usage doubles on the same inputs, trace history shows the regression instead of a vague bill spike.
- Pricing private models: run a fine-tuned Llama or an Ollama endpoint, add a model definition with your per-token prices, and compare its dollar cost against OpenAI.
Dependencies for Langfuse Cost Tracking Docker hosted on Railway
Railway wires together six services: the web app, worker, Postgres, Redis, ClickHouse, and a Storage Bucket replacing MinIO. All secrets generate per deploy, so you just wait for the worker's first ingest.
Deployment Dependencies for Managed Langfuse Cost Tracking Service (LLM Cost Tracking)
langfuse-web(langfuse/langfuse:3, port 3000) andlangfuse-worker(langfuse/langfuse-worker:3, port 3030).- Postgres, Redis, ClickHouse 24.8 with volume /var/lib/clickhouse, Railway Storage Bucket.
- Env: DATABASE_URL, REDIS_CONNECTION_STRING with ?family=0, CLICKHOUSE_URL, CLICKHOUSE_MIGRATION_URL, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, CLICKHOUSE_CLUSTER_ENABLED=false, LANGFUSE_S3_EVENT_UPLOAD_* and LANGFUSE_S3_MEDIA_UPLOAD_*, SALT, ENCRYPTION_KEY (64 hex), NEXTAUTH_SECRET, NEXTAUTH_URL.
Implementation Details for Langfuse Cost Tracking (Using Langfuse official docker image)
Ingestion: web writes batches to S3 and queues a Redis reference; worker ingests into ClickHouse. On first deploy, restart the worker once after web finishes migrations. The core repo is MIT licensed, so self-hosting has no usage limits.
How does Langfuse Cost Tracking compare against other LLM cost and observability tools
Langfuse vs Helicone (Helicone Alternative)
- Observability: Langfuse covers traces, generations and evals; Helicone is proxy-first cost.
- Cost capture: Langfuse ingests or infers from model definitions; Helicone captures at proxy, no code changes.
- Self-hosting: Both open source; Helicone lighter, Langfuse adds ClickHouse history. Helicone wins as quick drop-in proxy.
Langfuse vs LangSmith (LangSmith Alternative)
- License: Langfuse core MIT, fully self-hostable; LangSmith closed source, usually needs Enterprise.
- LLM cost details: Langfuse records per-usage-type USD cost, including cached tokens and long-context tiers.
- Custom pricing: Define match patterns and prices for self-hosted or fine-tuned models. LangSmith wins on LangChain internals.
Langfuse vs OpenMeter (OpenMeter Alternative)
- Scope: OpenMeter meters any event; Langfuse focuses on LLM observations with token context.
- Trace context: Langfuse attaches cost to traces, users and tags; OpenMeter lacks trace views.
- OpenMeter wins: General metering for non-LLM events, arbitrary pricing plans.
Langfuse vs provider usage dashboards (Provider Dashboard Alternative)
- Cross-provider: Langfuse shows cost by model, user, tag across providers; vendor dashboards siloed.
- Custom pricing: Langfuse applies negotiated rates, fine-tuned prices, not list prices.
- Per-trace detail: Langfuse breaks down input, output, cached tokens per trace. Provider dashboards win on invoice reconciliation.
How to use Langfuse Cost Tracking (the OSS LLM observability platform)?
- Sign up on your Railway domain, create a project, and copy the public and secret API keys.
- Send traces with the Python or JS SDK, or use the OpenAI wrapper, LangChain, or LiteLLM integration to capture usage automatically.
- Set userId and tags on each trace so cost rolls up by user and feature.
- Open a generation and confirm usage and cost appear under the observation, with per-type usage and cost details.
- For any model with no listed price, add a custom model definition in Project Settings, Models: a match_pattern regex plus prices per usage type.
- Build a dashboard of cost by model, user, and tag so billing questions have an answer.
How to self host Langfuse Cost Tracking on other VPS Services (Langfuse self hosting guide)
Clone the Repository
git clone https://github.com/langfuse/langfuse.git
cd langfuse
The repo includes a docker-compose.yml for single-VM self hosting.
Install Dependencies
Install Docker and Docker Compose on your VPS. The Compose file provisions Postgres, Redis, ClickHouse and MinIO as the S3-compatible bucket for event and media uploads.
Configure Environment Variables
Open docker-compose.yml and replace every value marked CHANGEME: SALT, ENCRYPTION_KEY (64 hex chars, for example from openssl rand -hex 32), NEXTAUTH_SECRET, and the Postgres, Redis, ClickHouse and MinIO passwords. Set NEXTAUTH_URL to http://your-domain:3000, or your HTTPS domain once a reverse proxy is in front. To use AWS S3 instead of MinIO, point LANGFUSE_S3_EVENT_UPLOAD_* and LANGFUSE_S3_MEDIA_UPLOAD_* at your bucket.
Start the Langfuse Cost Tracking Application
docker compose up -d
Wait for web migrations, then open http://your-domain:3000. The worker may need one restart after first deploy.
Official Pricing of Langfuse Cost Tracking (Langfuse pricing)
Self-hosted Langfuse Cost Tracking is open source under MIT and free with no usage limits; you pay only infrastructure. Langfuse Cloud starts with a free Hobby tier (50k units/mo, 30-day retention, 2 users).
Langfuse Cost Tracking cloud vs self hosted comparison (Pricing, features, costs, and more)
Self-hosting swaps Langfuse's per-unit pricing for your own infrastructure bill. You keep the same features but own scaling and the surprise invoices from model providers.
Monthly cost of self hosting Langfuse Cost Tracking on Railway
This 6-service stack (web, worker, Postgres, Redis, ClickHouse, S3 bucket) runs roughly $15-40/mo at low traffic, and the $5 Railway trial covers early testing. Cloud tiers charge extra units at $8 per 100k, which adds up fast at scale.
System Requirements for Hosting Langfuse Cost Tracking on a VPS
If you skip Railway and use Docker Compose on a single VM, budget 4 cores, 16 GiB RAM, and 100 GiB disk. That handles moderate trace volume, though ClickHouse wants more disk as observations accumulate. Anything less and you'll see ingestion lag when worker queues back up.
Frequently Asked Questions (FAQs)
Why does a generation show no cost?
No model definition matched the model name, or usage was missing. Add a price in Models with a match_pattern regex, then new traces get inferred cost.
How do I price a self-hosted Llama or Ollama model?
Create a custom model definition with a match_pattern for your model name and per-token input and output prices. New generations get cost after you save it.
Does changing a model price update old traces?
No. Model definition changes apply only to generations logged after the change; old traces keep their original cost.
Can I ingest my own cost numbers?
Yes. Send usage_details and cost_details from the SDK or API; ingested values take priority over inferred pricing.
How are cached tokens counted?
Usage buckets are mutually exclusive: input excludes input_cached_tokens, and total is the sum. Your own flat usage must already be exclusive to avoid double counting.
Does self-hosted Langfuse charge per trace?
No. Self-hosted Langfuse is free with no per-trace billing; you pay Railway for the stack and your model providers for tokens.
Template Content
langfuse-web
langfuse/langfuse:3Redis
redis:8.2ClickHouse
clickhouse/clickhouse-server:24.8langfuse-worker
langfuse/langfuse-worker:3langfuse-bucket
Bucket
