OpenAI Providers

The OpenAI Provider is the default provider for the Composio SDK. It transforms Composio tools into a format compatible with OpenAI’s function calling capabilities through both the Responses and Chat Completion APIs.

Setup

By default, the OpenAI Provider is installed when you install the Composio SDK. You can also install it manually:

$pip install composio_openai

Responses API

The Responses API is the recommended way to build more agentic flows with the OpenAI API. Read more about it in the OpenAI documentation

Before executing any tools that require authentication (like Gmail), you’ll need to:

  1. Create an Auth Configuration for your integration
  2. Set up a Connected Account for the user.
1from openai import OpenAI
2from composio import Composio
3from composio_openai import OpenAIResponsesProvider
4
5# Initialize Composio client with OpenAI Provider
6composio = Composio(provider=OpenAIResponsesProvider())
7openai = OpenAI()
8
9# Make sure to create an auth config and a connected account for the user with gmail toolkit
10# Make sure to replace "your-user-id" with the actual user ID
11user_id = "your-user-id"
12
13tools = composio.tools.get(user_id=user_id, tools=["GMAIL_SEND_EMAIL"])
14
15response = openai.responses.create(
16 model="gpt-5",
17 tools=tools,
18 input=[
19 {
20 "role": "user",
21 "content": "Send an email to soham.g@composio.dev with the subject 'Running OpenAI Provider snippet' and body 'Hello from the code snippet in openai docs'"
22 }
23 ]
24)
25
26# Execute the function calls
27result = composio.provider.handle_tool_calls(response=response, user_id=user_id)
28print(result)

Chat Completion API

The Chat Completion API generates a model response from a list of messages. Read more about it in the OpenAI documentation. The OpenAI Chat Provider is the default provider used by Composio SDK, but you can also explicitly initialise it.

Before executing any tools that require authentication (like Gmail), you’ll need to:

  1. Create an Auth Configuration for your integration
  2. Set up a Connected Account for the user.
1from openai import OpenAI
2from composio import Composio
3from composio_openai import OpenAIProvider
4
5# Initialize Composio client with OpenAI Provider
6composio = Composio(provider=OpenAIProvider())
7openai = OpenAI()
8
9# Make sure to create an auth config and a connected account for the user with gmail toolkit
10# Make sure to replace "your-user-id" with the actual user ID
11user_id = "your-user-id"
12
13tools = composio.tools.get(user_id=user_id, tools=["GMAIL_SEND_EMAIL"])
14
15response = openai.chat.completions.create(
16 model="gpt-5",
17 tools=tools,
18 messages=[
19 {"role": "user", "content": "Send an email to soham.g@composio.dev with the subject 'Running OpenAI Provider snippet' and body 'Hello from the code snippet in openai docs'"},
20 ],
21)
22
23# Execute the function calls
24result = composio.provider.handle_tool_calls(response=response, user_id=user_id)
25print(result)

Modifiers

Modifiers are functions that can be used to intercept and optionally modify the schema, the tool call request and the response from the tool call.

OpenAI provider modifiers are the standard framework modifiers. Read more here: Modifying tool schemas