Access Credentials
export NEOSANTARA_API_KEY="nsk_..."
export E2B_API_KEY="e2b_..."
Framework and SDK Integration
Agno
OpenAI SDK
Anthropic SDK
Agno provides
E2BTools with full sandbox mode for running shell commands and managing files.Library Installation
pip install -U agno e2b
Implementation Example
from agno.agent import Agent
from agno.models.neosantara import Neosantara
from agno.tools.e2b import E2BTools
agent = Agent(
model=Neosantara(id="deepseek-v4.1-flash"),
tools=[E2BTools()],
markdown=True,
show_tool_calls=True,
instructions=[
"Use E2B sandbox to run shell commands and manage files.",
"Show execution output completely."
]
)
agent.print_response(
"Create a project-demo directory, initialize a git repo inside it, "
"create a hello.py file that prints 'Hello Neosantara', then run it."
)
Use function calling to execute shell commands and file operations in an E2B sandbox. Available for Python and Node.js.
Library Installation
pip install -U openai e2b
npm install openai e2b
Implementation Example
import os
import json
from openai import OpenAI
from e2b import Sandbox
client = OpenAI(
base_url="https://api.neosantara.xyz/v1",
api_key=os.environ["NEOSANTARA_API_KEY"]
)
tools = [
{
"type": "function",
"function": {
"name": "run_shell",
"description": "Run a shell command in an isolated E2B sandbox.",
"parameters": {
"type": "object",
"properties": {
"command": {"type": "string", "description": "Shell command to execute."}
},
"required": ["command"]
}
}
},
{
"type": "function",
"function": {
"name": "write_file",
"description": "Write a file in the E2B sandbox.",
"parameters": {
"type": "object",
"properties": {
"path": {"type": "string", "description": "File path in the sandbox."},
"content": {"type": "string", "description": "File content."}
},
"required": ["path", "content"]
}
}
}
]
messages = [{"role": "user", "content": "Create a requirements.txt file with requests and httpx, then install with pip."}]
response = client.chat.completions.create(
model="deepseek-v4.1-flash",
messages=messages,
tools=tools,
tool_choice="auto"
)
message = response.choices[0].message
sandbox = Sandbox(api_key=os.environ["E2B_API_KEY"])
if message.tool_calls:
for tool_call in message.tool_calls:
args = json.loads(tool_call.function.arguments)
if tool_call.function.name == "run_shell":
result = sandbox.commands.run(args["command"])
output = result.stdout
elif tool_call.function.name == "write_file":
sandbox.files.write(args["path"], args["content"])
output = f"File {args['path']} written."
messages.append(message)
messages.append({
"role": "tool",
"tool_call_id": tool_call.id,
"content": output
})
final = client.chat.completions.create(
model="deepseek-v4.1-flash",
messages=messages
)
print(final.choices[0].message.content)
sandbox.kill()
import OpenAI from "openai";
import { Sandbox } from "e2b";
const client = new OpenAI({
baseURL: "https://api.neosantara.xyz/v1",
apiKey: process.env.NEOSANTARA_API_KEY,
});
const tools = [
{
type: "function",
function: {
name: "run_shell",
description: "Run a shell command in an isolated E2B sandbox.",
parameters: {
type: "object",
properties: {
command: { type: "string", description: "Shell command to execute." },
},
required: ["command"],
},
},
},
{
type: "function",
function: {
name: "write_file",
description: "Write a file in the E2B sandbox.",
parameters: {
type: "object",
properties: {
path: { type: "string", description: "File path in the sandbox." },
content: { type: "string", description: "File content." },
},
required: ["path", "content"],
},
},
},
];
const messages = [
{ role: "user", content: "Create a requirements.txt file with requests and httpx, then install with pip." },
];
const response = await client.chat.completions.create({
model: "deepseek-v4.1-flash",
messages,
tools,
tool_choice: "auto",
});
const message = response.choices[0].message;
const sandbox = await Sandbox.create();
if (message.tool_calls && message.tool_calls.length > 0) {
for (const toolCall of message.tool_calls) {
const args = JSON.parse(toolCall.function.arguments);
let output;
if (toolCall.function.name === "run_shell") {
const result = await sandbox.commands.run(args.command);
output = result.stdout;
} else if (toolCall.function.name === "write_file") {
await sandbox.files.write(args.path, args.content);
output = `File ${args.path} written.`;
}
messages.push(message);
messages.push({
role: "tool",
tool_call_id: toolCall.id,
content: output,
});
}
const final = await client.chat.completions.create({
model: "deepseek-v4.1-flash",
messages,
});
console.log(final.choices[0].message.content);
}
await sandbox.kill();
Use the Anthropic tool use interface with the Neosantara endpoint. Available for Python and Node.js.
Library Installation
pip install -U anthropic e2b
npm install @anthropic-ai/sdk e2b
Implementation Example
import os
from anthropic import Anthropic
from e2b import Sandbox
client = Anthropic(
base_url="https://api.neosantara.xyz/anthropic",
api_key=os.environ["NEOSANTARA_API_KEY"]
)
tools = [
{
"name": "run_shell",
"description": "Run a shell command in an isolated E2B sandbox.",
"input_schema": {
"type": "object",
"properties": {
"command": {"type": "string", "description": "Shell command to execute."}
},
"required": ["command"]
}
}
]
response = client.messages.create(
model="claude-3-7-sonnet",
max_tokens=1024,
tools=tools,
messages=[{"role": "user", "content": "Check the installed Python and pip versions in the sandbox."}]
)
sandbox = Sandbox(api_key=os.environ["E2B_API_KEY"])
for block in response.content:
if block.type == "tool_use":
command = block.input.get("command")
result = sandbox.commands.run(command)
print("Output:", result.stdout)
sandbox.kill()
import Anthropic from "@anthropic-ai/sdk";
import { Sandbox } from "e2b";
const client = new Anthropic({
baseURL: "https://api.neosantara.xyz/anthropic",
apiKey: process.env.NEOSANTARA_API_KEY,
});
const tools = [
{
name: "run_shell",
description: "Run a shell command in an isolated E2B sandbox.",
input_schema: {
type: "object",
properties: {
command: { type: "string", description: "Shell command to execute." },
},
required: ["command"],
},
},
];
const response = await client.messages.create({
model: "claude-3-7-sonnet",
max_tokens: 1024,
tools,
messages: [{ role: "user", content: "Check the installed Python and pip versions in the sandbox." }],
});
const sandbox = await Sandbox.create();
for (const block of response.content) {
if (block.type === "tool_use") {
const command = block.input.command;
const result = await sandbox.commands.run(command);
console.log("Output:", result.stdout);
}
}
await sandbox.kill();
Sandbox Capabilities
| Feature | API | Description |
|---|---|---|
| Shell command | sandbox.commands.run() | Execute shell commands with stdout/stderr |
| File write | sandbox.files.write() | Write files to the sandbox filesystem |
| File read | sandbox.files.read() | Read file contents from the sandbox |
| File list | sandbox.files.list() | List files and directories |
| Upload | sandbox.files.write() | Upload binary or text content |
| Download | sandbox.files.read() | Download files from the sandbox |
| Timeout | timeout parameter | Control maximum execution duration |
Next Steps
| Need | Guide |
|---|---|
| Python code execution and visualization | E2B Code Interpreter |
| Daytona sandbox with git and filesystem | Daytona |
| Tool calling on Gateway | Tool Calling Chat Completions |
| Supported model catalog | Models & Pricing |