vercelAI() when your app calls generateText, streamText, or an AI SDK agent. The integration supports AI SDK v7 and v6. It creates one Lemma trace for each AI SDK run, extracts the prompt or messages as trace input, and records model calls and tool executions as child spans.
Install
AI SDK v7
Create the Lemma telemetry integration once, then pass it to the AI SDKtelemetry.integrations option. Use telemetry.functionId for the agent name.
AI SDK v6
For AI SDK v6, pass the same helper throughexperimental_telemetry.integrations. Use experimental_telemetry.functionId for the agent name.
Streaming
Use the same integration withstreamText.
What Lemma records
| AI SDK event | Lemma record |
|---|---|
| Model call | Generation with model, provider, messages, output text, and duration |
| Tool execution | Tool call with name, input, output or error, and duration |
telemetry.functionId / experimental_telemetry.functionId for the agent name, or set it on the integration with vercelAI({ agentName: "support-agent" }).
For advanced cases, you can still attach to an existing trace by passing vercelAI({ trace }) or by calling AI SDK inside a lemma.trace() callback. If you use the callback form of lemma.trace(), the callback owns trace closure. If you pass a trace handle to vercelAI({ trace }), the integration closes it automatically at the end of the AI SDK operation.
Use recordInputs: false or recordOutputs: false to avoid sending prompts, tool inputs, tool outputs, or model output text.