The OpenAI Agents API provider for Composio SDK, providing seamless integration with OpenAI's Agents API and tools.
The OpenAI Agents API provider for Composio SDK, providing seamless integration with OpenAI's Agents API and tools.
- OpenAI Agents Integration: Seamless integration with OpenAI's Agents SDK
- Tool Integration: Easy integration of Composio tools with OpenAI Agents
- Type Safety: Full TypeScript support with proper type definitions
- Strict Mode: Support for strict mode tool parameter validation
``bash`
npm install @composio/openai-agents @openai/agentsor
yarn add @composio/openai-agents @openai/agentsor
pnpm add @composio/openai-agents @openai/agents
Required environment variables:
- COMPOSIO_API_KEY: Your Composio API keyOPENAI_API_KEY
- : Your OpenAI API key
`typescript
import { OpenAIAgentsProvider } from '@composio/openai-agents';
import { Composio } from '@composio/core';
import { Agent, run } from '@openai/agents';
const composio = new Composio({
provider: new OpenAIAgentsProvider(),
});
// Fetch tools from Composio
const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER', {
beforeExecute: async (toolSlug, toolkitSlug, params) => {
console.log(🔄 Executing tool ${toolSlug} from toolkit ${toolkitSlug}...);✅ Tool ${toolSlug} executed
return params;
},
afterExecute: async (toolSlug, toolkitSlug, result) => {
console.log();
return result;
},
});
// Create an agent with the tools
const agent = new Agent({
name: 'Hackernews assistant',
tools: tools,
});
// Run the agent with a query
const result = await run(agent, 'Tell me about the user pg in hackernews');`
The OpenAI Agents provider can be configured with various options:
`typescript``
const provider = new OpenAIAgentsProvider({
strict: true, // Enable strict mode for tool parameters
});
For more information about OpenAI Agents and how to use them, see:
- OpenAI Strict Mode
- OpenAI Agents SDK Documentation
- OpenAI Agents SDK GitHub