A ready-to-run example is available here!The
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.
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:Inheriting SaaS Credentials
Instead of providing your ownLLM_API_KEY, you can inherit the LLM configuration and secrets from your OpenHands Cloud account. This means you only need OPENHANDS_CLOUD_API_KEY — no separate LLM key required.
get_llm()
Fetches your account’s LLM settings (model, API key, base URL) and returns a ready-to-use LLM instance:
get_llm() calls GET /api/v1/users/me?expose_secrets=true, sending your Cloud API key in the Authorization header plus the sandbox’s X-Session-API-Key. That session key is issued by OpenHands Cloud for the running sandbox, so it scopes the request to that sandbox rather than acting like a separately provisioned second credential.
get_secrets()
Builds LookupSecret references for your SaaS-configured secrets. Raw values never transit through the SDK client — they are resolved lazily by the agent-server inside the sandbox:
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 |
Ready-to-run Example
This example is available on GitHub: examples/02_remote_agent_server/07_convo_with_cloud_workspace.py
examples/02_remote_agent_server/07_convo_with_cloud_workspace.py
Running the Example
SaaS Credentials Example
This example is available on GitHub: examples/02_remote_agent_server/10_cloud_workspace_share_credentials.py
LLM_API_KEY separately:
examples/02_remote_agent_server/10_cloud_workspace_share_credentials.py
Running the SaaS Credentials Example
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

