> ## Documentation Index
> Fetch the complete documentation index at: https://composio-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel AI SDK

> Build an agent with Vercel AI SDK and enable it to use 1000+ tools with Composio.

The Vercel AI SDK provider transforms Composio tools into Vercel's [tool format](https://sdk.vercel.ai/docs/ai-sdk-core/tools-and-tool-calling) 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.

**1. Install**

**Install**

```bash npm theme={null}
npm install @composio/core @composio/vercel ai @ai-sdk/anthropic
```

```bash pnpm theme={null}
pnpm add @composio/core @composio/vercel ai @ai-sdk/anthropic
```

```bash yarn theme={null}
yarn add @composio/core @composio/vercel ai @ai-sdk/anthropic
```

```bash bun theme={null}
bun add @composio/core @composio/vercel ai @ai-sdk/anthropic
```

**2. Configure API Keys**

**Configure API Keys**

> [!NOTE]
>
> Set `COMPOSIO_API_KEY` with your API key from [Settings](https://dashboard.composio.dev/~/project/settings/api-keys?utm_source=docs\&utm_medium=content\&utm_campaign=docs-providers-vercel) and `ANTHROPIC_API_KEY` with your [Anthropic API key](https://console.anthropic.com/settings/keys).

```txt .env theme={null}
COMPOSIO_API_KEY=xxxxxxxxx
ANTHROPIC_API_KEY=xxxxxxxxx
```

**3. Create session and run**

**Create session and run**

The Vercel provider is **agentic**: tools include an `execute` function, so the AI SDK handles tool calls automatically. Set [`stopWhen`](https://ai-sdk.dev/docs/ai-sdk-core/tools-and-tool-calling) to cap how many tool-calling steps a run can take.

```typescript theme={null}
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-5-5"),
  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.** Pass `strict: true` to the provider to rewrite each tool's input schema into the form OpenAI strict mode (structured outputs) accepts 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 `$ref`s, keep their original schema and log a warning:

```typescript theme={null}
import { Composio } from "@composio/core";
import { VercelProvider } from "@composio/vercel";

const composio = new Composio({ provider: new VercelProvider({ strict: true }) });
```

The option does not set the AI SDK's per-tool `strict` flag, so the model provider does not enforce the schema. It does change what the provider accepts locally: tool-call arguments are validated against the rewritten schema, so a call that leaves out an optional parameter instead of sending `null` fails validation, and those `null`s are dropped before the tool runs, as described above. If you set that flag yourself, use it only with OpenAI models and only on tools that did not log the warning above, since OpenAI rejects a tool that kept its original schema. Don't set it for Anthropic models: Anthropic strict mode allows at most 16 parameters with union types and 24 optional parameters across all strict tools in a request, and the rewrite turns every optional parameter into a union, so a request with about ten Composio tools is rejected. Anthropic strict mode also rejects recursive definitions and keywords such as `minimum` and `maximum` that some Composio tools use.

> [!NOTE]
>
> The provider sends each Composio tool's JSON Schema to the model as is, so keywords such as `format`, `contentEncoding`, and `contentMediaType` reach it, and validates tool-call arguments with a Zod schema built from the same JSON Schema. It also normalizes tool arguments, so it still works when a model emits tool input as a JSON string rather than an object.

> [!WARNING]
>
> `tool.inputSchema` is an AI SDK `Schema`. If you validate arguments yourself, import `asSchema` from `ai` and call `await asSchema(tool.inputSchema).validate(value)` instead of `tool.inputSchema.safeParse(value)`.

## Next

> [card] [What is a session?](https://composio-preview.mintlify.site/docs/how-composio-works.md)
>
> How sessions scope users, tools, and auth, and how to reuse them across requests.
