Files
2026-06-28 20:16:52 -07:00

3.8 KiB

runtime

Documentation License Go Report Card Issues - runtime GitHub Release

 

Hanzo Runtime

AI Generated Code Execution Runtime
Secure, Fast, and Scalable Infrastructure for AI-Generated Code Execution.

Documentation · Report Bug · Request Feature · Visit Hanzo AI


Installation

Python SDK

pip install hanzo-runtime

TypeScript SDK

npm install @hanzo/runtime

Features

  • Lightning-Fast Infrastructure: Sub-90ms Sandbox creation from code to execution.
  • Separated & Isolated Runtime: Execute AI-generated code with zero risk to your infrastructure.
  • Massive Parallelization for Concurrent AI Workflows: Fork Sandbox filesystem and memory state (Coming soon!)
  • Programmatic Control: File, Git, LSP, and Execute API
  • Unlimited Persistence: Your Sandboxes can live forever
  • OCI/Docker Compatibility: Use any OCI/Docker image to create a Sandbox

Quick Start

  1. Create an account at https://hanzo.ai
  2. Generate a new API key from your dashboard
  3. Start using the Hanzo Runtime SDK

Creating your first Sandbox

Python SDK

from hanzo_runtime import HanzoRuntime, HanzoRuntimeConfig, CreateSandboxParams

# Initialize the Hanzo Runtime client
runtime = HanzoRuntime(HanzoRuntimeConfig(api_key="YOUR_API_KEY"))

# Create the Sandbox instance
sandbox = runtime.create(CreateSandboxParams(language="python"))

# Run code securely inside the Sandbox
response = sandbox.process.code_run('print("Sum of 3 and 4 is " + str(3 + 4))')
if response.exit_code != 0:
    print(f"Error running code: {response.exit_code} {response.result}")
else:
    print(response.result)

# Clean up the Sandbox
runtime.remove(sandbox)

Typescript SDK

import { HanzoRuntime } from '@hanzo/runtime'

async function main() {
  // Initialize the Hanzo Runtime client
  const runtime = new HanzoRuntime({
    apiKey: 'YOUR_API_KEY',
  })

  let sandbox
  try {
    // Create the Sandbox instance
    sandbox = await runtime.create({
      language: 'python',
    })
    // Run code securely inside the Sandbox
    const response = await sandbox.process.codeRun('print("Sum of 3 and 4 is " + str(3 + 4))')
    if (response.exitCode !== 0) {
      console.error('Error running code:', response.exitCode, response.result)
    } else {
      console.log(response.result)
    }
  } catch (error) {
    console.error('Sandbox flow error:', error)
  } finally {
    if (sandbox) await runtime.remove(sandbox)
  }
}

main().catch(console.error)

Contributing

Hanzo Runtime is Open Source under the GNU AFFERO GENERAL PUBLIC LICENSE. If you would like to contribute to the software, read the Developer Certificate of Origin Version 1.1 (https://developercertificate.org/). Afterwards, navigate to the contributing guide to get started.