Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
md 47 lines 2.03 KB
Rendered Raw
1 # OpenAI × Composio
2
3 Runnable references for using Composio tools with OpenAI Chat Completions. The
4 canonical examples use the unauthenticated `HACKERNEWS` toolkit, so no connected
5 account is required.
6
7 These examples double as tests: the package is typechecked and linted on every
8 PR, and its smoke and agent entries run nightly against the staging backend.
9
10 ## Setup
11
12 ```bash
13 pnpm install
14 cp ts/examples/openai/.env.example ts/examples/openai/.env
15 ```
16
17 Set `COMPOSIO_API_KEY` and `OPENAI_API_KEY` in `.env` before running an agent.
18
19 ## Canonical examples
20
21 | File | What it shows | Run |
22 | -------------------- | ---------------------------------------------------------------- | ------------------------------------------ |
23 | `src/index.ts` | Direct tools with a bounded OpenAI function-calling loop | `pnpm --filter openai-example start` |
24 | `src/tool-router.ts` | Tool Router tools executed through the session that created them | `pnpm --filter openai-example tool-router` |
25 | `src/smoke.ts` | Provider and Tool Router wrapping without an OpenAI request | `pnpm --filter openai-example run smoke` |
26 | `src/cloudflare.ts` | The Tool Router agent on the Cloudflare Workers runtime | `pnpm --filter openai-example run cf:dev` |
27
28 The direct and Tool Router agents are separate modules under
29 `src/hackernews-agent/`. Each loop is capped at ten model turns and rejects an
30 empty final response.
31
32 ## Existing examples
33
34 The existing Chat Completions, Responses API, OpenAI Agents SDK, and MCP
35 experiments remain under `src/` and keep their existing package scripts.
36
37 ## Cloudflare Workers
38
39 The Worker reads credentials from its `env` binding rather than `process.env`.
40 Configure both secrets before deployment:
41
42 ```bash
43 pnpm --filter openai-example exec wrangler secret put COMPOSIO_API_KEY
44 pnpm --filter openai-example exec wrangler secret put OPENAI_API_KEY
45 ```
46
47 CI validates the Worker bundle with `wrangler deploy --dry-run`.