inis.run
Integrations

Vercel AI SDK

Pre-built tools for streamText and generateText agents.

Vercel's AI SDK does not ship a first-party inis plugin — and it does not need one. The pattern (same as E2B) is a small helper package that exports tool() definitions wired to the inis SDK.

Beta. Supported AI SDK range: ai@^5.0.0 — tested against v5. Newer majors exist and are not yet validated.

Install

npm install @inis-run/ai-sdk @inis-run/sdk ai zod

Usage

import { anthropic } from "@ai-sdk/anthropic";
import { generateText, stepCountIs } from "ai";
import { Client } from "@inis-run/sdk";
import { inisTools } from "@inis-run/ai-sdk";

// Create a persistent session first — tools do not auto-create one
const client = new Client({ token: process.env.INIS_API_KEY });
const session = await client.sessions.create({ egress: { mode: "deny" } });

try {
  const result = await generateText({
    model: anthropic("claude-sonnet-4-20250514"),
    system: "You are a data analyst. Run Python in the sandbox instead of guessing.",
    messages,
    tools: inisTools({ sessionId: session.sessionId }),
    stopWhen: stepCountIs(5),
  });
  console.log(result.text);
} finally {
  await session.destroy(); // this app owns the session
}

To reuse the same sandbox across turns/requests, persist session.sessionId yourself and pass it back into inisTools({ sessionId }) on the next request — there is no shared mutable ref object to pass around instead.

What inisTools() exports

ToolDescription
execute_pythonRun Python in the sandbox. Throws on non-zero exit.
execute_shellRun an arbitrary shell command. Throws on non-zero exit.
read_file / write_fileFile I/O under /workspace
list_filesList a directory (defaults to /workspace)

This is deliberately the smallest execution/file surface. sessionId is required — inisTools() only ever attaches to a session your app created, never creates or destroys one itself.

Session administration (pause, resume, checkpoint, restore, expose_port, capture_artifacts) and unbounded stateless-execution sandbox creation (execute_once) are opt-in from @inis-run/ai-sdk/lifecycle — add them only if your app wants the model to have that control. If you want the tools package to create the session for you, use createOwnedInisTools(), which returns the tools plus the new session's ID and a cleanup() that destroys it.

MCP alternative

If your stack already uses remote MCP, connect to https://mcp.inis.run/sse via the AI SDK MCP client — no tool definitions in your app code. Use @inis-run/ai-sdk when you want in-process tools in a Next.js or Node service.

On this page