Skip to main content
A ready-to-run example is available here!
The Runtime API (runtime.all-hands.dev) is designed primarily for benchmark evaluation at scale, not for building production applications. If you are building a production application with the SDK, use the OpenHands Cloud Workspace instead, which provides fully managed sandbox environments with SaaS credential support.
The API-sandboxed agent server demonstrates how to use APIRemoteWorkspace to connect to a OpenHands runtime API service. This eliminates the need to manage your own infrastructure, providing automatic scaling, monitoring, and secure sandboxed execution.

Key Concepts

APIRemoteWorkspace

The APIRemoteWorkspace connects to a hosted runtime API service:
This workspace type:
  • Connects to a remote runtime API service
  • Automatically provisions sandboxed environments
  • Manages container lifecycle through the API
  • Handles all infrastructure concerns

Runtime API Authentication

The example requires a runtime API key for authentication:
This key authenticates your requests to the hosted runtime service.

Pre-built Image Selection

You can specify which pre-built agent server image to use:
The runtime API will pull and run the specified image in a sandboxed environment.

Workspace Testing

Just like with DockerWorkspace, you can test the workspace before running the agent:
This verifies connectivity to the remote runtime and ensures the environment is ready.

Automatic RemoteConversation

The conversation uses WebSocket communication with the remote server:
All agent execution happens on the remote runtime infrastructure.
The same runtime flow also supports ACPAgent. For an end-to-end example, see the ACP Agent guide.
ACP-backed remote conversations use the ACP-capable conversation endpoints under /api/acp/conversations for creation, reads, and counts. If you reconnect to an existing ACP conversation by conversation_id, use ACPAgent rather than a standard Agent.

Ready-to-run Example

This example shows how to connect to a hosted runtime API for fully managed agent execution:
examples/02_remote_agent_server/04_convo_with_api_sandboxed_server.py
You can run the example code as-is.
Running the Example

Next Steps