Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
Add Providers section with all framework integrations
Sushmithamallesh2bc2dc18fbbe
diff --git a/fumadocs/content/docs/meta.json b/fumadocs/content/docs/meta.jsonindex b639b2f1f..deedba912 100644--- a/fumadocs/content/docs/meta.json+++ b/fumadocs/content/docs/meta.json@@ -4,6 +4,7 @@"index","quickstart","capabilities",+ "providers","---Tools and Triggers---","fetching-tools","authenticating-tools",diff --git a/fumadocs/content/docs/providers/anthropic.mdx b/fumadocs/content/docs/providers/anthropic.mdxnew file mode 100644index 000000000..a2c4fae6d--- /dev/null+++ b/fumadocs/content/docs/providers/anthropic.mdx@@ -0,0 +1,113 @@+---+title: Anthropic Provider+description: Use Composio tools with Claude+---++The Anthropic Provider transforms Composio tools into a format compatible with Anthropic's function calling capabilities through its Messages API.++## Setup++The Anthropic provider can be installed for both SDKs.++<Tabs items={["Python", "TypeScript"]}>+<Tab value="Python">+```bash+pip install composio composio-anthropic+```+</Tab>+<Tab value="TypeScript">+```bash+npm install @composio/anthropic @anthropic-ai/sdk+```+</Tab>+</Tabs>++You can specify the provider in the constructor. The constructor also takes in an optional `cacheTools` parameter.++<Tabs items={["Python", "TypeScript"]}>+<Tab value="Python">+```python+import anthropic++from composio import Composio+from composio_anthropic import AnthropicProvider++# Initialize tools.+anthropic_client = anthropic.Anthropic()+composio = Composio(provider=AnthropicProvider())+```+</Tab>+<Tab value="TypeScript">+```typescript+import { Composio } from "@composio/core";+import { AnthropicProvider } from "@composio/anthropic";+import Anthropic from '@anthropic-ai/sdk';++const composio = new Composio({+ provider: new AnthropicProvider({+ cacheTools: false, // default+ }),+});++const anthropic = new Anthropic();+```+</Tab>+</Tabs>++## Usage++<Tabs items={["Python", "TypeScript"]}>+<Tab value="Python">+```python+# Define your user ID+user_id = "your-user-id"++# Get GitHub tool for listing stargazers+tools = composio.tools.get(user_id=user_id, tools=["GITHUB_LIST_STARGAZERS"])++# Get response from the LLM+response = anthropic_client.messages.create(+ model="claude-sonnet-4-5",+ max_tokens=1024,+ tools=tools,+ messages=[+ {"role": "user", "content": "List my github stargazers. for the repo composiohq/composio"},+ ],+)++# Execute the function calls.+result = composio.provider.handle_tool_calls(user_id=user_id, response=response)+print(result)+```+</Tab>+<Tab value="TypeScript">+```typescript+const userId = "your-user-id";+const tools = await composio.tools.get(userId, {+ tools: ["GITHUB_LIST_STARGAZERS"]+})++const msg = await anthropic.messages.create({+ model: "claude-sonnet-4-5",+ messages: [+ {+ role: "user",+ content: "List my github stargazers. for the repo composiohq/composio",+ },+ ],+ tools: tools,+ max_tokens: 1000,+});++const res = await composio.provider.handleToolCalls(userId, msg);++console.log(res[0].content);+```+</Tab>+</Tabs>++## 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.++Anthropic provider modifiers are the standard framework modifiers. Read more here: [Modifying tool schemas](/docs/modify-tool-behavior/modifying-tool-schemas).diff --git a/fumadocs/content/docs/providers/crewai.mdx b/fumadocs/content/docs/providers/crewai.mdxnew file mode 100644index 000000000..2a565888e--- /dev/null+++ b/fumadocs/content/docs/providers/crewai.mdx@@ -0,0 +1,58 @@+---+title: CrewAI Provider+description: Use Composio tools with CrewAI agents+---++The CrewAI Provider formats the Composio tools into an object compatible with CrewAI's tool calling capabilities. Agents and LLM workflows built with this can call and execute the Composio tools.++## Setup++The CrewAI provider is available for only the Python SDK.++```bash+pip install composio_crewai==0.8.0+```++## Usage++```python+from crewai import Agent, Crew, Task+from langchain_openai import ChatOpenAI++from composio import Composio+from composio_crewai import CrewAIProvider++# Initialize tools.+openai_client = ChatOpenAI()+composio = Composio(provider=CrewAIProvider())++# Get All the tools+tools = composio.tools.get(user_id="default", toolkits=["GITHUB"])++# Define agent+crewai_agent = Agent(+ role="Github Agent",+ goal="""You take action on Github using Github APIs""",+ backstory=(+ "You are AI agent that is responsible for taking actions on Github "+ "on users' behalf. You need to take action on Github using Github APIs"+ ),+ verbose=True,+ tools=tools,+ llm=openai_client,+)++# Define task+task = Task(+ description=(+ "Star a repo composiohq/composio on GitHub, if the action is successful "+ "include Action executed successfully"+ ),+ agent=crewai_agent,+ expected_output="if the star happened",+)++my_crew = Crew(agents=[crewai_agent], tasks=[task])+result = my_crew.kickoff()+print(result)+```diff --git a/fumadocs/content/docs/providers/custom-python.mdx b/fumadocs/content/docs/providers/custom-python.mdxnew file mode 100644index 000000000..337c4f2ec--- /dev/null+++ b/fumadocs/content/docs/providers/custom-python.mdx@@ -0,0 +1,283 @@+---+title: Python Custom Provider+description: Learn how to create custom providers for any AI framework in Python+---++This guide shows how to create custom providers for the Composio Python SDK. Custom providers enable integration with different AI frameworks and platforms.++## Provider architecture++The Composio SDK uses a provider architecture to adapt tools for different AI frameworks. The provider handles:++1. **Tool format transformation**: Converting Composio tools into formats compatible with specific AI platforms+2. **Platform-specific integration**: Providing helper methods for seamless integration++## Types of providers++There are two types of providers:++1. **Non-agentic providers**: Transform tools for platforms that don't have their own agency (e.g., OpenAI, Anthropic)+2. **Agentic providers**: Transform tools for platforms that have their own agency (e.g., LangChain, CrewAI)++## Provider class hierarchy++```+BaseProvider (Abstract)+├── NonAgenticProvider (Abstract)+│ └── OpenAIProvider (Concrete)+│ └── AnthropicProvider (Concrete)+│ └── [Your Custom Non-Agentic Provider] (Concrete)+└── AgenticProvider (Abstract)+ └── LangchainProvider (Concrete)+ └── [Your Custom Agentic Provider] (Concrete)+```++## Quick start++The fastest way to create a new provider is using the provider scaffolding script:++```bash+# Create a non-agentic provider+make create-provider name=myprovider++# Create an agentic provider+make create-provider name=myagent agentic=true++# Create provider with custom output directory+make create-provider name=myprovider output=/path/to/custom/dir++# Combine options+make create-provider name=myagent agentic=true output=/my/custom/path+```++This will create a new provider in the specified directory (default: `python/providers/<provider-name>/`) with:+- Complete package structure with `pyproject.toml`+- Provider implementation template+- Demo script+- README with usage examples+- Type annotations and proper inheritance++<Callout>+The scaffolding script creates a fully functional provider template. You just need to implement the tool transformation logic specific to your platform. You can maintain your provider implementation in your own repository.+</Callout>++### Generated structure++The create-provider script generates the following structure:++```+python/providers/<provider-name>/+├── README.md # Documentation and usage examples+├── pyproject.toml # Project configuration+├── setup.py # Setup script for pip compatibility+├── <provider-name>_demo.py # Demo script showing usage+└── composio_<provider-name>/ # Package directory+ ├── __init__.py # Package initialization+ ├── provider.py # Provider implementation+ └── py.typed # PEP 561 type marker+```++After generation, you can:+1. Navigate to the provider directory: `cd python/providers/<provider-name>`+2. Install in development mode: `uv pip install -e .`+3. Implement your provider logic in `composio_<provider-name>/provider.py`+4. Test with the demo script: `python <provider-name>_demo.py`++## Creating a non-agentic provider++Non-agentic providers inherit from the `NonAgenticProvider` abstract class:++```python+from typing import List, Optional, Sequence, TypeAlias+from composio.core.provider import NonAgenticProvider+from composio.types import Tool, Modifiers, ToolExecutionResponse++# Define your tool format+class MyAITool:+ def __init__(self, name: str, description: str, parameters: dict):+ self.name = name+ self.description = description+ self.parameters = parameters++# Define your tool collection format+MyAIToolCollection: TypeAlias = List[MyAITool]++# Create your provider+class MyAIProvider(NonAgenticProvider[MyAITool, MyAIToolCollection], name="my-ai-platform"):+ """Custom provider for My AI Platform"""++ def wrap_tool(self, tool: Tool) -> MyAITool:+ """Transform a single tool to platform format"""+ return MyAITool(+ name=tool.slug,+ description=tool.description or "",+ parameters={+ "type": "object",+ "properties": tool.input_parameters.get("properties", {}),+ "required": tool.input_parameters.get("required", [])+ }+ )++ def wrap_tools(self, tools: Sequence[Tool]) -> MyAIToolCollection:+ """Transform a collection of tools"""+ return [self.wrap_tool(tool) for tool in tools]++ # Optional: Custom helper methods for your AI platform+ def execute_my_ai_tool_call(+ self,+ user_id: str,+ tool_call: dict,+ modifiers: Optional[Modifiers] = None+ ) -> ToolExecutionResponse:+ """Execute a tool call in your platform's format++ Example usage:+ result = my_provider.execute_my_ai_tool_call(+ user_id="default",+ tool_call={"name": "GITHUB_STAR_REPO", "arguments": {"owner": "composiohq", "repo": "composio"}}+ )+ """+ # Use the built-in execute_tool method+ return self.execute_tool(+ slug=tool_call["name"],+ arguments=tool_call["arguments"],+ modifiers=modifiers,+ user_id=user_id+ )+```++## Creating an agentic provider++Agentic providers inherit from the `AgenticProvider` abstract class:++```python+from typing import Callable, Dict, List, Sequence+from composio.core.provider import AgenticProvider, AgenticProviderExecuteFn+from composio.types import Tool+from my_provider import AgentTool++# Import the Tool/Function class that represents a callable tool for your framework+# Optionally define your custom tool format below+# class AgentTool:+# def __init__(self, name: str, description: str, execute: Callable, schema: dict):+# self.name = name+# self.description = description+# self.execute = execute+# self.schema = schema++# Define your tool collection format (typically a List)+AgentToolCollection: TypeAlias = List[AgentTool]++# Create your provider+class MyAgentProvider(AgenticProvider[AgentTool, List[AgentTool]], name="my-agent-platform"):+ """Custom provider for My Agent Platform"""++ def wrap_tool(self, tool: Tool, execute_tool: AgenticProviderExecuteFn) -> AgentTool:+ """Transform a single tool with execute function"""+ def execute_wrapper(**kwargs) -> Dict:+ result = execute_tool(tool.slug, kwargs)+ if not result.get("successful", False):+ raise Exception(result.get("error", "Tool execution failed"))+ return result.get("data", {})++ return AgentTool(+ name=tool.slug,+ description=tool.description or "",+ execute=execute_wrapper,+ schema=tool.input_parameters+ )++ def wrap_tools(+ self,+ tools: Sequence[Tool],+ execute_tool: AgenticProviderExecuteFn+ ) -> AgentToolCollection:+ """Transform a collection of tools with execute function"""+ return [self.wrap_tool(tool, execute_tool) for tool in tools]+```++## Using your custom provider++After creating your provider, use it with the Composio SDK:++### Non-agentic provider example++```python+from composio import Composio+from composio_myai import MyAIProvider+from myai import MyAIClient # Your AI platform's client++# Initialize tools+myai_client = MyAIClient()+composio = Composio(provider=MyAIProvider())++# Define task+task = "Star a repo composiohq/composio on GitHub"++# Get GitHub tools that are pre-configured+tools = composio.tools.get(user_id="default", toolkits=["GITHUB"])++# Get response from your AI platform (example)+response = myai_client.chat.completions.create(+ model="your-model",+ tools=tools, # These are in your platform's format+ messages=[+ {"role": "system", "content": "You are a helpful assistant."},+ {"role": "user", "content": task},+ ],+)+print(response)++# Execute the function calls+result = composio.provider.handle_tool_calls(response=response, user_id="default")+print(result)+```++### Agentic provider example++```python+import asyncio+from agents import Agent, Runner+from composio_myagent import MyAgentProvider+from composio import Composio++# Initialize Composio toolset+composio = Composio(provider=MyAgentProvider())++# Get all the tools+tools = composio.tools.get(+ user_id="default",+ tools=["GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER"],+)++# Create an agent with the tools+agent = Agent(+ name="GitHub Agent",+ instructions="You are a helpful assistant that helps users with GitHub tasks.",+ tools=tools,+)++# Run the agent+async def main():+ result = await Runner.run(+ starting_agent=agent,+ input=(+ "Star the repository composiohq/composio on GitHub. If done "+ "successfully, respond with 'Action executed successfully'"+ ),+ )+ print(result.final_output)++asyncio.run(main())+```++## Best practices++1. **Keep providers focused**: Each provider should integrate with one specific platform+2. **Handle errors gracefully**: Catch and transform errors from tool execution+3. **Follow platform conventions**: Adopt naming and structural conventions of the target platform+4. **Use type annotations**: Leverage Python's typing system for better IDE support and documentation+5. **Cache transformed tools**: Store transformed tools when appropriate to improve performance+6. **Add helper methods**: Provide convenient methods for common platform-specific operations+7. **Document your provider**: Include docstrings and usage examples+8. **Set meaningful provider names**: Use the name parameter for telemetry and debuggingdiff --git a/fumadocs/content/docs/providers/custom-typescript.mdx b/fumadocs/content/docs/providers/custom-typescript.mdxnew file mode 100644index 000000000..43b5925bd--- /dev/null+++ b/fumadocs/content/docs/providers/custom-typescript.mdx@@ -0,0 +1,303 @@+---+title: TypeScript Custom Provider+description: Learn how to create custom providers for any AI platform in TypeScript+---++This guide provides a comprehensive walkthrough of creating custom providers for the Composio TypeScript SDK, enabling integration with different AI frameworks and platforms.++## Provider Architecture++The Composio SDK uses a provider architecture to adapt tools for different AI frameworks. The provider handles:++1. **Tool Format Transformation**: Converting Composio tools into formats compatible with specific AI platforms+2. **Tool Execution**: Managing the flow of tool execution and results+3. **Platform-Specific Integration**: Providing helper methods for seamless integration++## Types of Providers++There are two types of providers:++1. **Non-Agentic Providers**: Transform tools for platforms that don't have their own agency (e.g., OpenAI)+2. **Agentic Providers**: Transform tools for platforms that have their own agency (e.g., LangChain, AutoGPT)++## Provider Class Hierarchy++```+BaseProvider (Abstract)+├── BaseNonAgenticProvider (Abstract)+│ └── OpenAIProvider (Concrete)+│ └── [Your Custom Non-Agentic Provider] (Concrete)+└── BaseAgenticProvider (Abstract)+ └── [Your Custom Agentic Provider] (Concrete)+```++## Creating a Non-Agentic Provider++Non-agentic providers implement the `BaseNonAgenticProvider` abstract class:++```typescript+import { BaseNonAgenticProvider, Tool } from '@composio/core';++// Define your tool format+interface MyAITool {+ name: string;+ description: string;+ parameters: {+ type: string;+ properties: Record<string, unknown>;+ required?: string[];+ };+}++// Define your tool collection format+type MyAIToolCollection = MyAITool[];++// Create your provider+export class MyAIProvider extends BaseNonAgenticProvider<MyAIToolCollection, MyAITool> {+ // Required: Unique provider name for telemetry+ readonly name = 'my-ai-platform';++ // Required: Method to transform a single tool+ override wrapTool(tool: Tool): MyAITool {+ return {+ name: tool.slug,+ description: tool.description || '',+ parameters: {+ type: 'object',+ properties: tool.inputParameters?.properties || {},+ required: tool.inputParameters?.required || [],+ },+ };+ }++ // Required: Method to transform a collection of tools+ override wrapTools(tools: Tool[]): MyAIToolCollection {+ return tools.map(tool => this.wrapTool(tool));+ }++ // Optional: Custom helper methods for your AI platform+ async executeMyAIToolCall(+ userId: string,+ toolCall: {+ name: string;+ arguments: Record<string, unknown>;+ }+ ): Promise<string> {+ // Use the built-in executeTool method+ const result = await this.executeTool(toolCall.name, {+ userId,+ arguments: toolCall.arguments,+ });++ return JSON.stringify(result.data);+ }+}+```++## Creating an Agentic Provider++Agentic providers implement the `BaseAgenticProvider` abstract class:++```typescript+import { BaseAgenticProvider, Tool, ExecuteToolFn } from '@composio/core';++// Define your tool format+interface AgentTool {+ name: string;+ description: string;+ execute: (args: Record<string, unknown>) => Promise<unknown>;+ schema: Record<string, unknown>;+}++// Define your tool collection format+interface AgentToolkit {+ tools: AgentTool[];+ createAgent: (config: Record<string, unknown>) => unknown;+}++// Create your provider+export class MyAgentProvider extends BaseAgenticProvider<AgentToolkit, AgentTool> {+ // Required: Unique provider name for telemetry+ readonly name = 'my-agent-platform';++ // Required: Method to transform a single tool with execute function+ override wrapTool(tool: Tool, executeToolFn: ExecuteToolFn): AgentTool {+ return {+ name: tool.slug,+ description: tool.description || '',+ schema: tool.inputParameters || {},+ execute: async (args: Record<string, unknown>) => {+ const result = await executeToolFn(tool.slug, args);+ if (!result.successful) {+ throw new Error(result.error || 'Tool execution failed');+ }+ return result.data;+ },+ };+ }++ // Required: Method to transform a collection of tools with execute function+ override wrapTools(tools: Tool[], executeToolFn: ExecuteToolFn): AgentToolkit {+ const agentTools = tools.map(tool => this.wrapTool(tool, executeToolFn));++ return {+ tools: agentTools,+ createAgent: config => {+ // Create an agent using the tools+ return {+ run: async (prompt: string) => {+ // Implementation depends on your agent framework+ console.log(`Running agent with prompt: ${prompt}`);+ // The agent would use the tools.execute method to run tools+ },+ };+ },+ };+ }++ // Optional: Custom helper methods for your agent platform+ async runAgent(agentToolkit: AgentToolkit, prompt: string): Promise<unknown> {+ const agent = agentToolkit.createAgent({});+ return await agent.run(prompt);+ }+}+```++## Using Your Custom Provider++After creating your provider, use it with the Composio SDK:++```typescript+import { Composio } from '@composio/core';+import { MyAIProvider } from './my-ai-provider';++// Create your provider instance+const myProvider = new MyAIProvider();++// Initialize Composio with your provider+const composio = new Composio({+ apiKey: 'your-composio-api-key',+ provider: myProvider,+});++// Get tools - they will be transformed by your provider+const tools = await composio.tools.get('default', {+ toolkits: ['github'],+});++// Use the tools with your AI platform+console.log(tools); // These will be in your custom format+```++## Provider State and Context++Your provider can maintain state and context:++```typescript+export class StatefulProvider extends BaseNonAgenticProvider<ToolCollection, Tool> {+ readonly name = 'stateful-provider';++ // Provider state+ private requestCount = 0;+ private toolCache = new Map<string, any>();+ private config: ProviderConfig;++ constructor(config: ProviderConfig) {+ super();+ this.config = config;+ }++ override wrapTool(tool: Tool): ProviderTool {+ this.requestCount++;++ // Use the provider state/config+ const enhancedTool = {+ // Transform the tool+ name: this.config.useUpperCase ? tool.slug.toUpperCase() : tool.slug,+ description: tool.description,+ schema: tool.inputParameters,+ };++ // Cache the transformed tool+ this.toolCache.set(tool.slug, enhancedTool);++ return enhancedTool;+ }++ override wrapTools(tools: Tool[]): ProviderToolCollection {+ return tools.map(tool => this.wrapTool(tool));+ }++ // Custom methods that use provider state+ getRequestCount(): number {+ return this.requestCount;+ }++ getCachedTool(slug: string): ProviderTool | undefined {+ return this.toolCache.get(slug);+ }+}+```++## Advanced: Provider Composition++You can compose functionality by extending existing providers:++```typescript+import { OpenAIProvider } from '@composio/openai';++// Extend the OpenAI provider with custom functionality+export class EnhancedOpenAIProvider extends OpenAIProvider {+ // Add properties+ private analytics = {+ toolCalls: 0,+ errors: 0,+ };++ // Override methods to add functionality+ override async executeToolCall(userId, tool, options, modifiers) {+ this.analytics.toolCalls++;++ try {+ // Call the parent implementation+ const result = await super.executeToolCall(userId, tool, options, modifiers);+ return result;+ } catch (error) {+ this.analytics.errors++;+ throw error;+ }+ }++ // Add new methods+ getAnalytics() {+ return this.analytics;+ }++ async executeWithRetry(userId, tool, options, modifiers, maxRetries = 3) {+ let attempts = 0;+ let lastError;++ while (attempts < maxRetries) {+ try {+ return await this.executeToolCall(userId, tool, options, modifiers);+ } catch (error) {+ lastError = error;+ attempts++;+ await new Promise(resolve => setTimeout(resolve, 1000 * attempts));+ }+ }++ throw lastError;+ }+}+```++## Best Practices++1. **Keep providers focused**: Each provider should integrate with one specific platform+2. **Handle errors gracefully**: Catch and transform errors from tool execution+3. **Follow platform conventions**: Adopt naming and structural conventions of the target platform+4. **Optimize for performance**: Cache transformed tools when possible+5. **Add helper methods**: Provide convenient methods for common platform-specific operations+6. **Provide clear documentation**: Document your provider's unique features and usage+7. **Use telemetry**: Set a meaningful provider name for telemetry insightsdiff --git a/fumadocs/content/docs/providers/google.mdx b/fumadocs/content/docs/providers/google.mdxnew file mode 100644index 000000000..376ffaac1--- /dev/null+++ b/fumadocs/content/docs/providers/google.mdx@@ -0,0 +1,110 @@+---+title: Google Gen AI Provider+description: Use Composio with Gemini through the Google Gen AI SDK+---++The Google provider transforms Composio tools into a format compatible with Gemini's function calling capabilities through it's API++## Setup++<Tabs items={["Python", "TypeScript"]}>+<Tab value="Python">+```bash+pip install google-genai composio_google+```+</Tab>+<Tab value="TypeScript">+```bash+npm install @google/genai+npm i @composio/core @composio/gemini+```+</Tab>+</Tabs>++<Tabs items={["Python", "TypeScript"]}>+<Tab value="Python">+```python+from composio import Composio+from composio_gemini import GeminiProvider+from google import genai+from google.genai import types++# Create composio client+composio = Composio(provider=GeminiProvider())+# Create google client+client = genai.Client()+```+</Tab>+<Tab value="TypeScript">+```typescript+import {Composio} from '@composio/core';+import {GoogleProvider} from '@composio/google'+import {GoogleGenAI} from '@google/genai'++const composio = new Composio({+ apiKey: "your-composio-api-key",+ provider: new GoogleProvider()+})++const ai = new GoogleGenAI({+ apiKey: "your-gemini-api-key"+})+```+</Tab>+</Tabs>++## Usage++<Tabs items={["Python", "TypeScript"]}>+<Tab value="Python">+```python+user_id = "0000-1111-2222"+tools = composio.tools.get(user_id, tools=["COMPOSIO_SEARCH_DUCK_DUCK_GO_SEARCH"])++# Create genai client config+config = types.GenerateContentConfig(tools=tools)++# # Use the chat interface.+chat = client.chats.create(model="gemini-2.0-flash", config=config)+response = chat.send_message("search about the latest info on windsurf acquisition.")+print(response.text)+```+</Tab>+<Tab value="TypeScript">+```typescript+// Use a unique identifier for each user in your application+const user_id = "your-external-user-id"++// Get tools - this returns already wrapped tools when using GoogleProvider+const tools = await composio.tools.get(user_id, 'HACKERNEWS_GET_USER')++const response = await ai.models.generateContent({+ model: 'gemini-2.0-flash-001',+ contents: "Search for the user 'pg's",+ config: {+ tools: [{ functionDeclarations: tools }],+ },+});++if (response.functionCalls && response.functionCalls.length > 0) {+ console.log(`Calling tool ${response.functionCalls[0].name}`);+ const functionCall = {+ name: response.functionCalls[0].name || '',+ args: response.functionCalls[0].args || {},+ };+ const result = await composio.provider.executeToolCall(user_id, functionCall);+ console.log(`Result: ${result}`);+} else {+ console.log('No function calls in the response');+ console.log(response.text);+}+```+</Tab>+</Tabs>++## 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](/docs/modify-tool-behavior/modifying-tool-schemas)diff --git a/fumadocs/content/docs/providers/langchain.mdx b/fumadocs/content/docs/providers/langchain.mdxnew file mode 100644index 000000000..b009dd97c--- /dev/null+++ b/fumadocs/content/docs/providers/langchain.mdx@@ -0,0 +1,132 @@+---+title: LangChain Provider+description: Use Composio tools with LangChain+---++The LangChain Provider transforms Composio tools into a format compatible with LangChain's function calling capabilities.++## Setup++<Tabs items={["Python", "TypeScript"]}>+<Tab value="Python">+```bash+pip install composio_langchain==0.8.0 langchain+```+</Tab>+<Tab value="TypeScript">+```bash+npm install @composio/langchain+```+</Tab>+</Tabs>++## Usage++<Tabs items={["Python", "TypeScript"]}>+<Tab value="Python">+```python+from composio import Composio+from composio_langchain import LangchainProvider+from langchain import hub # type: ignore+from langchain.agents import AgentExecutor, create_openai_functions_agent+from langchain_openai import ChatOpenAI++# Pull relevant agent model.+prompt = hub.pull("hwchase17/openai-functions-agent")++# Initialize tools.+openai_client = ChatOpenAI(model="gpt-5")++composio = Composio(provider=LangchainProvider())++# Get All the tools+tools = composio.tools.get(user_id="default", toolkits=["GITHUB"])++# Define task+task = "Star a repo composiohq/composio on GitHub"++# Define agent+agent = create_openai_functions_agent(openai_client, tools, prompt)+agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)++# Execute using agent_executor+agent_executor.invoke({"input": task})+```+</Tab>+<Tab value="TypeScript">+```typescript+import { ChatOpenAI } from '@langchain/openai';+import { HumanMessage, AIMessage } from '@langchain/core/messages';+import { ToolNode } from '@langchain/langgraph/prebuilt';+import { StateGraph, MessagesAnnotation } from '@langchain/langgraph';+import { Composio } from '@composio/core';+import { LangchainProvider } from '@composio/langchain';++// initiate composio+const composio = new Composio({+ apiKey: process.env.COMPOSIO_API_KEY,+ provider: new LangchainProvider(),+});++// fetch the tool+console.log(`🔄 Fetching the tool...`);+const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER');++// Define the tools for the agent to use+const toolNode = new ToolNode(tools);++// Create a model and give it access to the tools+const model = new ChatOpenAI({+ model: 'gpt-4o-mini',+ temperature: 0,+}).bindTools(tools);++// Define the function that determines whether to continue or not+function shouldContinue({ messages }: typeof MessagesAnnotation.State) {+ const lastMessage = messages[messages.length - 1] as AIMessage;++ // If the LLM makes a tool call, then we route to the "tools" node+ if (lastMessage.tool_calls?.length) {+ return 'tools';+ }+ // Otherwise, we stop (reply to the user) using the special "__end__" node+ return '__end__';+}++// Define the function that calls the model+async function callModel(state: typeof MessagesAnnotation.State) {+ console.log(`🔄 Calling the model...`);+ const response = await model.invoke(state.messages);++ // We return a list, because this will get added to the existing list+ return { messages: [response] };+}++// Define a new graph+const workflow = new StateGraph(MessagesAnnotation)+ .addNode('agent', callModel)+ .addEdge('__start__', 'agent') // __start__ is a special name for the entrypoint+ .addNode('tools', toolNode)+ .addEdge('tools', 'agent')+ .addConditionalEdges('agent', shouldContinue);++// Finally, we compile it into a LangChain Runnable.+const app = workflow.compile();++// Use the agent+const finalState = await app.invoke({+ messages: [new HumanMessage('Find the details of the user `pg` on HackerNews')],+});+console.log(`✅ Message recieved from the model`);+console.log(finalState.messages[finalState.messages.length - 1].content);++const nextState = await app.invoke({+ // Including the messages from the previous run gives the LLM context.+ // This way it knows we're asking about the weather in NY+ messages: [...finalState.messages, new HumanMessage('what about haxzie')],+});+console.log(`✅ Message recieved from the model`);+console.log(nextState.messages[nextState.messages.length - 1].content);+```+</Tab>+</Tabs>diff --git a/fumadocs/content/docs/providers/llamaindex.mdx b/fumadocs/content/docs/providers/llamaindex.mdxnew file mode 100644index 000000000..3ed46c33c--- /dev/null+++ b/fumadocs/content/docs/providers/llamaindex.mdx@@ -0,0 +1,166 @@+---+title: LlamaIndex Provider+description: Use Composio tools with LlamaIndex+---++The LlamaIndex Provider transforms Composio tools into a format compatible with LlamaIndex's function calling capabilities.++## Setup++<Tabs items={["Python", "TypeScript"]}>+<Tab value="Python">+```bash+pip install composio_llamaindex==0.8.0 llama-index+```+</Tab>+<Tab value="TypeScript">+```bash+npm install @composio/llamaindex @llamaindex/openai @llamaindex/workflow+```+</Tab>+</Tabs>++## Usage++<Tabs items={["Python", "TypeScript"]}>+<Tab value="Python">+```python+import asyncio+import dotenv+from composio_llamaindex import LlamaIndexProvider+from llama_index.core.agent.workflow import FunctionAgent+from llama_index.llms.openai import OpenAI++from composio import Composio++# Load environment variables from .env+dotenv.load_dotenv()++# Setup client+llm = OpenAI(model="gpt-5")+composio = Composio(provider=LlamaIndexProvider())++tools = composio.tools.get(+ user_id="[email protected]",+ tools=["GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER"],+)++workflow = FunctionAgent(+ tools=tools,+ llm=llm,+ system_prompt="You are an agent that performs github actions.",+)+++async def main():+ result = await workflow.run(+ user_msg="Hello! I would like to star a repo composiohq/composio on GitHub"+ )+ print(result)+++if __name__ == "__main__":+ asyncio.run(main())+```+</Tab>+<Tab value="TypeScript">+```typescript+import { Composio } from '@composio/core';+import { LlamaindexProvider } from '@composio/llamaindex';+import { openai } from '@llamaindex/openai';+import { agent } from '@llamaindex/workflow';+import 'dotenv/config';++// Initialize Composio with LlamaIndex provider+const composio = new Composio({+ apiKey: process.env.COMPOSIO_API_KEY,+ provider: new LlamaindexProvider(),+});++async function main() {+ // Get tools+ const tools = await composio.tools.get('[email protected]', {+ tools: ['GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER'],+ });++ // Create LlamaIndex agent with Composio tools+ const githubAgent = agent({+ name: 'GitHub Agent',+ description: 'An agent that performs GitHub actions',+ llm: openai({ model: 'gpt-4o-mini' }),+ systemPrompt: 'You are an agent that performs github actions.',+ tools,+ });++ // Run the agent+ const result = await githubAgent.run(+ 'Hello! I would like to star a repo composiohq/composio on GitHub'+ );++ console.log(result);+}++main().catch(console.error);+```+</Tab>+</Tabs>++## Advanced Usage++### Streaming Agent with Multiple Toolkits++```typescript+import { Composio } from '@composio/core';+import { LlamaindexProvider } from '@composio/llamaindex';+import { openai } from '@llamaindex/openai';+import { agent, agentStreamEvent } from '@llamaindex/workflow';+import 'dotenv/config';++const composio = new Composio({+ apiKey: process.env.COMPOSIO_API_KEY,+ provider: new LlamaindexProvider(),+});++async function streamingExample() {+ // Get tools from multiple toolkits with execution modifiers+ const tools = await composio.tools.get(+ 'default',+ {+ toolkits: ['gmail', 'googlecalendar', 'slack'],+ limit: 20,+ },+ {+ beforeExecute: ({ toolSlug, params }) => {+ console.log(`🔄 Executing ${toolSlug} with:`, params);+ return params;+ },+ afterExecute: ({ toolSlug, result }) => {+ console.log(`✅ ${toolSlug} completed:`, result);+ return result;+ },+ }+ );++ // Create streaming agent+ const assistantAgent = agent({+ name: 'Personal Assistant',+ description: 'A helpful personal assistant',+ llm: openai({ model: 'gpt-4o-mini' }),+ systemPrompt: 'You are a helpful personal assistant that can manage emails, calendar events, and slack messages.',+ tools,+ });++ // Stream the response+ const stream = await assistantAgent.runStream(+ 'Schedule a meeting for tomorrow at 2 PM and send a slack message about it'+ );++ for await (const event of stream) {+ if (agentStreamEvent.include(event)) {+ process.stdout.write(event.data.delta);+ }+ }+}++streamingExample().catch(console.error);+```diff --git a/fumadocs/content/docs/providers/mastra.mdx b/fumadocs/content/docs/providers/mastra.mdxnew file mode 100644index 000000000..51d588ea8--- /dev/null+++ b/fumadocs/content/docs/providers/mastra.mdx@@ -0,0 +1,62 @@+---+title: Mastra Provider+description: Use Composio with Mastra's TypeScript framework+---++Mastra is a TypeScript native framework for building agents with tools and MCPs. It expects tools to be in the following format:+- Inputs: What information the tool needs to run (defined with an `inputSchema`, often using Zod).+- Outputs: The structure of the data the tool returns (defined with an `outputSchema`).+- Execution Logic: The code that performs the tool's action.+- Description: Text that helps the agent understand what the tool does and when to use it.++More documentation [here](https://mastra.ai/en/docs/tools-mcp/overview#creating-tools)++The Mastra provider formats the Composio tools into this format along with the execution logic so that agents can call and execute the Composio tools.++## Setup++```bash+npm install @composio/mastra+```++You can specify the provider in the constructor.++```typescript+import { Composio } from "@composio/core";+import { MastraProvider } from "@composio/mastra";+import { Agent } from "@mastra/core/agent";+import { openai } from "@ai-sdk/openai";++const composio = new Composio({+ provider: new MastraProvider(),+});+```++## Usage++The tools are passed to the agent as a parameter.++```typescript+const userId = "john doe";++const tools = await composio.tools.get(+ userId,+ {+ toolkits: ["SUPABASE"],+ }+);++const agent = new Agent({+ name: "Supabase Agent",+ instructions: "You think therefore you are.",+ model: openai("gpt-4.1"),+ tools: tools,+});++const { text } = await agent.generate([+ { role: "user", content: "Tell me about my Supabase project" },+]);++console.log("\n🤖 Agent Response:\n");+console.log(text);+```diff --git a/fumadocs/content/docs/providers/meta.json b/fumadocs/content/docs/providers/meta.jsonnew file mode 100644index 000000000..637f8e891--- /dev/null+++ b/fumadocs/content/docs/providers/meta.json@@ -0,0 +1,16 @@+{+ "title": "Providers",+ "pages": [+ "openai",+ "anthropic",+ "google",+ "langchain",+ "llamaindex",+ "crewai",+ "vercel",+ "openai-agents",+ "mastra",+ "custom-typescript",+ "custom-python"+ ]+}diff --git a/fumadocs/content/docs/providers/openai-agents.mdx b/fumadocs/content/docs/providers/openai-agents.mdxnew file mode 100644index 000000000..265d99a2c--- /dev/null+++ b/fumadocs/content/docs/providers/openai-agents.mdx@@ -0,0 +1,94 @@+---+title: OpenAI Agents Provider+description: Use Composio with OpenAI's Agents SDK+---++The OpenAI Agents Provider is a provider that formats the Composio tools into an object compatible with OpenAI's Agents API.++OpenAI Agents SDK is different from the OpenAI SDK. It helps build agentic AI apps in a lightweight, easy-to-use package with very few abstractions.++<Tabs items={["Python", "TypeScript"]}>+<Tab value="Python">+## Setup++```bash+pip install composio openai-agents composio-openai-agents+```++## Usage++```python+import asyncio+from composio import Composio+from agents import Agent, Runner+from composio_openai_agents import OpenAIAgentsProvider++composio = Composio(api_key="your-api-key", provider=OpenAIAgentsProvider())++# Create a connected account for the user for the gmail toolkit and replace with your own user id+externalUserId = "your-user-id"++# Get Gmail tools that are pre-configured+tools = composio.tools.get(user_id=externalUserId, tools=["GMAIL_SEND_EMAIL"])++agent = Agent(+ name="Email Manager", instructions="You are a helpful assistant", tools=tools+)++# Run the agent+async def main():+ result = await Runner.run(+ starting_agent=agent,+ input="Send an email to [email protected] with the subject 'Hello from composio 👋🏻' and the body 'Congratulations on sending your first email using AI Agents and Composio!'",+ )+ print(result.final_output)++asyncio.run(main())+```+</Tab>+<Tab value="TypeScript">+## Setup++```bash+npm install @composio/core @openai/agents @composio/openai-agents+```++## Usage++```typescript+import { Composio } from "@composio/core";+import { Agent, run } from "@openai/agents";+import { OpenAIAgentsProvider } from "@composio/openai-agents";++// add OPENAI_API_KEY in your .env file+const composio = new Composio({+ apiKey: "your-api-key",+ provider: new OpenAIAgentsProvider(),+});++// Create a connected account for the user for the gmail toolkit and replace with your own user id+const externalUserId = "your-user-id";++// Fetch tools for GMAIL toolkit on behalf of the user+const tools = await composio.tools.get(externalUserId, {+ tools: ["GMAIL_SEND_EMAIL"],+ });++const agent = new Agent({+ name: "Email Manager",+ tools: tools,+});++console.log(`Running agent...`);+const result = await run(+ agent,+ "Send an email to [email protected] with the subject 'Hello from composio' and the body 'Congratulations on sending your first email using AI Agents and Composio!'"+);++console.log(`Received response from agent`);+if (result.finalOutput) {+ console.log(JSON.stringify(result.finalOutput, null, 2));+}+```+</Tab>+</Tabs>diff --git a/fumadocs/content/docs/providers/openai.mdx b/fumadocs/content/docs/providers/openai.mdxnew file mode 100644index 000000000..b9a82cb7d--- /dev/null+++ b/fumadocs/content/docs/providers/openai.mdx@@ -0,0 +1,204 @@+---+title: OpenAI Providers+description: Use Composio with OpenAI's Responses and Chat Completion APIs+---++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:++<Tabs items={["Python", "TypeScript"]}>+<Tab value="Python">+```bash+pip install composio_openai+```+</Tab>+<Tab value="TypeScript">+```bash+npm install @composio/openai+```+</Tab>+</Tabs>++## 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](https://platform.openai.com/docs/api-reference/responses)++<Callout>+Before executing any tools that require authentication (like Gmail), you'll need to:+1. [Create an Auth Configuration](/docs/authenticating-tools#creating-an-auth-config) for your integration+2. [Set up a Connected Account](/docs/authenticating-tools#connecting-an-account) for the user.+</Callout>++<Tabs items={["Python", "TypeScript"]}>+<Tab value="Python">+```python+from openai import OpenAI+from composio import Composio+from composio_openai import OpenAIResponsesProvider++# Initialize Composio client with OpenAI Provider+composio = Composio(provider=OpenAIResponsesProvider())+openai = OpenAI()++# Make sure to create an auth config and a connected account for the user with gmail toolkit+# Make sure to replace "your-user-id" with the actual user ID+user_id = "your-user-id"++tools = composio.tools.get(user_id=user_id, tools=["GMAIL_SEND_EMAIL"])++response = openai.responses.create(+ model="gpt-5",+ tools=tools,+ input=[+ {+ "role": "user",+ "content": "Send an email to [email protected] with the subject 'Running OpenAI Provider snippet' and body 'Hello from the code snippet in openai docs'"+ }+ ]+)++# Execute the function calls+result = composio.provider.handle_tool_calls(response=response, user_id=user_id)+print(result)+```+</Tab>+<Tab value="TypeScript">+```typescript+import OpenAI from 'openai';+import { Composio } from '@composio/core';+import { OpenAIResponsesProvider } from '@composio/openai';++// Initialize Composio client with OpenAI Provider+const composio = new Composio({+ provider: new OpenAIResponsesProvider(),+});+const openai = new OpenAI({});++// Make sure to create an auth config and a connected account for the user with gmail toolkit+// Make sure to replace "your-user-id" with the actual user ID+const userId = "your-user-id";++async function main() {+ try {+ const tools = await composio.tools.get(userId, {tools: ["GMAIL_SEND_EMAIL"]});++ const response = await openai.responses.create({+ model: "gpt-5",+ tools: tools,+ input: [+ {+ role: "user",+ content: "Send an email to [email protected] with the subject 'Running OpenAI Provider snippet' and body 'Hello from the code snippet in openai docs'"+ },+ ],+ });++ // Execute the function calls+ const result = await composio.provider.handleToolCalls(userId, response.output);+ console.log(result);+ } catch (error) {+ console.error('Error:', error);+ }+}++main();+```+</Tab>+</Tabs>++## Chat Completion API++The Chat Completion API generates a model response from a list of messages. Read more about it in the [OpenAI documentation](https://platform.openai.com/docs/api-reference/chat).+The OpenAI Chat Provider is the default provider used by Composio SDK, but you can also explicitly initialise it.++<Callout>+Before executing any tools that require authentication (like Gmail), you'll need to:+1. [Create an Auth Configuration](/docs/authenticating-tools#creating-an-auth-config) for your integration+2. [Set up a Connected Account](/docs/authenticating-tools#connecting-an-account) for the user.+</Callout>++<Tabs items={["Python", "TypeScript"]}>+<Tab value="Python">+```python+from openai import OpenAI+from composio import Composio+from composio_openai import OpenAIProvider++# Initialize Composio client with OpenAI Provider+composio = Composio(provider=OpenAIProvider())+openai = OpenAI()++# Make sure to create an auth config and a connected account for the user with gmail toolkit+# Make sure to replace "your-user-id" with the actual user ID+user_id = "your-user-id"++tools = composio.tools.get(user_id=user_id, tools=["GMAIL_SEND_EMAIL"])++response = openai.chat.completions.create(+ model="gpt-5",+ tools=tools,+ messages=[+ {"role": "user", "content": "Send an email to [email protected] with the subject 'Running OpenAI Provider snippet' and body 'Hello from the code snippet in openai docs'"},+ ],+)++# Execute the function calls+result = composio.provider.handle_tool_calls(response=response, user_id=user_id)+print(result)+```+</Tab>+<Tab value="TypeScript">+```typescript+import OpenAI from 'openai';+import { Composio } from '@composio/core';+import { OpenAIProvider } from '@composio/openai';++// Initialize Composio client with OpenAI Provider+const composio = new Composio({+ provider: new OpenAIProvider(),+});++const openai = new OpenAI();++// Make sure to create an auth config and a connected account for the user with gmail toolkit+// Make sure to replace "your-user-id" with the actual user ID+const userId = "your-user-id";++async function main() {+ try {+ const tools = await composio.tools.get(userId, {tools: ["GMAIL_SEND_EMAIL"]});++ const response = await openai.chat.completions.create({+ model: "gpt-5",+ tools: tools,+ messages: [+ {+ role: "user",+ content: "Send an email to [email protected] with the subject 'Running OpenAI Provider snippet' and body 'Hello from the code snippet in openai docs'"+ },+ ],+ });++ // Execute the function calls+ const result = await composio.provider.handleToolCalls(userId, response);+ console.log(result);+ } catch (error) {+ console.error('Error:', error);+ }+}++main();+```+</Tab>+</Tabs>++## 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](/docs/modify-tool-behavior/modifying-tool-schemas)diff --git a/fumadocs/content/docs/providers/vercel.mdx b/fumadocs/content/docs/providers/vercel.mdxnew file mode 100644index 000000000..ec297f716--- /dev/null+++ b/fumadocs/content/docs/providers/vercel.mdx@@ -0,0 +1,52 @@+---+title: Vercel AI SDK Provider+description: Use Composio with Vercel AI SDK+---++Vercel AI SDK allows you to configure an optional async `execute` function that the framework uses to execute the tool calls.++The Vercel provider for Composio formats the Composio tools and adds this `execute` function to the tool calls.++## Setup++Vercel AI SDK and the provider are only available for the TypeScript SDK.++```bash+npm install @composio/vercel+```++You can specify and import the provider in the constructor.++```typescript+import { Composio } from '@composio/core';+import { VercelProvider } from '@composio/vercel';+import { generateText } from 'ai';+import { openai } from "@ai-sdk/openai";++const composio = new Composio({+ provider: new VercelProvider(),+});+```++## Usage++```typescript+// create an auth config for gmail+// then create a connected account with an external user id that identifies the user+const externalUserId = "your-external-user-id";+const tools = await composio.tools.get(externalUserId, "GMAIL_SEND_EMAIL");++// env: OPENAI_API_KEY+const { text } = await generateText({+ model: openai("gpt-5"),+ messages: [+ {+ role: "user",+ content: `Send an email to [email protected] with the subject 'Hello from composio 👋🏻' and the body 'Congratulations on sending your first email using AI Agents and Composio!'`,+ },+ ],+ tools,+});++console.log("Email sent successfully!", { text });+```