OpenHands Agent Server

1.16.1 · active · verified Sun Apr 12

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

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically start the OpenHands Agent Server using `uvicorn`. This is useful for embedding the server within a larger Python application or for custom deployment configurations. The server will be accessible at `http://0.0.0.0:8000`.

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)

view raw JSON →