New

CodeSandbox is now part of Together AI! We have joined forces to launch CodeSandbox SDK and bring code interpretation to generative AI.

Learn more
arrow_back
Blog chevron_right News
May 20, 2025

CodeSandbox SDK Official Release

Our bigger, better infra is ready for prime time.

Ives van HoorneChristian Alfoni
Ives van Hoorne & Christian Alfoni
CodeSandbox SDK Official Release
Ives van Hoorne
Ives van HoorneCo-Founder of CodeSandbox

Today, I’m thrilled to share that we have officially released CodeSandbox SDK, which is now ready for prime time.

A few years ago, we set out to build a VM infrastructure capable of instantly cloning and launching virtual machines. Initially, our goal was simple: make CodeSandbox fast and seamless for our users.

But infrastructure alone wasn't enough. We also built a product on top of this infrastructure that continued our ethos of accessible, collaborative and empowering user experiences. This product focus led us to implement several features that power the CodeSandbox editor, used by more than 4 million developers every month:

  • Near instant forking of VMs
  • Templates
  • Interacting with VMs in the browser
  • Seamless forking and reconnects
  • Collaborative shells
  • Hot swapping CPU/memory requirements
  • Preview API to extend the experience into the code output
  • Preview URLs that can be shared
  • And much, much more…

Fast-forward to today, and we're witnessing an incredible surge in coding agents and AI-driven development tools, such as HeroUI and Blackbox AI. They all have something in common: the need for fast, collaborative sandbox environments. It became clear that the infrastructure we created for CodeSandbox was incredibly valuable for other innovative products as well.

That's why, last December, we introduced CodeSandbox SDK—a toolkit that empowers developers to effortlessly build coding agents, collaborative tools, and advanced developer experiences using our powerful infrastructure and feature set.

After months of rigorous testing and invaluable feedback from our early adopters, we’re now officially launching the SDK out of beta! Let’s explore what's new and how we’ve made it even easier to get started.

Pricing Updates

After Together AI acquired CodeSandbox, we were able to expand our infra capacity a lot, which has allowed us to raise our rate limits and lower our pricing. We want CodeSandbox SDK to be accessible and affordable at every stage of your product journey, from early prototypes to large-scale production.

Here's what's changing:

  • Pricing: We lowered our price-per-credit from $0.018 to $0.01486, which corresponds to $0.0446/hour/vCPU plus $0.0149/hour/GB RAM.
  • Rate Limit: We raised the cap of concurrent VMs by 2x in the Free (Build) plan (from 5 to 10) and 2.5x on the Scale plan (from 100 to 250).

As part of our continued partnership with Together AI, CodeSandbox SDK has also been integrated into the Together AI platform as Together Code Sandbox, allowing Together AI customers to seamlessly build powerful developer experiences using our infrastructure.

The New SDK

Christian Alfoni
Christian AlfoniLead Engineer at CodeSandbox

Although we have mostly been focusing on building some highly requested new features, we also took the time to review the consistency and accessibility of existing features. For example, we noticed that working with the low-level shells API could be confusing, so we abstracted that low-level API into clear, consistent and more accessible Terminals, Commands, Interpreters, Tasks, and Setup Steps.

We have also worked on other changes to separate the management of a Sandbox from sessions in a Sandbox. In addition to these updates, we have also added the following features:

  • Templates you build are now deployed to all our clusters
  • Define environment variables for Sandbox sessions
  • Define git credentials for Sandbox sessions
  • Create a Sandbox from a git repository
  • Create a preview in the browser with an API to manage navigation, code injection and messages

Finally, we rewrote our docs and added an example playground.

Throughout all of these changes, we kept actively listening to feedback, so we will be working on some major new features:

  • A complete publishing flow for templates, enabled by aliases that can reference specific builds
  • Immutable template builds, guaranteeing our optimized forking with extended snapshot lifetime
  • Use ipcountry with Sandbox creation to fork templates in the nearest cluster

Thanks to the new CodeSandbox SDK, interacting with Sandboxes securely from the browser has never been more accessible:

const sdk = new CodeSandbox();
 
app.post("/sandboxes", async (req, res) => {
  const sandbox = await sdk.sandboxes.create();
  // Sandboxes are private by default. We need to create a host token to
  // access its exposed hosts
  const hostToken = await sdk.hosts.createToken(sandbox.id);
  // Create an isolated session in the Sandbox for your user by
  // passing an existing user reference and the host token
  const session = await sandbox.createBrowserSession({
    id: req.session.username,
    hostToken,
  });
 
  res.json(session);
});
 
app.get("/sandboxes/:id", async (req, res) => {
  const sandbox = await sdk.sandboxes.resume(req.params.id);
  // Resume a session by passing the same user reference and
  // host token for the Sandbox
  const session = await sandox.createBrowserSession({
    id: req.session.username,
    hostToken: req.session.hostToken,
  });
 
  res.json(session);
});
import { connectToSandbox, createPreview } from "@codesandbox/browser";
 
// Pass the initial session on page load or request it
const session = await postJson("/sandboxes");
 
// Connect to the Sandbox and configure how to resume the session from
// the server when reconnecting. By default it reconnects on "visibilitychange"
const sandbox = await connectToSandbox({
  session,
  getSession: (id) => getJson(`/sandboxes/${id}`),
});
 
// This Sandbox is configured with a dev task that opens a port
const port = await sandbox.tasks.getTask("dev").waitForPort();
const preview = createPreview(sandbox.hosts.getUrl(port.port));
 
document.querySelector("#preview-container").append(preview.iframe);

Built for Innovation

Over the last six months, we've partnered closely with innovative teams like Superblocks and HeroUI, as well as dozens of other CodeSandbox users, to refine the CodeSandbox SDK. Thanks to their insights and our continuous improvements, we're confident the SDK is now ready to support your next big idea.

We can't wait to see what you build—give it a spin, and as always, let us know what you think!



Keep reading about News .

Joining Together AI and Introducing CodeSandbox SDK
News Dec 12, 2024

Joining Together AI and Introducing CodeSandbox SDK

We are starting a new chapter for CodeSandbox, building better tooling for our community.

CodeSandbox is Now SOC 2 Compliant
News May 23, 2024

CodeSandbox is Now SOC 2 Compliant

Another milestone that shows our commitment to keeping your code and data secure.

Introducing CodeSandbox CDE
News Jan 30, 2024

Introducing CodeSandbox CDE

CodeSandbox CDE is now live, bringing instant cloud development environments and usage-based billing.