Docs / Recipes / Vercel AI SDK
// AGENT FRAMEWORK · VERCEL AI SDK
Vercel AI SDK
Pattern A · full governance
Create the OpenAI provider with a custom baseURL pointing at the gateway. Every generateText / streamText call routes through Agentics.
Pattern A — routed through the gateway. Your call travels through Agentics via a base-URL swap, so it is governed (routing, budgets, guardrails) inline and the Proof Ledger writes one verifiable receipt server-side. The receipt hash comes back in the
x-agentics-receipt response header.
Install
shell
npm install ai @ai-sdk/openaiPoint the framework's OpenAI client at the gateway
The option is baseURL on createOpenAI; the SDK also honours OPENAI_BASE_URL.
TypeScript
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";
const openai = createOpenAI({
baseURL: "https://agentics.you/api/v1", // the only change
apiKey: "ak_…", // AGENTICS_API_KEY
headers: { "x-agentics-user": "alice@acme.com" },
});
const { text } = await generateText({
model: openai("@anthropic/claude-opus-4-8"),
prompt: "hi",
});
console.log(text);You can also configure it via environment: OPENAI_BASE_URL=https://agentics.you/api/v1.
Run one call → see the receipt
Run your normal invocation, then read the receipt for that call off the ledger:
shell
# after your run, the last call's receipt hash:
agentics log tail --limit 1
# → shows x-agentics-receipt: <receipt_hash> (verify it at /trust)Every call the framework makes is now routed, governed, and receipted server-side.