Framework integrations
AI2IN plugs into the popular agent frameworks as a code-interpreter tool — give your agent the ability to run Python in a secure sandbox. Each integration wraps run_code and returns the output to the model.
Vercel AI SDK
npm install @ai2in/sdk ai zodimport { ai2inCodeInterpreter } from "@ai2in/sdk/ai";
import { generateText } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
const { text } = await generateText({
model: anthropic("claude-opus-4-8"),
tools: {
runCode: ai2inCodeInterpreter({ apiKey: process.env.AI2IN_API_KEY }),
},
maxSteps: 5,
prompt: "What is the 30th Fibonacci number? Compute it with code.",
});
console.log(text);The tool sets both parameters (AI SDK v4) and inputSchema (v5), so it works across versions. The sandbox is created lazily on first call and reused, keeping kernel state across steps.
LangChain (Python)
pip install "ai2in[langchain]"from ai2in.langchain import create_code_interpreter_tool
from langchain_anthropic import ChatAnthropic
tool = create_code_interpreter_tool(api_key="ai2in_live_…")
llm = ChatAnthropic(model="claude-opus-4-8").bind_tools([tool])
# ... or drop `tool` into a LangGraph / AgentExecutor agentcreate_code_interpreter_tool returns a standard LangChain StructuredTool. Pass an existing Sandbox instead of api_key to control lifecycle yourself.
LangChain (JavaScript)
npm install @ai2in/sdk @langchain/core zodimport { createCodeInterpreterTool } from "@ai2in/sdk/langchain";
const tool = createCodeInterpreterTool({ apiKey: process.env.AI2IN_API_KEY });
// bind it to a chat model or add it to an agentReturns a DynamicStructuredTool.
Any function-calling model (Claude, GPT, …)
No framework needed — expose a tool and route calls to run_code yourself.
from anthropic import Anthropic
from ai2in import Sandbox
client = Anthropic()
sbx = Sandbox(api_key="ai2in_live_…")
tools = [{
"name": "run_code",
"description": "Run Python in a secure sandbox and return its output.",
"input_schema": {
"type": "object",
"properties": {"code": {"type": "string", "description": "Python to run"}},
"required": ["code"],
},
}]
msg = client.messages.create(
model="claude-opus-4-8",
max_tokens=1024,
tools=tools,
messages=[{"role": "user", "content": "Plot y=x^2 for x in 0..10 and save it."}],
)
for block in msg.content:
if block.type == "tool_use" and block.name == "run_code":
result = sbx.run_code(block.input["code"])
print(result.logs.stdout, result.error)
# feed `result` back as a tool_result and continue the loopMCP
AI2IN also ships a Model Context Protocol server, so any MCP-compatible client (Claude Desktop, IDEs, agent runtimes) can spawn and drive sandboxes as tools. See the AI2IN-DEV/mcp-server repo.