trace_id to your endpoint on every call within the header, and you forward that ID to the Galtea SDK wrapper in your code. That link is all Galtea needs to collect your spans and associate them with the right inference made for the evaluation in question.
The changes to your code are minimal: one import swap and one line to read the ID from the request header.
What Does NOT Change in Langfuse
When Does Galtea Export Data?
Galtea only exports span data when atrace_id is explicitly linked. Without it, Galtea does nothing — no data is sent, no spans are modified, no logs are written.
How Your Endpoint Is Called
Galtea calls your endpoint and injects theX-Galtea-Inference-Id HTTP header on every request. This header carries the trace_id that links the execution to a Galtea trace.
Galtea uses traces as the unit of evaluation — each one represents a single input/output pair that can be scored by metrics. By linking spans to a trace, Galtea knows which execution spans belong to which response, enabling span-aware evaluations and hence full visibility into how your agent arrived at each answer.
What You Change in Your Code
Step 1: Install and initialize the Galtea client
[langfuse] extra (pip install 'galtea[langfuse]') is only needed if you don’t already have langfuse installed — it simply adds langfuse as a dependency. Since you already have Langfuse installed, pip install galtea is enough. If you use the LangChain CallbackHandler, install with pip install 'galtea[langfuse-langchain]' to include langchain as well.
Step 2: Read the header and swap the import
Two changes: swap the Langfuse import for the Galtea wrapper and pass the ID; reading the header is just where the ID comes from. The wrapper handles everything else.- @observe (decorator)
- start_as_current_observation (context manager)
- CallbackHandler (LangChain)
trace_id kwarg is consumed by the wrapper — it does not reach your function’s parameters. The wrapper sets up the Galtea span context before the function runs and flushes it when it returns.@observe works on async def functions too. The wrapper detects the coroutine and awaits it before clearing context, so spans are correctly stamped with trace_id.When using Galtea’s SDK methods (
generate(), simulate()), this step is not needed — the SDK manages trace_id internally.What You Do NOT Need to Change
span.update(output=...),span.score(...)— native Langfuse span methodsroot.start_as_current_observation(...)— child observations on yielded spanspropagate_attributes(user_id=..., session_id=..., tags=...)— pure Langfuse, no wrapper needed- Any Langfuse dashboard configuration, alerts, or integrations
Version Compatibility
Requires Langfuse v3.0.0 or later (capped at<5.0.0). v2.x is not supported — it does not use OTel internally.
FAQ
Q: Will adding Galtea slow down my Langfuse traces? No. Galtea only batches and exports spans whentrace_id is set — otherwise it’s a no-op.
Q: Can I remove Galtea later without affecting Langfuse?
Yes. Swap the imports back (from langfuse import observe) and remove the galtea.Galtea(api_key=...) initialization. Langfuse continues working exactly as before.
Q: Does Galtea see my Langfuse API keys?
No. Galtea only receives span data (name, type, input, output, timing, hierarchy). It does not access your Langfuse credentials or cloud configuration.
Q: What if Langfuse adds new observation types?
An observation type Galtea does not recognize is sent as SPAN. Your spans are never dropped.