Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
docs: add multi-turn .use() examples to Vercel, OpenAI, Anthropic providers
Shows the pattern of creating a session once, storing the ID, and reusing it across requests with composio.use(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Abir Taheer committed
May 8, 2026 at 02:55 UTC
75e42e96901cff2be93b8edec44375dedf45e2b5
3 files changed
+105
docs/content/docs/providers/anthropic.mdx
+38
@@ -148,3 +148,41 @@ for (const block of response.content) {
148
</Tabs>
149
</Step>
150
</Steps>
151
+
152
+## Multi-turn chat
153
+
154
+For multi-turn apps, create the session once and reuse it across requests with `composio.use()`:
155
+
156
+<Tabs groupId="language" items={["Python", "TypeScript"]} persist>
157
+<Tab value="Python">
158
+```python
159
+from composio import Composio
160
+
161
+composio = Composio()
162
+
163
+# First request — create and store the session ID
164
+session = composio.create(user_id="user_123")
165
+session_id = session.session_id
166
+# store session_id in your database or chat state
167
+
168
+# Subsequent requests — reuse the session
169
+session = composio.use(session_id)
170
+tools = session.tools()
171
+```
172
+</Tab>
173
+<Tab value="TypeScript">
174
+```typescript
175
+import { Composio } from '@composio/core';
176
+const composio = new Composio({ apiKey: 'your_api_key' });
177
+// ---cut---
178
+// First request — create and store the session ID
179
+const session = await composio.create("user_123");
180
+const sessionId = session.sessionId;
181
+// store sessionId in your database or chat state
182
+
183
+// Subsequent requests — reuse the session
184
+const session2 = await composio.use(sessionId);
185
+const tools = await session2.tools();
186
+```
187
+</Tab>
188
+</Tabs>
docs/content/docs/providers/openai.mdx
+38
@@ -297,3 +297,41 @@ console.log(response.choices[0].message.content);
297
</IntegrationContent>
298
299
</IntegrationTabs>
300
+
301
+## Multi-turn chat
302
+
303
+For multi-turn apps, create the session once and reuse it across requests with `composio.use()`. Store the session ID in your database or chat state:
304
+
305
+<Tabs groupId="language" items={["Python", "TypeScript"]} persist>
306
+<Tab value="Python">
307
+```python
308
+from composio import Composio
309
+
310
+composio = Composio()
311
+
312
+# First request — create and store the session ID
313
+session = composio.create(user_id="user_123")
314
+session_id = session.session_id
315
+# store session_id in your database or chat state
316
+
317
+# Subsequent requests — reuse the session
318
+session = composio.use(session_id)
319
+tools = session.tools()
320
+```
321
+</Tab>
322
+<Tab value="TypeScript">
323
+```typescript
324
+import { Composio } from '@composio/core';
325
+const composio = new Composio({ apiKey: 'your_api_key' });
326
+// ---cut---
327
+// First request — create and store the session ID
328
+const session = await composio.create("user_123");
329
+const sessionId = session.sessionId;
330
+// store sessionId in your database or chat state
331
+
332
+// Subsequent requests — reuse the session
333
+const session2 = await composio.use(sessionId);
334
+const tools = await session2.tools();
335
+```
336
+</Tab>
337
+</Tabs>
docs/content/docs/providers/vercel.mdx
+29
@@ -56,3 +56,32 @@ console.log(text);
56
```
57
</Step>
58
</Steps>
59
+
60
+## Multi-turn chat
61
+
62
+For multi-turn apps, create the session once and reuse it across requests with `composio.use()`:
63
+
64
+```typescript
65
+import { anthropic } from "@ai-sdk/anthropic";
66
+import { Composio } from "@composio/core";
67
+import { VercelProvider } from "@composio/vercel";
68
+import { generateText, stepCountIs } from "ai";
69
+
70
+const composio = new Composio({ provider: new VercelProvider() });
71
+
72
+// First request — create and store the session ID
73
+const session = await composio.create("user_123");
74
+const sessionId = session.sessionId;
75
+// store sessionId in your database or chat state
76
+
77
+// Subsequent requests — reuse the session
78
+const session2 = await composio.use(sessionId);
79
+const tools = await session2.tools();
80
+
81
+const { text } = await generateText({
82
+ model: anthropic("claude-opus-4-6"),
83
+ tools,
84
+ prompt: "What emails did I get today?",
85
+ stopWhen: stepCountIs(10),
86
+});
87
+```