vercel-ai-sdk-knowledge-patch
Vercel AI SDK Knowledge Patch
Claude Opus 4.6 knows AI SDK through 3.x. It is unaware of the features below, which cover AI SDK 4.0 (2024-11-18) through 4.1 (2025-01-20).
Index
| Topic | Reference | Key features |
|---|---|---|
| 4.0 & 4.1 features | references/ai-sdk-4-features.md | PDF files, computer use tools, continuation, image generation, stream smoothing, createDataStreamResponse, tool context/repair, structured outputs with tools, new providers |
PDF Support (4.0)
Send PDFs as file type in message content:
const result = await generateText({
model: anthropic('claude-3-5-sonnet-20241022'),
messages: [{
role: 'user',
content: [
{ type: 'text', text: 'Summarize this.' },
{ type: 'file', data: fs.readFileSync('./doc.pdf'), mimeType: 'application/pdf' },
],
}],
});
Works with Anthropic, Google Generative AI, and Vertex AI.
Computer Use (4.0)
Anthropic tools accessible via anthropic.tools:
const computerTool = anthropic.tools.computer_20241022({
displayWidthPx: 1920, displayHeightPx: 1080,
execute: async ({ action, coordinate, text }) => { /* implement actions */ },
experimental_toToolResultContent: (result) => /* format result */,
});
await generateText({
model: anthropic('claude-3-5-sonnet-20241022'),
tools: { computer: computerTool },
maxSteps: 10,
});
Also: anthropic.tools.textEditor_20241022(), anthropic.tools.bash_20241022().
Continuation (4.0)
Auto-continue when generation hits length limit:
await generateText({
model: openai('gpt-4o'),
maxSteps: 5,
experimental_continueSteps: true,
prompt: 'Write a long essay...',
});
Image Generation (4.1)
import { experimental_generateImage as generateImage } from 'ai';
import { replicate } from '@ai-sdk/replicate';
const { image } = await generateImage({
model: replicate.image('black-forest-labs/flux-1.1-pro-ultra'),
prompt: 'A cityscape at sunset',
size: '16:9',
n: 3,
});
// image.base64, image.uint8Array
Providers: replicate.image(), openai.image(), vertex.image(), fireworks.image().
Stream Smoothing (4.1)
import { smoothStream, streamText } from 'ai';
const result = streamText({
model, prompt,
experimental_transform: smoothStream(),
});
Non-blocking Data Streaming (4.1)
Stream custom data before/alongside LLM output:
import { createDataStreamResponse, streamText } from 'ai';
return createDataStreamResponse({
execute: async (dataStream) => {
dataStream.writeData({ type: 'source', url: '...' });
const result = streamText({ model, messages });
result.mergeIntoDataStream(dataStream);
},
});
Tool Improvements (4.1)
Execute context: execute(args, { toolCallId, messages, abortSignal }).
Tool call repair:
await generateText({
model, tools, prompt,
experimental_repairToolCall: async ({ toolCall, tools, parameterSchema, error }) => {
if (NoSuchToolError.isInstance(error)) return null;
const { object } = await generateObject({ model, schema: tools[toolCall.toolName].parameters, prompt: '...' });
return { ...toolCall, args: JSON.stringify(object) };
},
});
Structured outputs with tools via experimental_output: Output.object({ schema }) (OpenAI only).
New Providers
| Package | Provider |
|---|---|
@ai-sdk/xai |
xAI Grok |
@ai-sdk/groq |
Groq |
@ai-sdk/replicate |
Replicate (image) |
@ai-sdk/fireworks |
Fireworks (language + image) |
@ai-sdk/deepinfra |
DeepInfra |
@ai-sdk/deepseek |
DeepSeek |
@ai-sdk/cerebras |
Cerebras |
Reference Files
| File | Contents |
|---|---|
| ai-sdk-4-features.md | Complete API reference for all 4.0 and 4.1 features with full code examples |
More from nevaberry/nevaberry-plugins
dioxus-knowledge-patch
Dioxus changes since training cutoff (latest: 0.7.4) — Signals replacing use_state, RSX macro overhaul, server functions, asset!() system, dx CLI, Element-as-Result. Load before working with Dioxus.
46rust-knowledge-patch
Rust changes since training cutoff (latest: 1.94.0) \u2014 Rust 2024 Edition, async closures, trait upcasting, new std APIs, cargo resolver v3. Load before working with Rust.
20postgresql-knowledge-patch
PostgreSQL changes since training cutoff (latest: 18.1) — JSON_TABLE, SQL/JSON functions, MERGE RETURNING, virtual generated columns, UUIDv7, temporal PRIMARY KEY. Load before working with PostgreSQL.
16bun-knowledge-patch
Bun changes since training cutoff (latest: 1.3.10) \u2014 S3 client, built-in SQL/Redis, route-based HTTP server, CSS bundler, V8 compatibility. Load before working with Bun.
14nextjs-knowledge-patch
Next.js changes since training cutoff (latest: 16.1) — proxy.ts, \"use cache\", Cache Components, navigation hooks, typed routes, auto PageProps, React 19.2. Load before working with Next.js.
14postgis-knowledge-patch
PostGIS changes since training cutoff (latest: 3.6.1) — SFCGAL CG_* rename, ST_CoverageClean, ST_AsRasterAgg, topology bigint IDs, viewport simplification, 3D SFCGAL ops. Load before working with PostGIS.
13