Getting started
1. Get an API key
Sign in at ai2in.dev, open API Keys in the dashboard, and create a key. It looks like ai2in_live_…. Keep it secret.
2. Install
bash
pip install ai2inbash
npm install @ai2in/sdkbash
npm install -g @ai2in/cli3. Run code
python
from ai2in import Sandbox
# Creates a sandbox on construction; the context manager kills it on exit.
with Sandbox(api_key="ai2in_live_…") as sbx:
execution = sbx.run_code("""
import pandas as pd
df = pd.DataFrame({"gst_lakh_cr": [1.87, 1.73, 1.95]})
df.describe()
""")
print(execution.text) # the main result's text
print(execution.logs.stdout) # captured stdoutjavascript
import { Sandbox } from "@ai2in/sdk";
const sbx = await Sandbox.create({ apiKey: "ai2in_live_…" });
const execution = await sbx.runCode(`
import pandas as pd
df = pd.DataFrame({"gst_lakh_cr": [1.87, 1.73, 1.95]})
df.describe()
`);
console.log(execution.text);
await sbx.kill();bash
ai2in login --key ai2in_live_…
ai2in run -e "import pandas as pd; print(pd.DataFrame({'x':[1,2]}).describe())"The kernel is stateful — variables persist across run_code calls in the same sandbox, just like a notebook.
4. Configuration
The SDKs default to https://api.ai2in.dev. Point them elsewhere (a self-hosted engine) with base_url / baseUrl, or the env vars the CLI reads:
bash
export AI2IN_API_KEY=ai2in_live_…
export AI2IN_BASE_URL=https://api.ai2in.devNext steps
- Core concepts
- Running code — rich outputs, streaming
- Sandbox lifecycle — pause/resume, timeouts