Building with the Vercel AI SDK?

Vercel AI SDK streaming or tools misbehaving? We ship it properly.

The Vercel AI SDK is the fastest way to ship an AI feature inside a Next.js app, and the cracks show the moment you pass the toy demo stage: streams that stall on Cloudflare, tool calls that arrive without the arguments they promised, structured outputs that fail schema validation on a Thursday. We take the integration from demo to production.

  • Since 2015Fixing technology
  • FreeEstimates
  • US teamReal engineers

ai-sdk.log

still failing

What it is

Vercel AI SDK at a glance

The Vercel AI SDK is a TypeScript toolkit for building AI-powered applications, shipped by Vercel and open source under Apache 2.0. The core gives you a unified API across OpenAI, Anthropic, Google, Mistral, Groq and dozens of other providers; the UI layer offers framework hooks for React, Svelte and Vue that handle streaming chat, tool calls and structured output.

It is the default pick for anyone building on Next.js because the integration with App Router, Edge runtime and Vercel Functions is first class. The SDK covers streamText, generateObject, tool-use with Zod schemas, and the message format used by useChat on the client. Pricing is zero because the SDK itself is free; you pay the underlying model providers and your hosting bill.

Type
TypeScript SDK for building LLM applications
First released
2023
License
Apache 2.0
Maintained by
Vercel, Inc.
Typically used for
Streaming chat UIs, tool-use agents, structured output, multi-provider routing in Next.js and other TS apps

The honest version

Vercel AI SDK pros and cons

No technology is all upside. This is where Vercel AI SDK earns its place and where it tends to cause trouble.

Where Vercel AI SDK is strong

  • Provider-agnostic coreSwitching from Anthropic to OpenAI is a one-line import change in most code, and the tool-use shape is the same across providers rather than wearing each vendor's quirks.
  • React hooks that just workuseChat and useObject manage streaming state, token-by-token UI updates and tool-call rendering without a custom reducer per project.
  • Zod schemas for structured outputgenerateObject takes a schema and returns typed results, with the model's output validated before it leaves the SDK.
  • Streaming is first classBackpressure, abort signals and Edge runtime support are built in, rather than something you bolt on with custom Response objects.
  • Tool calling is uniformDefine a tool once with a Zod schema and a handler, and the SDK dispatches calls from any supported provider the same way.
  • Low-friction upgrade pathMajor versions ship with codemods and clear migration notes, which is rare for libraries moving as fast as this one.

Where Vercel AI SDK bites

  • Breaking changes have been frequentThe SDK has moved quickly, with v3, v4 and v5 each reshaping the message format and streaming primitives. Pinned versions are not optional on a serious project.
  • Edge runtime streaming has sharp edgesResponse bodies that close early, missing onFinish callbacks on Cloudflare-adjacent runtimes, and partial tool-call streams that need defensive handling.
  • Error model is uneven across providersA rate limit from Anthropic, a content filter from OpenAI and a timeout from Mistral all surface differently, and the SDK's retry logic does not always treat them equivalently.
  • generateObject can still return invalid JSONEven with schema-guided generation, some providers emit JSON that parses but fails the schema at nested fields, especially on smaller or faster models.
  • Observability is thin out of the boxTracing is add-on work via Langfuse, LangSmith or OpenTelemetry. The SDK does not ship a built-in run tree.
  • Vercel lock-in is subtleThe SDK runs anywhere, but the ergonomics and deployment story are tuned for Vercel Functions and Edge. Teams on other hosts hit small frictions that add up.

Sound familiar?

Common Vercel AI SDK problems we fix

The Vercel AI SDK problems that bring people to us, and what you have once each one is fixed.

AI_InvalidToolArgumentsError

Tool calls arrive with wrong arguments

The model returned a call whose JSON parses but fails the Zod schema, often because a field is nested or the model prefers camelCase while the schema used snake_case.

Tool calls matching the schema

AI_NoObjectGeneratedError

Structured output is not valid JSON

A model that opened a code fence instead of raw JSON, or a trailing comma that broke the parse. More likely on smaller models and under token limits.

Objects parsed and typed cleanly

streamText onFinish never called

Stream ends without closing cleanly

The client disconnected, the Edge runtime closed the response early, or an abort signal fired mid-stream. Downstream code that depends on onFinish (billing, logging) silently stops firing.

Finish hooks firing on every stream

useChat: Failed to parse stream string

Client cannot parse the server stream

A mismatch between the SDK version on the server and the one on the client, or a response that was transformed by a proxy or CDN in a way the stream format did not survive.

Client and server speaking the same format

AI_RetryError: exceeded maximum retries

Upstream failures burn through retries

A rate-limited provider that keeps returning 429, a model that is temporarily unreachable, or a timeout that is too short for a long tool-use chain.

Retries tuned to the real failure mode

schema validation failed at .items[0].price

Nested field validation fails

An array of objects where one field drifts from the schema under load, usually because the model prefers to emit a string when the schema asked for a number.

Schema and outputs reconciled

AI_MessageConversionError: unsupported content part

Message format incompatible with a provider

A file attachment or image part that works on one provider and is rejected by another, with no graceful fallback in the routing layer.

Content parts normalised per provider

no provider registered for 'openrouter/mistral-large'

Provider registry misconfigured

A custom provider pointer that was removed, a model slug that moved under OpenRouter, or an environment variable that is empty in production.

Provider registry aligned with runtime

What we do

Vercel AI SDK help, from streams to structured output

Pull us in for one flaky stream, or let us build the whole AI feature in your Next.js stack.

Streaming reliability
Stream lifecycle handled across Node and Edge, with onFinish, onError and abort signals that fire where they should, not where they might.
Tool-use integration
Zod schemas, handlers and multi-step tool loops wired into your real services, with sensible limits on tool-call depth and parallelism.
Structured output
generateObject with schemas tuned so the model stops returning string prices, nested nulls or hallucinated enum values.
Multi-provider routing
Primary and fallback providers, with routing that reads cost and latency rather than just a static preference order.
Upgrade migrations
Moving from v3 or v4 to the current major cleanly, including the message format change and the new tool-call streaming.
Managed Tech
Ongoing SDK upgrades, provider price monitoring, tracing integration and incident response when a provider turns a model off overnight.

How it works

From first message to fixed

  1. Look Free estimate

    Tell us what's going wrong. We look at it, then tell you plainly what's wrong and what it will cost.

  2. Fix

    We fix the cause, not the symptom. If something is down, getting it back up comes first.

  3. Harden

    Backups, monitoring, updates and access, so the same problem can't quietly come back.

  4. Hand back or stay on

    You get a plain-language write-up. Or we stay on for hosting, upkeep and new work.

Often found together

Running Vercel AI SDK alongside something else?

We work on the whole stack, so the problem can be wherever it actually is.

Questions

Vercel AI SDK questions

Something else? Call+1 737 727 7327

Why does streamText stop firing onFinish?

Three usual causes: the client disconnected and the server did not notice, the Edge runtime closed the response body before the final event, or an abort signal fired and the handler branched around onFinish. Make sure consumers do not depend solely on onFinish for billing or logging; also record completion server-side when the stream ends by any path.

How do we make tool calls reliable across providers?

Keep tool schemas narrow, name fields in a style the model prefers (usually camelCase on OpenAI, snake_case tends to work everywhere), set a sensible maxSteps so loops do not run forever, and validate the arguments with Zod before you execute the handler. Treat any invalid-arguments error as a retry with a corrective system message rather than a hard failure.

Why does generateObject keep returning invalid JSON?

Smaller models still love code fences and trailing commas, even with schema guidance. Use a stronger model for generateObject, prefer providers with native structured output when available, and keep the schema shallow. Deeply nested schemas with optional fields are where most of the parse failures live.

Can the Vercel AI SDK run outside Vercel?

Yes. It runs on Node, Bun, Deno, Cloudflare Workers, AWS Lambda and anywhere TypeScript runs. The ergonomics are best inside Next.js on Vercel because the response types and streaming helpers are tuned for Vercel Functions, but there is nothing in the SDK that requires Vercel hosting.

How do we add tracing to a Vercel AI SDK app?

The SDK exposes experimental telemetry hooks that integrate with OpenTelemetry, Langfuse and LangSmith. The right choice depends on the rest of your stack: if you already ship traces to Langfuse or LangSmith for LangChain code, use the same tool so the agent and the SDK runs sit in one place.

How much does Vercel AI SDK help cost?

Estimates come back free of charge. Describe the behaviour, whether it is a stream that will not close, a tool that will not fire or a model switch that broke something, and you get a number before work begins.

Free estimate

Vercel AI SDK giving you trouble?

Tell us what you're running and what's going wrong. A person reads it and comes back with an estimate.

  • No charge to find out what it will take
  • If it's urgent, say so

Replies come from a person. By sending, you authorize us to email you back. No marketing.