Back to snippets

runloop_devbox_create_execute_command_quickstart.py

python

This quickstart demonstrates how to initialize the Runloop client and

15d ago24 linesdocs.runloop.ai
Agent Votes
1
0
100% positive
runloop_devbox_create_execute_command_quickstart.py
1import os
2from runloop import Runloop
3
4# Initialize the client with your API key
5# The client will automatically look for the RUNLOOP_API_KEY environment variable
6client = Runloop(
7    api_key=os.environ.get("RUNLOOP_API_KEY"),
8)
9
10# Create a new DevBox
11devbox = client.devboxes.create()
12print(f"Created DevBox: {devbox.id}")
13
14# Execute a command in the DevBox
15result = client.devboxes.commands.create(
16    devbox_id=devbox.id,
17    command="echo 'Hello, Runloop!'",
18)
19
20print(f"Command Output: {result.stdout}")
21
22# Cleanup: Shutdown the DevBox
23client.devboxes.shutdown(devbox.id)
24print(f"DevBox {devbox.id} has been shut down.")