Access Credentials
Export your Neosantara and E2B credentials to your system environment variables:export NEOSANTARA_API_KEY="nsk_..."
export E2B_API_KEY="e2b_..."
Framework and SDK Integration
Select the framework or client SDK you want to use to view the installation command and code example:Agno
LiteLLM
OpenAI SDK
Anthropic SDK
Agno is the recommended approach. Neosantara is supported natively via
Neosantara, and Agno provides a prebuilt E2BTools package. Agents manage tool calling, sandbox code execution, and response synthesis automatically without manual loop logic.Library Installation
pip install -U agno e2b-code-interpreter
Implementation Example
import os
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(timeout=600)],
markdown=True,
show_tool_calls=True,
instructions=[
"Use the E2B sandbox to run and verify Python code.",
"Present the final computation results and analysis clearly."
]
)
agent.print_response(
"Calculate the first 10 Fibonacci numbers and return them in a Python array."
)
Data Visualization
Agents can run data processing packages inside the sandbox environment:agent.print_response(
"Simulate latency metrics for 3 gateways: Neosantara 85ms, US Gateway 280ms, and EU Gateway 320ms. "
"Plot a bar chart with matplotlib and save the file to latency.png."
)
LiteLLM routes requests to Neosantara natively via the
neosantara/<model> prefix without manual base URL overrides.Library Installation
pip install -U litellm e2b-code-interpreter
Implementation Example
import os
from litellm import completion
from e2b_code_interpreter import Sandbox
response = completion(
model="neosantara/deepseek-v4.1-flash",
messages=[
{"role": "system", "content": "Return only executable Python code without markdown fences."},
{"role": "user", "content": "Compute square roots for numbers 1 to 5 and print each result."}
]
)
python_code = response.choices[0].message.content.strip()
with Sandbox(api_key=os.environ["E2B_API_KEY"]) as sandbox:
print("Executing in E2B sandbox...")
execution = sandbox.run_code(python_code)
if execution.error:
print("Execution error:", execution.error)
else:
for log in execution.logs.stdout:
print("Output:", log)
Use standard OpenAI function calling schemas to execute code within E2B sandboxes. Available for Python and Node.js.
Library Installation
pip install -U openai e2b-code-interpreter
npm install openai @e2b/code-interpreter
Implementation Example
import os
import json
from openai import OpenAI
from e2b_code_interpreter import Sandbox
client = OpenAI(
base_url="https://api.neosantara.xyz/v1",
api_key=os.environ["NEOSANTARA_API_KEY"]
)
tools = [{
"type": "function",
"function": {
"name": "run_python_code",
"description": "Execute Python code inside an isolated E2B sandbox.",
"parameters": {
"type": "object",
"properties": {
"code": {"type": "string", "description": "The Python code to execute."}
},
"required": ["code"]
}
}
}]
messages = [{"role": "user", "content": "Calculate the factorial of 8 using Python."}]
response = client.chat.completions.create(
model="deepseek-v4.1-flash",
messages=messages,
tools=tools,
tool_choice="auto"
)
message = response.choices[0].message
if message.tool_calls:
tool_call = message.tool_calls[0]
args = json.loads(tool_call.function.arguments)
with Sandbox(api_key=os.environ["E2B_API_KEY"]) as sandbox:
exec_result = sandbox.run_code(args["code"])
output_text = "\n".join(exec_result.logs.stdout)
messages.append(message)
messages.append({
"role": "tool",
"tool_call_id": tool_call.id,
"content": output_text
})
final_response = client.chat.completions.create(
model="deepseek-v4.1-flash",
messages=messages
)
print(final_response.choices[0].message.content)
import OpenAI from "openai";
import { Sandbox } from "@e2b/code-interpreter";
const client = new OpenAI({
baseURL: "https://api.neosantara.xyz/v1",
apiKey: process.env.NEOSANTARA_API_KEY,
});
const tools = [
{
type: "function",
function: {
name: "run_python_code",
description: "Execute Python code inside an isolated E2B sandbox.",
parameters: {
type: "object",
properties: {
code: { type: "string", description: "The Python code to execute." },
},
required: ["code"],
},
},
},
];
const messages = [{ role: "user", content: "Calculate the factorial of 8 using Python." }];
const response = await client.chat.completions.create({
model: "deepseek-v4.1-flash",
messages,
tools,
tool_choice: "auto",
});
const message = response.choices[0].message;
if (message.tool_calls && message.tool_calls.length > 0) {
const toolCall = message.tool_calls[0];
const args = JSON.parse(toolCall.function.arguments);
const sandbox = await Sandbox.create();
const execution = await sandbox.runCode(args.code);
const outputText = execution.logs.stdout.join("\n");
messages.push(message);
messages.push({
role: "tool",
tool_call_id: toolCall.id,
content: outputText,
});
const finalResponse = await client.chat.completions.create({
model: "deepseek-v4.1-flash",
messages,
});
console.log(finalResponse.choices[0].message.content);
}
Use native Anthropic tool schemas against the Neosantara Anthropic endpoint. Available for Python and Node.js.
Library Installation
pip install -U anthropic e2b-code-interpreter
npm install @anthropic-ai/sdk @e2b/code-interpreter
Implementation Example
import os
from anthropic import Anthropic
from e2b_code_interpreter import Sandbox
client = Anthropic(
base_url="https://api.neosantara.xyz/anthropic",
api_key=os.environ["NEOSANTARA_API_KEY"]
)
tools = [{
"name": "run_python_code",
"description": "Execute Python code inside an isolated E2B sandbox.",
"input_schema": {
"type": "object",
"properties": {
"code": {"type": "string", "description": "Python code to execute."}
},
"required": ["code"]
}
}]
response = client.messages.create(
model="claude-3-7-sonnet",
max_tokens=1024,
tools=tools,
messages=[{"role": "user", "content": "Compute 2 to the power of 16 in Python."}]
)
for block in response.content:
if block.type == "tool_use":
code_to_run = block.input.get("code")
with Sandbox(api_key=os.environ["E2B_API_KEY"]) as sandbox:
res = sandbox.run_code(code_to_run)
print("E2B Output:", res.logs.stdout)
import Anthropic from "@anthropic-ai/sdk";
import { Sandbox } from "@e2b/code-interpreter";
const client = new Anthropic({
baseURL: "https://api.neosantara.xyz/anthropic",
apiKey: process.env.NEOSANTARA_API_KEY,
});
const tools = [
{
name: "run_python_code",
description: "Execute Python code inside an isolated E2B sandbox.",
input_schema: {
type: "object",
properties: {
code: { type: "string", description: "Python code to execute." },
},
required: ["code"],
},
},
];
const response = await client.messages.create({
model: "claude-3-7-sonnet",
max_tokens=1024,
tools,
messages: [{ role: "user", content: "Compute 2 to the power of 16 in Python." }],
});
for (const block of response.content) {
if (block.type === "tool_use") {
const codeToRun = block.input.code;
const sandbox = await Sandbox.create();
const res = await sandbox.runCode(codeToRun);
console.log("E2B Output:", res.logs.stdout);
}
}
Comparison Matrix
| Framework | Tool Handling | Endpoint Configuration | Best For |
|---|---|---|---|
| Agno | Automatic via E2BTools | Automatic via Neosantara | Autonomous agents without writing boilerplate code extractors or execution loops. |
| LiteLLM | Direct sandbox execution | Automatic via neosantara prefix | Multi-provider routing or existing proxy infrastructure. |
| OpenAI SDK | Manual function calling loop | Manual via base_url parameter | Granular tool-calling loop control on standard OpenAI stacks in Python or Node.js. |
| Anthropic SDK | Manual tool use loop | Manual via base_url parameter | Claude model pipelines using native Anthropic schemas in Python or Node.js. |
Next Steps
| Goal | Guide |
|---|---|
| Agno framework guide | Agno Documentation |
| LiteLLM proxy guide | LiteLLM Documentation |
| Gateway tool calling | Chat Completions Tool Calling |
| Supported models catalog | Model Catalog & Pricing |