new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

AI SDK · Providers · all subjects

langfuse/setup

6 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Langfuse observability setup packages

Install the following packages for Langfuse observability integration: ai, @ai-sdk/openai, @langfuse/client, @langfuse/vercel-ai-sdk, @langfuse/tracing, @langfuse/otel, and @opentelemetry/sdk-node. The @langfuse/vercel-ai-sdk package targets AI SDK v7 and requires Node.js 22 or later.

Langfuse credentials configuration

Langfuse credentials can be set via environment variables LANGFUSE_SECRET_KEY, LANGFUSE_PUBLIC_KEY, and LANGFUSE_BASE_URL, or passed directly to the LangfuseSpanProcessor constructor. For EU region use https://cloud.langfuse.com; for US region use https://us.cloud.langfuse.com. Credentials are obtained by creating a project in the Langfuse dashboard after signing up for Langfuse Cloud or self-hosting.

Langfuse Node.js setup with instrumentation

For Node.js applications, add LangfuseSpanProcessor to OpenTelemetry NodeSDK spanProcessors array and register LangfuseVercelAiSdkIntegration with the AI SDK using registerTelemetry. After all AI SDK calls complete, call sdk.shutdown() to flush traces to Langfuse.

Langfuse Next.js setup with instrumentation

For Next.js applications, create or update the instrumentation.ts file. Import registerTelemetry from 'ai', create a LangfuseSpanProcessor instance, pass it to a NodeSDK spanProcessors array, call sdk.start(), and register LangfuseVercelAiSdkIntegration with registerTelemetry. For serverless routes that stream responses, flush the span processor after the response is scheduled to ensure traces are exported before the function exits.

Langfuse Node.js example with generateText

Example Node.js setup: import openai from @ai-sdk/openai, registerTelemetry and generateText from ai, LangfuseSpanProcessor from @langfuse/otel, LangfuseVercelAiSdkIntegration from @langfuse/vercel-ai-sdk, and NodeSDK from @opentelemetry/sdk-node. Create NodeSDK with spanProcessors containing LangfuseSpanProcessor, call sdk.start(), register LangfuseVercelAiSdkIntegration, call generateText with model, maxOutputTokens, prompt, and telemetry functionId, then await sdk.shutdown().

Langfuse troubleshooting requirements

Ensure Node.js 22 or later is used, use latest AI SDK package with @langfuse/vercel-ai-sdk installed, add missing runtimeContext keys to telemetry.includeRuntimeContext if values are missing in Langfuse, ensure only a single instrumentation file on Next.js, and if using Sentry, either set skipOpenTelemetrySetup: true in Sentry.init or follow Sentry's manual OTEL setup documentation.

Give your agent this brain

langfuse/setup — AI SDK · Providers