Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.uselemma.ai/llms.txt

Use this file to discover all available pages before exploring further.

To group multi-turn conversations in Lemma, use lemma.thread_id as the canonical thread attribute across related traces. Use the same thread ID value for every turn in the same conversation. When your framework telemetry accepts OpenTelemetry-style metadata keys, set lemma.thread_id exactly. When you also set gen_ai.agent.name, use snake_case, CamelCase, or kebab-case by semantic convention, such as support_agent, SupportAgent, or support-agent.

Langfuse framework telemetry

For greenfield apps, set thread metadata where the Langfuse framework integration emits spans. For the Vercel AI SDK, that is experimental_telemetry.metadata:
import { streamText } from "ai";

await streamText({
  model: "openai/gpt-4o-mini",
  messages,
  experimental_telemetry: {
    isEnabled: true,
    functionId: "support-agent",
    metadata: {
      "gen_ai.agent.name": "planwise-support-agent",
      "lemma.thread_id": threadId,
      "session.id": sessionId,
      "user.id": userId,
    },
  },
});

Langfuse SDK propagation

Use Langfuse propagation when you create spans or wrap functions directly with the Langfuse SDK. This keeps the thread/session context attached to child observations created inside the scope.
import {
  observe,
  propagateAttributes,
} from "@langfuse/tracing";

const runSupportAgent = observe(
  async (input: {
    messages: unknown[];
    threadId: string;
    userId: string;
  }) => {
    return await propagateAttributes(
      {
        userId: input.userId,
        sessionId: input.threadId,
        metadata: {
          threadId: input.threadId,
          lemmaThreadId: input.threadId,
        },
      },
      async () => {
        // Run your framework/model call here.
      },
    );
  },
  { name: "support-agent" },
);
lemma.thread_id is the canonical Lemma key when emitted as OpenTelemetry metadata. Langfuse SDK metadata fields are useful for propagation and filtering in Langfuse; use the exact lemma.thread_id key in framework telemetry hooks that support OpenTelemetry-style metadata keys.