Skip to main content
This is different from the CLI, which is interactive, and better for active development.

With Python

To run OpenHands in headless mode with Python:
  1. Ensure you have followed the Development setup instructions.
  2. Run the following command:
You’ll need to be sure to set your model, API key, and other settings via environment variables or the config.toml file.

Working with Repositories

You can specify a repository for OpenHands to work with using --selected-repo or the SANDBOX_SELECTED_REPO environment variable:
Note: Currently, authentication tokens (GITHUB_TOKEN, GITLAB_TOKEN, or BITBUCKET_TOKEN) are required for all repository operations, including public repositories. This is a known limitation that may be addressed in future versions to allow tokenless access to public repositories.

With Docker

Set environment variables and run the Docker command:
Note: If you used OpenHands before version 0.44, run mv ~/.openhands-state ~/.openhands to migrate your conversation history.
The -e SANDBOX_USER_ID=$(id -u) is passed to the Docker command to ensure the sandbox user matches the host user’s permissions. This prevents the agent from creating root-owned files in the mounted workspace.

Additional Options

Common command-line options:
  • -d "/path/to/workspace" - Set working directory
  • -f task.txt - Load task from file
  • -i 50 - Set max iterations
  • -b 10.0 - Set budget limit (USD)
  • --no-auto-continue - Interactive mode
Run poetry run python -m openhands.core.main --help for all options. Set export LOG_ALL_EVENTS=true to log all agent actions.