OpenHands AI

1.6.0 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This quickstart demonstrates how to initialize an LLM, create an agent with basic tools (Terminal, FileEditor, TaskTracker), set up a conversation in the current working directory, and assign a simple file-writing task. Ensure `LLM_API_KEY` and optionally `LLM_MODEL` are set in your environment variables.

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.")

view raw JSON →