Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | # @composio/vercel |
| 2 | |
| 3 | Composio provider for the [Vercel AI SDK](https://sdk.vercel.ai) (`ai`). It converts Composio tools into the AI SDK's tool format with built-in execution: each wrapped tool carries its own `execute` function, so the AI SDK runs tool calls for you without a manual agentic loop. |
| 4 | |
| 5 | ## Installation |
| 6 | |
| 7 | You need **Node.js 22.22.3 or newer**. The SDK is **ESM-only**: use `import` rather than CommonJS `require()`, and set `"type": "module"` in your project's `package.json`. |
| 8 | |
| 9 | ```bash |
| 10 | npm install @composio/core @composio/vercel ai @ai-sdk/anthropic |
| 11 | ``` |
| 12 | |
| 13 | `@ai-sdk/anthropic` powers the example below; swap in any AI SDK model package. |
| 14 | |
| 15 | Set two environment variables: |
| 16 | |
| 17 | - `COMPOSIO_API_KEY` from the [Composio dashboard](https://dashboard.composio.dev/settings) |
| 18 | - `ANTHROPIC_API_KEY` from [Anthropic](https://console.anthropic.com/settings/keys) (or the key for your chosen model provider) |
| 19 | |
| 20 | ### Verified SDK versions |
| 21 | |
| 22 | The published packages `@composio/core@0.28.0`, `@composio/vercel@0.13.0`, and `ai@7.0.162` pass a consumer typecheck on Node.js 24.22.1 with TypeScript 6.0.2. The check passes session tools to both `generateText` and `streamText` and loads the compiled ESM imports. This verifies the TypeScript integration, not live model or tool execution. |
| 23 | |
| 24 | ## Quickstart |
| 25 | |
| 26 | Create a session for your user, pass its tools to the AI SDK, and cap the run with `stopWhen`: |
| 27 | |
| 28 | ```typescript |
| 29 | import { anthropic } from '@ai-sdk/anthropic'; |
| 30 | import { Composio } from '@composio/core'; |
| 31 | import { VercelProvider } from '@composio/vercel'; |
| 32 | import { generateText, stepCountIs } from 'ai'; |
| 33 | |
| 34 | const composio = new Composio({ provider: new VercelProvider() }); |
| 35 | |
| 36 | // Each session is scoped to one of your users |
| 37 | const session = await composio.create('user_123'); |
| 38 | const tools = await session.tools(); |
| 39 | |
| 40 | const { text } = await generateText({ |
| 41 | model: anthropic('claude-sonnet-4-6'), |
| 42 | tools, |
| 43 | prompt: 'Summarize my emails from today', |
| 44 | stopWhen: stepCountIs(10), |
| 45 | }); |
| 46 | |
| 47 | console.log(text); |
| 48 | ``` |
| 49 | |
| 50 | For multi-turn conversations, store `session.sessionId` and reuse it with `composio.use(sessionId)` instead of creating a new session each turn. |
| 51 | |
| 52 | ## Strict mode |
| 53 | |
| 54 | Pass `strict: true` 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: |
| 55 | |
| 56 | ```typescript |
| 57 | const composio = new Composio({ provider: new VercelProvider({ strict: true }) }); |
| 58 | ``` |
| 59 | |
| 60 | 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. |
| 61 | |
| 62 | ## Tool schemas |
| 63 | |
| 64 | The provider passes each tool's JSON Schema to the AI SDK with `jsonSchema()`, so the model sees it as is, including keywords such as `format`, `contentEncoding`, and `contentMediaType`. Internal `$ref`s are inlined first. Tool-call arguments are validated with a Zod schema built from the same JSON Schema. In strict mode the model sees the strict rewrite instead, which drops string formats strict structured outputs reject. |
| 65 | |
| 66 | ## Links |
| 67 | |
| 68 | - [Vercel AI SDK provider docs](https://docs.composio.dev/docs/providers/vercel) |
| 69 | - [Composio quickstart](https://docs.composio.dev/docs/quickstart) |
| 70 | - [Composio documentation](https://docs.composio.dev) |