Skip to content

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: update OpenAI Agents SDK provider page to Steps pattern

Sushmithamalleshc0970e2f39a5
diff --git a/docs/content/docs/providers/openai-agents.mdx b/docs/content/docs/providers/openai-agents.mdx
index c12dde676..c0f4244ed 100644
--- a/docs/content/docs/providers/openai-agents.mdx
+++ b/docs/content/docs/providers/openai-agents.mdx
@@ -1,17 +1,16 @@
---
-title: OpenAI Agents
+title: OpenAI Agents SDK
description: Build an agent with OpenAI Agents SDK and enable it to use 800+ tools with Composio.
-keywords: [agents sdk]
+keywords: [openai agents sdk, agents sdk]
---
-<ToolTypeFlow>
+The OpenAI Agents SDK provider transforms Composio tools into the [Agents SDK tool format](https://openai.github.io/openai-agents-python/) with built-in execution.
-<ToolTypeOption id="native" name="Native Tools" icon="native">
<Steps>
<Step>
**Install**
-<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
+<Tabs groupId="language" items={["Python", "TypeScript"]} persist>
<Tab value="Python">
```bash
pip install composio composio-openai-agents openai-agents
@@ -19,7 +18,7 @@ pip install composio composio-openai-agents openai-agents
</Tab>
<Tab value="TypeScript">
```bash
-npm install dotenv @composio/core @composio/openai-agents @openai/agents
+npm install @composio/core @composio/openai-agents @openai/agents
```
</Tab>
</Tabs>
@@ -39,43 +38,32 @@ OPENAI_API_KEY=xxxxxxxxx
</Step>
<Step>
-**Create session and run agent**
+**Create session and run**
-<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
+<Tabs groupId="language" items={["Python", "TypeScript"]} persist>
<Tab value="Python">
```python
import asyncio
-from dotenv import load_dotenv
-load_dotenv()
-
from composio import Composio
-from agents import Agent, Runner
from composio_openai_agents import OpenAIAgentsProvider
+from agents import Agent, Runner
-# Initialize Composio with OpenAI Agents provider
composio = Composio(provider=OpenAIAgentsProvider())
-external_user_id = "user_2nFh83Hde"
-recipient_email = "[email protected]"
-
-# Create a session
-session = composio.create(user_id=external_user_id)
-
-# Get tools from the session
+# Create a session for your user
+session = composio.create(user_id="user_123")
tools = session.tools()
-# Create agent with tools
agent = Agent(
- name="Email Manager",
+ name="Email Agent",
instructions="You are a helpful assistant.",
tools=tools,
)
-# Run the agent
async def main():
result = await Runner.run(
starting_agent=agent,
- input=f"Send an email to {recipient_email} with the subject 'Hello from Composio' and the body 'Hello from the other side!'",
+ input="Send an email to [email protected] with the subject 'Hello' and body 'Hello from Composio!'",
)
print(result.final_output)
@@ -84,178 +72,32 @@ asyncio.run(main())
</Tab>
<Tab value="TypeScript">
```typescript
-import "dotenv/config";
import { Composio } from "@composio/core";
-import { Agent, run } from "@openai/agents";
import { OpenAIAgentsProvider } from "@composio/openai-agents";
+import { Agent, run } from "@openai/agents";
-// Initialize Composio with OpenAI Agents provider
const composio = new Composio({
provider: new OpenAIAgentsProvider(),
});
-const externalUserId = "user_2nFh83Hde";
-const recipientEmail = "[email protected]";
-
-// Create a session
-const session = await composio.create(externalUserId);
-
-// Get tools from the session
+// Create a session for your user
+const session = await composio.create("user_123");
const tools = await session.tools();
-// Create agent with tools
-const agent = new Agent({
- name: "Email Manager",
- instructions: "You are a helpful assistant.",
- tools: tools,
-});
-
-// Run the agent
-console.log("Running agent...");
-const result = await run(
- agent,
- `Send an email to ${recipientEmail} with the subject 'Hello from Composio' and the body 'This is a test email!'`
-);
-
-console.log("Received response from agent");
-if (result.finalOutput) {
- console.log(result.finalOutput);
-}
-```
-</Tab>
-</Tabs>
-</Step>
-</Steps>
-</ToolTypeOption>
-
-<ToolTypeOption id="mcp" name="MCP" icon="mcp">
-<Steps>
-<Step>
-**Install**
-
-<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
-<Tab value="Python">
-```bash
-pip install composio openai-agents
-```
-</Tab>
-<Tab value="TypeScript">
-```bash
-npm install dotenv @composio/core @openai/agents
-```
-</Tab>
-</Tabs>
-</Step>
-
-<Step>
-**Configure API Keys**
-
-<Callout type="info">
-Set `COMPOSIO_API_KEY` with your API key from [Settings](https://platform.composio.dev/?next_page=/settings) and `OPENAI_API_KEY` with your [OpenAI API key](https://platform.openai.com/api-keys).
-</Callout>
-
-```txt title=".env"
-COMPOSIO_API_KEY=xxxxxxxxx
-OPENAI_API_KEY=xxxxxxxxx
-```
-</Step>
-
-<Step>
-**Create session and run agent**
-
-<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
-<Tab value="Python">
-```python
-import asyncio
-from dotenv import load_dotenv
-load_dotenv()
-
-from composio import Composio
-from agents import Agent, Runner, HostedMCPTool
-
-# Initialize Composio
-composio = Composio()
-
-external_user_id = "user_2nFh83Hde"
-recipient_email = "[email protected]"
-
-# Create a session
-session = composio.create(user_id=external_user_id)
-
-# Create MCP tool
-composio_mcp = HostedMCPTool(
- tool_config={
- "type": "mcp",
- "server_label": "composio",
- "server_url": session.mcp.url,
- "require_approval": "never",
- "headers": session.mcp.headers,
- }
-)
-
-# Create agent with MCP tool
-agent = Agent(
- name="Email Manager",
- instructions="You are a helpful assistant.",
- tools=[composio_mcp],
-)
-
-# Run the agent
-async def main():
- result = await Runner.run(
- starting_agent=agent,
- input=f"Send an email to {recipient_email} with the subject 'Hello from Composio' and the body 'This is a test email!'",
- )
- print(result.final_output)
-
-asyncio.run(main())
-```
-</Tab>
-<Tab value="TypeScript">
-```typescript
-import "dotenv/config";
-import { Composio } from "@composio/core";
-import { Agent, run, hostedMcpTool } from "@openai/agents";
-
-// Initialize Composio
-const composio = new Composio();
-
-const externalUserId = "user_2nFh83Hde";
-const recipientEmail = "[email protected]";
-
-// Create a session
-const session = await composio.create(externalUserId);
-
-// Create agent with MCP tool
const agent = new Agent({
- name: "Email Manager",
+ name: "Email Agent",
instructions: "You are a helpful assistant.",
- tools: [
- hostedMcpTool({
- serverLabel: "composio",
- serverUrl: session.mcp.url,
- headers: session.mcp.headers,
- }),
- ],
+ tools,
});
-// Run the agent
-console.log("Running agent...");
const result = await run(
agent,
- `Send an email to ${recipientEmail} with the subject 'Hello from Composio' and the body 'This is a test email!'`
+ "Send an email to [email protected] with the subject 'Hello' and body 'Hello from Composio!'"
);
-console.log("Received response from agent");
-if (result.finalOutput) {
- console.log(result.finalOutput);
-}
+console.log(result.finalOutput);
```
</Tab>
</Tabs>
</Step>
</Steps>
-</ToolTypeOption>
-
-</ToolTypeFlow>
-