Vercel AI SDK: What It Is, What It Costs, and How to Start
Make your first model call in TypeScript, choose between streaming and structured output, and check what changes when you upgrade to AI SDK 7.
Published

If you’re adding a model to a TypeScript app, start with one server-side call. The Vercel AI SDK gives you the same function for asking different models a question. Version 7 earns its place when that answer also needs to arrive a sentence at a time, fit a form, or use data from your app.
What is Vercel AI SDK?
Vercel makes the AI SDK, a software development kit you install as the ai package. Think of it as the service desk at a library. Your app hands over a request in a familiar format. Behind the desk, a provider handles the request in the format its model expects. The model generates the answer. You decide what your app does with it.
That distinction matters when you add a “Draft reply” button to a support inbox. AI SDK Core can send a ticket to a model and return the draft. Your existing text editor can display it. You only need AI SDK UI, the frontend part of the toolkit, if you want its help managing interactions such as a streaming chat. Vercel’s SDK introduction
Vercel AI SDK models and provider packages
A provider package translates the SDK’s calls for a particular service. For example, @ai-sdk/anthropic lets your server call Anthropic directly using its own ANTHROPIC_API_KEY. With the SDK’s default configuration, passing a model name as a plain string takes a different path through Vercel AI Gateway, a hosted service that forwards requests. That route uses a Gateway credential. Anthropic connection options

You can keep the surrounding application code when switching providers, but check the feature your button depends on. A text-only reply is a simpler swap than a workflow that requires a specific tool or provider-only option. Check the provider capability directory before promising that a second model can take over.
The SDK is open source and free to use. Model usage is billed at the provider’s rates, including through Vercel AI Gateway’s pay-as-you-go pricing.
Vercel AI SDK examples you can run from a terminal
Start in a server-side project directory with Node.js 22 or later. A single file is enough to see where the request goes and what comes back. This uses the recipe prompt from Vercel’s Anthropic provider docs above, via the default Gateway route.
Install the core package
Bashnpm install aiYou can install the package and write the file before opening an account. The model request needs credentials.
Set the credential and write the call
Set
AI_GATEWAY_API_KEYin your local shell environment to your own Gateway key. Keep it on the server. Save this asrecipe.mjsso Node loads it as an ES module, the format that supports theimportbelow.JavaScriptimport { generateText } from 'ai'; const { text } = await generateText({ model: 'anthropic/claude-sonnet-5.5', prompt: 'Write a vegetarian lasagna recipe for 4 people.', }); console.log(text);Read the completed reply
Bashnode recipe.mjsWith a valid key and model access, the program waits for the reply, then prints the recipe text. Back in the support inbox, the ticket would supply the prompt and the resulting text would go into an editable draft. To watch text arrive in chunks in a terminal, follow Vercel’s streaming Node.js example.
Choose the result your app needs
Use generateText when the next action requires a complete answer, such as saving a draft. Use streamText when someone is waiting to read it. A stream lets the support agent start reading the opening line while the model writes the rest. Treat the draft as in progress until the stream finishes.
Vercel AI SDK structured output for ticket fields
If your inbox sorts tickets by topic, a paragraph saying “this sounds like a billing question” is an awkward input. Give the model a schema, a description of the fields and values your code accepts. With Output.object({ schema }) as the output option on generateText, your code reads the validated object from result.output. The same output option works with streamText. Structured data guide
Suppose the allowed topics are billing, delivery and returns. A valid “billing” value can still be the wrong choice for a customer asking about a late parcel. Let a support agent correct the category. Schema validation solves the problem of writing the result into the right field. Reviewing a sample of classified tickets tells you whether that field is useful.
When to add the UI hooks
In a React inbox, reach for useChat from @ai-sdk/react when a support agent needs to ask follow-up questions. The hook manages streamed messages and the loading and error states. Your component owns the text being typed. For a single suggested completion, useCompletion fits the interaction. To show fields filling in from streamed JSON, the UI guide describes useObject. AI SDK UI hooks and framework support
When a tool call needs another model call
A ticket saying “Where is my order?” needs a fact from your system. Give the model a tool, a function it can request by name. Describe the lookup, define the order ID it accepts in inputSchema, and provide an execute function that reads the order. The SDK validates the arguments. Your lookup must still check that the signed-in customer may see that order. A correctly formatted order ID says nothing about who owns it. Tool calling guide
When the model needs that result to decide what to do next, ToolLoopAgent manages the exchange. The model asks for the lookup, the tool returns the shipment status, and the model can use it to write a reply. Give the loop a stopping condition and decide what to show the support agent when a lookup fails. If the shipment status is already on the ticket, pass it into the first call and skip the loop. Vercel’s agent guide

Running an existing coding agent is a different job from defining an order lookup. The ACP harness adapter explainer covers connecting an existing agent, and the agent subscription billing guide covers when an existing plan can pay for that work. If you need several agents to claim tasks and report back in one place, see how Vercel Board organizes the handoff.
What changes when you move from AI SDK 6 to 7?
Check the runtime before changing your imports. Verified against Vercel’s docs on November 24, 2026, the current major is 7. Vercel published ai@7.0.180 on November 23 and shipped ai@7.0.181 later that day. Earlier patch notes and later patch notes
- Runtime and modules. Version 7 requires Node.js 22 or later. The packages use ES modules. If the deployment still runs Node.js 20, or a server file loads
aiwithrequire(), address those dependencies before deploying the update. - Structured output. If a v6 call uses
experimental_output, change both the option you pass and the result property you read tooutput. Code already using the stable name needs no edit for this change. - Instructions across steps. The top-level
systemoption becomesinstructions. More importantly, an instruction override returned byprepareStepnow carries into later steps until replaced. In v6 it applied only to the current step. If you tell the model to “only look up the shipment” for one step, explicitly restore the normal instructions when it is time to draft the reply.
From the project root, npx @ai-sdk/codemod v7 automates many source edits. Review the diff, then exercise a multi-step ticket through its final answer. A clean import check cannot tell you whether the model received the right instructions for that last step. Official v6 to v7 migration guide
Should you use it for this app?
Choose the SDK when multiple features can share the model integration. A support inbox that drafts text, classifies tickets and streams follow-ups has a reason to standardize those calls. For a single working provider-specific integration, keep it until you can name the feature that would benefit from a common interface. For a Python-only backend, this TypeScript package belongs on the JavaScript side of the application, if you have one.
The SDK gives you code to install. The model supplies the answer. If the problem you need to solve is routing requests through a hosted endpoint, start with how Vercel AI Gateway works.
What is Vercel AI for?
For a developer adding a model to an app, AI SDK Core handles model calls and AI SDK UI helps display responses. Start with Core for a server-side job.
How to check Vercel usage?
Select your team in the Vercel dashboard and open Usage in the sidebar. Filter by project to isolate the app. Vercel usage instructions
What is Google Gen AI SDK?
Google’s JavaScript and TypeScript package for Gemini is @google/genai. Choose it when you want Google’s client directly. Vercel’s package gives you a shared model interface across providers. Google Gen AI SDK reference
How to use Vercel to build an app?
Add the model call to your app locally. When you’re ready to host it on Vercel, use the CLI from the project directory and configure the server’s model credential in the deployment environment. Vercel deployment quickstart
Can I host my app on Vercel for free?
The Hobby hosting plan includes a free allocation. Check the limits for the resources your project will use. Vercel Hobby plan
Is Vercel better than Netlify?
For a first SDK integration, keep your current host if it supports the runtime and response streaming your feature needs. Test an entire streamed reply on that host before considering a move.
Is there a better alternative to Vercel?
If you mean the toolkit, the model provider’s own client is a good alternative for a feature tied to that provider. If you mean hosting, evaluate where the rest of your app already runs.
Is Vercel still free?
Vercel offers a free Hobby hosting plan. Installing the open-source SDK and paying for model requests are separate decisions.
Which is better, AWS or Vercel?
If your support app and order database already run on Amazon Web Services (AWS), start the model integration there. Evaluate a move to Vercel against a deployment need you can identify independently of the SDK.
- Published
- Category
- Build








