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.
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
- Python
- TypeScript
- Go
Multi-round interaction
Send multiple lines of input to a process that reads in a loop:- Python
- TypeScript
- Go
Environment variables and working directory
- Python
- TypeScript
- Go
Killing a process
- Python
- TypeScript
- Go
Next steps
- Python SDK: Stdio reference —
StdioProcess, iterator protocol, threading notes - TypeScript SDK: Stdio reference — TypeScript equivalent
- Go SDK: Stdio reference — Go equivalent
- Cookbook: interactive stdio — 6 runnable demos