- The Responses API, the recommended way to build agentic flows, where you run the tool-call loop yourself.
- The Chat Completions API, the classic message-based interface, where you also run the loop.
- The Agents SDK, where the SDK runs the loop and executes Composio tools for you.
- Responses API
- Chat Completions
- Agents SDK
The
OpenAIResponsesProvider transforms Composio tools into OpenAI’s function-calling format for the Responses API, then executes the tool calls the model returns and shapes the results into function_call_output items you feed back in.1
Install
Install
- Python
- TypeScript
2
Configure API Keys
Configure API Keys
Set
COMPOSIO_API_KEY with your API key from Settings and OPENAI_API_KEY with your OpenAI API key..env
3
Create session and run
Create session and runThe Responses API is the recommended way to build agentic flows with OpenAI. You pass
previous_response_id on each turn so the model keeps the prior context, and you send back only the new function_call_output items.Passing a session to
handle_tool_calls / handleToolCalls requires composio newer than 0.19.0 (Python) or @composio/core ≥ 0.17.0 with @composio/openai ≥ 0.12.0 (TypeScript). On earlier versions, execute session tools with session.execute().- Python
- TypeScript
Provider specifics
The OpenAI integration ships three providers, one per API surface:OpenAIResponsesProviderfor the Responses API.handleToolCallsexecutes eachfunction_calland returnsfunction_call_outputitems keyed bycall_id, paired withprevious_response_idso you only resend new outputs each turn.OpenAIProviderfor the Chat Completions API. This is the SDK default, sonew Composio()with no provider uses it. You keep the full message list and append each assistant message plus itstoolresults yourself.OpenAIAgentsProviderfor the Agents SDK. Tools come with execution wired in, so the SDK runs the loop for you.
OpenAIAgentsProvider preserves the source schema’s top-level additionalProperties setting in the tool declaration sent to the model. A schema with no declared properties is advertised as open, so the model can supply arbitrary keys.
Strict mode. Pass strict: true or strict=True to OpenAIResponsesProvider or OpenAIAgentsProvider to normalize each tool’s input schema for structured outputs. Every object lists all of its properties in required and is closed, while optional properties stay available but accept null. A null is dropped before the tool runs unless the tool’s own schema accepts null for that parameter. Tools whose schema strict mode cannot express, such as objects that accept arbitrary keys, allOf, prefixItems, or unresolved $refs, are sent without strict mode and log a warning.
- Python
- TypeScript
Pass the session to
handleToolCalls / handle_tool_calls when the model received tools from session.tools(). The helper preserves the provider’s argument normalization and executes every call through that session. For tools fetched via tools.get, pass the user ID instead.