Note: The sandbox is paused while the snapshot is being created. Snapshots are persistent and remain available even after the source sandbox is deleted.
import osfrom novita_sandbox import Novitanovita = Novita(api_key=os.getenv("NOVITA_API_KEY", ""))sandbox = novita.sandbox.create("base")# Prepare state you want to preservesandbox.commands.run("pip install requests")# Capture the current state (the sandbox is paused during this)snapshot = sandbox.create_snapshot()print("Snapshot ID:", snapshot.snapshot_id)sandbox.kill()
import { Novita } from 'novita-sandbox'const novita = new Novita({ apiKey: process.env.NOVITA_API_KEY || '',})const sandbox = await novita.sandbox.create('base')// Prepare state you want to preserveawait sandbox.commands.run('pip install requests')// Capture the current state (the sandbox is paused during this)const snapshot = await sandbox.createSnapshot()console.log('Snapshot ID:', snapshot.snapshotId)await sandbox.kill()