Skip to main content
Stdio keeps stdin open on a process inside the sandbox so you can send data incrementally and receive stdout/stderr as it’s produced. Unlike commands.run, which waits for the process to exit before returning output, stdio lets you:
  • Send input line by line — pipe data into cat, wc, jq, a database CLI, or any process that reads from stdin interactively.
  • Receive output as it arrives — via callbacks or an iterator, not as one blob at the end.
  • Separate stdout and stderr — independent callbacks for each stream.
  • Close stdin to signal EOF — the process sees end-of-file on its stdin, just like pressing Ctrl-D in a terminal.
  • Kill long-running processes — terminate a process mid-execution and retrieve the exit code.
Stdio is the right tool for REPLs, MCP servers, database shells, language servers, and any process that reads from stdin in a loop.

When to use Stdio vs Commands vs PTY

Default to commands.run. Use stdio.start when you need to pipe data into a running process. Use pty.create only when the command requires a real terminal.

Architecture

stdio.start uses four REST endpoints plus one SSE stream: The SSE stream emits event: stdout and event: stderr frames with base64-encoded data, plus a final event: exit frame with the exit code.

Quick start

Multi-round interaction

Send multiple lines of input to a process that reads in a loop:

Environment variables and working directory

Killing a process

Next steps