File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,10 +75,10 @@ Start a sandbox with your API key and run prompts.
7575<CodeGroup >
7676
7777``` typescript JavaScript & TypeScript
78- // sandbox.ts
7978import { Sandbox } from ' e2b'
8079
8180const sbx = await Sandbox .create (' claude-code' , {
81+ timeoutMs: 60_000 ,
8282 envs: {
8383 ANTHROPIC_API_KEY: ' <your api key>' ,
8484 },
@@ -89,16 +89,14 @@ const result = await sbx.commands.run(
8989 { timeoutMs: 0 }
9090)
9191console .log (result .stdout )
92-
93- await sbx .kill ()
9492```
9593
9694``` python Python
97- # sandbox.py
9895from e2b import Sandbox
9996
10097sbx = Sandbox(
10198 ' claude-code' ,
99+ timeout = 60 ,
102100 envs = {
103101 ' ANTHROPIC_API_KEY' : ' <your api key>' ,
104102 },
@@ -109,8 +107,6 @@ result = sbx.commands.run(
109107 timeout = 0 ,
110108)
111109print (result.stdout)
112-
113- sbx.kill()
114110```
115111
116112</CodeGroup >
Original file line number Diff line number Diff line change @@ -186,27 +186,21 @@ Start a sandbox and open the desktop in your browser.
186186<CodeGroup >
187187
188188``` typescript JavaScript & TypeScript
189- // sandbox.ts
190189import { Sandbox } from ' e2b'
191190
192- const sbx = await Sandbox .create (' desktop' )
191+ const sbx = await Sandbox .create (' desktop' , { timeoutMs: 60_000 } )
193192
194193const url = sbx .getHost (6080 )
195194console .log (' Desktop available at:' , url )
196-
197- await sbx .kill ()
198195```
199196
200197``` python Python
201- # sandbox.py
202198from e2b import Sandbox
203199
204- sbx = Sandbox(' desktop' )
200+ sbx = Sandbox(' desktop' , timeout = 60 )
205201
206202url = sbx.get_host(6080 )
207203print (' Desktop available at:' , url)
208-
209- sbx.kill()
210204```
211205
212206</CodeGroup >
Original file line number Diff line number Diff line change @@ -69,26 +69,20 @@ Start a sandbox and run containers.
6969
7070<CodeGroup >
7171``` typescript JavaScript & TypeScript
72- // sandbox.ts
7372import { Sandbox } from ' e2b'
7473
75- const sbx = await Sandbox .create (' e2b-docker-template' )
74+ const sbx = await Sandbox .create (' e2b-docker-template' , { timeoutMs: 60_000 } )
7675
7776const result = await sbx .commands .run (' sudo docker run --rm alpine echo "Hello from Alpine!"' )
7877console .log (result .stdout )
79-
80- await sbx .kill ()
8178```
8279
8380``` python Python
84- # sandbox.py
8581from e2b import Sandbox
8682
87- sbx = Sandbox(' e2b-docker-template' )
83+ sbx = Sandbox(' e2b-docker-template' , timeout = 60 )
8884
8985result = sbx.commands.run(' sudo docker run --rm alpine echo "Hello from Alpine!"' )
9086print (result.stdout)
91-
92- sbx.kill()
9387```
9488</CodeGroup >
Original file line number Diff line number Diff line change @@ -75,26 +75,20 @@ Start a sandbox and get the URL where your Expo app is running.
7575
7676<CodeGroup >
7777``` typescript JavaScript & TypeScript
78- // sandbox.ts
7978import { Sandbox } from ' e2b'
8079
81- const sbx = await Sandbox .create (' expo-app' )
80+ const sbx = await Sandbox .create (' expo-app' , { timeoutMs: 60_000 } )
8281
8382const url = sbx .getHost (8081 )
8483console .log (' Expo app running at:' , url )
85-
86- await sbx .kill ()
8784```
8885
8986``` python Python
90- # sandbox.py
9187from e2b import Sandbox
9288
93- sbx = Sandbox(' expo-app' )
89+ sbx = Sandbox(' expo-app' , timeout = 60 )
9490
9591url = sbx.get_host(8081 )
9692print (' Expo app running at:' , url)
97-
98- sbx.kill()
9993```
10094</CodeGroup >
Original file line number Diff line number Diff line change @@ -83,26 +83,20 @@ Start a sandbox and get the URL where your app is running.
8383
8484<CodeGroup >
8585``` typescript JavaScript & TypeScript
86- // sandbox.ts
8786import { Sandbox } from ' e2b'
8887
89- const sbx = await Sandbox .create (' nextjs-app-bun' )
88+ const sbx = await Sandbox .create (' nextjs-app-bun' , { timeoutMs: 60_000 } )
9089
9190const url = sbx .getHost (3000 )
9291console .log (' Next.js app running at:' , url )
93-
94- await sbx .kill ()
9592```
9693
9794``` python Python
98- # sandbox.py
9995from e2b import Sandbox
10096
101- sbx = Sandbox(' nextjs-app-bun' )
97+ sbx = Sandbox(' nextjs-app-bun' , timeout = 60 )
10298
10399url = sbx.get_host(3000 )
104100print (' Next.js app running at:' , url)
105-
106- sbx.kill()
107101```
108102</CodeGroup >
Original file line number Diff line number Diff line change @@ -85,26 +85,20 @@ Start a sandbox and get the URL where your app is running.
8585
8686<CodeGroup >
8787``` typescript JavaScript & TypeScript
88- // sandbox.ts
8988import { Sandbox } from ' e2b'
9089
91- const sbx = await Sandbox .create (' nextjs-app' )
90+ const sbx = await Sandbox .create (' nextjs-app' , { timeoutMs: 60_000 } )
9291
9392const url = sbx .getHost (3000 )
9493console .log (' Next.js app running at:' , url )
95-
96- await sbx .kill ()
9794```
9895
9996``` python Python
100- # sandbox.py
10197from e2b import Sandbox
10298
103- sbx = Sandbox(' nextjs-app' )
99+ sbx = Sandbox(' nextjs-app' , timeout = 60 )
104100
105101url = sbx.get_host(3000 )
106102print (' Next.js app running at:' , url)
107-
108- sbx.kill()
109103```
110104</CodeGroup >
You can’t perform that action at this time.
0 commit comments