OpenHands AI
OpenHands is an open-source, model-agnostic platform for AI-driven software development agents that can write, test, and deploy applications. It extends the idea of AI coding assistants into an "agentic" workflow, enabling systems to iteratively plan, take actions, observe results, and continue until a task is complete. It supports various large language models (LLMs) and provides a flexible, sandboxed environment for developing and deploying AI agents. The current version is 1.6.0, with frequent releases, often on a monthly cadence.
Warnings
- breaking OpenHands 1.0.0 introduced a 'new software-agent-sdk' and a complete architectural redesign, which broke compatibility with conversations and serialized agent sessions from pre-1.0.0 versions. The V0 API was also deprecated and removed on April 1, 2026.
- gotcha When running OpenHands with a Docker sandbox, especially in self-hosted deployments or for remote access, ensure `WEB_HOST`, `SANDBOX_CONTAINER_URL_PATTERN`, and `OH_SANDBOX_USE_HOST_NETWORK=true` environment variables are correctly configured. Incorrect settings can lead to connection failures, sandbox errors, or CORS issues.
- gotcha An LLM API key (e.g., for Anthropic or OpenAI) is essential for OpenHands to function. Without a valid key configured, the agent cannot interact with the language model and will not be able to perform tasks.
- deprecated The OpenHands V0 API was deprecated with the release of version 1.0.0 and was officially removed on April 1, 2026. Integrations relying on the V0 API will no longer work.
- gotcha Tools provided to an OpenHands agent are part of its initial system prompt and cannot be dynamically changed mid-conversation. To modify the set of tools available to an agent, a new conversation must be started, or conversation forking must be utilized.
- gotcha While `pip install openhands-ai` installs the SDK, the `openhands` CLI often has specific installation recommendations (e.g., using `uv` or Docker) to ensure the proper sandboxed runtime environment is configured, especially for local GUI or command-line execution.
Install
-
pip install openhands-ai
Imports
- LLM, Agent, Conversation, Tool
from openhands.sdk import LLM, Agent, Conversation, Tool
- FileEditorTool, TaskTrackerTool, TerminalTool
from openhands.tools.file_editor import FileEditorTool from openhands.tools.task_tracker import TaskTrackerTool from openhands.tools.terminal import TerminalTool
Quickstart
import os
from openhands.sdk import LLM, Agent, Conversation, Tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.task_tracker import TaskTrackerTool
from openhands.tools.terminal import TerminalTool
# NOTE: Replace with your actual LLM_API_KEY and desired model
llm = LLM(
model=os.environ.get("LLM_MODEL", "anthropic/claude-sonnet-4-5-20250929"),
api_key=os.environ.get("LLM_API_KEY", ""), # Ensure LLM_API_KEY is set in your environment
base_url=os.environ.get("LLM_BASE_URL", None),
)
agent = Agent(
llm=llm,
tools=[
Tool(name=TerminalTool.name),
Tool(name=FileEditorTool.name),
Tool(name=TaskTrackerTool.name),
],
)
cwd = os.getcwd()
conversation = Conversation(agent=agent, workspace=cwd)
print("Sending task to agent...")
conversation.send_message("Write 3 facts about the current project into FACTS.txt.")
conversation.run()
print("Agent finished.")