Vercel AI SDK
The Vercel AI SDK provider transforms Composio tools into Vercel's tool format with built-in execution, so you don't write a manual agentic loop. Each wrapped tool carries its own execute function, and the AI SDK calls it for you.
Install
npm install @composio/core @composio/vercel ai @ai-sdk/anthropicConfigure API Keys
Set COMPOSIO_API_KEY with your API key from Settings and ANTHROPIC_API_KEY with your Anthropic API key.
COMPOSIO_API_KEY=xxxxxxxxx
ANTHROPIC_API_KEY=xxxxxxxxxCreate session and run
The Vercel provider is agentic: tools include an execute function, so the AI SDK handles tool calls automatically. Set stopWhen to cap how many tool-calling steps a run can take.
import { anthropic } from "@ai-sdk/anthropic";
import { Composio } from "@composio/core";
import { VercelProvider } from "@composio/vercel";
import { generateText, stepCountIs } from "ai";
const composio = new Composio({ provider: new VercelProvider() });
// Create a session for your user
const session = await composio.create("user_123");
const tools = await session.tools();
const { text } = await generateText({
model: anthropic("claude-opus-4-6"),
tools,
prompt: "Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'",
stopWhen: stepCountIs(10),
});
console.log(text);Provider specifics
Strict mode. Some models reject tool schemas that contain optional parameters. Pass strict: true to the provider to normalize each tool's input schema for OpenAI structured outputs before it reaches the AI SDK: every object lists all of its properties in required and is closed, and optional properties stay available but accept null. A null is dropped before the tool runs unless the tool's own schema accepts null for that parameter, so nullable fields still receive an explicit null. Tools whose schema cannot be expressed in strict mode, such as objects that accept arbitrary keys, allOf, prefixItems, or unresolved $refs, keep their original schema and log a warning:
import { Composio } from "@composio/core";
import { VercelProvider } from "@composio/vercel";
const composio = new Composio({ provider: new VercelProvider({ strict: true }) });The provider converts each Composio tool's JSON Schema to a Zod schema for the AI SDK and normalizes tool arguments, so it still works when a model emits tool input as a JSON string rather than an object.
Next
What is a session?
How sessions scope users, tools, and auth, and how to reuse them across requests.