> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usecarry.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel AI SDK adapter

> Wrap any Vercel AI SDK model with proof-carrying memory in one line — gated before generation, a receipt on every call.

`@usecarry/vercel-ai` drops Carry's gate into any [Vercel AI SDK](https://sdk.vercel.ai) model. Memory is recalled and gated **before** generation — the model only ever sees authorized memory — and every call emits an Answer Receipt.

## One line

```ts theme={null}
import { withCarryMemory, createMemoryStore } from "@usecarry/vercel-ai";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";

const store = createMemoryStore({
  memories: [
    { id: "m1", namespace: "health", content: "Allergic to penicillin" },
    { id: "m2", namespace: "billing", content: "Card ending 4242" },
  ],
  policy: { aria: { billing: false } }, // revoke billing for this agent
});

const model = withCarryMemory(openai("gpt-4o"), {
  store,
  agent: "aria",
  onReceipt: (r) => console.log(r.used, r.blockedNamespaces), // proof of what it used
});

const { text } = await generateText({ model, prompt: "Am I allergic to anything?" });
// → recalls only `health`, injects it, answers. `billing` is never fetched.
```

Works with `generateText`, `streamText`, `generateObject` — anything that takes a model.

## Why

A raw vector-DB memory layer hands the model everything it retrieves. Carry enforces an **agent × namespace** policy at retrieval, so a revoked namespace is never injected into the prompt — and every generation carries a receipt proving exactly what memory reached the model.

## API

<CardGroup cols={2}>
  <Card title="withCarryMemory(model, opts)" icon="wand-magic-sparkles">
    Wraps a model with the Carry middleware. Returns the same model type.
  </Card>

  <Card title="carryMiddleware(opts)" icon="layer-group">
    The raw `LanguageModelMiddleware`, if you compose your own `wrapLanguageModel`.
  </Card>

  <Card title="createMemoryStore({ memories, policy })" icon="database">
    An in-memory Carry vault (default-allow; `policy[agent][ns] = false` revokes).
  </Card>

  <Card title="CarryStore" icon="plug">
    Implement `recall(agent, query)` to back it with your own store — Walrus, a DB, the CLI vault.
  </Card>
</CardGroup>

Options: `{ store, agent?, onReceipt? }`. `onReceipt(receipt)` fires on every call with `{ agent, query, used, blockedNamespaces, createdAt }`.
