Skip to content

An open-source, faster Devin alternative

TypeScript

Docs: embed example chart showing what the API enables

Igor Zalutski7114e8925be8
diff --git a/docs/sandboxes/usage.mdx b/docs/sandboxes/usage.mdx
index 4b89c347..eba900f4 100644
--- a/docs/sandboxes/usage.mdx
+++ b/docs/sandboxes/usage.mdx
@@ -13,6 +13,82 @@ A separate aggregator at [`GET /api/usage`](/api-reference/usage/get-usage)
serves the cross-sandbox leaderboard question — use that one when you
want to rank by spend across many sandboxes.
+## What you can build
+
+The shape of the response lets you reconstruct a familiar memory
+chart: allocated tier as a step line (it only changes when you
+resize), measured usage as a smooth curve underneath. The gap between
+them is the headroom you're paying for but not using.
+
+<svg viewBox="0 0 800 380" xmlns="http://www.w3.org/2000/svg" style={{width: "100%", height: "auto", maxWidth: "800px", display: "block", margin: "1.5em auto"}} role="img" aria-label="Example chart: a sandbox's allocated and used memory over 24 hours, showing a mid-day resize event, a load-test peak, and a brief stop">
+ <g stroke="#e5e7eb" strokeWidth="1">
+ <line x1="70" y1="50" x2="760" y2="50" />
+ <line x1="70" y1="102" x2="760" y2="102" />
+ <line x1="70" y1="154" x2="760" y2="154" />
+ <line x1="70" y1="206" x2="760" y2="206" />
+ <line x1="70" y1="258" x2="760" y2="258" />
+ <line x1="70" y1="310" x2="760" y2="310" stroke="#9ca3af" />
+ </g>
+
+ <g fontSize="11" fontFamily="ui-sans-serif, system-ui, sans-serif" fill="#6b7280" textAnchor="end">
+ <text x="64" y="54">2500</text>
+ <text x="64" y="106">2000</text>
+ <text x="64" y="158">1500</text>
+ <text x="64" y="210">1000</text>
+ <text x="64" y="262">500</text>
+ <text x="64" y="314">0</text>
+ </g>
+
+ <g fontSize="11" fontFamily="ui-sans-serif, system-ui, sans-serif" fill="#6b7280" textAnchor="middle">
+ <text x="70" y="330">00:00</text>
+ <text x="185" y="330">04:00</text>
+ <text x="300" y="330">08:00</text>
+ <text x="415" y="330">12:00</text>
+ <text x="530" y="330">16:00</text>
+ <text x="645" y="330">20:00</text>
+ <text x="760" y="330">24:00</text>
+ </g>
+
+ <text x="18" y="180" fontSize="11" fontFamily="ui-sans-serif, system-ui, sans-serif" fill="#6b7280" transform="rotate(-90 18 180)" textAnchor="middle">Memory (MiB)</text>
+
+ <path d="M 70,310 L 84,289 L 128,247 L 185,235 L 242,237 L 271,195 L 300,164 L 358,154 L 386,159 L 415,195 L 444,216 L 501,211 L 559,214 L 582,289 L 587,310 L 610,310 L 616,299 L 645,227 L 702,221 L 760,218 L 760,310 L 70,310 Z" fill="#10b981" fillOpacity="0.12" />
+
+ <path d="M 70,203 L 242,203 L 242,97 L 760,97" fill="none" stroke="#6366f1" strokeWidth="2" strokeDasharray="6 4" />
+
+ <path d="M 70,310 L 84,289 L 128,247 L 185,235 L 242,237 L 271,195 L 300,164 L 358,154 L 386,159 L 415,195 L 444,216 L 501,211 L 559,214 L 582,289 L 587,310 L 610,310 L 616,299 L 645,227 L 702,221 L 760,218" fill="none" stroke="#10b981" strokeWidth="2" />
+
+ <g fontSize="11" fontFamily="ui-sans-serif, system-ui, sans-serif" fill="#374151">
+ <circle cx="242" cy="150" r="3" fill="#6366f1" />
+ <line x1="245" y1="148" x2="295" y2="120" stroke="#9ca3af" strokeWidth="1" />
+ <text x="298" y="118">Resize 1 → 2 GiB</text>
+ </g>
+
+ <g fontSize="11" fontFamily="ui-sans-serif, system-ui, sans-serif" fill="#374151">
+ <circle cx="358" cy="154" r="3" fill="#10b981" />
+ <line x1="361" y1="150" x2="410" y2="125" stroke="#9ca3af" strokeWidth="1" />
+ <text x="413" y="123">Load-test peak (1500 MiB)</text>
+ </g>
+
+ <g fontSize="11" fontFamily="ui-sans-serif, system-ui, sans-serif" fill="#374151">
+ <line x1="598" y1="310" x2="598" y2="285" stroke="#9ca3af" strokeWidth="1" />
+ <text x="603" y="283">Stopped briefly</text>
+ </g>
+
+ <g fontSize="11" fontFamily="ui-sans-serif, system-ui, sans-serif" fill="#374151">
+ <line x1="510" y1="62" x2="535" y2="62" stroke="#6366f1" strokeWidth="2" strokeDasharray="6 4" />
+ <text x="540" y="66">allocatedMemoryMb</text>
+ <line x1="665" y1="62" x2="690" y2="62" stroke="#10b981" strokeWidth="2" />
+ <text x="695" y="66">usedMemoryMbAvg</text>
+ </g>
+</svg>
+
+The whole chart above is just two arrays out of `points[]`:
+`{ts, allocatedMemoryMb}` and `{ts, usedMemoryMbAvg}`. The annotations
+on it — resize, peak, downtime — fall out of the same data without a
+separate API call: a resize is a step in `allocatedMemoryMb`, the
+peak is the bucket where `usedMemoryMbPeak` is highest, and downtime
+is any stretch of `uptimeSeconds: 0`.
+
## What you get back
```json