OpenHands Agent Server
OpenHands Agent Server is the server-side component for OpenHands AI agents, providing RESTful and WebSocket APIs for agent interaction and management. It serves as the backbone for running and communicating with AI agents developed using the OpenHands Software Agent SDK. Currently at version 1.16.1, the library maintains an active development pace with minor versions released frequently.
Warnings
- breaking Significant API changes and less stability guarantees existed prior to v1.15.0. Upgrades from older versions may require reviewing REST API endpoint changes and deprecations.
- breaking WebSocket authentication mechanisms and secrets handling were improved and changed in v1.12.0. Clients connecting via WebSocket might require updates to their authentication headers or secrets management.
- gotcha The library explicitly requires Python 3.12 or newer. Attempting to install or run on older Python versions will result in `Requires-Python` errors during installation or runtime issues.
- gotcha Prior to v1.13.0, `hook_config` in `RemoteConversation` might have been silently dropped, preventing server-side execution of remote conversation hooks.
Install
-
pip install openhands-agent-server
Imports
- AppConfig
from openhands_agent_server.config import AppConfig
- FastAPI
from openhands_agent_server.main import app
Quickstart
import uvicorn
import os
# Set any necessary environment variables for configuration (e.g., API keys)
# For example, to configure an OpenAI key (replace with your actual key/method)
# os.environ['OPENAI_API_KEY'] = os.environ.get('OPENAI_API_KEY', 'your-openai-api-key')
if __name__ == "__main__":
# The server's main FastAPI application instance is named 'app' in 'openhands_agent_server.main'
print("Starting OpenHands Agent Server on http://0.0.0.0:8000")
uvicorn.run("openhands_agent_server.main:app", host="0.0.0.0", port=8000, reload=True)