Overview
In this example, you’ll learn how to:- Initialize Composio with OpenAI
- Fetch and use tools from Composio
- Handle tool calls from OpenAI responses
- Execute tools and process results
Prerequisites
Complete Example
How It Works
Initialize OpenAI and Composio
First, we create instances of both the OpenAI client and Composio SDK. Composio automatically detects and initializes the OpenAI provider.
Fetch Tools
We fetch the
HACKERNEWS_GET_USER tool from Composio. The tool is automatically formatted to work with OpenAI’s function calling format.Create Chat Completion
We send a message to OpenAI along with the available tools. OpenAI decides whether to use the tool based on the user’s request.
Expected Output
When you run this example, you’ll see:Next Steps
Anthropic Integration
Learn how to use Composio with Anthropic Claude
Custom Tools
Create your own custom tools with Composio