> ## Documentation Index
> Fetch the complete documentation index at: https://aivision.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Read the relevant procedure and prerequisites before suggesting commands. Cite the section and give an observable check. Treat sample data as illustrative. Report product actions and results only when verified in the user's environment.

# Langfuse setup and historical records

> Verify Langfuse SDK collection with a local Python or Node.js 22 example, without a model key. Read historical records from a connected external Langfuse project.

If your app already records model or tool calls through Langfuse, choose which records to read.

| What you want to do | Where to start |
| - | - |
| **Record the next request with your existing instrumentation** | [Keep the existing instrumentation](#existing-langfuse) and use your AI Vision project's endpoint and credentials. Send one request in a test environment and check its Trace ID. |
| **Read existing records in a Langfuse project** | If your platform is already connected to that project, [select the external data source and time range](#external-langfuse). |
| **Try collection before adding instrumentation** | [Get connection settings](#langfuse-connection) and choose the local Python or JavaScript / TypeScript example. It needs no model key. For Go, use the [Eino integration](https://aivision.mintlify.site/en/integrations/frameworks.md#eino). |

Instrumentation is application code that records operations, for example a tool's arguments, duration, and output. New examples use Python 3.11+ or Node.js 22+ and require no Langfuse Cloud account, aiv CLI, or model key. For an existing app, keep a compatible runtime and check the [validated SDK versions](#compatibility). AI Vision provides the account and credentials for native collection.

## 1. Get connection settings for your application

In the target space, open **Agent Access → Agent Market → Custom Agent integrations** and choose **Via Langfuse SDK**:

1. Choose your runtime language. For Node.js, select **JavaScript / TypeScript → Manual instrumentation**. For the minimal Python example, use **Python → Already using Langfuse tracing** to view connection settings. Here this option only supplies credentials: section 2 provides the complete code, so prior instrumentation is not required.
2. Use **Select project** to choose the project for your application. To create one, enter a name and click **Create project**.
3. In **Environment variables**, click **Get credentials**, then copy the connection settings for the selected project.

An existing Key may show only its prefix and a `••••` mask. The mask cannot run the example. Obtain complete credentials, or ask the space administrator for authorized settings if you cannot generate them.

Replace the example URL and both placeholders with the values from that page. Set them in the terminal where you will run the application:

```bash theme={null}
export LANGFUSE_BASE_URL="https://vision.example.com"
export LANGFUSE_PUBLIC_KEY="<AGENT_UUID>"
export LANGFUSE_SECRET_KEY="<SPACE_KEY>"
```

`LANGFUSE_PUBLIC_KEY` is this application's Agent UUID, and `LANGFUSE_SECRET_KEY` is its SpaceKey. They are not your sign-in credentials or a model provider's API key. Keep real values out of source control.

**Checkpoint:** all three values belong to the same application and space, and the application machine can reach the URL.

The screenshot shows the product connection page with demonstration projects and credentials. It does not prove a successful integration. Select a project and obtain complete credentials in your own space.

[![Project selection, environment variables and credentials on the Python Langfuse integration page](https://mintcdn.com/aivision/HGaGiOq1xpqDNh4a/assets/figures/onboarding-langfuse-python.en.light.jpg?fit=max\&auto=format\&n=HGaGiOq1xpqDNh4a\&q=85\&s=d5bcb3cb8aaf1f8d202491a388168b59)](https://aivision.mintlify.site/assets/figures/onboarding-langfuse-python.en.light.jpg)

[![Project selection, environment variables and credentials on the Python Langfuse integration page](https://mintcdn.com/aivision/HGaGiOq1xpqDNh4a/assets/figures/onboarding-langfuse-python.en.dark.jpg?fit=max\&auto=format\&n=HGaGiOq1xpqDNh4a\&q=85\&s=2e9b4ba257361ec9a398ae7abb3a41c7)](https://aivision.mintlify.site/assets/figures/onboarding-langfuse-python.en.dark.jpg)

Langfuse Python: select a project and obtain connection credentials · Demo data · Click to enlarge

### Existing Langfuse instrumentation

1. In your target space's Langfuse onboarding page, select **Already using Langfuse tracing**. Get the three settings for the application. `LANGFUSE_BASE_URL` is the AI Vision base URL, `LANGFUSE_PUBLIC_KEY` is the project's Agent UUID, and `LANGFUSE_SECRET_KEY` is the SpaceKey. Check [SDK compatibility](#compatibility) before changing the collection settings in a test environment. Use input approved for export.
2. Check the export protocol. `/api/public/otel/v1/traces` accepts **OTLP HTTP/protobuf**. With the validated JS SDK 5 or 6, configure a protobuf exporter for your existing `LangfuseSpanProcessor`. Choose **JavaScript / TypeScript** in the [minimal example](#sdk-examples) to see the endpoint and authentication.
3. Restart the test process and send a request with a known tool or model call. Record the Trace ID, then [verify the Trace in AI Vision](#langfuse-readback). Match the call name, input, and output. AI Vision stores the data in its native pipeline. Choose **SigNoz** if the list shows a source selector.

The exporter destination applies to subsequent requests using these settings. Historical records remain in the original Langfuse project. Evaluate migration options separately for prompts, experiments, and other historical data.

For an SDK, select what to export in the application's instrumentation. Plugin Privacy mode applies to the plugin that uses it. Keep the full SpaceKey in the application configuration and share only redacted export errors.

## 2. Choose a language and run your first record

Complete only one of the following language tabs. The commands use Bash/zsh syntax. Keep the three `LANGFUSE_*` environment variables from section 1 in your terminal. Both programs record local operations without model calls or model charges.

Choose **JavaScript / TypeScript** on Node.js 22 to run a local tool. After reading back this Trace, check the output of `normalize-input`.

> [tab] Python
>
> This generic manual Span example checks whether a record reaches the platform. A Span represents one operation. The example uses Python 3.11+ and Langfuse **5.x**, with **5.0.2** as the verified SDK baseline. These versions are for a new tutorial environment. Existing compatible SDKs do not need an upgrade to connect; collection with Python SDK 3.15.0 / 4.16.0 is also verified, as listed in the compatibility table below. If your interpreter is called `python3`, replace `python` in both installation and execution commands. LangChain, LangGraph, Deep Agents and OpenAI use their integration-page dependencies; other frameworks, including Google ADK, retain their own version requirements.
>
> ```bash theme={null}
> python --version
> mkdir aivision-langfuse-python
> cd aivision-langfuse-python
> python -m venv .venv
> source .venv/bin/activate
> python -m pip install "langfuse>=5.0.2,<6"
> ```
>
> Save this code as `example.py`:
>
> ```python theme={null}
> from langfuse import get_client
>
> langfuse = get_client()
> try:
>     with langfuse.start_as_current_observation(
>         as_type="span", name="sdk-connection-check"
>     ) as span:
>         span.update(input={"message": "hello AI Vision"})
>         span.update(output={"message": "connection check complete"})
>         print("AI Vision trace_id:", langfuse.get_current_trace_id())
> finally:
>     langfuse.flush()
>     langfuse.shutdown()
> ```
>
> In the directory containing the file, run it from the same terminal where you set the environment variables:
>
> ```bash theme={null}
> python example.py
> ```
>
> The terminal should print `AI Vision trace_id: ...`. The `finally` block flushes pending records and shuts down the client before the short-lived process exits. Continue to section 3 to read the record back from the platform.

> [tab] JavaScript / TypeScript
>
> Choose **Manual instrumentation** after the framework options for custom applications, unlisted frameworks, or additional business steps. It uses the Langfuse SDK to record only operations you explicitly instrument.
>
> This example uses **Node.js 22+**. The commands create a separate directory and install **Langfuse JS 6.0.0** to provide a consistent tutorial environment. Version 6.0.0 is not the minimum version for connecting: collection with **JS 5.14.0** is also verified, so existing users do not need an upgrade to connect. The example runs as TypeScript through `tsx`, with no TypeScript build configuration required. JavaScript services can use the same SDK APIs.
>
> ```bash theme={null}
> node --version
> mkdir aivision-langfuse-js
> cd aivision-langfuse-js
> npm init -y
> npm install "@langfuse/tracing@6.0.0" "@langfuse/otel@6.0.0" "@opentelemetry/sdk-node@~0.223.0" "@opentelemetry/exporter-trace-otlp-proto@~0.223.0" "@opentelemetry/otlp-exporter-base@~0.223.0" "dotenv@^17" "tsx@^4"
> ```
>
> On the integration page, select **JavaScript / TypeScript → Manual instrumentation → Run a complete example**, click **Download example**, and move `test_manual_js.ts` into the directory you just created. Alternatively, save the identical code below with that filename. The **Add to existing code** tab contains application variables and is not a standalone program.
>
> [![JavaScript TypeScript Langfuse integration page with manual instrumentation after the framework options, a Node.js logo, and guidance on when to use it](https://mintcdn.com/aivision/q2R_nkNhmIVwikZM/assets/figures/onboarding-langfuse-js.en.light.jpg?fit=max\&auto=format\&n=q2R_nkNhmIVwikZM\&q=85\&s=4d5e179b1c1af73a364399be608f5f51)](https://aivision.mintlify.site/assets/figures/onboarding-langfuse-js.en.light.jpg)
>
> [![JavaScript TypeScript Langfuse integration page with manual instrumentation after the framework options, a Node.js logo, and guidance on when to use it](https://mintcdn.com/aivision/q2R_nkNhmIVwikZM/assets/figures/onboarding-langfuse-js.en.dark.jpg?fit=max\&auto=format\&n=q2R_nkNhmIVwikZM\&q=85\&s=346a618665f39654487cead0fd01badc)](https://aivision.mintlify.site/assets/figures/onboarding-langfuse-js.en.dark.jpg)
>
> Langfuse JavaScript / TypeScript: manual instrumentation option and guidance · Demo data · Click to enlarge
>
> The screenshot illustrates the page layout. Use the SDK versions and protobuf exporter in the commands and code below.
>
> ```typescript theme={null}
> import "dotenv/config";
> import { NodeSDK } from "@opentelemetry/sdk-node";
> import { LangfuseSpanProcessor } from "@langfuse/otel";
> import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
> import { CompressionAlgorithm } from "@opentelemetry/otlp-exporter-base";
> import {
>   getActiveTraceId,
>   propagateAttributes,
>   startActiveObservation,
> } from "@langfuse/tracing";
> import { randomUUID } from "node:crypto";
>
> // Start once, before the first instrumented request.
> // If your service already has an OpenTelemetry SDK, add this processor there.
> // AI Vision's ingest endpoint accepts OTLP HTTP/protobuf.
> // Langfuse's default JS exporter uses JSON, so configure protobuf explicitly.
> const exporter = new OTLPTraceExporter({
>   url: `${process.env.LANGFUSE_BASE_URL?.replace(/\/$/, "")}/api/public/otel/v1/traces`,
>   headers: {
>     Authorization: `Basic ${Buffer.from(`${process.env.LANGFUSE_PUBLIC_KEY}:${process.env.LANGFUSE_SECRET_KEY}`).toString("base64")}`,
>   },
>   compression: process.env.LANGFUSE_OTEL_COMPRESSION === "none"
>     ? CompressionAlgorithm.NONE : CompressionAlgorithm.GZIP,
> });
> const processor = new LangfuseSpanProcessor({ exporter });
> const sdk = new NodeSDK({ spanProcessors: [processor] });
> sdk.start();
>
> async function main() {
>   try {
>     const input = { text: "Hello from my agent" };
>     await propagateAttributes(
>       { sessionId: randomUUID(), tags: ["integration:manual"] },
>       () => startActiveObservation("custom-agent-onboarding", async (request) => {
>         request.update({ input });
>         console.log("AI Vision trace_id:", getActiveTraceId());
>         const output = await startActiveObservation("normalize-input", async (step) => {
>           const normalized = input.text.trim().toLowerCase();
>           step.update({ input: input.text, output: normalized });
>           return normalized;
>         }, { asType: "tool" });
>         request.update({ output });
>         console.log(output);
>       }, { asType: "agent" }),
>     );
>   } finally {
>     // Short script: export completed spans even if the request fails.
>     // In a service, shut down only after all active requests have finished.
>     await sdk.shutdown();
>   }
> }
>
> main().catch((error) => {
>   console.error(error);
>   process.exitCode = 1;
> });
> ```
>
> If you copied the `.env` format from the page, save the three connection settings in `.env` in this directory; `dotenv/config` loads them. Downloading the `.ts` file alone does not supply credentials. Existing terminal variables override `.env`, so update them too when switching projects.
>
> Run it from that directory:
>
> ```bash theme={null}
> npx tsx test_manual_js.ts
> ```
>
> The terminal should print `AI Vision trace_id: ...` and `hello from my agent`. The program creates a `custom-agent-onboarding` root record and a `normalize-input` tool node, then waits for export through `sdk.shutdown()`. Verify this run in section 3; a successful process exit does not confirm delivery.
>
> Run this code on the server. Keep SpaceKey and `LANGFUSE_SECRET_KEY` out of browser bundles.

## 3. Verify this Trace in AI Vision

1. Copy this run's `trace_id` from the terminal. Select the same space and project on the Langfuse integration page.
2. In **Verify this request**, enter the ID in **Trace ID for this request**. Enter an independently known expected Span count if available, then select **Verify this Trace**.
3. Check the unique Span count, storage count, completeness, parent relationships, and usage. Use the [shared verification guide](https://aivision.mintlify.site/en/integrations/frameworks.md#verify-ingestion) for partial or unknown results and affected Span IDs. Select **Open this Trace**. For an existing integration, find the tool or model call you triggered. For a starter example, check the following values.

| Example | Node | Expected contents |
| - | - | - |
| Python | `sdk-connection-check` | Input `hello AI Vision`, output `connection check complete` |
| JavaScript / TypeScript | `custom-agent-onboarding` → `normalize-input` | Input `Hello from my agent`, output `hello from my agent` |

**Completion check:** you can read this run's Trace in the selected project and match its input and output. Neither starter calls a model: when the backend confirms there are no billable calls, usage coverage is **not applicable**. Missing evidence is **unknown**, not zero consumption. Reading all stored Spans checks transport and readback; it does not establish complete application instrumentation.

The connected label or historical Trace count cannot verify this run. If the record is missing, inspect SDK export logs. For connection errors, check that the application machine can reach the URL. For authentication errors, check complete credentials, space, and project; a masked key cannot authenticate. Refresh a time range covering this run, then follow [No data troubleshooting](https://aivision.mintlify.site/en/help/no-data.md) if needed.

[![From connection details to a Trace](https://mintcdn.com/aivision/coKTz7l1X0d3dZJw/assets/diagrams/sdk-first-trace.en.light.svg?fit=max\&auto=format\&n=coKTz7l1X0d3dZJw\&q=85\&s=21334a9e4c1d8332c9cbb1f873b42d2b)](https://aivision.mintlify.site/assets/diagrams/sdk-first-trace.en.light.svg)

[![From connection details to a Trace](https://mintcdn.com/aivision/coKTz7l1X0d3dZJw/assets/diagrams/sdk-first-trace.en.dark.svg?fit=max\&auto=format\&n=coKTz7l1X0d3dZJw\&q=85\&s=a48f3ee1c2edb82c94abaade26675fde)](https://aivision.mintlify.site/assets/diagrams/sdk-first-trace.en.dark.svg)

From connection details to a Trace · Concept diagram · Open full-size SVG

The name, input, and output in this diagram match the minimal Python example. After verifying your first record, instrument a real application request.

## 4. Instrument your application

### No existing Langfuse instrumentation

Return to the integration page and choose your language and framework. Node.js offers **LangChain**, **LangGraph**, **OpenAI**, and **Manual instrumentation**. Use that example's installation command. Choose **Add to existing code** to instrument your business code, or **Run a complete example** for a standalone program.

Complete framework and OpenAI examples need a model provider's API key, model name, and endpoint. These come from the provider and are separate from the three AI Vision `LANGFUSE_*` settings. Model connections configured in AI Vision for diagnosis are not automatically passed to your Agent. The manual instrumentation starter needs no model configuration; configure actual model calls in your application when you add them.

For Node.js, initialize OpenTelemetry once at service startup. If an SDK already exists, add the Langfuse processor to it. Use a callback, wrapper, or manual observation around actual model and tool operations. Keep the shared SDK alive between requests and close it only after all requests finish at service shutdown. Installing dependencies and setting environment variables alone does not record internal application calls.

The **OpenAI** JavaScript starter remains a non-streaming Chat Completions example. For text streaming, use the [public lifecycle API example](https://github.com/ob-labs/ai-vision-ob/blob/main/ai-vision/agent-plugins/langfuse/examples/openai-streaming-js.ts), which preserves completed records on cancellation or early exit. Keep the shared SDK alive until all requests finish, and do not instrument the same request twice.

Official references: [JS/TS SDK](https://langfuse.com/docs/observability/sdk/overview), [LangChain / LangGraph](https://langfuse.com/integrations/frameworks/langchain), and [OpenAI JS](https://langfuse.com/integrations/model-providers/openai-js). Official pages may show newer major versions. For a new example environment, use the installation commands here or on the relevant framework integration page. For an existing application, check its dependencies against the verified scope below; an upgrade solely to connect is unnecessary.

## View historical records from external Langfuse

In the original Langfuse project, note one record's Trace ID and timestamp. In **Agent traces** in AI Vision, choose the space and Agent that can query that external project, then set a time range covering the request. When **SigNoz / Langfuse** appears, select **Langfuse**. Search for the Trace ID and compare a tool or model call. When there is one source, the selector is omitted. If the record is missing, ask an administrator to verify the Agent is bound to the original project, then check the time range.

| In Langfuse | What to check in AI Vision |
| - | - |
| Trace | Open the request by the same Trace ID. |
| Observation, such as a Generation or tool call | Expand the call hierarchy, select the matching node, and compare the reported name, input, output, and duration. |
| Session | If a Session ID was reported, find it in [Sessions](https://aivision.mintlify.site/en/guides/sessions.md), then open a turn's Trace. |

To investigate new requests, [send them to native ingestion](#existing-langfuse). For a tool failure, open the new Trace and [run a rule diagnosis](https://aivision.mintlify.site/en/guides/diagnosis.md). To see what changed, [compare two Traces](https://aivision.mintlify.site/en/guides/trace-compare.md) from the native list. External Langfuse records are available for queries. Rule diagnosis and Trace comparison use native records. See the [official Langfuse data model](https://langfuse.com/docs/observability/data-model) for its object definitions.

## Compatibility

The official Langfuse integration catalog and AI Vision validation have separate scopes. Environment variables configure the connection; frameworks still need their callback, wrapper, or exporter. “Already using Langfuse tracing” does not mean every custom framework is verified. See [Custom Agent integrations](https://aivision.mintlify.site/en/integrations/frameworks.md) if you are still choosing collection.

AI Vision supports collection with the verified older and newer SDK versions below, using the same collection endpoint. Existing compatible SDKs do not need an upgrade to connect. Retain the instrumentation APIs and dependencies for your installed version instead of copying newer SDK examples verbatim. The table records specific verified baselines; it does not establish validation of every release in a major series or every framework combination.

| SDK | Verified and supported collection versions | New environment example on this page |
| - | - | - |
| Python | 3.15.0, 4.16.0, 5.0.2 | 5.x, installation range `>=5.0.2,<6`, verified baseline 5.0.2 |
| JavaScript / TypeScript | 5.14.0, 6.0.0 | Pinned to 6.0.0, with Node.js 22+ |

This page uses Python SDK 5 / JS SDK 6 to provide a consistent set of steps for reproducing the integration; these example versions are not minimum connection requirements. Each framework retains its own dependency constraints, including Google ADK. AI Vision accepts OTLP HTTP/protobuf. The verified JS 5.14.0 / 6.0.0 integrations require an explicit protobuf exporter because the default JS JSON exporter is not supported.

Collection SDK versions and query API versions have separate compatibility scopes. AI Vision supports the v1 compatibility query endpoints for Trace, Observation and Session. Here v1 / v2 refer to query API versions, independently of SDK major versions; this does not imply support for every Langfuse v1 API. Python SDK4 reads Observation v1 through `api.legacy.observations_v1`. Langfuse v2 queries are not yet supported.

Data collected with Python SDK 5 / JS SDK 6 can be queried through AI Vision's pages, native API or CLI. Python SDK5 removed SDK4's legacy read methods, so `api.legacy.observations_v1` cannot be reused in SDK5. The collection validation above does not establish validation of JS 5 / JS 6 query clients. Prompt management, offline experiments and historical data migration require separate assessment. Application plugin Privacy mode does not automatically filter SDK exports; control content in your instrumentation.

SpaceKeys are credentials. Keep their actual values out of public documentation and source code.

[Langfuse SDK documentation](https://langfuse.com/docs/observability/sdk/overview)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.