Today we are announcing the release of AI SDK 7.1.
AI SDK 7 gave you the primitives to build end-to-end production agents and frameworks, and 7.1 adds the controls you need to manage the long-running tasks and loops they run at scale. That includes steering in-flight turns, scaling to large toolsets, recovering from mid-stream errors, and tracing multi-process workflows as a single run.
AI SDK 7.1 adds control and durability across 9 categories:
Harnesses and tools with five new harness adapters (Cline, Cursor, fx, GitHub Copilot, and Grok Build), mid-turn steering for Codex, and provider-independent bash and web fetch tools.
Typed decisions with
experimental_decidefor choice, score, boolean, and bounding-box questions.Batch processing with background text and image generation.
Steering with corrections and queued follow-ups for running agents.
Realtime and streaming audio with streaming speech, transcription, and translation, continuous realtime sessions, and a WebSocket transport for
useChat.Code mode and tool search with sandboxed tool orchestration and on-demand tool discovery.
Async video generation with start and status functions, frame images, and reference inputs.
Agent and streaming controls with tool call concurrency, per-step call settings, step error callbacks, a first-content timeout, stream retries, and low-memory streaming.
Durable agents with
WorkflowAgent.generate()and one OpenTelemetry trace per durable run.
AI SDK also moves to a fixed release cadence: monthly minor releases and one major release per year.
pnpm i aiInstall AI SDK 7.1
Copy link to headingRelease cadence
AI SDK now follows a fixed release schedule:
Monthly minors with new features, on the Monday closest to the 1st of each month, except January.
One major per year, published in June in place of that month's minor release.
One year of full support for prior majors, with all applicable bug fixes backported. After that, only critical security fixes are backported for another six months.
AI SDK 5 support ends at the end of 2026. AI SDK 6 support ends on June 1, 2027.
Copy link to headingHarnesses and tools
AI SDK 7 introduced HarnessAgent, one API to run established agent harnesses such as Claude Code, Codex, and Pi. It gains five more harnesses and steering for Codex, alongside the first provider-independent tools.
Copy link to headingNew harness adapters
Teams standardize on different coding agents, and each agent has its own sessions, events, and tool formats.
Five more runtimes plug into HarnessAgent: Cline, Cursor, fx, GitHub Copilot, and Grok Build. Like the existing adapters, each new adapter normalizes the runtime's sessions, stream events, tools, and usage into the harness contract, so you can swap harnesses without changing your integration layer.
import { HarnessAgent } from '@ai-sdk/harness/agent';import { cursor } from '@ai-sdk/harness-cursor';import { createVercelNetworkSandboxSession } from '@ai-sdk/sandbox-vercel';
const agent = new HarnessAgent({ harness: cursor, model: 'gpt-5.6-luna',});
const sandboxSession = await createVercelNetworkSandboxSession({ runtime: 'node24', ports: [4000], template: await agent.getSandboxTemplate(),});const session = await agent.createSession({ sandboxSession });
const result = await agent.generate({ session, prompt: 'Inspect this project and summarize its purpose.',});Running Cursor as a HarnessAgent in a Vercel Sandbox
Learn more about harness adapters.
Copy link to headingCodex steering
The Codex adapter now connects to the Codex app-server, which lets you steer a turn: you can send another user message while the turn is still running instead of waiting for it to finish.
import { codex } from '@ai-sdk/harness-codex';import { HarnessAgent } from '@ai-sdk/harness/agent';
const agent = new HarnessAgent({ harness: codex });
const result = await agent.stream({ session, prompt: 'What is the weather in Paris?',});
// while the turn is running:await agent.experimental_steer({ session, text: 'Actually, I meant Paris, Texas.',});Steering a running Codex turn
To steer generateText, streamText, and ToolLoopAgent, see Steering.
Learn more about the Codex harness adapter.
Copy link to headingFirst-party tools
AI SDK 7.1 includes first-party tools for running shell commands, reading web content, and discovering tools on demand. They work with any model that supports tool calling.
@ai-sdk/tool-bash runs commands in the sandbox session you pass as experimental_sandbox. @ai-sdk/tool-web-fetch reads web pages and documents by URL, with domain allowlists or blocklists.
For agents with many tools, toolSearch() lets the model find the tools it needs without loading every definition up front. Mark tools with deferLoading: true; matching tools become available on the next step after a search.
import { createJustBashNetworkSandboxSession } from '@ai-sdk/sandbox-just-bash';import { createBashTool } from '@ai-sdk/tool-bash';import { createWebFetchTool } from '@ai-sdk/tool-web-fetch';import { generateText, isStepCount, toolSearch } from 'ai';
const session = await createJustBashNetworkSandboxSession();
const result = await generateText({ model: 'openai/gpt-6.2-astra', tools: { search: toolSearch(), bash: { ...createBashTool(), deferLoading: true }, webFetch: { ...createWebFetchTool(), deferLoading: true }, }, experimental_sandbox: session.restricted(), stopWhen: isStepCount(5), prompt: 'Read https://ai-sdk.dev/docs/introduction ' + 'and write a summary to summary.txt.',});Using the bash and web fetch tools with any model
Learn more about tools.
Copy link to headingTyped decisions
Agents answer many small classification questions: which team owns a ticket, how severe it is, and whether the customer wants a refund. Writing a structured output call for each one is repetitive, and the answers have to be validated before you can branch on them.
experimental_decide answers a set of named choice, score, boolean, and bounding-box questions about one shared state in a single call. The state can be text, JSON, or a combination of text, files, and JSON. Answers are typed: a choice answer is a union of the option keys you defined.
import { experimental_decide as decide } from 'ai';
const result = await decide({ model: 'openai/gpt-6-luna-decisions', state: { message: ticket.body }, questions: { department: { type: 'choice', instructions: 'Which team should handle this?', criteria: { billing: 'Payments and refunds', support: 'Other requests', }, }, severity: { type: 'score', instructions: 'How severe is the issue?', criteria: ['Cosmetic', 'Workaround exists', 'Blocking; no workaround'], }, requestsRefund: { type: 'boolean', instructions: 'Is the customer requesting money back?', }, },});
result.answers.department.choice; // 'billing' | 'support'
if (result.answers.requestsRefund.probability >= 0.8) { // route to the refunds queue}Answering three typed questions about a support ticket in one call
Boolean answers include a probability, the model's estimate that the answer is true, so you can route on a threshold. Native decision models can also return probability distributions for choice and score answers. Use a native decision model where a provider offers one, and a language model adapter where it does not.
Learn more about decisions.
Copy link to headingBatch processing
Jobs like classifying a backlog, summarizing support tickets, or generating images for a catalog can now run in the background instead of keeping a request open.
experimental_startBatch submits text or image requests and returns a serializable batch reference. experimental_getBatchStatus and experimental_getBatchResults retrieve the status and results later.
Where the provider supports them, you can also cancel a batch with experimental_cancelBatch, list batches with experimental_listBatches, and pass a webhookUrl to be notified on completion.
import { anthropic } from '@ai-sdk/anthropic';import { experimental_getBatchResults as getBatchResults, experimental_startBatch as startBatch,} from 'ai';
const batch = await startBatch({ provider: anthropic, requests: [ { id: 'capital-france', type: 'text', model: 'claude-haiku-5-5', prompt: 'What is the capital of France?', }, { id: 'capital-germany', type: 'text', model: 'claude-haiku-5-5', prompt: 'What is the capital of Germany?', }, ],});
// later, when the batch is completed:for await (const item of getBatchResults({ provider: anthropic, batch })) { if (item.type === 'text' && item.status === 'succeeded') { console.log(item.id, item.text); }}Submitting a batch and reading the results later
Text requests can use different models and include tool definitions. Client tools are not executed in a batch: tool calls are returned to your application. Batch processing is available for AI Gateway, Anthropic, Google, OpenAI, and xAI.
Learn more about batch processing.
Copy link to headingSteering
Previously, users who noticed a problem in the middle of a run had to wait until the end of the turn or abort the job and start over.
Experimental steering lets you correct generateText, streamText, and ToolLoopAgent while they run.
Create a steering object with experimental_createSteering() and pass it as experimental_steering. steer() adds a user message at the next step boundary without interrupting running tools. queue() holds a follow-up until the agent has finished its current task.
import { experimental_createSteering, isStepCount, streamText } from 'ai';
const steering = experimental_createSteering();
const result = streamText({ model: 'openai/gpt-6.2-astra', tools: { weather }, stopWhen: isStepCount(10), prompt: 'What is the weather in Paris?', experimental_steering: steering,});
// when the user sends a correction while the agent is running:await steering.steer('I meant Paris, Texas.');
// a follow-up that waits until the current task is finished:steering.queue('Then compare it with the weather in Austin.');Correcting a running agent and queueing a follow-up
steer() and queue() resolve with an outcome that tells you whether the message was delivered. Pass an id to make retries safe: sending a message again with the same id returns the outcome of the first message. Steering messages are streamed as steering-message parts, added to the assistant message by useChat, and listed on each step so you can save the full conversation.
Learn more about steering.
Copy link to headingRealtime and streaming audio
Experimental realtime support in AI SDK 7 covered direct, turn-based browser sessions. In 7.1, speech, transcription, and translation can stream as well, and realtime sessions can run continuously, connect through your server, or use provider-managed transports.
Copy link to headingStreaming speech
Spoken responses feel slow when listeners have to wait for the full text before any audio starts to play.
To make speech experiences feel naturally realtime, experimental_streamSpeech turns text into audio as it arrives. It accepts a complete string or a stream of text, including the textStream of streamText, so playback can start before the model has finished writing.
import { elevenLabs } from '@ai-sdk/elevenlabs';import { experimental_streamSpeech as streamSpeech, streamText } from 'ai';
const { textStream } = streamText({ model: 'openai/gpt-6.2-astra', prompt: 'Tell me a short story.',});
const result = streamSpeech({ model: elevenLabs.speech('eleven_flash_v2_5'), text: textStream, voice: '21m00Tcm4TlvDq8ikWAM', outputFormat: { type: 'audio/mpeg' },});
for await (const chunk of result.audioStream) { // chunk is a Uint8Array of audio bytes in generation order}Speaking a response while the text is still being generated
Learn more about streaming speech.
Copy link to headingStreaming transcription and translation
For live audio input, streamTranscription produces transcript updates before the audio stream is complete, and streamSpeechTranslation translates live speech into audio and text in the target language.
import { openai } from '@ai-sdk/openai';import { streamSpeechTranslation } from 'ai';
const result = streamSpeechTranslation({ model: openai.speechTranslation('gpt-realtime-translate'), audio: audioStream, // ReadableStream<Uint8Array | string> inputAudioFormat: { type: 'audio/pcm', rate: 24000 }, targetLanguage: 'es',});
for await (const part of result.fullStream) { if (part.type === 'output-text-delta') { process.stdout.write(part.delta); }}Translating live speech into Spanish
transcribe now also returns separate word timings in words, and accepts timestampGranularities to request word or segment timestamps.
Learn more about transcription, word and segment timings, and translation.
Copy link to headingRealtime connections
In AI SDK 7, realtime sessions were turn-based and connected the browser directly to the provider with a short-lived token. In 7.1, three more connection types are available:
Continuous OpenAI Live conversations through an application-owned WebSocket relay or browser WebRTC.
Server-owned connections, where a trusted server opens the WebSocket instead of creating a browser token.
Provider-managed transports, where the provider handles the audio transport and your server creates and closes the sessions.
import { openai } from '@ai-sdk/openai';import { experimental_useRealtime as useRealtime } from '@ai-sdk/react';
// Module scope: created once, so they are the same objects on every render.const model = openai.experimental_realtime('gpt-live-1');const sessionConfig = { instructions: 'Be a concise, friendly assistant.', providerOptions: { openai: { delegation: { type: 'client' }, }, },};
export function LiveConversation() { const realtime = useRealtime({ model, api: { websocket: 'wss://your-app.example/live' }, sessionConfig, });
return ( <> <button onClick={realtime.connect}>Connect microphone</button> <button onClick={() => realtime.close()}>End conversation</button> <p> {realtime.status}: {realtime.session?.usage?.seconds} seconds </p> </> );}Connecting to a continuous OpenAI Live conversation through a WebSocket relay
Learn more about realtime and continuous conversations.
Copy link to headingWebSocket chat transport
WebSocketChatTransport is a chat transport for useChat that sends chat requests and receives UI message streams over one persistent WebSocket connection. It supports cancellation and sequence-based resume.
import { useChat } from '@ai-sdk/react';import { WebSocketChatTransport } from 'ai';import { useMemo } from 'react';
export default function Chat() { const transport = useMemo( () => new WebSocketChatTransport({ url: '/api/chat' }), [], );
const { messages, sendMessage, stop } = useChat({ transport });
// ... render the chat}Using useChat over a persistent WebSocket connection
Learn more about WebSocketChatTransport.
Copy link to headingCode mode
Agents with many tools run into two problems:
The model orchestrates tools one step at a time and passes every intermediate result through its context.
Every tool definition takes up room in the prompt whether the model needs it or not.
Code mode and tool search address these problems by moving multi-tool orchestration into code outside the context window and loading tool definitions on demand instead of up front.
With @ai-sdk/code-mode, the model writes JavaScript or TypeScript that calls your tools inside an isolated QuickJS sandbox. That code can call tools concurrently, combine their results, and filter large responses before anything returns to the model's context.
Use experimental_toolCallers with generateText, streamText, or ToolLoopAgent to choose which tools code mode can call and which the model can still call directly.
import { DIRECT_TOOL_CALL, experimental_codeModeTool as codeModeTool,} from '@ai-sdk/code-mode';import { generateText, isStepCount } from 'ai';
const result = await generateText({ model: 'openai/gpt-6.2-astra', tools: { code_mode: codeModeTool({ executionPolicy: { timeoutMs: 30_000 }, }), getInventory, getDemand, }, experimental_toolCallers: { getInventory: ['code_mode', DIRECT_TOOL_CALL], getDemand: ['code_mode'], }, stopWhen: isStepCount(10), prompt: 'Compare inventory and demand for product sku_123.',});Letting the model combine tool results in code before they reach its context
Learn more about code mode.
Copy link to headingAsync video generation
Generating a video can take several minutes, and AI SDK 7's experimental_generateVideo keeps the call open until it finishes.
7.1 lets you start a video generation and check its status later, or get notified via webhook, and adds first/last frame and reference inputs.
Copy link to headingStart and status
experimental_startVideo starts a video generation and returns a serializable operation reference immediately.
Store the operation and check it later with experimental_getVideoStatus, or pass a webhookUrl to get notified where the provider supports it.
import { klingai } from '@ai-sdk/klingai';import { experimental_getVideoStatus as getVideoStatus, experimental_startVideo as startVideo,} from 'ai';
const model = klingai.video('kling-v3.0-t2v');
const { operation } = await startVideo({ model, prompt: 'A white kitten chases a butterfly across a sunlit garden.',});
// persist the operation, then check it later, e.g. in a background job:const result = await getVideoStatus(model, { operation });
if (result.status === 'completed') { // the video is ready}Starting a video generation and checking it later
Copy link to headingFrame images and reference inputs
Pass first and last frame images through frameImages, and reference images or videos through inputReferences, to anchor a video to existing assets.
import { klingai } from '@ai-sdk/klingai';import { experimental_generateVideo as generateVideo } from 'ai';
const { video } = await generateVideo({ model: klingai.video('kling-v3.0-i2v'), prompt: 'The cat walks across the scene and transforms into a dog by the end', frameImages: [ { image: 'https://example.com/first-frame.png', frameType: 'first_frame' }, { image: 'https://example.com/last-frame.png', frameType: 'last_frame' }, ],});Generating a video between a first and a last frame
Learn more about video generation.
Copy link to headingAgent and streaming controls
Agents in production need limits and recovery: bounded tool execution, different settings per step, and a way to survive a provider error in the middle of a stream.
AI SDK 7.1 introduces tool concurrency limits, per-step model settings, step error hooks, first-content timeouts, mid-stream retries, and low-memory streaming so long runs stay bounded and recoverable.
Copy link to headingTool call concurrency
By default, AI SDK runs multiple tool calls in a step concurrently. When later calls depend on side effects from earlier ones, you can now use toolCallConcurrency in generateText, streamText, or ToolLoopAgent to cap parallel execution. Setting it to 1 runs calls sequentially in the order the model generated them.
const result = await generateText({ model, tools, prompt: 'Update the file, then read it.', toolCallConcurrency: 1,});Running tool calls one at a time
Learn more about tool call concurrency.
Copy link to headingPer-step call settings
prepareStep can now override model call settings such as temperature, maxOutputTokens, and reasoning for an individual step. This is useful when tool-calling steps need more deterministic sampling than the final response.
const agent = new ToolLoopAgent({ model, temperature: 0.7, tools, prepareStep: async ({ stepNumber }) => { if (stepNumber === 0) { return { temperature: 0, maxOutputTokens: 300 }; } return {}; },});Overriding call settings for the first step
Learn more about loop control.
Copy link to headingStep errors and first-content timeout
onStepError now runs instead of onStepEnd when a step fails without producing a result. For example, it runs if a provider request throws an error or a stream closes without output.
Also, the firstChunkMs timeout aborts a step when its stream opens but no content arrives within the limit.
const result = streamText({ model, prompt: 'Invent a new holiday and describe its traditions.', timeout: { firstChunkMs: 10000, // 10 seconds for first content in each step },});Aborting a step when no content arrives within 10 seconds
Learn more about lifecycle callbacks and timeouts.
Copy link to headingStream retries
maxRetries only catches failures before a response starts streaming. To recover from provider errors that arrive mid-stream, streamText now adds an opt-in streamRetries option.
Each retry reruns only the failed model step, preserving earlier completed steps, their tool results, and any output already emitted to the stream.
const result = streamText({ model, prompt: 'Write a vegetarian lasagna recipe for 4 people.', streamRetries: 2,});Retrying provider errors after streaming has started
Learn more about stream retries.
Copy link to headingLow-memory streaming
By default, streamText buffers a copy of the stream for replay and retains the final output. That overhead isn't necessary for long, single-pass streams. The new experimental_streamTextLowMemory function accepts the same options without the replay buffer, and for plain text streaming, skips holding the full generated text in memory.
import { experimental_streamTextLowMemory as streamTextLowMemory } from 'ai';
const result = streamTextLowMemory({ model, prompt: 'Describe the history of astronomy.',});
for await (const delta of result.textStream) { process.stdout.write(delta);}
console.log(await result.totalUsage);Streaming a long response without a replay buffer
Learn more about low-memory streaming.
Copy link to headingDurable agents
AI SDK 7.1 extends WorkflowAgent with two new features:
Non-streaming execution via
generate().A durable OpenTelemetry bridge that stitches runs that suspend and resume across processes into a single trace.
Copy link to headingWorkflowAgent.generate()
WorkflowAgent previously only supported streaming. Use generate() for durable execution when you need the completed result without a stream. It uses the same durable tool loop as stream().
export async function summarize(modelId: string, text: string) { 'use workflow';
const agent = new WorkflowAgent({ model: modelId, instructions: 'Summarize the text briefly.', }); const result = await agent.generate({ prompt: text }); return { text: result.text, usage: result.usage };}Running a durable agent without streaming
Learn more about WorkflowAgent.
Copy link to headingDurable tracing
Because a WorkflowAgent run can suspend and resume across different processes, it's hard to view the full execution as a single trace. The new durable OpenTelemetry bridge stitches those steps into one agent operation, preserving the original timestamps on every model and tool span.
import { OpenTelemetry, OpenTelemetryIdGenerator } from '@ai-sdk/otel';import { NodeSDK } from '@opentelemetry/sdk-node';import { registerTelemetry } from 'ai';
const durable = new OpenTelemetryIdGenerator();new NodeSDK({ idGenerator: durable, sampler: durable }).start();registerTelemetry(new OpenTelemetry({ durable }));Reporting a durable WorkflowAgent run as one trace
Learn more about durable tracing.
Copy link to headingGet started
Install AI SDK 7.1 with one command.
pnpm i aiInstall AI SDK 7.1