together-code-sandbox
Together Code Sandbox
Overview
Full VM sandboxes with Docker support, memory snapshots, and sub-3-second cloning. Powered by CodeSandbox infrastructure.
- SDK:
npm install @codesandbox/sdk - Auth: CodeSandbox API token from https://codesandbox.io/t/api
- Features: Docker/Dev Containers, filesystem persistence, browser connectivity
Quick Start
import { CodeSandbox } from "@codesandbox/sdk";
const sdk = new CodeSandbox(process.env.CSB_API_KEY!);
// Create a sandbox
const sandbox = await sdk.sandboxes.create();
const session = await sandbox.connect();
// Run commands
const output = await session.commands.run("echo 'Hello World'");
console.log(output); // Hello World
Sandbox Lifecycle
| Bootup Type | Description |
|---|---|
FORK |
Created from a template (snapshot clone) |
RUNNING |
Already running (on resume) |
RESUME |
Resumed from hibernation |
CLEAN |
Fresh start (no snapshot available) |
Templates
Create custom templates with pre-configured environments:
npx @codesandbox/sdk build ./my-template --ports 5173
Use templates when creating sandboxes:
const sandbox = await sdk.sandboxes.create({
source: 'template',
id: 'my-template-tag',
});
Browser Connectivity
Connect sandboxes to browser sessions:
// Server-side
const session = await sandbox.createBrowserSession({ id: req.session.username });
// Client-side
import { connectToSandbox } from '@codesandbox/sdk/browser';
const sandbox = await connectToSandbox({
session: initialSessionFromServer,
getSession: (id) => fetchJson(`/api/sandboxes/${id}`),
});
await sandbox.fs.writeTextFile('test.txt', 'Hello World');
VM Sizes & Pricing
| VM Size | CPU | RAM | Cost/hour |
|---|---|---|---|
| Pico | 2 cores | 1 GB | $0.0743 |
| Nano | 2 cores | 4 GB | $0.1486 |
| Micro | 4 cores | 8 GB | $0.2972 |
| Small | 8 cores | 16 GB | $0.5944 |
| Medium | 16 cores | 32 GB | $1.1888 |
| Large | 32 cores | 64 GB | $2.3776 |
| XLarge | 64 cores | 128 GB | $4.7552 |
Default recommendation: Nano for most workloads, Pico for simple code execution.
Concurrent VM Plans
- Build (free): 10 concurrent VMs
- Scale: 250 concurrent VMs ($170/mo base)
- Enterprise: Custom limits and credit discounts
Key Features
- Memory snapshots: Checkpoint and restore VM state
- Sub-3s cloning: Fork from templates instantly
- Docker support: Full Dev Container spec support
- FS persistence: Git version control on VM filesystem
- Auto-hibernate: Sandboxes hibernate when disconnected
Resources
- Official docs: Together Code Sandbox
More from zainhas/togetherai-skills
together-code-interpreter
Use this skill for Together AI Code Interpreter workflows: remote Python execution, session reuse, file uploads, data analysis, plots, and stateful notebook-like runs through the TCI API. Reach for it whenever the user wants managed remote Python execution on Together AI instead of local execution, raw clusters, or full model hosting.
33together-audio
Text-to-speech and speech-to-text via Together AI, including REST, streaming, and realtime WebSocket TTS, plus transcription, translation, diarization, timestamps, and live STT. Reach for it whenever the user needs audio in or audio out on Together AI rather than chat generation, image or video creation, or model training.
14together-images
Text-to-image generation and image editing via Together AI, including FLUX and Kontext models, LoRA-based styling, reference-image guidance, and local image downloads. Reach for it whenever the user wants to generate or edit images on Together AI rather than create videos or build text-only chat applications.
14together-chat-completions
Real-time and streaming text generation via Together AI's OpenAI-compatible chat/completions API, including multi-turn conversations, tool and function calling, structured JSON outputs, and reasoning models. Reach for it whenever the user wants to build or debug text generation on Together AI, unless they specifically need batch jobs, embeddings, fine-tuning, dedicated endpoints, dedicated containers, or GPU clusters.
13together-dedicated-endpoints
Single-tenant GPU endpoints on Together AI with autoscaling and no rate limits. Deploy fine-tuned or uploaded models, size hardware, and manage endpoint lifecycle. Reach for it whenever the user needs predictable always-on hosting rather than serverless inference, custom containers, or raw clusters.
13together-video
Text-to-video and image-to-video generation via Together AI, including keyframe control, model and dimension selection, asynchronous job polling, and video downloads. Reach for it whenever the user wants motion generation on Together AI rather than still-image generation or text-only inference.
12