OpenAIProvider
@composio/core / provider/OpenAIProvider / OpenAIProvider
Class: OpenAIProvider
Defined in: ts/packages/core/src/provider/OpenAIProvider.ts:22
Base class for all non-agentic toolsets. This class is not meant to be used directly, but rather to be extended by concrete provider implementations.
Extends
Constructors
Constructor
new OpenAIProvider():
OpenAIProvider
Defined in: ts/packages/core/src/provider/OpenAIProvider.ts:45
Creates a new instance of the OpenAIProvider.
This is the default provider for the Composio SDK and is automatically available without additional installation.
Returns
OpenAIProvider
Example
Overrides
BaseNonAgenticProvider
.constructor
Properties
_isAgentic
readonly
_isAgentic:false
=false
Defined in: ts/packages/core/src/provider/BaseProvider.ts:93
Internal
Whether the provider is agentic. This is set automatically set by the core SDK implementation for different provider types.
Inherited from
BaseNonAgenticProvider
._isAgentic
name
readonly
name:"openai"
='openai'
Defined in: ts/packages/core/src/provider/OpenAIProvider.ts:23
The name of the provider. Used to identify the provider in the telemetry.
Overrides
Methods
_setExecuteToolFn()
_setExecuteToolFn(
executeToolFn
):void
Defined in: ts/packages/core/src/provider/BaseProvider.ts:36
Internal
Set the function to execute a tool. This is set automatically and injected by the core SDK.
Parameters
executeToolFn
GlobalExecuteToolFn
Returns
void
Inherited from
BaseNonAgenticProvider
._setExecuteToolFn
executeTool()
executeTool(
toolSlug
,body
,modifers?
):Promise
<{ }>
Defined in: ts/packages/core/src/provider/BaseProvider.ts:50
Global function to execute a tool.
This function is used by providerds to implement helper functions to execute tools.
This is a 1:1 mapping of the execute
method in the Tools
class.
Parameters
toolSlug
string
The slug of the tool to execute.
body
The body of the tool execution.
modifers?
ExecuteToolModifiers
The modifiers of the tool execution.
Returns
Promise
<{ }>
The result of the tool execution.
Inherited from
BaseNonAgenticProvider
.executeTool
executeToolCall()
executeToolCall(
userId
,tool
,options?
,modifiers?
):Promise
<string
>
Defined in: ts/packages/core/src/provider/OpenAIProvider.ts:200
Executes a tool call from OpenAI’s chat completion.
This method processes a tool call from OpenAI’s chat completion API, executes the corresponding Composio tool, and returns the result.
Parameters
userId
string
The user ID for authentication and tracking
tool
ChatCompletionMessageToolCall
The tool call from OpenAI
options?
ExecuteToolFnOptions
Optional execution options
modifiers?
ExecuteToolModifiers
Optional execution modifiers
Returns
Promise
<string
>
The result of the tool call as a JSON string
Example
handleAssistantMessage()
handleAssistantMessage(
userId
,run
,options?
,modifiers?
):Promise
<ToolOutput
[]>
Defined in: ts/packages/core/src/provider/OpenAIProvider.ts:322
Handles all the tool calls from the OpenAI Assistant API.
This method processes tool calls from an OpenAI Assistant run, executes each tool call, and returns the tool outputs for submission.
Parameters
userId
string
The user ID for authentication and tracking
run
Run
The Assistant run object containing tool calls
options?
ExecuteToolFnOptions
Optional execution options
modifiers?
ExecuteToolModifiers
Optional execution modifiers
Returns
Promise
<ToolOutput
[]>
Array of tool outputs for submission
Example
handleToolCalls()
handleToolCalls(
userId
,chatCompletion
,options?
,modifiers?
):Promise
<string
[]>
Defined in: ts/packages/core/src/provider/OpenAIProvider.ts:258
Handles tool calls from OpenAI’s chat completion response.
This method processes tool calls from an OpenAI chat completion response, executes each tool call, and returns the results.
Parameters
userId
string
The user ID for authentication and tracking
chatCompletion
ChatCompletion
The chat completion response from OpenAI
options?
ExecuteToolFnOptions
Optional execution options
modifiers?
ExecuteToolModifiers
Optional execution modifiers
Returns
Promise
<string
[]>
Array of tool execution results as JSON strings
Example
waitAndHandleAssistantStreamToolCalls()
waitAndHandleAssistantStreamToolCalls(
userId
,client
,runStream
,thread
,options?
,modifiers?
):AsyncGenerator
<AssistantStreamEvent
,void
,unknown
>
Defined in: ts/packages/core/src/provider/OpenAIProvider.ts:394
Waits for the assistant stream and handles the tool calls.
This method processes an OpenAI Assistant stream, handles any tool calls that require action, and yields each event from the stream. It’s designed for streaming Assistant responses while handling tool calls in real-time.
Parameters
userId
string
The user ID for authentication and tracking
client
OpenAI
The OpenAI client instance
runStream
Stream
<AssistantStreamEvent
>
The Assistant run stream
thread
Thread
The thread object
options?
ExecuteToolFnOptions
Optional execution options
modifiers?
ExecuteToolModifiers
Optional execution modifiers
Returns
AsyncGenerator
<AssistantStreamEvent
, void
, unknown
>
Generator yielding stream events
Example
waitAndHandleAssistantToolCalls()
waitAndHandleAssistantToolCalls(
userId
,client
,run
,thread
,options?
,modifiers?
):Promise
<Run
>
Defined in: ts/packages/core/src/provider/OpenAIProvider.ts:512
Waits for the assistant tool calls and handles them.
This method polls an OpenAI Assistant run until it completes or requires action, handles any tool calls, and returns the final run object. It’s designed for non-streaming Assistant interactions.
Parameters
userId
string
The user ID for authentication and tracking
client
OpenAI
The OpenAI client instance
run
Run
The initial run object
thread
Thread
The thread object
options?
ExecuteToolFnOptions
Optional execution options
modifiers?
ExecuteToolModifiers
Optional execution modifiers
Returns
Promise
<Run
>
The final run object after completion
Example
wrapMcpServerResponse()
wrapMcpServerResponse(
data
,serverName
,connectedAccountIds?
,userIds?
,toolkits?
):McpServerGetResponse
Defined in: ts/packages/core/src/provider/OpenAIProvider.ts:60
Transform MCP URL response into OpenAI-specific format. OpenAI uses the standard format by default.
Parameters
data
McpUrlResponse
The MCP URL response data
serverName
string
Name of the MCP server
connectedAccountIds?
string
[]
Optional array of connected account IDs
userIds?
string
[]
Optional array of user IDs
toolkits?
string
[]
Optional array of toolkit names
Returns
McpServerGetResponse
Standard MCP server response format
Overrides
BaseNonAgenticProvider
.wrapMcpServerResponse
wrapTool()
wrapTool(
tool
):ChatCompletionTool
Defined in: ts/packages/core/src/provider/OpenAIProvider.ts:114
Wraps a Composio tool in the OpenAI function calling format.
This method transforms a Composio tool definition into the format expected by OpenAI’s function calling API.
Parameters
tool
The Composio tool to wrap
Returns
ChatCompletionTool
The wrapped tool in OpenAI format
Example
Overrides
BaseNonAgenticProvider
.wrapTool
wrapTools()
wrapTools(
tools
):OpenAiToolCollection
Defined in: ts/packages/core/src/provider/OpenAIProvider.ts:164
Wraps multiple Composio tools in the OpenAI function calling format.
This method transforms a list of Composio tools into the format expected by OpenAI’s function calling API.
Parameters
tools
object
[]
Array of Composio tools to wrap
Returns
Array of wrapped tools in OpenAI format