File tree Expand file tree Collapse file tree
app/(docs)/docs/quickstart/api-key Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import Link from ' next/link'
2+
3+ # API Key
4+
5+ To use the API key, you can either:
6+
7+ - ** Set the API key as the ` E2B_API_KEY ` environment variable** to avoid passing it each time you create a sandbox.
8+ - Or pass it directly to the ` Sandbox ` constructor as shown below:
9+
10+ <CodeGroup >
11+ ``` js {{ language: 'js' }}
12+ import { Sandbox } from ' @e2b/code-interpreter'
13+
14+ const sandbox = await Sandbox .create ({ apiKey: ' YOUR_API_KEY' })
15+ await sandbox .notebook .execCell (' x = 1' )
16+
17+ const execution = await sandbox .notebook .execCell (' x+=1; x' )
18+ console .log (execution .text ) // outputs 2
19+
20+ await sandbox .close ()
21+ ```
22+ ``` python {{ language: 'python' }}
23+ from e2b_code_interpreter import CodeInterpreter
24+
25+ with CodeInterpreter(api_key = " YOUR_API_KEY" ) as code_interpreter:
26+ sandbox.notebook.exec_cell(" x = 1" )
27+ execution = sandbox.notebook.exec_cell(" x+=1; x" )
28+ print (execution.text) # outputs 2
29+ ```
30+ </CodeGroup >
31+
32+ ## Where to find API key
33+
34+ You can get your API key at <Link href = " /dashboard?tab=keys" >dashboard</Link >.
35+
36+ <br />
37+
38+ # Access Token
39+
40+ The access token is used only in the CLI and is ** not needed in the SDK** . There's no need to set it when logging into the CLI using ` e2b auth login ` .
41+
42+ <Note >
43+ To authenticate without the browser, you can set ` E2B_ACCESS_TOKEN ` as an environment variable. This is useful for CI/CD pipelines.
44+ </Note >
45+
46+ ## Where to find Access token
47+
48+ You can get your ** Access token key** at the <Link href = " /dashboard/account" >dashboard</Link >.
49+
Original file line number Diff line number Diff line change @@ -58,6 +58,10 @@ export const docRoutes: NavGroup[] = [
5858 title : 'Install custom packages' ,
5959 href : '/docs/quickstart/install-custom-packages' ,
6060 } ,
61+ {
62+ title : 'API Key' ,
63+ href : '/docs/quickstart/api-key' ,
64+ } ,
6165 ] ,
6266 } ,
6367 {
You can’t perform that action at this time.
0 commit comments