Skip to content

Services API

Outcome APIs on a governed sandbox. Send a job — screen text for PII, extract a document — and the platform runs it isolated (gVisor), masks Indian PII, blocks exfiltration, and returns the result plus a tamper-evident audit trail. India-resident (Mumbai). Base URL https://api.ai2in.dev; auth Authorization: Bearer ai2in_….

Full machine-readable contract: GET https://api.ai2in.dev/v1/openapi.json (OpenAPI 3.1 — import into Postman, Swagger, or a codegen).


PII Guard — POST /v1/govern/scan

The DPDP guardrail for anything running LLMs in India. Send any text; get back which sensitive identifiers it contains (Aadhaar / PAN / GSTIN / card / email / phone), a risk level, per-type counts, and a redacted copy — appended to the tamper-evident ledger (unless record:false).

bash
curl -s -X POST https://api.ai2in.dev/v1/govern/scan \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  --data '{"text":"Customer PAN ABCPS1234K, Aadhaar 2341 2345 6783"}'
json
{
  "flags": ["pan", "aadhaar"],
  "risk": "high",
  "entities": { "pan": 1, "aadhaar": 1 },
  "masked": "Customer PAN ABC•••••4K, Aadhaar •••• •••• 6783",
  "ledger_ref": "scan-9bfd…"
}

Pass "record": false for a pure scan with no ledger write. Otherwise every scan is an entry a customer can point to as proof they screened for PII.

Use it in your LLM pipeline before logging, storing, or sending model output; as an input filter on user messages; or as a batch scrubber over a corpus.


Document Intelligence — POST /v1/documents/extract

Send an Indian document's text; a gVisor sandbox extracts structured fields and validates them with the real algorithms — PAN format, Aadhaar UIDAI Verhoeff checksum, GSTIN checksum, IFSC. Returns the fields, per-check validations, a redacted copy, and an audit ref.

bash
curl -s -X POST https://api.ai2in.dev/v1/documents/extract \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  --data '{"type":"auto","text":"PAN ABCPS1234K, Aadhaar 2341 2345 6783, GSTIN 27ABCDE1234F1Z5, IFSC HDFC0001234, amount Rs 1,84,500"}'
json
{
  "type": "auto",
  "fields": {
    "pan": "ABCPS1234K",
    "aadhaar": ["234123456783"],
    "gstin": ["27ABCDE1234F1Z5"],
    "ifsc": "HDFC0001234",
    "amounts": ["Rs 1,84,500"]
  },
  "validations": {
    "pan_format": true,
    "aadhaar_checksum": true,
    "gstin_checksum": false,
    "ifsc_format": true
  },
  "valid": false,
  "redacted": "PAN ABC•••••4K, Aadhaar •••• •••• 6783, GSTIN 27•••••••••••Z5, …",
  "pii": ["pan", "gstin", "aadhaar"],
  "ledger_ref": "doc-b8d8…"
}

valid is the AND of all applicable checks — so a forged Aadhaar or a bad GSTIN checksum makes the document fail, automatically. fields are the raw values (the caller owns the data); redacted is the PII-safe copy for logs.

When a sandbox opens: every extract call opens a fresh gVisor sandbox with no internet, runs the validation code inside it, records the activity to the ledger, and tears the sandbox down. A hallucinated or malicious document can't touch the host or the network.

type accepts auto (detect everything) or a specific hint (pan, aadhaar, gstin, invoice, bank).


AI Operators — POST /v1/operators/run

An AI worker that uses a real computer. Boots a disposable XFCE desktop (Firefox + LibreOffice) in a gVisor sandbox in Mumbai and drives it with a claude-opus-4-8 computer-use loop — screenshot → click / type / scroll → screenshot — to finish a task on the actual screen. This is the path for software that has no API: portals, legacy ERPs, back-office web apps. Every action is written to the ledger; the desktop is isolated, India-resident, and torn down after.

The call is async — it returns a live noVNC stream_url you can open in a browser to watch the operator work, plus a run_id to poll.

bash
# 1) start a run — returns immediately with a live stream URL
curl -s -X POST https://api.ai2in.dev/v1/operators/run \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  --data '{"task":"Open example.com and report the main heading text.","url":"https://example.com"}'
json
{
  "run_id": "op-e4d403…",
  "status": "running",
  "stream_url": "http://<host>:32796/vnc.html",
  "sandbox_id": "sbx_c38fc7…",
  "ledger_ref": "op-e4d403…"
}
bash
# 2) poll for progress + result
curl -s https://api.ai2in.dev/v1/operators/runs/op-e4d403… -H "Authorization: Bearer $KEY"
json
{
  "status": "done",
  "success": true,
  "result": "The main heading on example.com is \"Example Domain\".",
  "steps": [ { "n": 1, "action": "finish", "detail": "…" } ],
  "final_screenshot_b64": "iVBORw0KGgo…",
  "ledger_ref": "op-e4d403…"
}

When a sandbox opens: every run boots a fresh desktop sandbox, the operator drives it step by step (each click/keystroke ledgered), and the desktop is destroyed when the task finishes. A misfire can't touch the host or the network beyond the allowlist. Pass url to open a starting page, and max_steps to cap the run. This is a long call (the agent works step by step) — allow a few minutes.


Secure Code Execution — POST /v1/run

The primitive, as one call. Send code; it opens a fresh gVisor sandbox (no internet), runs it, returns the output, and tears the sandbox down. Governed — the code and its output are screened for PII and recorded to the ledger. No LLM, so it's fast (~1–2s) and cheap. This is the building block the outcome APIs above are made of, exposed directly.

bash
curl -s -X POST https://api.ai2in.dev/v1/run \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  --data '{"language":"python","code":"import platform; print(platform.python_version())"}'
json
{
  "language": "python",
  "stdout": "3.12.3\n",
  "stderr": "",
  "result": null,
  "ledger_ref": "run-3f8a…"
}

language is python (default) or bash. Only /tmp is writable inside the sandbox; there is no network. Use it to run untrusted or model-generated code safely, as a serverless code runner, or as a governed eval for an agent you host yourself.


Agent Task — POST /v1/agents/tasks

A general-purpose governed agent, as a service. Give it any task in plain English (plus optional input data) and a claude-opus-4-8 agent uses a Python tool inside an isolated gVisor sandbox to accomplish it — iterating on real output — then returns a concise result and the steps it took. Every code run is written to the ledger. This is AgentDesk's engine, unbundled from the KYC/claims verticals so you can point it at anything.

bash
curl -s -X POST https://api.ai2in.dev/v1/agents/tasks \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  --data '{
    "task": "From the CSV in /tmp, find the top 3 products by revenue and summarise.",
    "data": "product,units,price\nWidget,120,50\nGadget,200,30\nGizmo,60,80\n",
    "filename": "sales.csv"
  }'
json
{
  "result": "Top 3 by revenue: Gadget ₹6,000, Widget ₹6,000, Gizmo ₹4,800.",
  "steps": [ { "type": "code", "code": "import pandas as pd …", "stdout": "…" } ],
  "ledger_ref": "task-9c2e…"
}

data is optional — when present it's written to /tmp/{filename} for the agent to read. This is a longer call (the agent plans and runs code) — allow ~20–90s. Needs an Anthropic key on the engine; without one it returns 501.


Data Analysis — POST /v1/analyze

Code Interpreter as a service. Send a dataset + a natural-language question; a Claude agent (claude-opus-4-8) writes Python and runs it in an isolated gVisor sandbox (pandas / numpy / matplotlib, no internet), iterates on the real output, and returns a plain-language answer, any charts (base64 PNG), and the code it ran. Every code run is written to the ledger.

bash
curl -s -X POST https://api.ai2in.dev/v1/analyze \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  --data '{
    "question": "Total revenue per product, and which is highest? Plot it.",
    "data": "product,region,units,price\nWidget,North,120,50\nGadget,North,200,30\nGizmo,North,60,80\n"
  }'
json
{
  "answer": "Total revenue per product: Gadget 10,500 (highest), Widget 10,000, Gizmo 4,800.",
  "charts": [{ "name": "revenue_by_product.png", "image_b64": "iVBORw0KGgo…" }],
  "steps": [ { "type": "code", "code": "import pandas as pd …", "stdout": "…" } ],
  "ledger_ref": "analyze-…"
}

Send the dataset inline as data (CSV/text) or as base64 data_b64; charts are base64 PNGs you can render directly. This is a longer call (the agent writes and runs code) — allow ~30–90s.


Audit trail

Every response carries a ledger_ref. Fetch its entries:

bash
curl -s https://api.ai2in.dev/v1/govern/ledger/{ref} -H "Authorization: Bearer $KEY"

Entries are hash-chained (row_hash / prev_hash); prove integrity with the verify_agent_ledger() function or the Governance console. See also the AgentDesk API for the full agent-workforce services.

Sovereign compute for Indian AI — hosted in Mumbai (ap-south-1).