# Vercel AI SDK (/docs/integrations/vercel-ai)



The Vercel AI SDK is a **Node** integration. On the base install, the `ai` package and the
first-party `@ai-sdk/*` providers (OpenAI, Anthropic, Google, Groq, Mistral, xAI, the gateway) are
discovered and metered automatically — including non-chat calls like embeddings, images, speech
and transcription. Init as usual — see [init parameters](/docs/sdk/init) — and call `generateText`
/ `streamText` exactly as you do today.

## Community providers [#community-providers]

A community `@ai-sdk`-style provider isn't auto-discovered — it bundles its own nested copy of the
provider packages. Hand it to `init()`:

```typescript
import { someCommunityProvider } from "ai-sdk-community-provider";

tp.init({
  /* … see init parameters … */
  instrumentModules: { aiSdkProviders: [someCommunityProvider] },
});
```

`aiSdkProviders` is an array and accepts provider factories, constructed model instances, or
package namespaces — pass whichever you have.

## Bundled or edge runtimes [#bundled-or-edge-runtimes]

Where module patching can't reach — a bundled build, an edge runtime — wrap the model with the
middleware instead:

```typescript
import { wrapLanguageModel } from "ai";
import { openai } from "@ai-sdk/openai";
import * as tp from "token-police";

const model = wrapLanguageModel({
  model: openai("gpt-4o-mini"),
  middleware: tp.tokenPoliceAiSdkMiddleware(),
});
```

## Tools are always manual [#tools-are-always-manual]

Tool `execute` functions are **never** captured automatically here — unlike LangChain or the
OpenAI Agents SDK. The model calls around them are metered and enforced as normal; the tool steps
just don't appear on their own in the trace.

<Callout type="info">
  Under enforce, a blocked `streamText` surfaces through the stream's error path (`onError`, or a
  rejected promise) rather than throwing at call time; a blocked `generateText` throws directly.
  Either way it is a `TokenPoliceBlockedError` — see [Errors](/docs/sdk/errors).
</Callout>

<Callout type="warn" title="Reroute does not switch the model on the Vercel AI SDK">
  A Reroute rule does not switch the model on the Vercel AI SDK — those calls still run on the
  original model. Metering and blocking work normally. See [Actions](/docs/rules/actions#reroute).
</Callout>

## Next [#next]

<Cards>
  <Card title="Node & ESM" href="/docs/sdk/node-esm" description="Import order and instrumentModules." />

  <Card title="Flushing & serverless" href="/docs/sdk/flushing-and-serverless" description="Drain telemetry before a function freezes." />
</Cards>
