Skip to main content
A sandbox keeps running until its timeout expires or until you stop it manually. By default, a new sandbox stays alive for 5 minutes. You can set a different timeout when creating the sandbox, update the timeout while it is running, inspect sandbox information, or kill it when you are done.

Create a sandbox with a timeout

Set the timeout at creation time when you know how long the work should run.
import { Sandbox } from 'novita-sandbox/code-interpreter'

// Timeout is in milliseconds.
const sandbox = await Sandbox.create({ timeoutMs: 60_000 })

await sandbox.kill()

Update the timeout

You can use the setTimeout method to reset how much longer the sandbox should stay alive. This is useful when user activity continues after the original timeout would have expired.
import { Sandbox } from 'novita-sandbox/code-interpreter'

const sandbox = await Sandbox.create({ timeoutMs: 60_000 })

await sandbox.setTimeout(300_000)

await sandbox.kill()

Get sandbox information

You can use the getInfo method in JavaScript or get_info method in Python to inspect the sandbox ID, template, metadata, current state, and expiration time.
import { Sandbox } from 'novita-sandbox/code-interpreter'

const sandbox = await Sandbox.create({ timeoutMs: 60_000 })

const info = await sandbox.getInfo()

console.log(info.sandboxId)
console.log(info.templateId)
console.log(info.state)
console.log(info.startedAt)
console.log(info.endAt)

await sandbox.kill()

Kill a sandbox

You can use the kill method to shut down a sandbox before its timeout expires when you no longer need it.
import { Sandbox } from 'novita-sandbox/code-interpreter'

const sandbox = await Sandbox.create({ timeoutMs: 60_000 })
const sandboxId = sandbox.sandboxId

await sandbox.kill()

// Or kill by ID.
await Sandbox.kill(sandboxId)

Next steps

Last modified on June 8, 2026