composio-openai
Adapts Composio tools to OpenAI function calling, for both the Responses API and the Chat Completions API.
Installation
pip install composio composio-openai openai
Set COMPOSIO_API_KEY (create one at https://dashboard.composio.dev/settings) and OPENAI_API_KEY in your environment.
Quickstart
This package exports two providers: OpenAIResponsesProvider for the Responses API and OpenAIProvider for Chat Completions. Both are non-agentic: the model returns tool calls, you execute them with handle_tool_calls, and you feed the results back.
import json
from openai import OpenAI
from composio import Composio
from composio_openai import OpenAIResponsesProvider
composio = Composio(provider=OpenAIResponsesProvider())
client = OpenAI()
# Create a session for your user
session = composio.create(user_id="user_123")
tools = session.tools()
response = client.responses.create(
model="gpt-5.2",
tools=tools,
input=[
{
"role": "user",
"content": "Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'"
}
]
)
# Agentic loop: keep executing tool calls until the model responds with text
while True:
tool_calls = [o for o in response.output if o.type == "function_call"]
if not tool_calls:
break
results = composio.provider.handle_tool_calls(response=response, session=session)
response = client.responses.create(
model="gpt-5.2",
tools=tools,
previous_response_id=response.id,
input=[
{"type": "function_call_output", "call_id": tool_calls[i].call_id, "output": json.dumps(result)}
for i, result in enumerate(results)
]
)
# Print final response
for item in response.output:
if item.type == "message":
print(item.content[0].text)
Chat Completions
OpenAIProvider targets client.chat.completions.create and is the Composio SDK default, so Composio() with no provider uses it. The loop is the same shape: call handle_tool_calls(response=response, session=session), append the results as tool messages, and call the API again. Pass user_id instead for tools fetched with tools.get(). See the docs page for the full example.
Links
- OpenAI provider docs: https://docs.composio.dev/docs/providers/openai
- Composio docs: https://docs.composio.dev
Release files for composio-openai 0.24.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| composio_openai-0.24.0.tar.gz | 2.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| composio_openai-0.24.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.0 kB
Release files / composio_openai-0.24.0.tar.gz
| Download URL | composio_openai-0.24.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
818f72c83d21993f82ce01e0d9f282d0b71cd8738d93e2cb4aa2c7d5f1a5c44f
|
|
BLAKE2b-256 checksum How to use checksums |
a5a6d973958ee16924ec061a3a83d2469845b6b54a812ab90e9ab8c8caa1d8a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / composio_openai-0.24.0-py3-none-any.whl
| Download URL | composio_openai-0.24.0-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c79646ce27c7fb559e909893c3b1a6dfd02a569f36ff44a0b74b996c480ed5a
|
|
BLAKE2b-256 checksum How to use checksums |
633692d9522f3b37a74e06c795e235e69c43062de3a5f3d7c652e1dafd9ec467
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|