Introduction
Learn about tool calling with Composio
Tool calling as a concept was introduced due to LLMs lack of ability to interact with data and influence external systems. Earlier you might be able to ask an LLM to write you a nice email, but you would have to manually send it. With tool calling, you can now provide an LLM a valid tools for example, GMAIL_SEND_EMAIL
to go and accomplish the task autonomously.
Composio extends this by providing a platform to connect your AI agents to external tools like Gmail, GitHub, Salesforce, etc. It’s like a bridge between your AI and the tools it needs to get work done.
Tool Calling with Composio
Here’s a typical flow when your agent uses a tool via Composio:
Essentially: Your app gets tool definitions from Composio, the LLM decides which to use, your app tells Composio to run it (handle_tool_calls
), and Composio securely executes the real API call.
Example: Using a Composio Tool with OpenAI
Let’s see this in action. We’ll ask an OpenAI model to fetch a GitHub username using a pre-built Composio tool.
(Assumes you’ve completed the Setup steps: installed SDKs, run composio login
, and composio add github
)
1. Initialize Clients & Toolset Get your LLM client and Composio toolset ready.
2. Get the Composio Tool Fetch the specific tool definition from Composio, formatted for your LLM.
3. Send Request to LLM Provide the user’s task and the Composio tools to the LLM.
4. Handle Tool Call via Composio
If the LLM decided to use a tool, pass the response to handle_tool_calls
. Composio takes care of the execution.
This example showcases how Composio seamlessly integrates with the LLM’s tool-calling mechanism, handling the complex parts of API interaction securely and reliably.