OpenAI Agents SDK
The OpenAI Agents SDK provider transforms Composio tools into the Agents SDK tool format with built-in execution.
Install
pip install composio composio-openai-agents openai-agentsnpm install @composio/core @composio/openai-agents @openai/agentsConfigure API Keys
Set COMPOSIO_API_KEY with your API key from Settings and OPENAI_API_KEY with your OpenAI API key.
COMPOSIO_API_KEY=xxxxxxxxx
OPENAI_API_KEY=xxxxxxxxxCreate session and run
import asyncio
from composio import Composio
from composio_openai_agents import OpenAIAgentsProvider
from agents import Agent, Runner
composio = Composio(provider=OpenAIAgentsProvider())
# Create a session for your user
session = composio.create(user_id="user_123")
tools = session.tools()
agent = Agent(
name="Email Agent",
instructions="You are a helpful assistant.",
tools=tools,
)
async def main():
result = await Runner.run(
starting_agent=agent,
input="Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'",
)
print(result.final_output)
asyncio.run(main())import { Composio } from "@composio/core";
import { OpenAIAgentsProvider } from "@composio/openai-agents";
import { Agent, run } from "@openai/agents";
const composio = new Composio({
provider: new OpenAIAgentsProvider(),
});
// Create a session for your user
const session = await composio.create("user_123");
const tools = await session.tools();
const agent = new Agent({
name: "Email Agent",
instructions: "You are a helpful assistant.",
tools,
});
const result = await run(
agent,
"Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'"
);
console.log(result.finalOutput);