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: Open ai agents provider (#2197)
Sushmitha Malleshb295db479340
diff --git a/fern/pages/src/providers/openai-agents.mdx b/fern/pages/src/providers/openai-agents.mdxindex d9a8a4a93..7fe505650 100644--- a/fern/pages/src/providers/openai-agents.mdx+++ b/fern/pages/src/providers/openai-agents.mdx@@ -13,46 +13,35 @@ The OpenAI Agents Provider is a provider that formats the Composio tools into anOpenAI Agents SDK is different from the OpenAI SDK. It helps build agentic AI apps in a lightweight, easy-to-use package with very few abstractions.-## Setup--```bash-pip install composio_openai_agents==0.8.0 openai-agents-```--### Usage-```python Python maxLines=60 wordWrap-import asyncio--from agents import Agent, Runner--from composio import Composio-from composio_openai_agents import OpenAIAgentsProvider--# Initialize Composio toolset-composio = Composio(provider=OpenAIAgentsProvider())--# Get all the tools-tools = composio.tools.get(- user_id="default",- tools=["GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER"],-)--# Create an agent with the tools-agent = Agent(- name="GitHub Agent",- instructions="You are a helpful assistant.",- tools=tools,-)--# Run the agent-async def main():- result = await Runner.run(- starting_agent=agent,- input=(- "Star the repository composiohq/composio on GitHub"- ),- )- print(result.final_output)--asyncio.run(main())-```\ No newline at end of file+<Tabs>+ <Tab title="Python">+ ### Setup++ ```bash+ pip install composio openai-agents composio-openai-agents+ ```++ ### Usage++ <SnippetCode+ src="fern/snippets/providers/python/openai-agents.py"+ startLine={1}+ endLine={26}+ />+ </Tab>+ <Tab title="TypeScript">+ ### Setup++ ```bash+ npm install @composio/core @openai/agents @composio/openai-agents+ ```++ ### Usage++ <SnippetCode+ src="fern/snippets/providers/typescript/openai-agents.ts"+ startLine={1}+ endLine={33}+ />+ </Tab>+</Tabs>diff --git a/fern/snippets/providers/python/openai-agents.py b/fern/snippets/providers/python/openai-agents.pynew file mode 100644index 000000000..81e06595b--- /dev/null+++ b/fern/snippets/providers/python/openai-agents.py@@ -0,0 +1,26 @@+import asyncio+from composio import Composio+from agents import Agent, Runner+from composio_openai_agents import OpenAIAgentsProvider++composio = Composio(api_key="your-api-key", provider=OpenAIAgentsProvider())++# Create a connected account for the user for the gmail toolkit and replace with your own user id+externalUserId = "your-user-id"++# Get Gmail tools that are pre-configured+tools = composio.tools.get(user_id=externalUserId, tools=["GMAIL_SEND_EMAIL"])++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="Send an email to [email protected] with the subject 'Hello from composio 👋🏻' and the body 'Congratulations on sending your first email using AI Agents and Composio!'",+ )+ print(result.final_output)++asyncio.run(main())\ No newline at end of filediff --git a/fern/snippets/providers/typescript/openai-agents.ts b/fern/snippets/providers/typescript/openai-agents.tsnew file mode 100644index 000000000..8ba2330d4--- /dev/null+++ b/fern/snippets/providers/typescript/openai-agents.ts@@ -0,0 +1,33 @@+import { Composio } from "@composio/core";+import { Agent, run } from "@openai/agents";+import { OpenAIAgentsProvider } from "@composio/openai-agents";++// add OPENAI_API_KEY in your .env file+const composio = new Composio({+ apiKey: "your-api-key",+ provider: new OpenAIAgentsProvider(),+});++// Create a connected account for the user for the gmail toolkit and replace with your own user id+const externalUserId = "your-user-id";++// Fetch tools for GMAIL toolkit on behalf of the user+const tools = await composio.tools.get(externalUserId, {+ tools: ["GMAIL_SEND_EMAIL"],+ });++const agent = new Agent({+ name: "Email Manager",+ tools: tools,+});++console.log(`Running agent...`);+const result = await run(+ agent,+ "Send an email to [email protected] with the subject 'Hello from composio' and the body 'Congratulations on sending your first email using AI Agents and Composio!'"+);++console.log(`Received response from agent`);+if (result.finalOutput) {+ console.log(JSON.stringify(result.finalOutput, null, 2));+}\ No newline at end of file