Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

migrate-ai-sdk-v6-to-v7 — Claude Code skill: how to install

Migrates applications from Vercel AI SDK 6.x to 7.0. It updates dependencies, fixes breaking API changes, and rewrites step-handling patterns.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add vercel/ai --skill migrate-ai-sdk-v6-to-v7 -a claude-code
Open on GitHub

What migrate-ai-sdk-v6-to-v7 does

The skill audits package.json, bumps AI SDK packages to v7, and systematically replaces deprecated APIs based on the official migration checklist. It renames core configuration keys like system to instructions, switches streaming consumers from fullStream to stream, and replaces legacy callbacks such as onFinish with onEnd.

Multi-step behavior introduces a semantic shift. Properties like usage, content, and toolCalls now accumulate data across every step rather than returning only the last one. If your application expects the previous single-step output, the skill switches those reads to result.finalStep. Telemetry is also removed from ai directly; @ai-sdk/otel is added only when OpenTelemetry spans are actively used.

Your build will fail immediately if your runtime runs below Node.js 22. AI SDK 7.0 ships as pure ESM, which means legacy require() calls must be rewritten to standard imports.

What it helps with

  • Migrate generateText and streamText from system to instructions
  • Replace fullStream with stream and add guards for stream chunk types
  • Preserve final-step semantics using result.finalStep for usage and content
  • Extract OpenTelemetry tracing into the separate @ai-sdk/otel package

Example prompts for the agent

  • Migrate this project from Vercel AI SDK v6 to v7
  • Update our AI SDK calls from system to instructions and fix breaking changes
  • Fix type errors after upgrading @ai-sdk packages to version 7

How to install migrate-ai-sdk-v6-to-v7

1Skills CLI (Vercel)

npx skills add vercel/ai --skill migrate-ai-sdk-v6-to-v7 -a claude-code

2Manually: put the files in place

~/.claude/skills/migrate-ai-sdk-v6-to-v7/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/migrate-ai-sdk-v6-to-v7/

From the same set2

The whole set →

Similar

agent-architecture-audit affaan-m This skill checks agent and LLM applications across 12 layers. Use it when an agent degrades and the failing layer is hard to locate. Claude Code CX Codex Cursor +1 4,700installs pytorch-patterns affaan-m This skill guides PyTorch model, training-loop, and data-loading work with practical patterns. Use it when reviewing code or tracking down runs that fail to reproduce. Claude Code CX Codex Cursor +1 4,700installs search-first affaan-m A skill that makes the agent search npm, PyPI, MCP servers and GitHub for existing tools before it writes custom code. Claude Code CX Codex Cursor +1 4,700installs microsoft-docs official github Finds official Microsoft documentation, tutorials, and code samples for Azure, .NET, VS Code, and GitHub work. Use it when an agent needs a source tied to a specific technology or version. GitHub Copilot 14,881installs cost-aware-llm-pipeline affaan-m A skill for apps that call LLM APIs: picks a model by task complexity, tracks spend, caches prompts. Useful when your API bill keeps climbing. Claude Code CX Codex Cursor +1 4,600installs fal-ai-media affaan-m This skill connects Claude Code to fal.ai MCP for generating images, video, speech, and audio. Use it when an agent needs to create media from prompts or source files. Claude Code CX Codex Cursor +1 4,600installs skill-creator official anthropics Creates and refines skills, then tests them with prompts, evaluations, and performance checks. Claude Code Claude.ai 414,180installs writing-for-agents Matt Pocock Guidance for writing skills and agent-facing documents. Use it when editing AGENTS.md, CLAUDE.md, or reference files reached from them. Claude Code 466,719installs

Questions about migrate-ai-sdk-v6-to-v7

How do I install migrate-ai-sdk-v6-to-v7 in Claude Code?

Run npx skills add vercel/ai --skill migrate-ai-sdk-v6-to-v7 -a claude-code. This downloads the skill checklist into your local assistant environment.

What does migrate-ai-sdk-v6-to-v7 do?

It guides coding agents through upgrading Vercel AI SDK from version 6 to 7. The skill updates API names, switches callback hooks, and adjusts multi-step response structures.

What runtime does AI SDK 7.0 require?

The runtime must be Node.js 22 or higher. The packages are strictly ESM, so CommonJS require() calls will no longer work.

Source text

SKILL.md · Apache-2.0
---
name: migrate-ai-sdk-v6-to-v7
description: Migrate applications from AI SDK 6.x to AI SDK 7.0. Use when upgrading Vercel AI SDK packages, fixing v7 migration errors, or when the user mentions AI SDK v6, v7, upgrade, migration, breaking changes, system to instructions, fullStream, telemetry, tool context, or finalStep.
---

## AI SDK 6 to 7 Migration

Use `content/docs/08-migration-guides/23-migration-guide-7-0.mdx` from the AI SDK repo as the source of truth. This skill is the working checklist; read the guide for exact examples or when behavior is unclear.

## Migration Workflow

1. Ensure the user has a clean backup or committed baseline before editing.
2. Inspect `package.json` and lockfiles to identify installed `ai`, `@ai-sdk/*`, provider, UI, MCP, and telemetry packages.
3. Upgrade AI SDK packages to latest versions, and add `@ai-sdk/otel` only if the project uses OpenTelemetry spans.
4. Update runtime and module assumptions: Node.js must be `>=22`, and AI SDK packages are ESM-only. Replace `require()` imports with ESM imports and add `"type": "module"` or use `.mjs` where needed.
5. Search for the v6 patterns below, migrate only the code that exists, then run typecheck and targeted tests.

Prefer behavior-preserving changes. When v7 changes semantics, decide whether the app wants the new all-steps behavior or the previous final-step-only behavior.

## Core API Changes

- `experimental_customProvider` -> `customProvider`.
- `experimental_generateImage` -> `generateImage`; `Experimental_GenerateImageResult` -> `GenerateImageResult`.
- `experimental_transcribe` -> `transcribe`; `Experimental_TranscriptionResult` -> `TranscriptionResult`.
- `experimental_generateSpeech` -> `generateSpeech`; `Experimental_SpeechResult` -> `SpeechResult`.
- `experimental_output` option/result -> `output` option/result.
- `CallSettings` -> `LanguageModelCallOptions & Omit<RequestOptions, 'timeout'>`; `prepareCallSettings` -> `prepareLanguageModelCallOptions`.
- `stepCountIs` -> `isStepCount`.

## Prompts and Steps

- Rename top-level `system` to `instructions` for `generateText`, `streamText`, `generateObject`, `streamObject`, and `streamUI`.
- Move `{ role: 'system' }` messages from `prompt` or `messages` into top-level `instructions`. Only use `allowSystemInMessages: true` for trusted persisted messages.
- Rename `experimental_prepareStep` to `prepareStep`.
- In `prepareStep`, rename returned `system` to `instructions`.
- In `experimental_repairToolCall`, use `{ instructions }` instead of `{ system }`.
- Audit `prepareStep` behavior: returned `instructions` and `messages` now carry forward into later steps. If code depended on one-step-only overrides, rebuild from `initialInstructions`, `initialMessages`, and `responseMessages` explicitly.

## Lifecycle Callbacks

- `experimental_onStart` -> `onStart`.
- `experimental_onStepStart` -> `onStepStart`.
- `onFinish` -> `onEnd`.
- `onStepFinish` -> `onStepEnd`.
- For `embed`, `embedMany`, and `rerank`, `experimental_onFinish` -> `onEnd`.
- Callback event fields use `instructions` instead of `system`.

## Usage, Telemetry, and Include Options

- `usage.cachedInputTokens` -> `usage.inputTokenDetails.cacheReadTokens`.
- `usage.reasoningTokens` -> `usage.outputTokenDetails.reasoningTokens`.
- OpenTelemetry moved out of `ai`; install `@ai-sdk/otel` and call `registerTelemetry(new OpenTelemetry(...))` at app startup.
- Telemetry is enabled by default once an integration is registered. Remove redundant `isEnabled: true`; use `isEnabled: false` to opt out per call.
- Move `experimental_telemetry.tracer` into the `OpenTelemetry` constructor.
- `experimental_telemetry` -> `telemetry`.
- Telemetry integration callbacks: `onRerankFinish` -> `onRerankEnd`, `onEmbedFinish` -> `onEmbedEnd`. Update tracing-channel subscribers for the same event type names.
- `experimental_include` -> `include`.
- `includeRawChunks` -> `include.rawChunks`.
- Request and response bodies are excluded by default. If code reads `request.body` or `response.body`, opt in with `include.requestBody` and, for `generateText`, `include.responseBody`.

## Streaming, Messages, and Tools

- `StreamTextResult.fullStream` -> `stream`.
- `streamText` `onChunk` now receives all stream parts, including lifecycle, boundary, finish, abort, and error parts. Guard by `chunk.type` before assuming text/tool/raw content.
- `step.response.messages` is no longer accumulated across previous steps. Use `result.responseMessages` for the full response message history, or flatten `result.steps`.
- Tool execution callbacks: `experimental_onToolCallStart` -> `onToolExecutionStart`, `experimental_onToolCallFinish` -> `onToolExecutionEnd`.
- Tool callback `experimental_context` -> `context`.
- Split shared runtime data from tool-specific data: use top-level `runtimeContext` for orchestration state, declare per-tool `contextSchema`, and pass per-tool values through `toolsContext`.
- Move `needsApproval` from `tool()` / `dynamicTool()` into per-call or agent `toolApproval`.
- `experimental_activeTools` -> `activeTools`.
- `ToolCallOptions` -> `ToolExecutionOptions`.
- `isToolOrDynamicToolUIPart` -> `isToolUIPart`.

## Content Parts and Reasoning

- Tool result `{ type: 'media' }` is removed; use `{ type: 'file-data' }`.
- Migrate `toModelOutput` `image-*`, `file-*`, `file-id`, and `image-file-id` variants to canonical `{ type: 'file', mediaType, data: { type: 'data' | 'url' | 'reference', ... } }`.
- User message `{ type: 'image', image, mediaType? }` is deprecated; use `{ type: 'file', mediaType: 'image' | 'image/*', data }`.
- Add support for the new `reasoning-file` content type in exhaustive switches, renderers, serializers, and validators.
- When adopting top-level `reasoning`, remove overlapping provider-specific reasoning settings from `providerOptions` unless provider-specific settings intentionally take precedence.

## Multi-Step Result Shape

- `result.usage` now includes all steps; `result.totalUsage` is deprecated. Use `result.finalStep.usage` for final-step-only usage.
- Top-level `content`, `toolCalls`, `staticToolCalls`, `dynamicToolCalls`, `toolResults`, `staticToolResults`, `dynamicToolResults`, `files`, `sources`, and `warnings` now include all steps. Use `finalStep` for previous final-step-only behavior.
- Top-level `reasoning`, `reasoningText`, `request`, `response`, and `providerMetadata` are deprecated for final-step data. Use `result.finalStep.*`; for `streamText`, await `result.finalStep`.
- Apply the same result-shape rules to `onEnd` events.

## Stream Response Helpers

The `streamText` result helper methods are deprecated. Replace result methods with top-level stateless helpers:

- `result.toUIMessageStream(...)` -> `toUIMessageStream({ stream: result.stream, ... })`.
- `result.toUIMessageStreamResponse(...)` -> `toUIMessageStream(...)` plus `createUIMessageStreamResponse({ stream })`.
- `result.pipeUIMessageStreamToResponse(response, ...)` -> `toUIMessageStream(...)` plus `pipeUIMessageStreamToResponse({ response, stream })`.
- `result.toTextStreamResponse()` -> `toTextStream({ stream: result.stream })` plus `createTextStreamResponse({ stream })`.
- `result.pipeTextStreamToResponse(response)` -> `toTextStream({ stream: result.stream })` plus `pipeTextStreamToResponse({ response, stream })`.

## Package-Specific Checks

- MCP: `MCPTransportConfig.redirect` now defaults to `'error'`. Only set `redirect: 'follow'` for trusted MCP servers that rely on redirects.
- Vue: `@ai-sdk/vue` `Chat` class is deprecated. Prefer `useChat`, including getter/ref init for reactive chat inputs.
- Anthropic and `@ai-sdk/google-vertex/anthropic`: `providerMetadata.anthropic.cacheCreationInputTokens` was removed. Use `usage.inputTokenDetails.cacheWriteTokens`; raw Anthropic usage remains at `finalStep.providerMetadata?.anthropic?.usage`.
- Google: rename `GoogleGenerativeAI*` types, classes, and functions to `Google*`, e.g. `createGoogleGenerativeAI` -> `createGoogle`. The `google` entry point is unchanged.

## Validation

Run the project typecheck after edits, then the smallest relevant test suite. Also smoke-test streaming, chat UI, tool execution, telemetry, and multi-step flows if the migration touched them. If type errors remain, search the migration guide for the exact removed or renamed symbol before inventing a workaround.

© vercel · Apache-2.0 · vercel/ai

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor