The AI SDK gives applications one interface for switching between language models and providers.
2
Tools, maxSteps, and structured outputs let a model choose actions, process their results, and return type-safe data.
3
A deep research workflow can recursively generate queries, search with Exa, reject weak or duplicate sources, extract learnings, and produce a Markdown report.
Summary
Nico Albanese introduces the Vercel AI SDK through three building blocks: text generation, tool calling, and structured outputs. He shows how the unified provider interface lets a Node.js application switch models by changing one line, then explains how maxSteps creates a multi-step agent that can call tools, receive results, and continue until it produces text. The workshop then builds a deep research clone for a query about becoming a Division I shot put athlete. The workflow generates search queries, searches the web with Exa, evaluates source relevance, extracts learnings and follow-up questions, and recursively explores those questions while tracking accumulated research. A final reasoning model turns the collected material into a Markdown report. The implementation uses TypeScript, Zod schemas, and local state to reduce repeated content in model calls. Albanese is direct about the need to control prompts, context size, recursion depth, and breadth.
The unified model interface makes provider changes a one-line edit
Nico begins with generateText, using OpenAI's GPT-4o mini and a simple "hello world" prompt. The same function accepts either a prompt or an array of role-and-content messages. The AI SDK's unified interface means the application can switch providers by changing the model value. He demonstrates this with a question about the 2025 AI Engineer Summit. GPT-4o mini cannot answer because it has no web access and its training cutoff is in 2024. He then switches to Perplexity Sonar Pro, which returns the February 19 to February 22 dates and New York location, along with sources accessible through the result's sources property. He also shows Google Gemini 1.5 Flash with search grounding.
Tools let a model request actions while the application runs the code
Tools expose a name, description, parameters, and an execute function. The description helps the model decide when to use the tool, while the parameters describe the data it must extract from the conversation. In the first example, the model calls an addNumbers tool for "What's 10 + 5?" The AI SDK parses the call, invokes the asynchronous JavaScript execute function, and returns the arguments and result in tool results. At that point the model has generated a tool call instead of an answer, so result.text is empty. The developer can either handle the result manually or let the SDK manage the next generation.
maxSteps creates a multi-step agent without hand-written routing
Nico describes maxSteps as a limit on repeated model generations. When a model produces a tool call and receives a tool result, the SDK sends that result back with the earlier conversation context. The model then chooses whether to call another tool or produce plain text. With addNumbers, the first step calls the tool and the second step returns "10 + 5 equals 15." A second example adds getWeather, which fetches weather data from latitude and longitude. The model infers those coordinates from its training data after receiving city names, calls getWeather for San Francisco and New York in parallel, calls addNumbers on the two temperatures, and then writes the final response. Nico says this inference pattern is useful in some cases but should not be copied directly into production.
Structured outputs turn model responses into validated TypeScript data
The SDK supports structured output through the experimental output option on generateText and through generateObject, which Nico calls his favorite AI SDK function. Using Zod, the developer defines the expected shape, such as an object with a numeric sum field. The SDK then returns a type-safe object and throws an error if the output does not match the schema. generateObject can also return arrays of strings, as in the example that asks for 10 definitions of AI agents. Zod's describe method adds instructions to individual fields. Nico uses it to ask for definitions containing as much jargon as possible, showing how schema descriptions can guide the model without putting every instruction into the main prompt.
Deep research is a workflow made from smaller model calls
The practical project is a Node.js terminal program that accepts a research prompt and writes a report to the file system. The workflow starts by generating several subqueries from the original question. For each subquery, it searches the web, checks whether the result is relevant, extracts a learning and follow-up questions, and can repeat the process at greater depth. Nico explains breadth as the number of inquiry branches at each level and depth as the number of levels to explore. For an electric-car example, branches might cover vehicle specifications, charging infrastructure, and battery technology. The design combines ordinary functions such as generateObject with an autonomous loop that decides when to search again.
The search-and-evaluate loop uses tool feedback to recover from poor results
The searchAndProcess function gives a model two tools: one searches the web and the other evaluates the latest result. Search results go into a local pending array and are also returned to the conversation. The evaluate tool reads the latest pending result and uses generateObject in enum mode to classify it as either relevant or irrelevant. If it is irrelevant, the tool returns "Search results are irrelevant, please search again with a more specific query." On the next step, the model sees that feedback and can issue a better search. Nico keeps the actual long result in local state instead of asking the model to reproduce it as tool arguments. That avoids extra tokens, time, and possible copying errors.
Recursive research needs explicit state and limits
Once relevant pages produce learnings and follow-up questions, the workflow needs to research those questions too. Nico moves the main logic into a deepResearch function and introduces shared research state. The state stores the original query, active queries, search results, learnings, and completed queries. Each recursion builds a new prompt from the overall goal, earlier searches, and follow-up questions, then calls deepResearch again with reduced depth and breadth. The function returns when depth reaches zero, which prevents an endless loop and limits API usage and waiting time. The evaluator also receives previously used URLs and marks a repeated page as irrelevant, so the same source does not consume context repeatedly.
A final model needs a precise report specification
The collected research is passed to generateReport, which uses OpenAI o3-mini to synthesize a report. Nico first tries a general prompt and gets a useful result, but the model has to infer the desired format. He then adds a system prompt that gives the model an expert researcher persona, supplies the date, requires Markdown, and explains how to handle speculation and prediction. The second report is more structured and includes headings and date information. Nico says the complete workflow fits in 218 lines of code. The example report covers Division I shot put recruiting, training, technique, and beginner mistakes, but the implementation is meant as a compact demonstration of combining search, evaluation, recursion, structured outputs, and final synthesis.
"This is quite a simple but powerful way to allow the model to keep running autonomously picking the next step in the process."12:11
Who should watch
You are building a TypeScript or Node.js application that needs to switch between model providers without rewriting its model calls.
You need a practical pattern for giving language models tools, handling multi-step execution, and returning validated objects.
You want to understand how a deep research feature can be decomposed into query generation, web search, source evaluation, recursive follow-up, and report synthesis.