The Agent Server package (Documentation Index
Fetch the complete documentation index at: https://allhandsai-codex-agent-server-user-docs.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
openhands-agent-server) runs the OpenHands Software Agent SDK behind an HTTP and WebSocket API. Use it when another service, such as an Agent Canvas backend, needs to start conversations, stream events, and run file or command operations in a workspace without embedding the SDK directly in the same process.
When to Use It
Use the Agent Server when you need:- A backend process that clients can reach over HTTP/WebSocket.
- A long-running service for conversations and workspace files.
- A server API that can be protected with a session API key.
- A clean boundary between your application backend and the agent runtime.
Install
Install the same release of the SDK packages in the Python environment that will run the server:OpenHands/software-agent-sdk repository, use the repository’s normal uv setup instead:
Start a Local Server
For local-only use, bind to127.0.0.1:
SESSION_API_KEY or OH_SESSION_API_KEYS_* is already set in your shell, the server will require that key for /api/* requests. Unset those variables for unauthenticated local-only testing.
Secure the Server
By default, the Agent Server starts without API authentication. Before exposing it to another process, container, host, or user, set at least one session API key.X-Session-API-Key header. This request returns the conversation count when the key is accepted:
OH_SECRET_KEY encrypts sensitive values stored with conversations, including LLM API keys and secrets. Keep it stable across restarts. If it changes, previously encrypted values cannot be restored.Connect From Python
Pass the server URL and API key toWorkspace. The SDK sends the key as X-Session-API-Key and uses remote HTTP/WebSocket calls for workspace and conversation operations.
Expose It Safely
If another service runs on the same machine, keep the server bound to127.0.0.1 and let that service connect locally.
If another host must connect to the server:
- Set
OH_SESSION_API_KEYS_0andOH_SECRET_KEY. - Bind the server to a reachable interface, for example
--host 0.0.0.0. - Put the server behind TLS, a private network, or a trusted reverse proxy.
- Restrict firewall access to only the services that need it.
- Configure CORS only for browser clients that must call the server directly.
Runtime Files
By default, the server stores conversation and workspace data underworkspace/ relative to the process working directory:
Useful Endpoints
GET /health- Basic health check.GET /ready- Readiness check after startup initialization.GET /server_info- Version, uptime, and available tool information.GET /docs- Interactive OpenAPI documentation./api/*- Authenticated conversation, workspace, file, command, and settings APIs when session API keys are configured.
Troubleshooting
- 401 responses: Send
X-Session-API-Keywith one of the configuredOH_SESSION_API_KEYS_*values. - Secrets disappear after restart: Set a stable
OH_SECRET_KEYbefore starting the server. - Port already in use: Change the port with
--port. - Browser CORS errors: Add the browser origin with
OH_ALLOW_CORS_ORIGINS_0. - Cannot reach the server from another host: Check
--host, firewall rules, reverse proxy routing, and TLS configuration.
Next Steps
- Local Agent Server - Run and connect to a local server.
- Docker Sandboxed Server - Run the server in an isolated Docker workspace.
- API Sandboxed Server - Start agent servers through a hosted runtime API.
- Agent Server API Reference - Browse the generated REST API docs.

