Quickstart
Install the SDK
Section titled “Install the SDK”pip install synapserunnpm install @runsynapse/sdkGet an API Key
Section titled “Get an API Key”Set your API key as an environment variable:
export SYNAPSE_API_KEY="cell_sk_live_..."Create and Run a Sandbox
Section titled “Create and Run a Sandbox”-
Create a sandbox
from synapse import Cellcell = Cell() # or Cell(api_key="...", template="python3") -
Execute code
result = cell.run("x = 42")result = cell.run("print(x * 2)")print(result.stdout) # "84" -
Work with files
cell.write_file("hello.txt", "Hello from Synapse!")content = cell.read_file("hello.txt")print(content) # "Hello from Synapse!" -
Run shell commands
result = cell.command("ls -la /data/")print(result.stdout) -
Clean up
cell.kill()
-
Create a sandbox
import { Cell } from '@runsynapse/sdk';const cell = await Cell.create(); -
Execute code
await cell.run("x = 42");const result = await cell.run("print(x * 2)");console.log(result.stdout); // "84" -
Work with files
await cell.writeFile("hello.txt", "Hello from Synapse!");const content = await cell.readFile("hello.txt");console.log(content); // "Hello from Synapse!" -
Run shell commands
const result = await cell.command("ls -la /data/");console.log(result.stdout); -
Clean up
await cell.kill();
Verify Execution Receipts
Section titled “Verify Execution Receipts”Every execution returns a cryptographic receipt — a SHA-256 hash of the code, result, and timestamp:
result = cell.run("print(2 + 2)")print(result.receipt)# {# "execution_id": "exec_a1b2c3...",# "code_hash": "sha256:e3b0c44...",# "result_hash": "sha256:4f3c2b1...",# "template": "python3",# "timestamp": 1715702400000# }Streaming Output
Section titled “Streaming Output”For long-running code, stream stdout/stderr in real-time:
result = cell.run( "import time\nfor i in range(5):\n print(f'Step {i}')\n time.sleep(1)", on_stdout=lambda line: print(f"[live] {line}"), on_stderr=lambda line: print(f"[err] {line}"),)const result = await cell.run( `import time\nfor i in range(5):\n print(f'Step {i}')\n time.sleep(1)`, { onStdout: (line) => console.log(`[live] ${line}`), onStderr: (line) => console.log(`[err] ${line}`), });Next Steps
Section titled “Next Steps”- Migrating from E2B — Switch in under 10 minutes
- Running Code — Advanced execution patterns
- Filesystem — Full file operations reference
- Agent Integrations — Use with LangChain, CrewAI, OpenAI