import { ... } from "langsmith/experimental/vercel";Wraps LangSmith config in a way that matches AI SDK provider types.
import { createLangSmithProviderOptions } from "langsmith/experimental/vercel";
import * as ai from "ai";
const lsConfig = createLangSmithProviderOptions<typeof ai.generateText>({
// Will have appropriate typing
processInputs: (inputs) => {
const { messages } = inputs;
return {
messages: messages?.map((message) => ({
...message,
content: "REDACTED",
})),
prompt: "REDACTED",
};
},
});
Note: AI SDK expects only JSON values in an object for provider options, but LangSmith's config may contain non-JSON values. These are not passed to the underlying AI SDK model, so it is safe to cast the typing here.
Creates a LangSmith Telemetry for the Vercel AI SDK.
This adapter implements the Vercel AI SDK's Telemetry interface
and maps lifecycle events to LangSmith traces. It creates a root span for
the entire generation, child LLM spans for each step, and tool spans for
tool calls.
import { generateText, registerTelemetry } from "ai";
import { LangSmithTelemetry } from "langsmith/experimental/vercel";
registerTelemetry(LangSmithTelemetry());
const result = await generateText({
model: openai("gpt-4o"),
prompt: "Hello!",
});
Only available in Vercel AI SDK 7.
Wraps Vercel AI SDK 6 or AI SDK 5 functions with LangSmith tracing capabilities.