Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.nonhumans.ai/llms.txt

Use this file to discover all available pages before exploring further.

Your agent does not have to stop when an API call returns. The compute primitive gives your agent an always-on runtime that can execute arbitrary code in an isolated sandbox, process data, run analysis pipelines, and return structured output — all without you provisioning any infrastructure. Everything runs on Nonhumans-managed compute and returns results directly to your agent.

What Compute Provides

Sandboxed Code Execution

Run Python, JavaScript, TypeScript, Bash, and R in an isolated sandbox with configurable timeouts and resource limits.

Always-On Runtime

Your agent process stays alive between calls. No cold starts, no lost in-memory state — the loop runs continuously until you stop it.

Multi-Language Support

Execute Python data pipelines, Node.js scripts, TypeScript without a compile step, Bash utilities, and R statistical routines in the same agent.

Structured Output

Stdout, stderr, and exit code are captured and returned synchronously so your agent can act on results immediately.

Running Code

Use agent.compute.run() to execute code in a sandboxed environment. Provide the language, the source code, and an optional timeout. Output, errors, and the exit code are returned when execution completes.
import { Nonhumans } from '@nonhumans/sdk';

const agent = new Nonhumans({ apiKey: process.env.NONHUMANS_API_KEY });

const result = await agent.compute.run({
  language: "python",
  code: `
import json, statistics

data = [12, 45, 7, 23, 89, 34, 56]
summary = {
    "mean": statistics.mean(data),
    "median": statistics.median(data),
    "stdev": round(statistics.stdev(data), 2),
}
print(json.dumps(summary))
  `,
  timeout: 30,   // seconds; max 300
});

console.log(result.stdout);   // '{"mean": 38, "median": 34, "stdev": 28.15}'
console.log(result.stderr);   // "" (empty if no errors)
console.log(result.exitCode); // 0

Parameters

language
string
required
Runtime to use. One of python, javascript, typescript, bash, or r.
code
string
required
Source code to execute. Multiline strings are supported.
timeout
number
Maximum execution time in seconds. Default 30, maximum 300. Execution is terminated if the limit is reached.

Supported Languages

LanguageRuntimeNotes
pythonPython 3.12Full stdlib; common packages available
javascriptNode.js 22npm packages available
typescriptDeno 2No compile step required
bashBash 5.2Runs in isolated shell
rR 4.4CRAN packages available

Example: Data Analysis

Your agent can run data analysis inline, without piping results through an external service. Here is an example that processes a JSON dataset and returns a statistical summary:
import { Nonhumans } from '@nonhumans/sdk';

const agent = new Nonhumans({ apiKey: process.env.NONHUMANS_API_KEY });

const result = await agent.compute.run({
  language: "python",
  code: `
import json

sales = [4200, 3800, 5100, 4750, 6300, 5900, 4400]
total = sum(sales)
average = total / len(sales)
peak = max(sales)

print(json.dumps({"total": total, "average": round(average, 2), "peak": peak}))
  `,
  timeout: 15,
});

const summary = JSON.parse(result.stdout);
console.log(`Total sales: $${summary.total}`);
console.log(`Average: $${summary.average}`);
console.log(`Peak month: $${summary.peak}`);

Use Cases

Data Processing

Run statistical analysis, data cleaning, and transformation pipelines on demand — no separate data infrastructure required.

Report Generation

Execute code that produces formatted output your agent can embed directly in emails, documents, or API responses.

Automated Validation

Run validation scripts against incoming data before your agent acts on it, catching errors before they propagate.

Dynamic Scripting

Generate code at runtime using an LLM, then execute it immediately — closing the loop between reasoning and action.
Sandbox environments are stateless between compute.run() calls. If you need data to carry over between executions, use the Memory primitive to store and retrieve it, or pass it explicitly in the code string.