OpenHandsCloudWorkspace demonstrates how to use the OpenHands Cloud to provision and manage sandboxed environments for agent execution. This provides a seamless experience with automatic sandbox provisioning, monitoring, and secure execution without managing your own infrastructure.
Basic Example
This example is available on GitHub: examples/02_remote_agent_server/06_convo_with_cloud_workspace.py
examples/02_remote_agent_server/06_convo_with_cloud_workspace.py
Running the Example
Key Concepts
OpenHandsCloudWorkspace
TheOpenHandsCloudWorkspace connects to OpenHands Cloud to provision sandboxes:
- Connects to OpenHands Cloud API
- Automatically provisions sandboxed environments
- Manages sandbox lifecycle (create, poll status, delete)
- Handles all infrastructure concerns
Getting Your API Key
To use OpenHands Cloud, you need an API key:- Go to app.all-hands.dev
- Sign in to your account
- Navigate to Settings → API Keys
- Create a new API key
OPENHANDS_CLOUD_API_KEY environment variable.
Configuration Options
TheOpenHandsCloudWorkspace supports several configuration options:
| Parameter | Type | Default | Description |
|---|---|---|---|
cloud_api_url | str | Required | OpenHands Cloud API URL |
cloud_api_key | str | Required | API key for authentication |
sandbox_spec_id | str | None | None | Custom sandbox specification ID |
init_timeout | float | 300.0 | Timeout for sandbox initialization (seconds) |
api_timeout | float | 60.0 | Timeout for API requests (seconds) |
keep_alive | bool | False | Keep sandbox running after cleanup |
Keep Alive Mode
By default, the sandbox is deleted when the workspace is closed. To keep it running:Workspace Testing
You can test the workspace before running the agent:Comparison with Other Workspace Types
| Feature | OpenHandsCloudWorkspace | APIRemoteWorkspace | DockerWorkspace |
|---|---|---|---|
| Infrastructure | OpenHands Cloud | Runtime API | Local Docker |
| Authentication | API Key | API Key | None |
| Setup Required | None | Runtime API access | Docker installed |
| Custom Images | Via sandbox specs | Direct image specification | Direct image specification |
| Best For | Production use | Custom runtime environments | Local development |
Next Steps
- API-based Sandbox - Connect to Runtime API service
- Docker Sandboxed Server - Run locally with Docker
- Local Agent Server - Development without containers
- Agent Server Overview - Architecture and implementation details

