Create an Account

If you don’t have a Novita account, you need to sign up first. For details, please refer to Quickstart guide.

Create API Key

Go to the Novita Key Management page, you can create an API key and save the API key value for use in subsequent steps.

Install SDK

Since Novita Agent Sandbox service is compatible with the E2B protocol, you can use any SDK that supports the E2B protocol to use Novita Agent Sandbox.

You can install the SDK by executing the following commands.

npm i @e2b/code-interpreter dotenv

Configure Environment Variables

Create a .env file in your project folder (if it doesn’t exist), and configure the API key and API domain address.

For JavaScript and TypeScript projects, you need to import the dotenv/config package in your project; for Python projects, you need to import the dotenv library in your project and call the load_dotenv method to load environment variables. For details, please refer to the example.

.env
E2B_API_KEY=sk_*** # Novita API key obtained from previous steps
E2B_DOMAIN=sandbox.novita.ai # Novita Agent Sandbox service domain

Or you can configure the API key and API domain address by setting environment variables in your terminal.

Bash
export E2B_API_KEY=sk_*** # Novita API key obtained from previous steps
export E2B_DOMAIN=sandbox.novita.ai # Novita Agent Sandbox service domain

Use SDK to Start Agent Sandbox

Below is a simple example showing how to create a sandbox through the SDK and run specified commands.

import 'dotenv/config'
import { Sandbox } from '@e2b/code-interpreter'

const sbx = await Sandbox.create()
const execution = await sbx.runCode('print("hello world")')
console.log(execution.logs)

const files = await sbx.files.list('/')
console.log(files)

// Close sandbox when no longer needed
await sbx.kill()

Execute the following commands to run the above code.

npx tsx ./index.ts