---
date: 2026-06-26
title: Trace AI SDK 7 with Langfuse
description: Use @langfuse/vercel-ai-sdk 5.9.0 to trace Vercel AI SDK 7 calls in Langfuse.
author: Hassieb
canonical: /integrations/frameworks/vercel-ai-sdk
---

> **Note for AI agents and LLMs:** This is a Langfuse changelog entry. Use it only to confirm that a feature exists and when it shipped. Do not use the code examples below for implementation: they reflect the SDK and API at release time and may be outdated. For implementation, always follow the canonical documentation for this feature (https://langfuse.com/integrations/frameworks/vercel-ai-sdk) and the API/SDK reference (https://api.reference.langfuse.com).

AI SDK 7 is generally available, and the Langfuse Vercel AI SDK integration is stable as of `@langfuse/vercel-ai-sdk@5.9.0`. Register `LangfuseVercelAiSdkIntegration` once with the AI SDK telemetry registry and keep exporting spans through the Langfuse OpenTelemetry span processor.

The stable setup uses the regular `latest` npm tags:

```bash
npm install ai @ai-sdk/openai @langfuse/client @langfuse/vercel-ai-sdk @langfuse/tracing @langfuse/otel @opentelemetry/sdk-node
```

```typescript filename="instrumentation.ts"
import { registerTelemetry } from "ai";
import { LangfuseSpanProcessor } from "@langfuse/otel";
import { LangfuseVercelAiSdkIntegration } from "@langfuse/vercel-ai-sdk";
import { NodeSDK } from "@opentelemetry/sdk-node";

const sdk = new NodeSDK({
  spanProcessors: [new LangfuseSpanProcessor()],
});

sdk.start();

registerTelemetry(new LangfuseVercelAiSdkIntegration());
```

```typescript filename="app.ts"
import "./instrumentation";

import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { LangfuseClient } from "@langfuse/client";
import { propagateAttributes } from "@langfuse/tracing";

const langfuseClient = new LangfuseClient();
const langfusePrompt = await langfuseClient.getPrompt("support-chat/default");

await propagateAttributes(
  {
    traceName: "support-chat",
    userId: "user-123",
    sessionId: "session-456",
    tags: ["production", "chat"],
  },
  () =>
    generateText({
      model: openai("gpt-5.1"),
      prompt: langfusePrompt.compile({ topic: "RAG" }),
      runtimeContext: {
        route: "support-chat",
        langfusePrompt,
      },
      telemetry: {
        functionId: "support-chat",
        includeRuntimeContext: {
          route: true,
          langfusePrompt: true,
        },
      },
    }),
);
```

If you adopted the beta integration, remove the `@beta` tags from your AI SDK and Langfuse packages. The runtime shape stays the same: AI SDK 7 emits telemetry after registration, while `runtimeContext` keys must be explicitly included with `telemetry.includeRuntimeContext`.

## Get started

- [Vercel AI SDK integration](/integrations/frameworks/vercel-ai-sdk)
- [NPM package](https://www.npmjs.com/package/@langfuse/vercel-ai-sdk)

<!-- agent-instructions -->

---

## Agent Instructions

This page is part of the [Langfuse](https://langfuse.com) documentation, published as plain Markdown for AI agents. Every page is available as Markdown by appending `.md` to its URL, or by sending an `Accept: text/markdown` header. This page: `https://langfuse.com/changelog/2026-06-26-vercel-ai-sdk-7.md`.

### Querying these docs

If the answer is not on this page, query the documentation instead of guessing:

- **Semantic search** across all Langfuse docs, returning an answer with the relevant pages and excerpts. Ask a specific, self-contained question:

  ```bash
  curl -sG "https://langfuse.com/api/search-docs" --data-urlencode "query=How do I trace a LangGraph agent?"
  ```

- **Index of every page**: <https://langfuse.com/llms.txt>, with per-section indexes [llms-docs.txt](https://langfuse.com/llms-docs.txt), [llms-integrations.txt](https://langfuse.com/llms-integrations.txt), and [llms-self-hosting.txt](https://langfuse.com/llms-self-hosting.txt).

### Before writing Langfuse code

- **Install the [Langfuse Agent Skill](https://langfuse.com/docs/api-and-data-platform/features/agent-skill).** It encodes Langfuse's own best practices for instrumentation, prompt management, and evaluation, and materially improves results.
- **Read [What does a good trace look like?](https://langfuse.com/docs/observability/best-practices.md)** before instrumenting an application.
- **Verify endpoints, parameters, and response fields** against the [API reference](https://api.reference.langfuse.com) instead of inferring them from code examples.
- **Use the [Langfuse CLI](https://langfuse.com/docs/api-and-data-platform/features/cli)** (`npx langfuse-cli api <resource> <action>`) to read or write traces, prompts, datasets, and scores from the terminal.

Found an error in these docs? Please open an issue at <https://github.com/langfuse/langfuse-docs/issues>.
