Workspaces (beta)

Configure environments for local tools to run on

Overview

Composio ships with a pre-defined set of local tools that run only on a machine. These tools manipulate files, execute shell commands, and manage code projects.

Python SDK Only: Workspaces are currently only available in the Python SDK. TypeScript support isn’t available for this feature.

Host Workspace

Run local tools directly on your host machine with full system access and native performance.

Docker Workspace

Isolate tool execution in containers for better security and reproducibility.

E2B Workspace

Execute tools in code sandboxes powered by E2B.

Fly.io Workspace

Deploy and manage workspaces for tool execution to Fly.io for global distribution and scale.

Host

By default, all local tools run directly on your host machine.

Lists out the files in current directory
1from composio_openai import ComposioToolSet, App, Action, WorkspaceType
2from openai import OpenAI
3
4client = OpenAI()
5
6toolset = ComposioToolSet(workspace_config=WorkspaceType.Host())
7entity = toolset.get_entity(id="default")
8tools = toolset.get_tools(["FILETOOL_LIST_FILES"])
9
10question = "List all files in the current directory"
11
12response = client.chat.completions.create(
13 model="gpt-4o-mini",
14 max_tokens=1024,
15 tools=tools,
16 messages=[{"role": "user", "content": question}],
17)
18result = toolset.handle_tool_calls(response)
19print(result)

Docker

  • Secure sandboxed environments
  • Consistent execution across systems
  • Easy dependency management
  • Perfect for production deployments

To use Docker workspaces, install the Docker workspace extension:

$pip install composio-core[docker]
1from composio_openai import ComposioToolSet, App, Action, WorkspaceType
2from openai import OpenAI
3
4client = OpenAI()
5
6toolset = ComposioToolSet(workspace_config=WorkspaceType.Docker(
7 image="python:3.9", # Base image to use
8 volumes={"/host/path": "/container/path"} # Optional volume mounts
9))
10tools = toolset.get_tools(["FILETOOL_LIST_FILES"])
11
12response = client.chat.completions.create(
13 model="gpt-4o-mini",
14 max_tokens=1024,
15 tools=tools,
16 messages=[{"role": "user", "content": "List files in container"}],
17)
18result = toolset.handle_tool_calls(response)
19print(result)

E2B

  • Secure serverless execution
  • No infrastructure management
  • Pay-per-use pricing
  • Automatic scaling

To use E2B workspaces, install the E2B workspace extension:

$pip install composio-core[e2b]
1from composio_openai import ComposioToolSet, App, Action, WorkspaceType
2from openai import OpenAI
3
4client = OpenAI()
5
6toolset = ComposioToolSet(workspace_config=WorkspaceType.E2B(
7 api_key="your_e2b_api_key", # Required: E2B API Key
8 template="2h9ws7lsk32jyow50lqz", # Optional: Template ID for creating the sandbox
9 port=8000, # Optional: Port for launching the toolserver (default: 8000)
10 environment={"KEY": "VALUE"} # Optional: Environment variables
11))
12tools = toolset.get_tools(["FILETOOL_LIST_FILES"])
13
14response = client.chat.completions.create(
15 model="gpt-4o-mini",
16 max_tokens=1024,
17 tools=tools,
18 messages=[{"role": "user", "content": "List files in E2B sandbox"}],
19)
20result = toolset.handle_tool_calls(response)
21print(result)

Fly.io

  • Deploy close to users
  • Automatic load balancing
  • Built-in monitoring
  • Edge computing capabilities

To use Fly.io workspaces, install the Fly.io workspace extension:

$pip install composio-core[flyio]
1from composio_openai import ComposioToolSet, App, Action, WorkspaceType
2from openai import OpenAI
3
4client = OpenAI()
5
6toolset = ComposioToolSet(workspace_config=WorkspaceType.Flyio(
7 token="your_flyio_token", # Required: Fly.io API token
8 image="your-custom-image:tag", # Optional: Docker image to use
9 ports=[{ # Optional: Additional ports to expose
10 "ports": [
11 {
12 "port": 3000,
13 "handlers": ["http"] # Available handlers: http, tls
14 }
15 ]
16 }],
17 environment={"KEY": "VALUE"} # Optional: Environment variables
18))
19tools = toolset.get_tools(["FILETOOL_LIST_FILES"])
20
21response = client.chat.completions.create(
22 model="gpt-4o-mini",
23 max_tokens=1024,
24 tools=tools,
25 messages=[{"role": "user", "content": "List files in Fly.io instance"}],
26)
27result = toolset.handle_tool_calls(response)
28print(result)

Each workspace type offers unique benefits. Choose the appropriate workspace based on your specific requirements for security, scalability, and deployment needs. Remember to install the corresponding workspace extension using composio-core[extension_name] before using any workspace type other than the default host configuration.

Built with