Koyeb Sandboxes: JavaScript SDK Now Available
Today, we’re releasing the JavaScript SDK with full TypeScript support for Koyeb Sandboxes. Less than a month ago, we introduced Koyeb Sandboxes and our Python SDK, giving teams a simple way to run AI-generated code securely in isolated environments.
The JavaScript SDK expands this experience and brings the same secure, high-performance sandboxes directly to JavaScript/TypeScript applications, so developers can run AI-generated and untrusted code safely without managing infrastructure.
Run AI or untrusted code safely with Koyeb Sandboxes.
Koyeb Sandboxes are backed by purpose-built infrastructure designed for secure, high-performance execution. Each sandbox runs with true isolation, is available on both CPU and GPU Instances, and can be deployed across multiple regions worldwide for low-latency execution wherever your applications and users are.
Sandboxes are billed only for the underlying compute and storage resources you actually use. Pricing starts at $0.000001/second ($0.0036/hr). For more detailed information, check out the Koyeb Instances page and the Koyeb pricing page.
Get Started with the JavaScript SDK
Sandboxes provide an isolated, ephemeral environment to safely run, test, and experiment with code. Here is how you can get started with Koyeb Sandboxes and the JS SDK:
Create Your First Sandbox
To create a sandbox, install the @koyeb/sandbox-sdk package:
npm install @koyeb/sandbox-sdk
Create a Koyeb API token in the Koyeb control panel, add the KOYEB_API_TOKEN variable to your environment.
export KOYEB_API_TOKEN=your-koyeb-api-token
Create a JavaScript file and add the following code to build your first sandbox:
import { Sandbox } from '@koyeb/sandbox-sdk';
// Use the `create()` function to create a new Sandbox
const sandbox = await Sandbox.create({ image: 'node', name: 'example-sandbox' });
// To execute code in your Sandbox, use the `exec()` function.
// This code creates a JavaScript file and the executes it, printing `"Hello World!"`
const fs = sandbox.filesystem;
const jsCode = '#!/usr/bin/env node\nconsole.log("Hello World!");\n';
await fs.write_file("/tmp/script.js", jsCode);
await sandbox.exec("chmod +x /tmp/script.js");
const result = await sandbox.exec("node /tmp/script.js");
console.log(result.stdout);
// When you're finished with the Sandbox, use the `delete()` function to permanently delete it:
await sandbox.delete();
That’s it! You now can easily spin up sandboxes to execute code securely and at scale.
Spin up fully isolated environments directly from JavaScript or Python. Spawn thousands of sandboxes effortlessly.
Build with Koyeb Sandboxes
Koyeb Sandboxes give you a secure, fully isolated environment to run untrusted or AI-generated code, without managing the underlying infrastructure.
We’d love to see what you build! Share your projects and ideas on the Koyeb community, or report bugs and feature requests via the JavaScript/TypeScript SDK GitHub repo or Slack.
Here’s how to dive in:
- Follow the Koyeb Sandbox Quickstart to get up and running in minutes.
- Explore the Sandbox lifecycle to understand how sandboxes are created, run, and cleaned up.
- Learn how to take actions on files and folders within your sandboxes.
- See how to run commands inside your sandboxes for executing code or automating tasks.
- Check out our tutorials on secure code execution using OpenAI Codex and the Claude Agent SDK with Koyeb Sandboxes
At Koyeb, we provide high-performance, serverless infrastructure for running AI-generated and untrusted code safely at scale. Our platform runs fully isolated, secure microVMs on bare-metal servers around the world with autoscaling, scale-to-zero, and minimal cold starts.
Interested in the work we’re doing? We’re hiring!