new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

AI SDK · Providers · all subjects

langsmith/setup

10 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

LangSmith does not require LangChain framework

Use of LangChain's open-source frameworks is not necessary to use LangSmith with the AI SDK.

LangSmith minimum version requirement

LangSmith version 0.3.63 or higher is required for use with the AI SDK observability guide.

LangSmith packages to install

Install @ai-sdk/openai (or another AI SDK provider) and the langsmith package from npm. Example: npm install @ai-sdk/openai langsmith

LangSmith required environment variables

Set LANGCHAIN_TRACING=true, LANGCHAIN_API_KEY=<your-api-key>, and OPENAI_API_KEY=<your-openai-api-key> (or the API key for your selected provider).

LangSmith wrapAISDK import and usage

Import wrapAISDK from 'langsmith/experimental/vercel'. Call wrapAISDK(ai) at the start of your code to wrap the AI SDK's generateText and streamText methods for tracing.

LangSmith trace logging with generateText example

Example code that traces a generateText call: ```ts import { openai } from '@ai-sdk/openai'; import * as ai from 'ai'; import { wrapAISDK } from 'langsmith/experimental/vercel'; const { generateText, streamText } = wrapAISDK(ai); await generateText({ model: openai('gpt-5-nano'), prompt: 'Write a vegetarian lasagna recipe for 4 people.', }); ``` This produces a trace visible in the LangSmith dashboard.

LangSmith trace logging with tool calls example

Example code that traces generateText with tool calls: ```ts import * as ai from 'ai'; import { tool, isStepCount } from 'ai'; import { openai } from '@ai-sdk/openai'; import { z } from 'zod'; import { wrapAISDK } from 'langsmith/experimental/vercel'; const { generateText, streamText } = wrapAISDK(ai); await generateText({ model: openai('gpt-5-nano'), messages: [ { role: 'user', content: 'What are my orders and where are they? My user ID is 123', }, ], tools: { listOrders: tool({ description: 'list all orders', inputSchema: z.object({ userId: z.string() }), execute: async ({ userId }) => `User ${userId} has the following orders: 1`, }), viewTrackingInformation: tool({ description: 'view tracking information for a specific order', inputSchema: z.object({ orderId: z.string() }), execute: async ({ orderId }) => `Here is the tracking information for ${orderId}`, }), }, stopWhen: isStepCount(5), }); ```

LangSmith traceable wrapper example

Example using traceable to wrap and group AI SDK calls: ```ts import * as ai from 'ai'; import { tool, isStepCount } from 'ai'; import { openai } from '@ai-sdk/openai'; import { z } from 'zod'; import { traceable } from 'langsmith/traceable'; import { wrapAISDK } from 'langsmith/experimental/vercel'; const { generateText, streamText } = wrapAISDK(ai); const wrapper = traceable( async (input: string) => { const { text } = await generateText({ model: openai('gpt-5-nano'), messages: [ { role: 'user', content: input, }, ], tools: { listOrders: tool({ description: 'list all orders', inputSchema: z.object({ userId: z.string() }), execute: async ({ userId }) => `User ${userId} has the following orders: 1`, }), viewTrackingInformation: tool({ description: 'view tracking information for a specific order', inputSchema: z.object({ orderId: z.string() }), execute: async ({ orderId }) => `Here is the tracking information for ${orderId}`, }), }, stopWhen: isStepCount(5), }); return text; }, { name: 'wrapper', }, ); await wrapper('What are my orders and where are they? My user ID is 123.'); ``` This groups runs together in LangSmith.

LangSmith serverless environment flushing

When tracing in serverless environments, you must wait for all runs to flush before the environment shuts down. See the LangSmith documentation for specific examples.

LangSmith supports multiple AI SDK providers

LangSmith tracing works with any AI SDK provider, not just OpenAI. The guide examples use OpenAI, but you can substitute any other supported provider.

Give your agent this brain