Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
docs(openai-agents): Add Native Tools code examples
Sushmithamalleshb57370e37211
diff --git a/docs/content/docs/providers/openai-agents.mdx b/docs/content/docs/providers/openai-agents.mdxindex 34042f7ee..ccfbde195 100644--- a/docs/content/docs/providers/openai-agents.mdx+++ b/docs/content/docs/providers/openai-agents.mdx@@ -4,10 +4,6 @@ description: Use Composio with OpenAI's Agents SDKkeywords: [agents sdk]----OpenAI Agents SDK is a lightweight framework for building agentic AI apps with minimal abstractions.--## Usage-<ToolTypeFlow><ToolTypeOption id="native" name="Native Tools" icon="native">@@ -23,7 +19,7 @@ pip install composio composio-openai-agents openai-agents</Tab><Tab value="TypeScript">```bash-npm install @composio/core @composio/openai-agents @openai/agents+npm install dotenv @composio/core @composio/openai-agents @openai/agents```</Tab></Tabs>@@ -48,12 +44,83 @@ OPENAI_API_KEY=xxxxxxxxx<Tabs groupId="language" items={['Python', 'TypeScript']} persist><Tab value="Python">```python-# TODO: Native tools Python code+import asyncio+from dotenv import load_dotenv+load_dotenv()++from composio import Composio+from agents import Agent, Runner+from composio_openai_agents import OpenAIAgentsProvider++# 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+tools = session.tools()++# Create agent with tools+agent = Agent(+ name="Email Manager",+ 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!'",+ )+ print(result.final_output)++asyncio.run(main())```</Tab><Tab value="TypeScript">```typescript-// TODO: Native tools TypeScript code+import "dotenv/config";+import { Composio } from "@composio/core";+import { Agent, run } from "@openai/agents";+import { OpenAIAgentsProvider } from "@composio/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+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>