
Deploy Langfuse OpenAI Agents
Trace OpenAI Agents SDK runs, tools and handoffs
Just deployed
/var/lib/postgresql/data
langfuse-web
Just deployed
ClickHouse
Just deployed
/var/lib/clickhouse
langfuse-worker
Just deployed
Redis
Just deployed
/data
langfuse-bucket
Bucket
Just deployed
Deploy and Host self hosted Langfuse OpenAI Agents (Open-Source Tracing for OpenAI Agents SDK) on Railway
This template deploys a self-hosted Langfuse v3 stack built for tracing OpenAI Agents SDK apps. It suits Python teams running multi-agent workflows who want full trace data in-house.
About Hosting Langfuse OpenAI Agents open-source software on Railway (self hosted Langfuse for OpenAI Agents SDK tracing template)
Self-hosting Langfuse keeps every agent run, tool call and handoff from your OpenAI Agents SDK app on servers you control.
Railway provisions the six services, wires private networking, generates secrets per deploy and persists the ClickHouse volume. You still own the data, keys and retention.
Why Deploy Langfuse OpenAI Agents, the OpenAI Traces dashboard alternative on Railway (Railway Free Trial)
The OpenAI Traces dashboard keeps your agent runs on OpenAI's servers with limited control over how tool calls and handoffs are retained.
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 OpenAI Agents 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 OpenAI Agents self hosting
A six-service Langfuse stack for OpenAI Agents traces makes the hosting choice matter.
| Provider | What You Get with Railway | What You Get with the Other Provider |
|---|---|---|
| DigitalOcean | Template deploys for all six services, with private networking and per-deploy secrets. | A full VM you control, but you write the Compose stack and handle upgrades and backups. |
| AWS | One project view across web, worker, Postgres, Redis, ClickHouse, and the bucket. | Deep control over networking and S3, but a much larger setup and billing surface. |
| Hetzner | No server sizing decision before you know your trace volume. | Low raw compute cost, but you own every restart, patch, and disk resize. |
Agent runs with many tool calls and handoffs generate trace volume faster than you might expect, so weigh ops time against control.
Common Use Cases for hosted Langfuse OpenAI Agents
- Debugging a triage agent that hands off to the wrong specialist: Each handoff shows up as a span, so you see which agent got the request and what it was given.
- Timing slow tool calls: Every
@function_toolcall is its own span with name, arguments and duration, so a slow lookup stands out in the tree. - Per-user token cost for an agent app: Passing
user_idthroughpropagate_attributestags every span in a run, so you can total usage per customer. - Keeping traces in-house instead of the OpenAI dashboard: Prompts, tool arguments and outputs stay in your own Postgres and ClickHouse services on Railway.
- Building eval datasets from real agent runs: Curate production traces into Langfuse datasets, so failures become regression cases for your next agent version.
Dependencies for Langfuse OpenAI Agents Docker hosted on Railway
Running Langfuse on Railway means six services that must come up in order before your agent code can trace anything.
Deployment Dependencies for Managed Langfuse OpenAI Agents Service (LLM Observability)
Both Langfuse services reference Postgres, Redis, ClickHouse and the bucket through variables like DATABASE_URL, REDIS_CONNECTION_STRING and CLICKHOUSE_URL.
Implementation Details for Langfuse OpenAI Agents (Using Langfuse official docker image)
Set CLICKHOUSE_CLUSTER_ENABLED=false for a single-node ClickHouse, and provide CLICKHOUSE_MIGRATION_URL with CLICKHOUSE_USER and CLICKHOUSE_PASSWORD.
How does Langfuse OpenAI Agents compare against other ways to trace OpenAI Agents SDK apps
Langfuse OpenAI Agents vs OpenAI Traces dashboard (Competitor Alternative)
- Where it wins: The OpenAI Traces dashboard needs no setup if your agents run on the OpenAI API.
- Data location: Langfuse keeps agent runs, tool calls and handoff spans on your own Railway services.
- Cross-provider scope: The OpenInference instrumentor hooks the Agents SDK, so the trace model holds if you mix providers later.
- Team workflow: Langfuse adds scores, datasets and prompt versions on top of the trace tree.
Langfuse OpenAI Agents vs LangSmith (Competitor Alternative)
- Where it wins: LangSmith is smoother if your app already runs on LangChain or LangGraph.
- Self-hosting: LangSmith is closed source and self-hostable only on Enterprise, while this Langfuse stack is MIT licensed.
- Instrumentation: Langfuse plugs into the Agents SDK without rewriting agent code around another framework.
Langfuse OpenAI Agents vs Arize Phoenix (Competitor Alternative)
- Where it wins: Phoenix suits local, notebook-style debugging and embedding analysis.
- License: Phoenix ships under the Elastic License 2.0, which is source available rather than fully open source.
- Focus: Phoenix leans toward evaluation and exploration, while Langfuse emphasizes production trace storage and team access.
- Shared standard: Both build on OpenTelemetry and OpenInference, so instrumentation stays portable.
Langfuse OpenAI Agents vs AgentOps (Competitor Alternative)
- Where it wins: AgentOps is a hosted service you can wire up with a few lines of SDK code.
- Hosting control: Langfuse runs as services you deploy yourself, so you own retention, backups and access rules.
- Cost shape: Self-hosting trades vendor billing for infrastructure time, so compare expected trace volume before choosing.
How to use Langfuse OpenAI Agents (the OSS LLM observability platform)?
- Sign up on your Railway Langfuse domain and create a project.
- Generate an API key pair in the project settings.
- Install:
pip install openai-agents langfuse openinference-instrumentation-openai-agents. - Export
LANGFUSE_PUBLIC_KEY,LANGFUSE_SECRET_KEY,LANGFUSE_BASE_URL=https://your-langfuse-domainandOPENAI_API_KEY. - Run the script below, then open Tracing in your project.
from langfuse import get_client
from openinference.instrumentation.openai_agents import OpenAIAgentsInstrumentor
from agents import Agent, Runner
langfuse = get_client()
print(langfuse.auth_check()) # True when keys and host are correct
OpenAIAgentsInstrumentor().instrument()
agent = Agent(name="Assistant", instructions="Answer in one sentence.")
result = Runner.run_sync(agent, "What does a handoff do?")
print(result.final_output)
langfuse.flush()
How to self host Langfuse OpenAI Agents on other VPS Services (Langfuse self hosting guide)
This path is for a VM you manage yourself. Langfuse's official docs use Docker Compose for a single machine, so these steps follow that layout. Plan on about 4 cores, 16 GiB RAM and 100 GiB disk.
Clone the Repository
Clone the upstream repository and move into the folder.
git clone https://github.com/langfuse/langfuse.git
cd langfuse
Install Dependencies
Install Docker and the Compose plugin on the host. Your OpenAI Agents app can run anywhere, so it doesn't need to live on this server.
docker compose version
Configure Environment Variables
Copy the example env file and set NEXTAUTH_URL to your public domain, such as https://your-domain.
Start the Langfuse OpenAI Agents Application
Start the stack detached, then confirm the web container is answering on port 3000. Point LANGFUSE_BASE_URL at that domain in your agent code.
docker compose up -d
docker compose logs -f langfuse-web
Railway handles the service wiring, secrets and persistent volumes for you, which is the part you'd otherwise maintain by hand on a VPS.
Official Pricing of Langfuse OpenAI Agents (Langfuse pricing)
Langfuse self hosting is free and open source. Check the official Langfuse pricing page for current plan details before you budget.
Langfuse OpenAI Agents cloud vs self hosted comparison (Pricing, features, costs, and more)
Langfuse Cloud charges by units, so an agent app that emits a lot of spans per run can climb tiers faster than you expect. The two options below are the trade-off in practice.
Monthly cost of self hosting Langfuse OpenAI Agents on Railway
Railway bills the six services in this stack, which include langfuse-web, langfuse-worker, Postgres, Redis, ClickHouse 24.8 and the Storage Bucket.
System Requirements for Hosting Langfuse OpenAI Agents on a VPS
Langfuse's self-hosting guidance for a single VM is 4 cores, 16 GiB RAM and 100 GiB of disk. Budget for those numbers before you commit to a small instance.
Frequently Asked Questions (FAQs)
Do I still need the OpenAI traces dashboard if I use Langfuse?
Not for your own agent runs. The OpenAI dashboard is still useful if you want to compare against what OpenAI recorded.
Why are my spans missing in a short script?
Usually the script exits before spans are sent. Call langfuse.flush() at the end, and make sure OpenAIAgentsInstrumentor().instrument() runs before any agent code.
How do I tag runs with user_id and session_id?
Wrap runs in propagate_attributes(user_id=..., session_id=..., tags=[...]) from the langfuse package. Every span inside that scope inherits the values, which makes per-user filtering easy.
Are handoffs and tool calls captured?
Yes.
Does it work with async runs?
Yes, as long as the instrumentor is active before the event loop starts work and you flush at the end. Set LANGFUSE_DEBUG="True" if spans seem to vanish.
What data is stored?
Traces, observations and scores go to ClickHouse, and raw events and media go to the Railway Storage Bucket.
Template Content
langfuse-web
langfuse/langfuse:3ClickHouse
clickhouse/clickhouse-server:24.8langfuse-worker
langfuse/langfuse-worker:3Redis
redis:8.2langfuse-bucket
Bucket

