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:

1npm install @composio/openai

The OpenAI Provider is used by default when you initialize the Composio SDK but you can explicitly specify it.

1import { Composio } from "@composio/core";
2import { OpenAIProvider } from "@composio/openai";
3import { OpenAI } from "openai";
4
5const composio = new Composio({
6 apiKey: "your-composio-api-key",
7 provider: new OpenAIProvider(),
8});
9
10const openai = new OpenAI();

Responses API

Handling tool calls from the Responses API

  • Pending on SDK

Streaming

Handling streaming responses from the Responses API

  • Pending on SDK

Chat Completion API

1const userId = "your@example.com";
2const tools = await composio.tools.get(userId, "HACKERNEWS");
3
4const completion = await openai.chat.completions.create({
5 model: "gpt-4o",
6 messages: [
7 {
8 role: "user",
9 content: "What is the latest hackernews post about?",
10 },
11 ],
12 tools: tools,
13});
14
15const result = await composio.provider.handleToolCall(userId, completion);
16
17console.log(result);

Streaming

Handling streaming responses from the Chat Completion API

  • Pending on SDK

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: Framework Modifiers