A ready-to-run example is available here!The OpenHands Cloud provides fully managed sandbox environments for agent execution. There are two ways to use it:
- OpenHandsCloudWorkspace - SDK integration for running agents with your own LLM configuration
- Cloud API Direct - Launch one-off tasks that use your cloud-configured LLM and credentials
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. See Obtaining an API Key for detailed instructions. Store this key securely and use it as theOPENHANDS_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 |
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
Launching One-Off Tasks via Cloud API
For scenarios where you want to launch a task and let it run asynchronously in the cloud (without waiting for completion), you can use the OpenHands Cloud API directly. This is particularly useful for:- CI/CD workflows - Trigger code reviews or automated tasks without blocking pipelines
- Background processing - Launch long-running tasks and check results later
- Minimal configuration - Only need an API key; LLM and GitHub credentials come from your cloud account
Key Benefits
| Aspect | OpenHandsCloudWorkspace | Cloud API Direct |
|---|---|---|
| LLM Configuration | You provide LLM_API_KEY | Uses your cloud-configured LLM |
| GitHub Access | You provide GITHUB_TOKEN | Uses your cloud-configured credentials |
| Execution Model | Blocking (waits for completion) | Non-blocking (fire and forget) |
| Best For | Interactive scripts, testing | CI/CD, automated workflows |
How It Works
The Cloud API creates a conversation that:- Uses your account’s configured LLM (no API key needed in the request)
- Has access to your GitHub credentials (if configured in your cloud account)
- Runs asynchronously - you get a conversation URL to track progress
- Can be viewed in the OpenHands Cloud UI
Example: PR Review Workflow
This example from the PR Review GitHub Action demonstrates launching a code review task via the Cloud API:Using in GitHub Actions
The PR Review workflow demonstrates a complete implementation:See the full PR Review example: examples/03_github_workflows/02_pr_review
When to Use Each Approach
| Use Case | Recommended Approach |
|---|---|
| Interactive development | OpenHandsCloudWorkspace |
| Unit tests with cloud sandbox | OpenHandsCloudWorkspace |
| CI/CD code reviews | Cloud API Direct |
| Background automation | Cloud API Direct |
| Need custom LLM config | OpenHandsCloudWorkspace |
| Want simplest setup | Cloud API Direct |
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
- PR Review Workflow - Complete GitHub Actions example

