OpenAI Agents Provider

Use Composio with OpenAI's Agents SDK

OpenAI Agents Provider

The OpenAI Agents Provider is a provider that formats the Composio tools into an object compatible with OpenAI’s Agents API.

OpenAI 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

$pip install composio openai-agents composio-openai-agents

Usage

Python
1import asyncio
2from composio import Composio
3from agents import Agent, Runner
4from composio_openai_agents import OpenAIAgentsProvider
5
6composio = Composio(api_key="your-api-key", provider=OpenAIAgentsProvider())
7
8# Create a connected account for the user for the gmail toolkit and replace with your own user id
9externalUserId = "your-user-id"
10
11# Get Gmail tools that are pre-configured
12tools = composio.tools.get(user_id=externalUserId, tools=["GMAIL_SEND_EMAIL"])
13
14agent = Agent(
15name="Email Manager", instructions="You are a helpful assistant", tools=tools
16)
17
18# Run the agent
19async def main():
20result = await Runner.run(
21 starting_agent=agent,
22 input="Send an email to soham.g@composio.dev with the subject 'Hello from composio 👋🏻' and the body 'Congratulations on sending your first email using AI Agents and Composio!'",
23)
24print(result.final_output)
25
26asyncio.run(main())