Skip to main content

Create an Account

If you don’t have a Novita account, sign up first. For details, please refer to Quickstart guide. New users can complete a quick account setup survey to claim free Sandbox usage through promotional credits. No credit card is required.

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

You can install the SDK by executing the following commands.
npm i novita-sandbox

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
NOVITA_API_KEY=sk_*** # Novita API key obtained from previous steps
Or you can configure the API key and API domain address by setting environment variables in your terminal.
Bash
export NOVITA_API_KEY=sk_*** # Novita API key obtained from previous steps

Use SDK to Start Agent Sandbox

Below is a simple example showing how to create a sandbox through the SDK and run specified commands.
// index.ts
import 'dotenv/config'
import { Sandbox } from 'novita-sandbox/code-interpreter'

// The .env file should be located in the project root directory
// dotenv/config will automatically look for .env in the current working directory
// Or 
// You can set the environment variable in the command line
// export NOVITA_API_KEY=sk_***

async function main() {
  const sandbox = await Sandbox.create()
  try {
    const execution = await sandbox.runCode('print("hello world")')
    console.log(execution.logs)

    const files = await sandbox.files.list('/tmp')
    console.log(files)
  } finally {
    // Close sandbox when no longer needed
    await sandbox.kill()
  }
}
main().catch((err) => {
  console.error(err)
  process.exit(1)
})

Execute the following commands to run the above code.
npx tsx ./index.ts
Last modified on June 9, 2026