Skip to main content
The OpenHands SDK is a modular framework for building AI agents that interact with code, files, and system commands. Agents can execute bash commands, edit files, browse the web, and more.

Prerequisites

Install the uv package manager (version 0.8.13+):

Installation

Step 1: Acquire an LLM API Key

The SDK requires an LLM API key from any LiteLLM-supported provider. See our recommended models for best results.
Bring your own API key from providers like:Example:
If you have a ChatGPT Plus or Pro subscription, you can use LLM.subscription_login() to authenticate with your ChatGPT account and access Codex models without consuming API credits.
Learn more →
Tip: Model name prefixes depend on your provider
  • If you bring your own provider key (Anthropic/OpenAI/etc.), use that provider’s model name, e.g. anthropic/claude-sonnet-4-5-20250929 OpenHands supports dozens of models, you can choose the model you want to try.
  • If you use OpenHands Cloud, use openhands/-prefixed models, e.g. openhands/claude-sonnet-4-5-20250929
Many examples in the docs read the model from the LLM_MODEL environment variable. You can set it like:
Set Your API Key:

Step 2: Install the SDK

openhands-sdk and openhands-tools are a matched set: they are built, tested, and released together at the same version number, and openhands-tools imports openhands-sdk internals directly. Always install and upgrade them in a single pip command so their versions match. Installing them separately can leave a newer openhands-tools against an older openhands-sdk (for example, when a previously installed copy is not upgraded), which fails at import with errors like ModuleNotFoundError: No module named 'openhands.sdk.utils.path'. To pin a specific release, use the same version for both, e.g. pip install "openhands-sdk==1.22.1" "openhands-tools==1.22.1".

Step 3: Run Your First Agent

Here’s a complete example that creates an agent and asks it to perform a simple task:
examples/01_standalone_sdk/01_hello_world.py
Run the example:
You should see the agent understand your request, explore the project, and create a file with facts about it.

Core Concepts

Agent: An AI-powered entity that can reason, plan, and execute actions using tools. Tools: Capabilities like executing bash commands, editing files, or browsing the web. Workspace: The execution environment where agents operate (local, Docker, or remote). Conversation: Manages the interaction lifecycle between you and the agent.

Basic Workflow

  1. Configure LLM: Choose model and provide API key
  2. Create Agent: Use preset or custom configuration
  3. Add Tools: Enable capabilities (bash, file editing, etc.)
  4. Start Conversation: Create conversation context
  5. Send Message: Provide task description
  6. Run Agent: Agent executes until task completes or stops
  7. Get Result: Review agent’s output and actions

Try More Examples

The repository includes 24+ examples demonstrating various capabilities:

Next Steps

Explore Documentation

Build Custom Solutions

Get Help