Skip to main content
Goal: Create a sandbox, execute code, and see the output in under 5 minutes.
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

pip install hopx-ai

Step 1.5: Verify Installation

Verify the SDK is installed correctly:
python -c "import hopx_ai; print(f'HopX SDK {hopx_ai.__version__} installed successfully')"
Expected output: HopX SDK 0.3.0 installed successfully

Step 2: Set Your API key

Set the HOPX_API_KEY environment variable:
# Linux/macOS
export HOPX_API_KEY="your-api-key-here"

# Windows (PowerShell)
$env:HOPX_API_KEY="your-api-key-here"
Get your API key from console.hopx.dev → Settings → API Keys

Step 3: Create and Run Your First Sandbox

Create a file hello_hopx.py:
from hopx_ai import Sandbox

# Create a sandbox (~100ms)
sandbox = Sandbox.create(template="code-interpreter")

# Execute code in the sandbox
result = sandbox.run_code('print("Hello from HopX!")')

# Print the output
print(result.stdout)
Expected Output:
Hello from HopX!

Cleanup - delete the sandbox

sandbox.kill()

## Step 4: Run It

```bash
python hello_hopx.py

Expected Output

Hello from HopX!

What Just Happened?

  1. Sandbox.create() - Created a new sandbox from the code-interpreter template (Python environment)
  2. sandbox.run_code() - Executed Python code in the sandbox
  3. result.stdout - Retrieved the standard output from code execution
  4. sandbox.kill() - Deleted the sandbox to free resources

Next Steps

Now that you have a working setup, explore more:

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_KEY is set: echo $HOPX_API_KEY
  • Get your key at console.hopx.dev
“Template not found” error?
  • Use template="code-interpreter" (default Python template)
  • See Available Templates for options
Network timeout?
  • Check internet connection
  • Verify firewall allows HTTPS (port 443)
For more help, see the Troubleshooting Guide.