@devries-cameron20 / composio-1 / commits / e156b1250
Fork 0

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 TypeScript examples to Instant tools page

Brendan O'Leary committed Oct 5, 2026 at 12:51 UTC e156b1250bcd52ff4fdce0ac327078d893e92b43
1 file changed +56 -7
docs/content/docs/instant-tools.mdx
+56 -7
@@ -70,8 +70,10 @@ Top-level `toolkits` controls which tools the Session can discover and run. Omit
70
71 ## Run a search with an agent
72
73 -Install `composio`, `openai-agents`, and `python-dotenv`, then put `COMPOSIO_API_KEY` and `OPENAI_API_KEY` in a `.env` file as in the [Quickstart](/docs/quickstart). This small agent can choose when to search. The wrapper prints the Instant charge after each search call:
73 +Install `composio`, `openai-agents`, and `python-dotenv` for Python, or `@composio/core`, `@openai/agents`, `zod`, and `dotenv` for TypeScript. Put `COMPOSIO_API_KEY` and `OPENAI_API_KEY` in a `.env` file as in the [Quickstart](/docs/quickstart). This small agent can choose when to search. The wrapper prints the Instant charge after each search call:
74
75 +<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
76 +<Tab value="Python">
77 ```python
78 from agents import Agent, Runner, function_tool
79 from composio import Composio
@@ -90,6 +92,49 @@ agent = Agent(name="Researcher", instructions="Use search when you need current
92 while prompt := input("You: "):
93 print(Runner.run_sync(agent, prompt).final_output)
94 ```
95 +</Tab>
96 +<Tab value="TypeScript">
97 +```typescript
98 +import "dotenv/config";
99 +import { Composio } from "@composio/core";
100 +import { Agent, run, tool } from "@openai/agents";
101 +import { createInterface } from "node:readline/promises";
102 +import { z } from "zod";
103 +
104 +const session = await new Composio().create("user_123", {
105 + toolkits: ["exa"],
106 + instant: { returnInstantCharge: true },
107 +});
108 +
109 +const search = tool({
110 + name: "search",
111 + description: "Search the web for current information.",
112 + parameters: z.object({ query: z.string() }),
113 + execute: async ({ query }) => {
114 + const result = await session.execute("EXA_SEARCH", { query });
115 + console.log("Instant charge:", result.instantCharge ?? "none");
116 + return JSON.stringify(result.data);
117 + },
118 +});
119 +
120 +const agent = new Agent({
121 + name: "Researcher",
122 + instructions: "Use search when you need current information.",
123 + tools: [search],
124 +});
125 +const readline = createInterface({ input: process.stdin, output: process.stdout });
126 +try {
127 + while (true) {
128 + const prompt = await readline.question("You: ");
129 + if (!prompt) break;
130 + console.log((await run(agent, prompt)).finalOutput);
131 + }
132 +} finally {
133 + readline.close();
134 +}
135 +```
136 +</Tab>
137 +</Tabs>
138
139 The charge is present only if an Instant account served the call. A connected-account call prints `none`. Check the [tool input schema](/reference/api-reference/tools/getToolsByToolSlug) if you change tools or arguments.
140
@@ -137,18 +182,17 @@ Check the current [tool input schema](/reference/api-reference/tools/getToolsByT
182
183 ### Read charge details
184
140 -With `instant.return_instant_charge` enabled, the response from `session.execute()` includes `instant_charge` when an Instant account runs the tool. Read it from the result above:
185 +With `instant.return_instant_charge` enabled (`instant.returnInstantCharge` in TypeScript), the response from `session.execute()` includes `instant_charge` (`instantCharge` in TypeScript) when an Instant account runs the tool. Read it from the result above:
186
187 +<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
188 +<Tab value="Python">
189 ```python
190 charge = result.instant_charge
191 if charge is not None:
192 print(charge["amount"], charge["currency"], charge["charged_by"])
193 ```
147 -
148 -The `InstantCharge` type is exported from `composio.types` and includes `amount`, `currency`, and `charged_by`. Python provider integrations and mixed local/remote multi-tool execution also preserve these charge details.
149 -
150 -In TypeScript, read `instantCharge` from the result:
151 -
194 +</Tab>
195 +<Tab value="TypeScript">
196 ```typescript
197 // @noErrors
198 import { Composio } from "@composio/core";
@@ -159,8 +203,13 @@ const session = await composio.create("user_123", {
203 instant: { returnInstantCharge: true },
204 });
205 const result = await session.execute("EXA_SEARCH", { query: "Composio documentation" });
206 +// ---cut---
207 console.log(result.instantCharge ?? "No Instant charge");
208 ```
209 +</Tab>
210 +</Tabs>
211 +
212 +The `InstantCharge` type is exported from `composio.types` and includes `amount`, `currency`, and `charged_by`. Python provider integrations and mixed local/remote multi-tool execution also preserve these charge details.
213
214 ## Control Instant usage
215