Skip to main content
Execute code in HopX sandboxes using multiple execution modes. This hub covers all code execution methods, from simple synchronous runs to advanced background and streaming execution.

What You’ll Learn

  • How to execute code synchronously and asynchronously
  • How to capture rich outputs (plots, DataFrames, visualizations)
  • How to run code in the background for long-running tasks
  • How to stream execution results in real-time
  • How to manage processes and handle async webhooks

Code Execution Overview

Execution ModeSDK MethodAPI Endpoint
Synchronoussandbox.run_code()POST /execute
Rich Outputsandbox.run_code() with rich_outputPOST /execute
Backgroundsandbox.run_code_background()POST /execute/background
Streamingsandbox.run_code_stream()POST /execute/stream
Process Managementsandbox.list_processes()GET /processes
Async WebhooksWebhook configurationWebhook endpoints

Core Concepts

Synchronous Execution

Execute code and wait for results. Perfect for quick scripts and data analysis.

Rich Output Capture

Capture matplotlib plots, pandas DataFrames, and other rich outputs automatically.

Background Execution

Run long-running code without blocking. Perfect for training models or processing large datasets.

Streaming Execution

Stream execution results in real-time as code runs.

Process Management

List, monitor, and manage background processes.

Async Webhooks

Handle code execution results via webhooks for async workflows.
  • Async Webhooks - Handle results via webhooks
  • SDK: Webhook configuration in SDK | API: Webhook endpoints

SDK Reference

Python SDK

Complete reference for Python code execution.

JavaScript SDK

Complete reference for JavaScript/TypeScript code execution.

API Reference

VM Agent API

REST API endpoints for code execution.

Quick Start

If you’re new to code execution, start here:
  1. Synchronous Execution - Execute your first code
  2. Rich Output - Capture plots and DataFrames
  3. Background Execution - Run long-running tasks

Next Steps