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/openai-agents |
| 2 | |
| 3 | Composio provider for the [OpenAI Agents SDK](https://openai.github.io/openai-agents-js/) (`@openai/agents`). It converts Composio tools into the Agents SDK's native tool format so your agents can act across 1000+ apps. |
| 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`. See the [SDK quickstart](https://docs.composio.dev/docs/quickstart) for framework setup. |
| 8 | |
| 9 | ```bash |
| 10 | npm install @composio/core @composio/openai-agents @openai/agents |
| 11 | ``` |
| 12 | |
| 13 | Set two environment variables: |
| 14 | |
| 15 | - `COMPOSIO_API_KEY` from the [Composio dashboard](https://dashboard.composio.dev/settings) |
| 16 | - `OPENAI_API_KEY` from [OpenAI](https://platform.openai.com/api-keys) |
| 17 | |
| 18 | ## Quickstart |
| 19 | |
| 20 | Create a session for your user, hand its tools to an agent, and run it: |
| 21 | |
| 22 | ```typescript |
| 23 | import { Composio } from '@composio/core'; |
| 24 | import { OpenAIAgentsProvider } from '@composio/openai-agents'; |
| 25 | import { Agent, run } from '@openai/agents'; |
| 26 | |
| 27 | const composio = new Composio({ provider: new OpenAIAgentsProvider() }); |
| 28 | |
| 29 | // Each session is scoped to one of your users |
| 30 | const session = await composio.create('user_123'); |
| 31 | const tools = await session.tools(); |
| 32 | |
| 33 | const agent = new Agent({ |
| 34 | name: 'Personal Assistant', |
| 35 | instructions: 'You are a helpful personal assistant. Use Composio tools to take action.', |
| 36 | model: 'gpt-5.2', |
| 37 | tools, |
| 38 | }); |
| 39 | |
| 40 | const result = await run(agent, 'Summarize my emails from today'); |
| 41 | console.log(result.finalOutput); |
| 42 | ``` |
| 43 | |
| 44 | For multi-turn conversations, store `session.sessionId` and reuse it with `composio.use(sessionId)` instead of creating a new session each turn. |
| 45 | |
| 46 | ## Strict mode |
| 47 | |
| 48 | Pass `strict: true` to register tools with strict JSON schema validation (see the [Agents SDK options reference](https://openai.github.io/openai-agents-js/guides/tools/#options-reference)). Each tool's input schema is normalized for OpenAI structured outputs: 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, are registered without strict mode and log a warning: |
| 49 | |
| 50 | ```typescript |
| 51 | const provider = new OpenAIAgentsProvider({ strict: true }); |
| 52 | ``` |
| 53 | |
| 54 | ## Links |
| 55 | |
| 56 | - [Composio quickstart](https://docs.composio.dev/docs/quickstart) |
| 57 | - [Composio documentation](https://docs.composio.dev) |
| 58 | - [OpenAI Agents SDK documentation](https://openai.github.io/openai-agents-js/) |