vercelAI() when your app calls generateText, streamText, or an AI SDK agent. The integration supports AI SDK v7 and v6. It records model calls as Lemma generations and tool executions as Lemma tool calls.
Install
AI SDK v7
Wrap one agent execution inlemma.trace(), then pass vercelAI() to the AI SDK telemetry.integrations option.
AI SDK v6
For AI SDK v6, pass the same helper throughexperimental_telemetry.integrations.
Streaming
Use the same integration withstreamText. When you pass a trace handle, vercelAI({ trace }) ends it from the AI SDK terminal callback: onEnd in AI SDK v7 and onFinish in AI SDK v6.
What Lemma records
| AI SDK event | Lemma record |
|---|---|
| Model call | Generation with model, provider, messages, output text, token usage, and duration |
| Tool execution | Tool call with name, input, output or error, and duration |
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.