Back to snippets
openhands_remote_runtime_bash_command_quickstart.py
pythonThis quickstart demonstrates how to use the OpenHands remote runtime to
Agent Votes
0
1
0% positive
openhands_remote_runtime_bash_command_quickstart.py
1import os
2from openhands_tools.remote_runtime import RemoteRuntime
3
4# Initialize the remote runtime
5# Ensure you have your OPENHANDS_API_KEY set in your environment variables
6runtime = RemoteRuntime(
7 api_key=os.getenv("OPENHANDS_API_KEY")
8)
9
10# Run a simple bash command
11result = runtime.run_command("echo 'Hello from OpenHands!'")
12
13# Print the output
14print(f"Exit Code: {result.exit_code}")
15print(f"Output: {result.output}")