Quickstart
Make your first sandbox, run a command in it and remove it, from the command line or from code.
You need one thing: your lane’s API key. It starts with ibk_. It was shown to you once, when it was made, so keep it in a password manager or a secret store.
1. Put your key in the environment
Every tool reads the key from the IBBY_API_KEY environment variable. Paste it without echoing it, so it stays out of your shell history:
read -rs IBBY_API_KEY && export IBBY_API_KEY
2. Make a sandbox and run a command
With the command line tool:
npm install --global @ibby-ai/cli
ibby sandboxes create --workdir /work
echo 'echo hello from the sandbox' > hello.sh
ibby sandboxes write-files sbx_... --file /work/hello.sh=./hello.sh
ibby sandboxes exec sbx_... -- sh /work/hello.sh
ibby sandboxes remove sbx_...
create prints the new sandbox. Copy its id (sbx_...) into the commands after it.
The same steps in TypeScript:
import { Ibby } from "@ibby-ai/sdk";
const ibby = new Ibby({ apiKey: process.env["IBBY_API_KEY"] ?? "" });
const sandbox = await ibby.create({ workdir: "/work" });
await sandbox.writeFiles({ "/work/hello.sh": "echo hello from the sandbox\n" });
const result = await sandbox.exec({ command: ["sh", "/work/hello.sh"] });
if (result.outcome === "exited") {
console.log(result.exit_code, result.stdout);
}
await sandbox.remove();
And in Python:
import os
from ibby import Ibby
with Ibby(os.environ["IBBY_API_KEY"]) as client:
sandbox = client.create(workdir="/work")
sandbox.write_files({"/work/hello.sh": "echo hello from the sandbox\n"})
result = sandbox.exec(["sh", "/work/hello.sh"])
print(result.outcome, result.stdout)
sandbox.remove()
3. Clean up
A sandbox stops on its own when its lifetime ends (two minutes unless you ask for more, five at most). Removing it yourself frees it at once.
Next
- Concepts explains lanes, sandboxes, jobs, retries and errors.
- The pages for the TypeScript SDK, the Python SDK and the command line tool cover every call.
- Usage and cost lists your runs and their estimated cost.