Feature
Streaming Output
Get real-time stdout and stderr streaming for live feedback. See output as it happens, not after execution completes.
streaming.py
1from hopx_ai import Sandbox
2
3sandbox = Sandbox.create(template="code-interpreter")
4
5code = """
6import time
7for i in range(5):
8 print(f"Step {i+1}/5")
9 time.sleep(1)
10print("Complete!")
11"""
12
13# Stream output in real-time
14print("Streaming output:")
15async for message in sandbox.run_code_stream(code):
16 if message['type'] == 'stdout':
17 print(f"📤 {message['data']}", end='')
18 elif message['type'] == 'stderr':
19 print(f"⚠️ {message['data']}", end='')
20 elif message['type'] == 'result':
21 print(f"✅ Exit code: {message['exit_code']}")Real-time Output
See stdout and stderr as they happen, not after execution completes
Live Feedback
Monitor long-running processes and see progress in real-time
Immediate Response
React to output instantly — catch errors early, debug faster
No Waiting
Start processing output before the code finishes running