hopx-ai


Namehopx-ai JSON
Version 0.1.21 PyPI version JSON
download
home_pageNone
SummaryOfficial Python SDK for HOPX.AI Sandboxes
upload_time2025-11-15 08:46:22
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords cloud containers hopx hopx-ai microvm sandbox vm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Hopx Python SDK

[![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
[![Version](https://img.shields.io/badge/version-0.1.19-blue.svg)](CHANGELOG.md)

Official Python SDK for [Hopx.ai](https://hopx.ai) - Cloud sandboxes for AI agents and code execution.

## ๐Ÿš€ What is Hopx.ai?

**Hopx.ai** provides secure, isolated cloud sandboxes that spin up in seconds. Perfect for:

- ๐Ÿค– **AI Agents** - Give your LLM agents safe environments to execute code, run commands, and manipulate files
- ๐Ÿ”ฌ **Code Execution** - Run untrusted code safely in isolated VMs
- ๐Ÿงช **Testing & CI/CD** - Spin up clean environments for integration tests
- ๐Ÿ“Š **Data Processing** - Execute data analysis scripts with rich output capture
- ๐ŸŒ **Web Scraping** - Run browser automation in controlled environments
- ๐ŸŽ“ **Education** - Provide students with sandboxed coding environments

Each sandbox is a **lightweight VM** with:
- Full root access
- Pre-installed development tools
- Network access (configurable)
- Persistent filesystem during session
- Auto-cleanup after timeout

## ๐Ÿ“‹ Key Use Cases

### 1. AI Code Execution Agent

```python
from hopx_ai import Sandbox

# Your AI agent generates code
agent_code = """
import pandas as pd
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
print(df.describe())
"""

# Execute safely in sandbox
sandbox = Sandbox.create(template="python")
result = sandbox.run_code(agent_code)

if result.success:
    print(result.stdout)  # Show output to user
else:
    print(f"Error: {result.error}")

sandbox.kill()
```

### 2. Data Analysis with Rich Outputs

```python
# Generate charts and capture them automatically
code = """
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)
plt.plot(x, np.sin(x))
plt.title('Sine Wave')
plt.show()
"""

sandbox = Sandbox.create(template="python")
result = sandbox.run_code(code)

# Get PNG chart data
if result.rich_outputs:
    png_data = result.rich_outputs[0].data  # Base64 PNG
    # Save or display the chart
    
sandbox.kill()
```

### 3. Multi-Step Workflow

```python
from hopx_ai import Sandbox

sandbox = Sandbox.create(template="nodejs", timeout_seconds=600)

# Step 1: Clone repo and install dependencies
sandbox.commands.run("git clone https://github.com/user/project.git /app")
sandbox.commands.run("cd /app && npm install")

# Step 2: Run tests
result = sandbox.commands.run("cd /app && npm test")
print(f"Tests: {'โœ… PASSED' if result.exit_code == 0 else 'โŒ FAILED'}")

# Step 3: Build
sandbox.commands.run("cd /app && npm run build")

# Step 4: Get build artifacts
files = sandbox.files.list("/app/dist/")
for file in files:
    print(f"Built: {file.name} ({file.size} bytes)")

sandbox.kill()
```

### 4. File Processing

```python
sandbox = Sandbox.create(template="python")

# Upload data
sandbox.files.write("/tmp/data.csv", csv_content)

# Process it
result = sandbox.run_code("""
import pandas as pd
df = pd.read_csv('/tmp/data.csv')
result = df.groupby('category').sum()
result.to_csv('/tmp/output.csv')
print(f"Processed {len(df)} rows")
""")

# Download result
output = sandbox.files.read("/tmp/output.csv")
print(output)

sandbox.kill()
```

## ๐ŸŽฏ Quick Start

### Installation

```bash
pip install hopx-ai
```

### Basic Example

```python
from hopx_ai import Sandbox

# Create sandbox (~100ms)
sandbox = Sandbox.create(
    template="python",  # or "nodejs", "go", "rust", etc.
    api_key="your-api-key"  # or set HOPX_API_KEY env var
)

# Execute code
result = sandbox.run_code("""
import sys
print(f"Python {sys.version}")
print("Hello from Hopx!")
""")

print(result.stdout)
# Output:
# Python 3.11.x
# Hello from Hopx!

# Cleanup
sandbox.kill()
```

### Context Manager (Auto-Cleanup)

```python
from hopx_ai import Sandbox

with Sandbox.create(template="python") as sandbox:
    result = sandbox.run_code("print(2 + 2)")
    print(result.stdout)  # "4"
# Sandbox automatically cleaned up
```

### Async Support

```python
from hopx_ai import AsyncSandbox
import asyncio

async def main():
    async with AsyncSandbox.create(template="python") as sandbox:
        result = await sandbox.run_code("print('Async!')")
        print(result.stdout)

asyncio.run(main())
```

## ๐Ÿ“š Core Features

### Code Execution

Execute code in multiple languages with automatic output capture:

```python
# Python
result = sandbox.run_code("print('Hello')", language="python")

# JavaScript
result = sandbox.run_code("console.log('Hello')", language="javascript")

# Bash
result = sandbox.run_code("echo 'Hello'", language="bash")

# With environment variables
result = sandbox.run_code(
    "import os; print(os.environ['API_KEY'])",
    env={"API_KEY": "secret"}
)
```

### File Operations

```python
# Write files
sandbox.files.write("/app/config.json", '{"key": "value"}')

# Read files
content = sandbox.files.read("/app/config.json")

# List directory
files = sandbox.files.list("/app/")
for file in files:
    print(f"{file.name}: {file.size} bytes")

# Delete files
sandbox.files.delete("/app/temp.txt")
```

### Commands

```python
# Run command synchronously
result = sandbox.commands.run("ls -la /app")
print(result.stdout)

# Run in background
cmd_id = sandbox.commands.run_async("python long_task.py")
# ... do other work ...
result = sandbox.commands.get_result(cmd_id)
```

### Environment Variables

```python
# Set single variable
sandbox.env.set("DATABASE_URL", "postgresql://...")

# Set multiple
sandbox.env.set_many({
    "API_KEY": "key123",
    "DEBUG": "true"
})

# Get variable
value = sandbox.env.get("API_KEY")

# Delete variable
sandbox.env.delete("DEBUG")
```

### Template Building

Build custom environments:

```python
from hopx_ai import Template, wait_for_port
from hopx_ai.template import BuildOptions

# Define template
template = (
    Template()
    .from_python_image("3.11")
    .copy("requirements.txt", "/app/requirements.txt")
    .copy("src/", "/app/src/")
    .run("cd /app && pip install -r requirements.txt")
    .set_workdir("/app")
    .set_env("PORT", "8000")
    .set_start_cmd("python src/main.py", wait_for_port(8000))
)

# Build template
result = await Template.build(
    template,
    BuildOptions(
        alias="my-python-app",
        api_key="your-api-key",
        on_log=lambda log: print(f"[{log['level']}] {log['message']}")
    )
)

print(f"Template ID: {result.template_id}")

# Create sandbox from template
sandbox = Sandbox.create(template_id=result.template_id)
```

## ๐Ÿ” Authentication

Set your API key:

```bash
export HOPX_API_KEY="your-api-key"
```

Or pass it directly:

```python
sandbox = Sandbox.create(
    template="python",
    api_key="your-api-key"
)
```

Get your API key at [hopx.ai/dashboard](https://hopx.ai/dashboard)

## ๐ŸŽ“ Templates

Pre-built templates available:

- `python` - Python 3.11 with pip, numpy, pandas, requests
- `nodejs` - Node.js 20 with npm, common packages
- `code-interpreter` - Python with data science stack (pandas, numpy, matplotlib, seaborn, scikit-learn)
- `go` - Go 1.21
- `rust` - Rust with Cargo
- `java` - Java 17 with Maven

Or build your own with `Template.build()`!

## ๐Ÿ“– Documentation

- [Full Documentation](https://docs.hopx.ai)
- [API Reference](https://docs.hopx.ai/python/api)
- [Examples](https://github.com/hopx-ai/hopx/tree/main/python/examples)
- [Cookbook](https://github.com/hopx-ai/hopx/tree/main/cookbook/python)

## ๐Ÿ› ๏ธ Advanced Features

### Rich Output Capture

Automatically capture charts, tables, and visualizations:

```python
result = sandbox.run_code("""
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [1, 4, 9])
plt.title('My Chart')
plt.show()
""")

# Get PNG data
for output in result.rich_outputs:
    if output.type == "image/png":
        # Save to file
        import base64
        with open("chart.png", "wb") as f:
            f.write(base64.b64decode(output.data))
```

### Process Management

```python
# List processes
processes = sandbox.processes.list()
for proc in processes:
    print(f"{proc.pid}: {proc.name} (CPU: {proc.cpu_percent}%)")

# Kill process
sandbox.processes.kill(1234)
```

### Desktop Automation (Premium)

```python
# Get VNC info
vnc = sandbox.desktop.get_vnc_info()
print(f"Connect to: {vnc.url}")

# Take screenshot
screenshot = sandbox.desktop.screenshot()  # Returns PNG bytes

# Control mouse
sandbox.desktop.mouse_click(100, 200)

# Type text
sandbox.desktop.keyboard_type("Hello, World!")
```

### Health & Metrics

```python
# Check health
health = sandbox.get_health()
print(health.status)  # "healthy"

# Get metrics
metrics = sandbox.get_metrics()
print(f"CPU: {metrics.cpu_percent}%")
print(f"Memory: {metrics.memory_mb}MB")
print(f"Disk: {metrics.disk_mb}MB")
```

## ๐Ÿค Error Handling

```python
from hopx_ai import (
    HopxError,
    AuthenticationError,
    CodeExecutionError,
    FileNotFoundError,
    RateLimitError
)

try:
    sandbox = Sandbox.create(template="python")
    result = sandbox.run_code("1/0")  # Will raise CodeExecutionError
    
except AuthenticationError:
    print("Invalid API key")
except CodeExecutionError as e:
    print(f"Code execution failed: {e.stderr}")
except RateLimitError:
    print("Rate limit exceeded")
except HopxError as e:
    print(f"API error: {e.message}")
```

## ๐Ÿ’ก Best Practices

1. **Always clean up**: Use context managers or call `.kill()` explicitly
2. **Set timeouts**: Prevent runaway sandboxes with `timeout_seconds`
3. **Handle errors**: Wrap code in try/except for production use
4. **Use templates**: Pre-built templates are faster than custom ones
5. **Batch operations**: Group related operations to reduce API calls
6. **Monitor resources**: Check metrics if running long tasks

## ๐Ÿ› Troubleshooting

**Sandbox creation timeout?**
- Check your API key is valid
- Verify network connectivity
- Try a different region

**Code execution fails?**
- Check `result.stderr` for error messages
- Ensure required packages are installed in sandbox
- Verify file paths are correct

**File not found?**
- Use absolute paths (e.g., `/app/file.txt`)
- Check file was uploaded successfully
- Verify working directory

## ๐Ÿ“„ License

MIT License - see [LICENSE](LICENSE) file for details.

## ๐Ÿ”— Links

- [Website](https://hopx.ai)
- [Documentation](https://docs.hopx.ai)
- [Dashboard](https://hopx.ai/dashboard)
- [GitHub](https://github.com/hopx-ai/hopx)
- [Discord Community](https://discord.gg/hopx)
- [Twitter](https://twitter.com/hopx_ai)

## ๐Ÿ†˜ Support

- Email: support@hopx.ai
- Discord: [discord.gg/hopx](https://discord.gg/hopx)
- Issues: [GitHub Issues](https://github.com/hopx-ai/hopx/issues)

---

**Built with โค๏ธ by the Hopx team**

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "hopx-ai",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "cloud, containers, hopx, hopx-ai, microvm, sandbox, vm",
    "author": null,
    "author_email": "\"HOPX.AI\" <support@hopx.ai>",
    "download_url": "https://files.pythonhosted.org/packages/0c/52/4ae94016455875b96d066c88101f33eb71a865bbbec931995e645664d756/hopx_ai-0.1.21.tar.gz",
    "platform": null,
    "description": "# Hopx Python SDK\n\n[![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)\n[![Version](https://img.shields.io/badge/version-0.1.19-blue.svg)](CHANGELOG.md)\n\nOfficial Python SDK for [Hopx.ai](https://hopx.ai) - Cloud sandboxes for AI agents and code execution.\n\n## \ud83d\ude80 What is Hopx.ai?\n\n**Hopx.ai** provides secure, isolated cloud sandboxes that spin up in seconds. Perfect for:\n\n- \ud83e\udd16 **AI Agents** - Give your LLM agents safe environments to execute code, run commands, and manipulate files\n- \ud83d\udd2c **Code Execution** - Run untrusted code safely in isolated VMs\n- \ud83e\uddea **Testing & CI/CD** - Spin up clean environments for integration tests\n- \ud83d\udcca **Data Processing** - Execute data analysis scripts with rich output capture\n- \ud83c\udf10 **Web Scraping** - Run browser automation in controlled environments\n- \ud83c\udf93 **Education** - Provide students with sandboxed coding environments\n\nEach sandbox is a **lightweight VM** with:\n- Full root access\n- Pre-installed development tools\n- Network access (configurable)\n- Persistent filesystem during session\n- Auto-cleanup after timeout\n\n## \ud83d\udccb Key Use Cases\n\n### 1. AI Code Execution Agent\n\n```python\nfrom hopx_ai import Sandbox\n\n# Your AI agent generates code\nagent_code = \"\"\"\nimport pandas as pd\ndf = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})\nprint(df.describe())\n\"\"\"\n\n# Execute safely in sandbox\nsandbox = Sandbox.create(template=\"python\")\nresult = sandbox.run_code(agent_code)\n\nif result.success:\n    print(result.stdout)  # Show output to user\nelse:\n    print(f\"Error: {result.error}\")\n\nsandbox.kill()\n```\n\n### 2. Data Analysis with Rich Outputs\n\n```python\n# Generate charts and capture them automatically\ncode = \"\"\"\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nx = np.linspace(0, 10, 100)\nplt.plot(x, np.sin(x))\nplt.title('Sine Wave')\nplt.show()\n\"\"\"\n\nsandbox = Sandbox.create(template=\"python\")\nresult = sandbox.run_code(code)\n\n# Get PNG chart data\nif result.rich_outputs:\n    png_data = result.rich_outputs[0].data  # Base64 PNG\n    # Save or display the chart\n    \nsandbox.kill()\n```\n\n### 3. Multi-Step Workflow\n\n```python\nfrom hopx_ai import Sandbox\n\nsandbox = Sandbox.create(template=\"nodejs\", timeout_seconds=600)\n\n# Step 1: Clone repo and install dependencies\nsandbox.commands.run(\"git clone https://github.com/user/project.git /app\")\nsandbox.commands.run(\"cd /app && npm install\")\n\n# Step 2: Run tests\nresult = sandbox.commands.run(\"cd /app && npm test\")\nprint(f\"Tests: {'\u2705 PASSED' if result.exit_code == 0 else '\u274c FAILED'}\")\n\n# Step 3: Build\nsandbox.commands.run(\"cd /app && npm run build\")\n\n# Step 4: Get build artifacts\nfiles = sandbox.files.list(\"/app/dist/\")\nfor file in files:\n    print(f\"Built: {file.name} ({file.size} bytes)\")\n\nsandbox.kill()\n```\n\n### 4. File Processing\n\n```python\nsandbox = Sandbox.create(template=\"python\")\n\n# Upload data\nsandbox.files.write(\"/tmp/data.csv\", csv_content)\n\n# Process it\nresult = sandbox.run_code(\"\"\"\nimport pandas as pd\ndf = pd.read_csv('/tmp/data.csv')\nresult = df.groupby('category').sum()\nresult.to_csv('/tmp/output.csv')\nprint(f\"Processed {len(df)} rows\")\n\"\"\")\n\n# Download result\noutput = sandbox.files.read(\"/tmp/output.csv\")\nprint(output)\n\nsandbox.kill()\n```\n\n## \ud83c\udfaf Quick Start\n\n### Installation\n\n```bash\npip install hopx-ai\n```\n\n### Basic Example\n\n```python\nfrom hopx_ai import Sandbox\n\n# Create sandbox (~100ms)\nsandbox = Sandbox.create(\n    template=\"python\",  # or \"nodejs\", \"go\", \"rust\", etc.\n    api_key=\"your-api-key\"  # or set HOPX_API_KEY env var\n)\n\n# Execute code\nresult = sandbox.run_code(\"\"\"\nimport sys\nprint(f\"Python {sys.version}\")\nprint(\"Hello from Hopx!\")\n\"\"\")\n\nprint(result.stdout)\n# Output:\n# Python 3.11.x\n# Hello from Hopx!\n\n# Cleanup\nsandbox.kill()\n```\n\n### Context Manager (Auto-Cleanup)\n\n```python\nfrom hopx_ai import Sandbox\n\nwith Sandbox.create(template=\"python\") as sandbox:\n    result = sandbox.run_code(\"print(2 + 2)\")\n    print(result.stdout)  # \"4\"\n# Sandbox automatically cleaned up\n```\n\n### Async Support\n\n```python\nfrom hopx_ai import AsyncSandbox\nimport asyncio\n\nasync def main():\n    async with AsyncSandbox.create(template=\"python\") as sandbox:\n        result = await sandbox.run_code(\"print('Async!')\")\n        print(result.stdout)\n\nasyncio.run(main())\n```\n\n## \ud83d\udcda Core Features\n\n### Code Execution\n\nExecute code in multiple languages with automatic output capture:\n\n```python\n# Python\nresult = sandbox.run_code(\"print('Hello')\", language=\"python\")\n\n# JavaScript\nresult = sandbox.run_code(\"console.log('Hello')\", language=\"javascript\")\n\n# Bash\nresult = sandbox.run_code(\"echo 'Hello'\", language=\"bash\")\n\n# With environment variables\nresult = sandbox.run_code(\n    \"import os; print(os.environ['API_KEY'])\",\n    env={\"API_KEY\": \"secret\"}\n)\n```\n\n### File Operations\n\n```python\n# Write files\nsandbox.files.write(\"/app/config.json\", '{\"key\": \"value\"}')\n\n# Read files\ncontent = sandbox.files.read(\"/app/config.json\")\n\n# List directory\nfiles = sandbox.files.list(\"/app/\")\nfor file in files:\n    print(f\"{file.name}: {file.size} bytes\")\n\n# Delete files\nsandbox.files.delete(\"/app/temp.txt\")\n```\n\n### Commands\n\n```python\n# Run command synchronously\nresult = sandbox.commands.run(\"ls -la /app\")\nprint(result.stdout)\n\n# Run in background\ncmd_id = sandbox.commands.run_async(\"python long_task.py\")\n# ... do other work ...\nresult = sandbox.commands.get_result(cmd_id)\n```\n\n### Environment Variables\n\n```python\n# Set single variable\nsandbox.env.set(\"DATABASE_URL\", \"postgresql://...\")\n\n# Set multiple\nsandbox.env.set_many({\n    \"API_KEY\": \"key123\",\n    \"DEBUG\": \"true\"\n})\n\n# Get variable\nvalue = sandbox.env.get(\"API_KEY\")\n\n# Delete variable\nsandbox.env.delete(\"DEBUG\")\n```\n\n### Template Building\n\nBuild custom environments:\n\n```python\nfrom hopx_ai import Template, wait_for_port\nfrom hopx_ai.template import BuildOptions\n\n# Define template\ntemplate = (\n    Template()\n    .from_python_image(\"3.11\")\n    .copy(\"requirements.txt\", \"/app/requirements.txt\")\n    .copy(\"src/\", \"/app/src/\")\n    .run(\"cd /app && pip install -r requirements.txt\")\n    .set_workdir(\"/app\")\n    .set_env(\"PORT\", \"8000\")\n    .set_start_cmd(\"python src/main.py\", wait_for_port(8000))\n)\n\n# Build template\nresult = await Template.build(\n    template,\n    BuildOptions(\n        alias=\"my-python-app\",\n        api_key=\"your-api-key\",\n        on_log=lambda log: print(f\"[{log['level']}] {log['message']}\")\n    )\n)\n\nprint(f\"Template ID: {result.template_id}\")\n\n# Create sandbox from template\nsandbox = Sandbox.create(template_id=result.template_id)\n```\n\n## \ud83d\udd10 Authentication\n\nSet your API key:\n\n```bash\nexport HOPX_API_KEY=\"your-api-key\"\n```\n\nOr pass it directly:\n\n```python\nsandbox = Sandbox.create(\n    template=\"python\",\n    api_key=\"your-api-key\"\n)\n```\n\nGet your API key at [hopx.ai/dashboard](https://hopx.ai/dashboard)\n\n## \ud83c\udf93 Templates\n\nPre-built templates available:\n\n- `python` - Python 3.11 with pip, numpy, pandas, requests\n- `nodejs` - Node.js 20 with npm, common packages\n- `code-interpreter` - Python with data science stack (pandas, numpy, matplotlib, seaborn, scikit-learn)\n- `go` - Go 1.21\n- `rust` - Rust with Cargo\n- `java` - Java 17 with Maven\n\nOr build your own with `Template.build()`!\n\n## \ud83d\udcd6 Documentation\n\n- [Full Documentation](https://docs.hopx.ai)\n- [API Reference](https://docs.hopx.ai/python/api)\n- [Examples](https://github.com/hopx-ai/hopx/tree/main/python/examples)\n- [Cookbook](https://github.com/hopx-ai/hopx/tree/main/cookbook/python)\n\n## \ud83d\udee0\ufe0f Advanced Features\n\n### Rich Output Capture\n\nAutomatically capture charts, tables, and visualizations:\n\n```python\nresult = sandbox.run_code(\"\"\"\nimport matplotlib.pyplot as plt\nplt.plot([1, 2, 3], [1, 4, 9])\nplt.title('My Chart')\nplt.show()\n\"\"\")\n\n# Get PNG data\nfor output in result.rich_outputs:\n    if output.type == \"image/png\":\n        # Save to file\n        import base64\n        with open(\"chart.png\", \"wb\") as f:\n            f.write(base64.b64decode(output.data))\n```\n\n### Process Management\n\n```python\n# List processes\nprocesses = sandbox.processes.list()\nfor proc in processes:\n    print(f\"{proc.pid}: {proc.name} (CPU: {proc.cpu_percent}%)\")\n\n# Kill process\nsandbox.processes.kill(1234)\n```\n\n### Desktop Automation (Premium)\n\n```python\n# Get VNC info\nvnc = sandbox.desktop.get_vnc_info()\nprint(f\"Connect to: {vnc.url}\")\n\n# Take screenshot\nscreenshot = sandbox.desktop.screenshot()  # Returns PNG bytes\n\n# Control mouse\nsandbox.desktop.mouse_click(100, 200)\n\n# Type text\nsandbox.desktop.keyboard_type(\"Hello, World!\")\n```\n\n### Health & Metrics\n\n```python\n# Check health\nhealth = sandbox.get_health()\nprint(health.status)  # \"healthy\"\n\n# Get metrics\nmetrics = sandbox.get_metrics()\nprint(f\"CPU: {metrics.cpu_percent}%\")\nprint(f\"Memory: {metrics.memory_mb}MB\")\nprint(f\"Disk: {metrics.disk_mb}MB\")\n```\n\n## \ud83e\udd1d Error Handling\n\n```python\nfrom hopx_ai import (\n    HopxError,\n    AuthenticationError,\n    CodeExecutionError,\n    FileNotFoundError,\n    RateLimitError\n)\n\ntry:\n    sandbox = Sandbox.create(template=\"python\")\n    result = sandbox.run_code(\"1/0\")  # Will raise CodeExecutionError\n    \nexcept AuthenticationError:\n    print(\"Invalid API key\")\nexcept CodeExecutionError as e:\n    print(f\"Code execution failed: {e.stderr}\")\nexcept RateLimitError:\n    print(\"Rate limit exceeded\")\nexcept HopxError as e:\n    print(f\"API error: {e.message}\")\n```\n\n## \ud83d\udca1 Best Practices\n\n1. **Always clean up**: Use context managers or call `.kill()` explicitly\n2. **Set timeouts**: Prevent runaway sandboxes with `timeout_seconds`\n3. **Handle errors**: Wrap code in try/except for production use\n4. **Use templates**: Pre-built templates are faster than custom ones\n5. **Batch operations**: Group related operations to reduce API calls\n6. **Monitor resources**: Check metrics if running long tasks\n\n## \ud83d\udc1b Troubleshooting\n\n**Sandbox creation timeout?**\n- Check your API key is valid\n- Verify network connectivity\n- Try a different region\n\n**Code execution fails?**\n- Check `result.stderr` for error messages\n- Ensure required packages are installed in sandbox\n- Verify file paths are correct\n\n**File not found?**\n- Use absolute paths (e.g., `/app/file.txt`)\n- Check file was uploaded successfully\n- Verify working directory\n\n## \ud83d\udcc4 License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## \ud83d\udd17 Links\n\n- [Website](https://hopx.ai)\n- [Documentation](https://docs.hopx.ai)\n- [Dashboard](https://hopx.ai/dashboard)\n- [GitHub](https://github.com/hopx-ai/hopx)\n- [Discord Community](https://discord.gg/hopx)\n- [Twitter](https://twitter.com/hopx_ai)\n\n## \ud83c\udd98 Support\n\n- Email: support@hopx.ai\n- Discord: [discord.gg/hopx](https://discord.gg/hopx)\n- Issues: [GitHub Issues](https://github.com/hopx-ai/hopx/issues)\n\n---\n\n**Built with \u2764\ufe0f by the Hopx team**\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Official Python SDK for HOPX.AI Sandboxes",
    "version": "0.1.21",
    "project_urls": {
        "Documentation": "https://docs.hopx.ai",
        "Homepage": "https://hopx.ai",
        "Issues": "https://github.com/hopx-ai/hopx/issues",
        "Repository": "https://github.com/hopx-ai/hopx"
    },
    "split_keywords": [
        "cloud",
        " containers",
        " hopx",
        " hopx-ai",
        " microvm",
        " sandbox",
        " vm"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "00dce1e5f117662bb591c2899d928a715d6b9de0e78bcb56a53feb6bcdab67f6",
                "md5": "73b8fa1acb2c6e0adb6496bbc4fe8d0a",
                "sha256": "f7593b506ea9adab407d3728ec9275c071416513f4cc4da8064b8bda2e8deb90"
            },
            "downloads": -1,
            "filename": "hopx_ai-0.1.21-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "73b8fa1acb2c6e0adb6496bbc4fe8d0a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 84895,
            "upload_time": "2025-11-15T08:46:20",
            "upload_time_iso_8601": "2025-11-15T08:46:20.893648Z",
            "url": "https://files.pythonhosted.org/packages/00/dc/e1e5f117662bb591c2899d928a715d6b9de0e78bcb56a53feb6bcdab67f6/hopx_ai-0.1.21-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0c524ae94016455875b96d066c88101f33eb71a865bbbec931995e645664d756",
                "md5": "f25b542d5eade84872b9004cf93ea8f3",
                "sha256": "981b00e57c0ce245a9bf3f304ef16e3a0a90e4979f05902f37484012988910bd"
            },
            "downloads": -1,
            "filename": "hopx_ai-0.1.21.tar.gz",
            "has_sig": false,
            "md5_digest": "f25b542d5eade84872b9004cf93ea8f3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 270175,
            "upload_time": "2025-11-15T08:46:22",
            "upload_time_iso_8601": "2025-11-15T08:46:22.138387Z",
            "url": "https://files.pythonhosted.org/packages/0c/52/4ae94016455875b96d066c88101f33eb71a865bbbec931995e645664d756/hopx_ai-0.1.21.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-11-15 08:46:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hopx-ai",
    "github_project": "hopx",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "hopx-ai"
}
        
Elapsed time: 3.01430s