Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add loading API key from env variable to docs
Jakub Novakc1107faa8887
diff --git a/apps/docs/src/app/getting-started/api-key/page.mdx b/apps/docs/src/app/getting-started/api-key/page.mdxindex 5b722b2ac..5537d50b2 100644--- a/apps/docs/src/app/getting-started/api-key/page.mdx+++ b/apps/docs/src/app/getting-started/api-key/page.mdx@@ -5,3 +5,9 @@ import APIKey from './APIKey'<APIKey/>Follow the [Basics](/playgrounds/overview) to start using the SDK.++++## Use API key++<CodeGroupAutoload path="api_key/api_key" isRunnable={false}/>diff --git a/apps/docs/src/code/js/api_key/api_key.js b/apps/docs/src/code/js/api_key/api_key.jsnew file mode 100644index 000000000..d8985d832--- /dev/null+++ b/apps/docs/src/code/js/api_key/api_key.js@@ -0,0 +1,14 @@+import {Session} from '@e2b/sdk'++// You can pass an API key explicitly+const explicitAPIKey = await Session.create({+ id: 'Nodejs',+ apiKey: process.env.E2B_API_KEY,+})+await explicitAPIKey.close()++// If you don't pass an API key, the SDK will look for it in the E2B_API_KEY environment variable+const APIKeyFromEnvVariable = await Session.create({+ id: 'Nodejs',+})+await APIKeyFromEnvVariable.close()diff --git a/apps/docs/src/code/python/api_key/api_key.py b/apps/docs/src/code/python/api_key/api_key.pynew file mode 100644index 000000000..d79fb0294--- /dev/null+++ b/apps/docs/src/code/python/api_key/api_key.py@@ -0,0 +1,19 @@+import asyncio+from os import getenv++from e2b import Session++E2B_API_KEY = getenv("E2B_API_KEY")+++async def main():+ # You can pass an API key explicitly+ explicit_api_key = await Session.create(id="Nodejs", api_key=E2B_API_KEY)+ await explicit_api_key.close()++ # If you don't pass an API key, the SDK will look for it in the E2B_API_KEY environment variable+ api_key_from_env_variable = await Session.create(id="Nodejs")+ await api_key_from_env_variable.close()+++asyncio.run(main())