> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openhands.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Hello World

> The simplest possible OpenHands agent - configure an LLM, create an agent, and complete a task.

export const path_to_script_0 = "examples/01_standalone_sdk/01_hello_world.py"

> A ready-to-run example is available [here](#ready-to-run-example)!

## Your First Agent

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

<Steps>
  <Step>
    ### LLM Configuration

    Configure the language model that will power your agent:

    ```python icon="python" theme={null}
    llm = LLM(
        model=model,
        api_key=SecretStr(api_key),
        base_url=base_url,  # Optional
        service_id="agent"
    )
    ```
  </Step>

  <Step>
    ### Select an Agent

    Use the preset agent with common built-in tools:

    ```python icon="python" theme={null}
    agent = get_default_agent(llm=llm, cli_mode=True)
    ```

    The default agent includes `BashTool`, `FileEditorTool`, etc.

    <Tip>
      For the complete list of available tools see the
      [tools package source code](https://github.com/OpenHands/software-agent-sdk/tree/main/openhands-tools/openhands/tools).
    </Tip>
  </Step>

  <Step>
    ### Start a Conversation

    Start a conversation to manage the agent's lifecycle:

    ```python icon="python" theme={null}
    conversation = Conversation(agent=agent, workspace=cwd)
    conversation.send_message(
      "Write 3 facts about the current project into FACTS.txt."
    )
    conversation.run()
    ```
  </Step>

  <Step>
    ### 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:

    ```text icon="text" wrap theme={null}
    FACTS.txt
    ---------
    1. This is a Python project using the OpenHands Software Agent SDK.
    2. The project includes examples demonstrating various agent capabilities.
    3. The SDK provides tools for file manipulation, bash execution, and more.
    ```
  </Step>
</Steps>

## Ready-to-run Example

<Note>
  This example is available on GitHub: [examples/01\_standalone\_sdk/01\_hello\_world.py](https://github.com/OpenHands/software-agent-sdk/blob/main/examples/01_standalone_sdk/01_hello_world.py)
</Note>

```python icon="python" wrap expandable examples/01_standalone_sdk/01_hello_world.py theme={null}
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


llm = LLM(
    model=os.getenv("LLM_MODEL", "anthropic/claude-sonnet-4-5-20250929"),
    api_key=os.getenv("LLM_API_KEY"),
    base_url=os.getenv("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)

conversation.send_message("Write 3 facts about the current project into FACTS.txt.")
conversation.run()
print("All done!")
```

You can run the example code as-is.

<Note>
  The model name should follow the [LiteLLM convention](https://models.litellm.ai/): `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.
</Note>

<CodeGroup>
  <CodeBlock language="bash" filename="Bring-your-own provider key" icon="terminal" wrap>
    {`export LLM_API_KEY="your-api-key"\nexport LLM_MODEL="anthropic/claude-sonnet-4-5-20250929"  # or openai/gpt-4o, etc.\ncd software-agent-sdk\nuv run python ${path_to_script_0}`}
  </CodeBlock>

  <CodeBlock language="bash" filename="OpenHands Cloud" icon="terminal" wrap>
    {`# https://app.all-hands.dev/settings/api-keys\nexport LLM_API_KEY="your-openhands-api-key"\nexport LLM_MODEL="openhands/claude-sonnet-4-5-20250929"\ncd software-agent-sdk\nuv run python ${path_to_script_0}`}
  </CodeBlock>
</CodeGroup>

<Tip>
  **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](/sdk/guides/llm-subscriptions) for details.
</Tip>

## Next Steps

* **[Custom Tools](/sdk/guides/custom-tools)** - Create custom tools for specialized needs
* **[Model Context Protocol (MCP)](/sdk/guides/mcp)** - Integrate external MCP servers
* **[Security Analyzer](/sdk/guides/security)** - Add security validation to tool usage
