mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
* update docs for headless mode * fix newline * fix command parsing * add docs * Update README.md * Update headless-mode.md * empty commit * update integration tests --------- Co-authored-by: tobitege <10787084+tobitege@users.noreply.github.com> Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>
1.3 KiB
1.3 KiB
Running in Headless Mode
You can run OpenHands via a CLI, without starting the web application. This makes it easy to automate tasks with OpenHands.
With Python
To run OpenHands in headless mode with Python, follow the Development setup instructions, and then run:
poetry run python -m openhands.core.main -t "write a bash script that prints hi"
With Docker
To run OpenHands in headless mode with Docker, run:
# Set WORKSPACE_BASE to the directory you want OpenHands to edit
WORKSPACE_BASE=$(pwd)/workspace
# Set LLM_API_KEY to an API key, e.g. for OpenAI or Anthropic
LLM_API_KEY="abcde"
# Set LLM_MODEL to the model you want to use
LLM_MODEL="gpt-4o"
docker run -it \
--pull=always \
-e SANDBOX_USER_ID=$(id -u) \
-e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \
-e LLM_API_KEY=$LLM_API_KEY \
-e LLM_MODEL=$LLM_MODEL \
-v $WORKSPACE_BASE:/opt/workspace_base \
-v /var/run/docker.sock:/var/run/docker.sock \
--add-host host.docker.internal:host-gateway \
--name openhands-app-$(date +%Y%m%d%H%M%S) \
ghcr.io/all-hands-ai/openhands:main \ # TODO: pin a version here
python -m openhands.core.main \
-t "Write a bash script that prints Hello World"