You are reading a legacy (pre v1.0) document.
Your API Key
Use API key
To use the API key, you either:
- Set the API key as the
E2B_API_KEY
environment variable - Or pass it directly to the
CodeInterpreter
constructor like this:
import { CodeInterpreter } from '@e2b/code-interpreter'
const sandbox = await CodeInterpreter.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()