What Vercel AI SDK already keeps
Messages are managed by your app — typically persisted per chat by your own code. There is no built-in long-term fact store.
Where Auld fits
Define recall and remember with the SDK’s tool() helper inside your route handler, closing over the signed-in user’s id. Route on results: when recall returns nothing, the model can ask instead of guessing.
| Concern | Vercel AI SDK | Auld |
|---|---|---|
| Current conversation | Yes | Not needed |
| Facts across sessions and channels | Your code | Yes |
| Which fact is current after a change | Your code | Yes, with history |
| What was true on a date | Your code | Yes (asOf) |
| Who may see a memory | Your code | Identities and audiences |
| Source for each statement | Your code | Returned with every memory |
Implementation sequence
Authenticate in the route
Read the user from your session.
Define tools inline
Use
tool()with a Zod input schema.Pass to streamText
Allow a few steps so the model can recall and then answer.
Ingest after the stream
Send the user turn in
onFinish.
Example
const AULD = process.env.AULD_API_BASE!; // e.g. https://YOUR-AULD-HOST
const headers = { Authorization: `Bearer ${process.env.AULD_API_KEY}`, "Content-Type": "application/json" };
async function auldPost(path: string, body: unknown) {
const res = await fetch(`${AULD}/v1/${path}`, { method: "POST", headers, body: JSON.stringify(body) });
if (!res.ok) throw new Error(`Auld ${path} failed: ${res.status}`);
return res.json();
}
export const remember = (text: string, userId: string, sourceId: string, occurredAt: string) =>
auldPost("records", { sourceId, text, occurredAt, author: userId, visibility: `user:${userId}` });
export const recall = (query: string, userId: string, maxTokens = 2000) =>
auldPost("recall", { query, viewer: userId, maxTokens });import { streamText, tool, stepCountIs } from "ai";
import { z } from "zod";
import { recall, remember } from "@/lib/auld";
export async function POST(req: Request) {
const { messages } = await req.json();
const user = await getSessionUser(req); // your auth
const result = streamText({
model,
messages,
stopWhen: stepCountIs(4),
tools: {
recallMemory: tool({
description: "Recall facts about this user's past decisions and account state",
inputSchema: z.object({ query: z.string() }),
execute: async ({ query }) => recall(query, user.id),
}),
},
onFinish: async () => {
const last = messages.at(-1);
await remember(String(last?.content ?? ""), user.id, `chat-${user.id}-${Date.now()}`, new Date().toISOString());
},
});
return result.toUIMessageStreamResponse();
}Illustrative example · standard HTTP · check the framework’s current docs for exact signatures
Or connect the MCP server
If your Vercel AI SDK setup can use MCP tools, point it at the Auld MCP endpoint instead of writing wrappers. The model gets remember, recall, forget and memory_status. Use wrappers when you need to inject the user id yourself or post-process results; use MCP for speed of setup.
Custom integration recipe using standard HTTP/MCP tools
- This recipe wires Vercel AI SDK’s own tool interface to the Auld REST API or MCP server; there is nothing Auld-specific to install.
- Bind the viewer id from your authentication layer, not from model output.
- Ingestion is asynchronous — poll the job before depending on a just-sent fact in tests.
- Recall returns up to your plan’s token limit (8,000 on Pay as you go and Flex).
Frequently asked questions
Does recall slow the first token?
With a tool, the model decides; for latency-sensitive paths, recall in parallel with other setup and inject the result into the system prompt.
Which SDK version?
Signatures change between major versions; check the AI SDK docs for your version.