From abf7b8e0d75cfbacb2137f5d974fef1df35809d8 Mon Sep 17 00:00:00 2001 From: Jakub Novak Date: Wed, 23 Apr 2025 13:45:40 +0200 Subject: [PATCH] Add API key page --- .../(docs)/docs/quickstart/api-key/page.mdx | 49 +++++++++++++++++++ apps/web/src/components/Navigation/routes.tsx | 4 ++ 2 files changed, 53 insertions(+) create mode 100644 apps/web/src/app/(docs)/docs/quickstart/api-key/page.mdx diff --git a/apps/web/src/app/(docs)/docs/quickstart/api-key/page.mdx b/apps/web/src/app/(docs)/docs/quickstart/api-key/page.mdx new file mode 100644 index 0000000000..a6adf4757e --- /dev/null +++ b/apps/web/src/app/(docs)/docs/quickstart/api-key/page.mdx @@ -0,0 +1,49 @@ +import Link from 'next/link' + +# API Key + +To use the API key, you can either: + +- **Set the API key as the `E2B_API_KEY` environment variable** to avoid passing it each time you create a sandbox. +- Or pass it directly to the `Sandbox` constructor as shown below: + + +```js {{ language: 'js' }} +import { Sandbox } from '@e2b/code-interpreter' + +const sandbox = await Sandbox.create({ apiKey: 'YOUR_API_KEY' }) +await sandbox.notebook.execCell('x = 1') + +const execution = await sandbox.notebook.execCell('x+=1; x') +console.log(execution.text) // outputs 2 + +await sandbox.close() +``` +```python {{ language: 'python' }} +from e2b_code_interpreter import CodeInterpreter + +with CodeInterpreter(api_key="YOUR_API_KEY") as code_interpreter: +sandbox.notebook.exec_cell("x = 1") +execution = sandbox.notebook.exec_cell("x+=1; x") +print(execution.text) # outputs 2 +``` + + +## Where to find API key + +You can get your API key at dashboard. + +
+ +# Access Token + +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`. + + +To authenticate without the browser, you can set `E2B_ACCESS_TOKEN` as an environment variable. This is useful for CI/CD pipelines. + + +## Where to find Access token + +You can get your **Access token key** at the dashboard. + diff --git a/apps/web/src/components/Navigation/routes.tsx b/apps/web/src/components/Navigation/routes.tsx index 2fac7a08a8..fd70367b0d 100644 --- a/apps/web/src/components/Navigation/routes.tsx +++ b/apps/web/src/components/Navigation/routes.tsx @@ -58,6 +58,10 @@ export const docRoutes: NavGroup[] = [ title: 'Install custom packages', href: '/docs/quickstart/install-custom-packages', }, + { + title: 'API Key', + href: '/docs/quickstart/api-key', + }, ], }, {