AI SDK 4.0 brings PDF handling, computer use, and Grok support

The AI SDK, an open-source toolkit for AI application development in JavaScript and TypeScript, has released version 4.0. The update focuses on document processing, agentic capabilities, and model provider expansion, building on the ecosystem that has powered production deployments like Val Town's Townie assistant and Chatbase's customer support platform.

Here's what changed and what it means for developers building with the SDK and frameworks like Next.js and Svelte.

Native PDF processing for three major providers

PDF documents remain the standard format for contracts, research papers, and technical reports, making them a critical input for AI workflows. AI SDK 4.0 adds first-class PDF file handling to three providers: Anthropic, Google Generative AI, and Google Vertex AI.

PDFs are treated as a standard content type within the unified API, so integrating them into prompts is straightforward. You can pass the file directly in message content without additional parsing infrastructure:

import { generateText } from 'ai';

import { anthropic } from '@ai-sdk/anthropic';

const result = await generateText({

model: anthropic('claude-3-5-sonnet-20241022'),

messages: [

{

role: 'user',

content: [

{

type: 'text',

text: 'What is an embedding model according to this document?',

},

{

type: 'file',

data: fs.readFileSync('./data/ai.pdf'),

mimeType: 'application/pdf',

},

],

},

],

});

Because provider support sits behind a shared interface, switching from Anthropic to Google or Vertex AI only requires changing the model string. The SDK handles the provider-specific file formatting. PDFs work with any compatible model for text extraction, summarization, and document-based question answering.

Anthropic computer use tools for system control

Version 4.0 enables Anthropic computer use scenarios with Claude Sonnet 3.5. The SDK exposes three predefined tools that cover common system interaction patterns: the Computer Tool (mouse, keyboard, screenshots), the Text Editor Tool (file manipulation), and the Bash Tool (terminal commands).

Anthropic defines each tool's interface, but the execution logic is yours to implement. Every tool requires an execute function that maps SDK actions to your specific runtime environment, such as moving a mouse on your operating system or running commands in a container:

import { generateText } from 'ai';

import { anthropic } from '@ai-sdk/anthropic';

import { executeComputerAction, getScreenshot } from '@/lib/ai'; // user-defined

const computerTool = anthropic.tools.computer_20241022({

displayWidthPx: 1920,

displayHeightPx: 1080,

execute: async ({ action, coordinate, text }) => {

switch (action) {

case 'screenshot': {

return {

type: 'image',

data: getScreenshot(),

};

}

default: {

return executeComputerAction(action, coordinate, text);

}

}

},

experimental_toToolResultContent: (result) => {

return typeof result === 'string'

? [{ type: 'text', text: result }]

: [{ type: 'image', data: result.data, mimeType: 'image/png' }];

},

});

const result = await generateText({

model: anthropic('claude-3-5-sonnet-20241022'),

prompt: 'Move the cursor to the center of the screen and take a screenshot',

tools: { computer: computerTool },

});

These tools integrate with the SDK's maxSteps mechanism, which allows the model to chain multiple tool calls in sequence. In practice, this enables agentic workflows where Claude interprets a screen, decides on an action, performs it, and evaluates the result without manual intervention:

const result = await generateText({

model: anthropic('claude-3-5-sonnet-20241022'),

prompt: 'Summarize the AI news from this week.',

tools: { computer: computerTool, textEditor: textEditorTool, bash: bashTool },

maxSteps: 10,

});

The Anthropic computer use implementation is currently in beta. Vercel advises developers to run it in isolated environments with virtual machines and to limit any access to sensitive data.

Bypassing model output limits

Language models can consume large context windows but are constrained in what they can produce in one generation call. When a model hits that ceiling, it returns a finish reason of length.

The prompt engineering template above relies on this. AI SDK 4.0's continuation support now detects that state by setting the experimental_continueSteps flag on either generateText or streamText, and it automatically re-engages the model to complete the generation, producing one coherent output from successive requests. It also tracks combined token usage across the steps so you don't lose cost visibility.

import { generateText } from 'ai';

import { openai } from '@ai-sdk/openai';

const result = await generateText({

model: openai('gpt-4o'),

maxSteps: 5,

experimental_continueSteps: true,

prompt:

'Write a book about Roman history, ' +

'from the founding of the city of Rome ' +

'to the fall of the Western Roman Empire. ' +

'Each chapter MUST HAVE at least 1000 words.',

});

For streaming responses, the SDK forces clean word boundaries so partial tokens never hit the wire. Developers may also notice some trailing tokens trimmed from individual steps to avoid whitespace artifacts.

A first-party xAI Grok provider

The xAI Grok model now has an official, first-party provider in the AI SDK. Previously, developers used a generic OpenAI-compatible shim.

To begin with the xAI provider:

pnpm install ai @ai-sdk/xai

It works with the full range of AI SDK Core methods. A typical generateText call looks like this:

import { xai } from '@ai-sdk/xai';

import { generateText } from 'ai';

const { text } = await generateText({

model: xai('grok-beta'),

prompt: 'Write a vegetarian lasagna recipe for 4 people.',

});

Documentation is available in the official xAI provider guide.

Expanded provider roster

The 4.0 release includes several partner-level updates:

  • Cohere: v2 support with added tool calling
  • OpenAI: predicted outputs and prompt caching support
  • Google Generative AI & Vertex AI: file inputs, fine-tuned models, schema support, tool choice, frequency penalty. Vertex AI also adds text embedding models.
  • Amazon Bedrock: first-class support for Amazon Titan embedding models
  • Groq: first-party provider, replacing the previous OpenAI-compatible fallback
  • xAI: first-party Grok provider as noted above
  • LM Studio, Baseten, Together AI: new SDK-maintained OpenAI-compatible adapter providers

Next.js chatbot template major refresh

The open-source Next.js AI Chatbot template has been updated to reflect patterns Vercel built up while shipping v0. The template is now built on Next.js 15, React 19, and Auth.js 5.

The new version includes a redesigned user interface with model switching as a built-in pattern. It also addresses a common production gap in starter templates: it ships with a PostgreSQL integration layer for transactional persistence.

An additional architectural pattern previewed here is the "v0 blocks" style interactive workspace, enabling richer interfaces beyond a standard chat window. These can be combined with domain-specific tools for hybrid workflows involving both the user and on the model.

Getting to version 4.0

As expected of a major version bump, AI SDK 4.0 includes breaking changes that primarily remove previously deprecated APIs. The team has provided automated codemods for the tedious flag updates, with manual instructions laid out in the official migration guide when code requires intentional changes.

Following the production track record of the previous 3.x releases, the 4.x channel pushes the SDK toward better multimodal handling and loop automation, practical capabilities for builders who need PDF content as model context or models that can operate a graphical interface.

Beyond the Core: Ecosystem and Credits

The AI SDK 4.0 release is not the work of a single team. It is the result of combined efforts from the core group at Vercel — Lars, Jeremy, Walter, and Nico — along with a broader set of community contributors who helped shape the final package.

Several community members contributed merged pull requests to this release. Their work helped refine the SDK across multiple areas, from provider integrations to core utilities. Contributors include minpeter, hansemannn, HarshitChhipa, skull8888888, nalaso, bhavya3024, gastonfartek, michaeloliverx, mauhai, yoshinorisano, Saran33, K-Mistele, MrHertal, h4r5h4, and tonyfarney.

The feedback and code contributions from this group remain a key part of how the AI SDK evolves. As the project moves forward, that input continues to inform the direction of the tooling. For a complete changelog or to explore the technical details of AI SDK 4.0, refer to the official Vercel AI SDK GitHub repository and the v4.0 announcement.