Skip to main content
A ready-to-run example is available here!

Your First Agent

This is the most basic example showing how to set up and run an OpenHands agent.
1

LLM Configuration

Configure the language model that will power your agent:
2

Select an Agent

Use the preset agent with common built-in tools:
The default agent includes BashTool, FileEditorTool, etc.
For the complete list of available tools see the tools package source code.
3

Start a Conversation

Start a conversation to manage the agent’s lifecycle:
4

Expected Behavior

When you run this example:
  1. The agent analyzes the current directory
  2. Gathers information about the project
  3. Creates FACTS.txt with 3 relevant facts
  4. Completes and exits
Example output file:

Ready-to-run Example

This example is available on GitHub: examples/01_standalone_sdk/01_hello_world.py
examples/01_standalone_sdk/01_hello_world.py
You can run the example code as-is.
The model name should follow the LiteLLM convention: provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o). The LLM_API_KEY should be the API key for your chosen provider.
ChatGPT Plus/Pro subscribers: You can use LLM.subscription_login() to authenticate with your ChatGPT account and access Codex models without consuming API credits. See the LLM Subscriptions guide for details.

Next Steps