Launch Week 3: Five days of launches

Switch from Langfuse V1 to Confident AI

Move your traces from Langfuse SDK v1 to Confident AI with confident-trace. Auto instrumentation replaces your trace and generation objects.

Overview

Langfuse SDK v1 sends traces through its own ingestion API, not OpenTelemetry. You build each trace by hand: a Langfuse client, a trace, then a span or a generation for every step. confident-trace replaces those objects with OpenTelemetry spans. init() instruments your provider clients, span marks your own steps, and the trace fields move onto update_trace() in Python and updateTrace() in TypeScript.

In this guide, you will:

  • Pick a migration method: one copyable prompt for your coding agent, or manual.
  • Install confident-trace and replace the Langfuse keys with one CONFIDENT_API_KEY.
  • Replace the traced OpenAI calls with init() so auto instrumentation emits the model spans.
  • Replace langfuse.trace() with span and update_trace() so every trace keeps its name, user, session and metadata.
  • Drop the manual generations that auto instrumentation now records for you, and keep an LLM span for the model calls it does not cover.
  • See what changes once the traces land in Confident AI: evals on every trace, datasets curated from production, alerts when quality drops.
$200 in migration credits, applied after your callBook a call, show us your current setup, and we map your traces, datasets and prompts together. Applied as a coupon to your first paid invoice, one per organization.Book a migration call

Prerequisites

  • A Project API Key, CONFIDENT_API_KEY (for example confident_us_proj_...). Retrieve yours here.
  • Python 3.10+ for the Python SDK, or Node.js 22+ for the TypeScript SDK.
  • Your existing Langfuse setup on SDK v1: Python langfuse<2 (run pip show langfuse) or TypeScript langfuse@1 (run npm ls langfuse). The before snippets below follow the Langfuse v1 SDKs, last released as Python 1.14.0 and TypeScript 1.3.0.

Choose a Migration Method

MethodWhat you doLangfuse SDK v1
Coding-agent migrationGive your coding assistant one prompt and review its changesSupported. See Switch in One Prompt below
Manual migrationMake the SDK changes yourself, step by stepSupported. See Switch Manually below
OpenTelemetry migrationAdd a Confident AI exporter and keep your Langfuse instrumentationNot available. Langfuse SDK v1 sends traces through the Langfuse ingestion API, not OpenTelemetry, so there is no span to redirect. It is available from Langfuse Python SDK v3 and TypeScript SDK v4

Switch in One Prompt

Give the prompt below to your coding assistant, such as Claude Code, Cursor or Codex, from the root of your repository. It finds your Langfuse integration, confirms the SDK version, makes the changes from this guide, and tells you what still needs your hands. Review the diff before you merge it.

Prompt
Migrate this codebase from Langfuse to Confident AI using confident-trace.

1. Find every Langfuse integration: imports of langfuse, Langfuse() and new Langfuse() clients, langfuse.trace(), trace.span(), trace.generation(), generation.end(), langfuse.openai, the Langfuse CallbackHandler, and LANGFUSE_* environment variables or keys passed in code.
2. Confirm the installed Langfuse SDK version with pip show langfuse or npm ls langfuse. This migration is for Langfuse SDK v1. If the major version is different, stop and tell me which version you found.
3. Make the changes from https://www.confident-ai.com/docs/guides/migrate-to-langfuse-alternative-v1:
   - install confident-trace and call init() once at startup
   - replace langfuse.openai, and generations around OpenAI calls, with the plain OpenAI client
   - replace langfuse.trace() with span on the traced function and update_trace() (updateTrace() in TypeScript) for name, user, session and metadata, with sessionId as thread_id (threadId)
   - replace trace.span() with span, or with span(...) / withSpan()
   - keep generations for model calls auto instrumentation does not cover as LLM spans with update_span() (updateSpan())
   - remove the Langfuse CallbackHandler from LangChain callbacks
   - replace the Langfuse keys with CONFIDENT_API_KEY, and langfuse.flush() / shutdownAsync() with flush() / shutdown()
4. Preserve existing tracing behavior where possible: the same span names, nesting, inputs, outputs, users, sessions and metadata.
5. Do not delete Langfuse prompt, dataset or score calls. List them for me instead.
6. When you are done, summarize every change and list anything that needs manual configuration, such as setting CONFIDENT_API_KEY, the EU endpoint, or model calls you could not map.

Switch Manually

  1. Install confident-trace

    One package. Provider SDKs stay optional peers. CONFIDENT_API_KEY replaces the Langfuse public key, secret key and host. For the EU region, also set CONFIDENT_OTEL_ENDPOINT=https://eu.otel.confident-ai.com/v1/traces.

    pip uninstall langfuse
    pip install confident-trace
    export CONFIDENT_API_KEY=...
    # replaces LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_HOST
  2. Replace the traced OpenAI calls with init()

    In Python, drop the Langfuse import of OpenAI. In TypeScript, Langfuse v1 has no OpenAI integration, so you wrapped each call in a generation. Either way, auto instrumentation now emits the span from the plain client, with the model, messages and token usage.

    from langfuse.openai import openai
    
    response = openai.chat.completions.create(
        model="gpt-4.1-mini",
        messages=[{"role": "user", "content": "Hello"}],
    )
  3. Replace langfuse.trace() with span and update_trace()

    The function you wrapped in a trace becomes a span. Its return value becomes the trace output. The trace fields you passed to langfuse.trace() move onto update_trace() (updateTrace() in TypeScript), and the session ID becomes the thread ID.

    from langfuse import Langfuse
    from langfuse.model import CreateTrace
    
    langfuse = Langfuse()
    
    def support_chat(question: str) -> str:
        trace = langfuse.trace(
            CreateTrace(
                name="support-chat",
                userId="user-7",
                sessionId="session-42",
                input=question,
                metadata={"plan": "enterprise"},
            )
        )
        return openai.chat.completions.create(
            model="gpt-4.1-mini",
            messages=[{"role": "user", "content": question}],
        ).choices[0].message.content
  4. Drop the manual generations

    A generation you created around an OpenAI call is now redundant: auto instrumentation records the same model span. Keep an LLM span with update_span() (updateSpan() in TypeScript) for model calls it does not cover, such as a self-hosted model behind your own HTTP client.

    from langfuse.model import CreateGeneration, UpdateGeneration, Usage
    
    generation = trace.generation(
        CreateGeneration(name="answer", model="my-model", prompt=messages)
    )
    completion, prompt_tokens, completion_tokens = call_my_model(messages)
    generation.end(
        UpdateGeneration(
            completion=completion,
            usage=Usage(promptTokens=prompt_tokens, completionTokens=completion_tokens),
        )
    )

    trace.span() works the same way: replace it with span or a with span("name"): block (withSpan() in TypeScript). For LangChain, remove the Langfuse CallbackHandler from your callbacks. init() instruments LangChain directly.

Run your app once. The trace appears in your project's Observatory within seconds. If it does not, check that CONFIDENT_API_KEY is set in the same process and that the app flushes before it exits. flush() from confident-trace replaces langfuse.flush() in Python, and await tracing.shutdown() replaces await langfuse.shutdownAsync() in TypeScript.

Field Mapping

Langfuse v1confident-trace
Langfuse()init()
CreateTrace(name=...)@span(name=...) or update_trace(name=...)
CreateTrace(userId=...)update_trace(user_id=...)
CreateTrace(sessionId=...)update_trace(thread_id=...)
CreateTrace(input=..., output=...)update_trace(input=..., output=...)
CreateTrace(metadata=...)update_trace(metadata=...)
CreateSpan(name=...)@span or with span("name"):
CreateGeneration(model=..., prompt=...)span(type="llm") with update_span(model=..., input=...)
UpdateGeneration(completion=...)update_span(output=...)
Usage(promptTokens=..., completionTokens=...)update_span(input_token_count=..., output_token_count=...)
langfuse.flush()flush()

What Changes

Tracing is where you start. Evals are where it pays off. Every trace gets a score. Low scores become dataset rows. Dataset rows become regression tests. Your next release ships against real production failures.

CapabilityLangfuseConfident AI
OpenTelemetry ingestionYesOTLP over HTTP and gRPC
Auto-instrumented providersOpenAI wrapper and LangChain callbackOpenAI, Anthropic, Google GenAI, Bedrock, 5 gateways, 16 frameworks
Built-in eval metricsManaged evaluators, custom scoring50+ research-backed metrics through DeepEval
Online evals on traces, spans and threadsTraces onlyYes
Quality-aware alerting on eval scoresSlack, webhook, GitHub ActionsEmail, Slack, Discord, Teams
Prompt and use case drift detectionNoYes
Automatic dataset curation from productionManual add to datasetIngestion tasks, filtered and tagged
Multi-turn simulationNoYes
Git-based prompt managementNoBranches, PRs, approvals, eval actions
Cross-functional workflows, no codeNoPMs and QA run evals over HTTP
Regression testing and CI gatesNoYes
Safety monitoringNoToxicity, bias, PII on production traffic

Migration Questions

Do I have to upgrade Langfuse first?

No. You move straight from Langfuse SDK v1 to confident-trace. There is no need to step through Langfuse v2, v3 or v4 on the way.

Can I run both during the switch?

Yes. Langfuse v1 and confident-trace do not share a client, so both can trace the same app while you compare. Remove the Langfuse calls once you are ready to cut over.

What about my Langfuse datasets and prompts?

We import them on the migration call. Langfuse exports through its public API and scheduled blob storage export. We map the result to Confident AI datasets and prompt versions.

What about my scores?

Scores you sent with langfuse.score() do not move over as traces. Confident AI runs evals on every trace instead, with 50+ metrics through DeepEval. We can import your historical scores on the migration call.

How do I get the $200?

Book the call. After it, we apply a $200 coupon to your organization's first paid invoice. One reward per organization.

Is the TypeScript SDK ready?

The Python SDK is stable on PyPI. The TypeScript SDK is an alpha release on npm. The TypeScript snippets in this guide follow the alpha API.

Last updated on

Built byConfident AI