Prerequisites: Python 3.8+, pip, HopX API key
Time: ~5 minutes This quickstart gets you from zero to your first successful code execution. Follow these steps in order.
What You’ll Learn
In this quickstart, you’ll learn how to:- Install and verify the Python SDK
- Set up API key authentication
- Create a sandbox from a template
- Execute Python code in the sandbox
- Access execution results and output
- Clean up sandboxes properly
Step 1: Install the SDK
Step 1.5: Verify Installation
Verify the SDK is installed correctly:HopX SDK 0.3.0 installed successfully
Step 2: Set Your API key
Set theHOPX_API_KEY environment variable:
Get your API key from console.hopx.dev → Settings → API Keys
Step 3: Create and Run Your First Sandbox
Create a filehello_hopx.py:
Cleanup - delete the sandbox
sandbox.kill()Expected Output
What Just Happened?
Sandbox.create()- Created a new sandbox from thecode-interpretertemplate (Python environment)sandbox.run_code()- Executed Python code in the sandboxresult.stdout- Retrieved the standard output from code executionsandbox.kill()- Deleted the sandbox to free resources
Related
- API Quickstart - Get started with the API
- Sandbox Class Reference - Complete SDK reference
- Creating Sandboxes - Learn more about sandbox creation
- Code Execution - Understand code execution
Next Steps
Now that you have a working setup, explore more:- Creating Sandboxes - Learn about different templates and options
- Code Execution - Run Python, JavaScript, Bash, and more
- File Operations - Read, write, and manage files in sandboxes
- CLI Quickstart - Use HopX from the command line
- API Reference - Complete SDK documentation
Quickstart Variations
For more advanced quickstart examples including async/await, error handling, and context managers, see the Advanced Quickstart Guide (coming soon).
Troubleshooting
“API key required” error?- Verify
HOPX_API_KEYis set:echo $HOPX_API_KEY - Get your key at console.hopx.dev
- Use
template="code-interpreter"(default Python template) - See Available Templates for options
- Check internet connection
- Verify firewall allows HTTPS (port 443)

