# Streaming command output - Documentation

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown is available with `Accept: text/markdown` and `.md` URL variants.

Source: /docs/guides/sandbox-commands-streaming

# Streaming command output

Command output can be streamed in real time by providing `onStdout` and `onStderr` callbacks to `commands.run()` in JavaScript, or `on_stdout` and `on_stderr` callbacks in Python.

JavaScript & TypeScript

Python

```
import { Sandbox } from 'novita-sandbox/code-interpreter'

const sandbox = await Sandbox.create()
const result = await sandbox.commands.run('echo hello; sleep 1; echo world', {
onStdout: (data) => {
console.log(data)
},
onStderr: (data) => {
console.log(data)
},
})

console.log(result)

await sandbox.kill()
```

```
from novita_sandbox.code_interpreter import Sandbox

sandbox = Sandbox.create()

result = sandbox.commands.run('echo hello; sleep 1; echo world',
on_stdout=lambda data: print(data),
on_stderr=lambda data: print(data))

print(result)

sandbox.kill()
```

Last modified on June 4, 2026
