Langfuse JS/TS SDKs
    Preparing search index...

    Class LangfuseVercelAiSdkIntegration

    Implements

    • Telemetry
    Index

    Constructors

    Methods

    • Optionally runs the tool execute function in a telemetry-integration-specific context. This enables nested traces — e.g. when a tool's execute function calls generateText, the inner call's spans become children of the tool span.

      Type Parameters

      • T

      Parameters

      • __namedParameters: { callId: string; execute: () => PromiseLike<T>; toolCallId: string }

      Returns PromiseLike<T>

    • Called for each chunk received during streaming. Only relevant for streamText — not called during generateText.

      Parameters

      • event: OnChunkEvent<ToolSet>

      Returns void

    • Called when an individual embedding model call (doEmbed) completes. Contains the embeddings, usage, and any warnings from the model response.

      Parameters

      • event: EmbedFinishEvent

      Returns void

    • Called when an individual embedding model call (doEmbed) begins. For embed, there is one call. For embedMany, there may be multiple calls when values are chunked.

      Parameters

      • event: EmbedStartEvent

      Returns void

    • Called when an unrecoverable error occurs during the generation lifecycle. The error value is untyped — it may be an Error instance, an AISDKError, or any thrown value.

      Use this to record error details on telemetry spans and set error status.

      Parameters

      • error: unknown

      Returns void

    • Called when an operation completes. Fired for text generation (generateText/streamText), object generation (generateObject/streamObject), embedding (embed/embedMany), and reranking operations.

      Use the event shape or operationId to distinguish between operation types.

      Parameters

      • event:
            | ObjectOnFinishEvent<unknown>
            | EmbedOnFinishEvent
            | RerankOnFinishEvent
            | OnFinishEvent<ToolSet>

      Returns void

    • Parameters

      • event: ObjectOnStepFinishEvent

      Returns void

    • Parameters

      • event: ObjectOnStepStartEvent

      Returns void

    • Called when an individual reranking model call (doRerank) completes. Contains the ranking results from the model response.

      Parameters

      • event: RerankFinishEvent

      Returns void

    • Called when an individual reranking model call (doRerank) begins. There is one call per rerank invocation.

      Parameters

      • event: RerankStartEvent

      Returns void

    • Called when an operation begins. Fired for text generation (generateText/streamText), object generation (generateObject/streamObject), embedding (embed/embedMany), and reranking operations.

      Use the operationId field to distinguish between operation types.

      Parameters

      • event:
            | ObjectOnStartEvent
            | EmbedOnStartEvent
            | RerankOnStartEvent
            | OnStartEvent<ToolSet, Context, Output<any, any, any>>

      Returns void

    • Called when an individual step (single LLM invocation) completes. The event is a StepResult containing the model's response, tool calls and results, usage statistics, finish reason, and optional request/response bodies.

      Parameters

      • event: OnStepFinishEvent<ToolSet>

      Returns void

    • Called when an individual step (single LLM invocation) begins. A generation may consist of multiple steps (e.g. when tool calls trigger follow-up LLM calls). Use this to create per-step spans or record step-level inputs.

      The event includes the step number, accumulated previous step results, and the messages that will be sent to the model.

      Parameters

      • event: StepStartEventWithPrompt

      Returns void

    • Parameters

      • event: ToolExecutionEndEvent<ToolSet>

      Returns void

    • Parameters

      • event: ToolExecutionStartEvent<ToolSet>

      Returns void

    • Called when a tool execution completes, either successfully or with an error. The event uses a discriminated union on the success field — check event.success to determine whether output or error is available.

      The event includes execution duration (durationMs) for performance tracking.

      Parameters

      • event: ToolExecutionEndEvent<ToolSet>

      Returns void

    • Called when a tool execution begins, before the tool's execute function is invoked. Use this to create tool-level spans or log tool invocations.

      Parameters

      • event: ToolExecutionStartEvent<ToolSet>

      Returns void