From vercel-ai-sdk-knowledge-patch
Provides knowledge patch for Vercel AI SDK 4.0-4.1 features: PDF support, computer use tools, continuation, image generation, stream smoothing, tool repair. Load before AI SDK tasks.
npx claudepluginhub nevaberry/nevaberry-plugins --plugin vercel-ai-sdk-knowledge-patchThis skill uses the workspace's default tool permissions.
Implements structured self-debugging workflow for AI agent failures: capture errors, diagnose patterns like loops or context overflow, apply contained recoveries, and generate introspection reports.
Designs and optimizes AI agent action spaces, tool definitions, observation formats, error recovery, and context for higher task completion rates.
Compares coding agents like Claude Code and Aider on custom YAML-defined codebase tasks using git worktrees, measuring pass rate, cost, time, and consistency.
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).
| 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 |
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.
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().
Auto-continue when generation hits length limit:
await generateText({
model: openai('gpt-4o'),
maxSteps: 5,
experimental_continueSteps: true,
prompt: 'Write a long essay...',
});
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().
import { smoothStream, streamText } from 'ai';
const result = streamText({
model, prompt,
experimental_transform: smoothStream(),
});
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);
},
});
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).
| 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 |
| File | Contents |
|---|---|
| ai-sdk-4-features.md | Complete API reference for all 4.0 and 4.1 features with full code examples |