Install
Create a Python environment and install the server package and its SDK dependencies:OpenHands/software-agent-sdk repository, see Agent Server Package § Install for the uv-based setup.
Start Without Authentication
For local development on your own machine, start the server on loopback:http://127.0.0.1:8000/docs.
If SESSION_API_KEY (legacy alias) 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.
Start With an API Key
Set a session API key before starting the server:/api/* must include the session key. 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 the SDK
UseWorkspace(host=..., api_key=...) to connect SDK code to the server:
OH_SESSION_API_KEYS_0, remove the api_key=... argument.
The working_dir value is relative to the server’s process working directory. See Runtime Files for the default directory layout.
Connect From Another Service
For a non-SDK backend service, pass the session API key asX-Session-API-Key:
127.0.0.1 when the backend runs on the same machine. If the backend runs on another host, use a private network or reverse proxy, enable TLS, and restrict network access to trusted callers.
For CORS configuration and running directly from a checkout of OpenHands/software-agent-sdk, see the Agent Server Package page.
Ready-to-Run Example
This example is available on GitHub: examples/02_remote_agent_server/01_convo_with_local_agent_server.py.
Workspace(host=...), and runs a RemoteConversation.
You can run the example code as-is.
The model name should follow the LiteLLM convention:
provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o).
The LLM_API_KEY should be the API key for your chosen provider.Troubleshooting
- 401 Unauthorized: Check that the client sends
X-Session-API-Keyand that it matchesOH_SESSION_API_KEYS_0. - Secrets are missing after restart: Set a stable
OH_SECRET_KEYbefore starting the server. - The server is reachable locally but not from another machine: Use
--host 0.0.0.0only behind trusted network controls, then check firewall and proxy rules. - CORS errors in a browser: Set
OH_ALLOW_CORS_ORIGINS_0to the browser app origin. - Port conflict: Start with another port, for example
--port 8001.
Next Steps
- Agent Server Package - Installation, security, and operational guidance.
- Docker Sandboxed Server - Run the server in an isolated Docker workspace.
- API Sandboxed Server - Start hosted runtime workspaces.
- Agent Server API Reference - Browse generated endpoint docs.

