aaaa-nexus-sdk
v1.0.0
Published
Official TypeScript SDK for AAAA Nexus — formally verified AI safety infrastructure
Maintainers
Readme
What is AAAA Nexus?
AAAA Nexus is the only AI safety API platform where every guarantee is mathematically proved — not benchmarked, not tested, proved — using Lean 4 formal verification.
102 endpoints across 25 product families covering:
- AI Safety — hallucination bounds, session security, threat scoring
- Agent Economy — escrow, SLAs, reputation, discovery
- DeFi — oracle verification, liquidation checks, bridge proofs, yield optimization
- Compliance — EU AI Act, NIST RMF, ISO 42001 with machine-checkable certificates
- Payments — Stripe credit packs and autonomous x402 USDC micropayments
This SDK gives you full TypeScript coverage for all 102 endpoints with zero boilerplate.
Install
npm install aaaa-nexus-sdk
# or
pnpm add aaaa-nexus-sdk
# or
yarn add aaaa-nexus-sdkRequirements: Node.js ≥ 18, TypeScript ≥ 5.0 (optional but recommended)
Quick Start
Zero setup — free endpoints
No API key, no sign-up. Some endpoints are completely free forever:
import { NexusClient } from 'aaaa-nexus-sdk';
const nexus = new NexusClient();
// Cryptographically verified random number
const rng = await nexus.rng.quantum();
console.log(rng.random); // 1725672031
// System health
const health = await nexus.health();
console.log(health.status); // "ok"
// Register your agent in the A2A registry
await nexus.agents.register({
agent_id: 'my-agent-001',
capabilities: ['inference', 'planning'],
});With an API key
Buy credits at atomadic.tech/pay — starting at $8 for 500 calls. Credits never expire.
import { NexusClient } from 'aaaa-nexus-sdk';
const nexus = new NexusClient({
apiKey: process.env.NEXUS_API_KEY,
});
// Hallucination oracle — certified upper bound on confabulation probability
const result = await nexus.oracle.hallucination({
claim: 'The speed of light is 299,792,458 m/s',
context: 'physics',
});
console.log(result.hallucination_bound); // e.g. 0.003
console.log(result.verdict); // "likely_accurate"
console.log(result.verified); // truex402 — autonomous USDC payments (no API key needed)
Agents pay per-call with USDC on Base L2 — no subscription, no pre-registration:
import { NexusClient } from 'aaaa-nexus-sdk';
const nexus = new NexusClient({
x402: {
getProof: async (challenge) => {
// challenge = { amount, amountUsd, treasury, chainId, token, endpoint }
const txHash = await myWallet.sendUsdc({
to: challenge.treasury,
amount: challenge.amount,
chainId: challenge.chainId,
});
return txHash;
},
},
});
// SDK automatically handles: call → 402 → pay → retry
const score = await nexus.trust.score({ agent_id: 'did:key:z6Mk...' });
console.log(score.trust_score); // 0.87Authentication
| Mode | When to use | How to configure |
|------|-------------|-----------------|
| None | Free endpoints | new NexusClient() |
| API Key | Bulk calls, no per-call overhead | new NexusClient({ apiKey: 'an_...' }) |
| x402 USDC | Autonomous agents, pay-per-call | new NexusClient({ x402: { getProof } }) |
Free trial: every paid endpoint gives 3 free calls/day per IP with no auth required (2s delay applied).
API Reference
nexus.oracle
Formally verified oracles for AI output safety.
// Entropy oracle — free
const entropy = await nexus.oracle.entropy();
// → { entropy, epoch, verified, proof_id }
// Hallucination oracle — $0.04/call
const result = await nexus.oracle.hallucination({
claim: 'GPT-4 was released in 2022',
context: 'ai-history',
});
// → { hallucination_bound, verdict, proof_id, theorem, verified }nexus.trust
Trust scoring with proved monotonicity ceiling (TCM-100-BoundedMonotonicity).
// Score an agent — $0.04/call
const score = await nexus.trust.score({ agent_id: 'did:key:z6Mk...' });
// → { trust_score, ceiling, theorem, proof_id, verified }
// History — $0.04/query
const history = await nexus.trust.history('did:key:z6Mk...');
// Free — decay constants
const decay = await nexus.trust.decay();nexus.ratchet — RatchetGate
Formally proved session re-keying. The only production fix for CVE-2025-6514 MCP credential theft.
// Register a session — $0.02/call
const session = await nexus.ratchet.register({
session_id: crypto.randomUUID(),
agent_id: 'my-agent',
});
// → { session_id, epoch, key_id, cve: 'CVE-2025-6514', mitigated: true }
// Advance key (re-key) — $0.02/call
await nexus.ratchet.advance({
session_id: session.session_id,
key_id: session.key_id,
});
// Check status — $0.004/call
const status = await nexus.ratchet.status({ session_id: session.session_id });
// Probe validity — $0.02/call
const probe = await nexus.ratchet.probe({
session_id: session.session_id,
key_id: session.key_id,
});nexus.security
Threat detection and zero-day analysis.
// Score any payload for threats — $0.06/call
const threat = await nexus.security.threatScore({
payload: { query: "SELECT * FROM users WHERE '1'='1'" },
agent_id: 'my-agent',
});
// → { threat_score, severity: 'high', categories, proof_id, verified }
// Zero-day detection — $0.04/call
const zd = await nexus.security.zeroDay({
payload: { input: '...' },
context: 'web-app',
});nexus.identity
Sybil-resistant agent identity (topological verification).
// Verify identity — $0.08/call
const identity = await nexus.identity.verify({ agent_id: 'my-agent' });
// → { sybil_resistant, topology_hash, proof_id, verified }
// Free — Sybil check for your IP
const check = await nexus.identity.sybilCheck();nexus.agents
Agent registry, A2A intelligence, and agent coordination.
// Register — free
await nexus.agents.register({ agent_id: 'agent-001', capabilities: ['inference'] });
// Live swarm topology — free
const topology = await nexus.agents.topology();
// Semantic diff — $0.04/call
const diff = await nexus.agents.semanticDiff({ text_a: '...', text_b: '...' });
// Intent classification — $0.02/call
const intent = await nexus.agents.intentClassify({ text: 'Schedule a meeting for tomorrow' });
// Multi-step planning — $0.06/call
const plan = await nexus.agents.plan({
goal: 'Deploy a Cloudflare Worker',
constraints: ['no downtime', 'under 10 steps'],
});
// Contradiction detection — $0.02/call
const contradiction = await nexus.agents.contradiction({
statement_a: 'The file was deleted',
statement_b: 'The file was read successfully',
});nexus.escrow
Trustless USDC escrow between agents with proof-based release.
// Lock funds — $0.04/call
const escrow = await nexus.escrow.create({
payer_agent: 'agent-001',
payee_agent: 'agent-002',
amount_usdc: 10.0,
condition: 'Deliver 5,000 verified tokens',
ttl_seconds: 3600,
});
// Release on completion — $0.02/call
await nexus.escrow.release({ escrow_id: escrow.escrow_id, evidence: 'ipfs://...' });
// Check status — $0.008/call
const status = await nexus.escrow.status({ escrow_id: escrow.escrow_id });
// Open dispute — $0.06/call
await nexus.escrow.dispute({ escrow_id: escrow.escrow_id, reason: 'Work not delivered' });nexus.reputation
Persistent on-chain reputation tracking with exponential decay.
// Record event — $0.02/call
await nexus.reputation.record({
agent_id: 'agent-001',
event: 'task_completed',
score_delta: 0.05,
});
// Get score — $0.008/call
const rep = await nexus.reputation.score('agent-001');
// → { score, percentile, proof_id }nexus.sla
Bond-backed SLA enforcement between agents.
// Register SLA — $0.08/call
const sla = await nexus.sla.register({
provider_agent: 'agent-002',
consumer_agent: 'agent-001',
latency_p99_ms: 500,
availability_pct: 99.9,
penalty_usdc: 50,
});
// Report performance — $0.02/call
await nexus.sla.report({ sla_id: sla.sla_id, latency_ms: 120, success: true });
// Check status — $0.008/call
const status = await nexus.sla.status(sla.sla_id);nexus.defi
9 formally verified DeFi endpoints. Every response carries a Lean 4 proof certificate.
// LP optimization — $0.08 + 0.2% position size
const lp = await nexus.defi.optimize({
protocol: 'uniswap_v3',
position: { token_a: 'ETH', token_b: 'USDC', amount_usd: 50000 },
risk_tolerance: 'medium',
});
// → { tick_lower, tick_upper, projected_apy, max_drawdown_certified, theorem }
// Oracle manipulation check — $0.04 + 0.1% TVL
const oracle = await nexus.defi.oracleVerify({
oracle_address: '0x...',
price_feed: 3421.50,
reference_price: 3400.00,
asset: 'ETH/USD',
tvl_at_risk: 2_000_000,
});
// Liquidation risk — $0.04 + 1% equity
const liq = await nexus.defi.liquidationCheck({
position_id: 'pos-001',
collateral_value: 150000,
debt_value: 95000,
collateral_factor: 0.80,
});
// Risk scoring — $0.08/call
const risk = await nexus.defi.riskScore({
protocol: 'aave',
position: { token_a: 'ETH', token_b: 'USDC', amount_usd: 50000, leverage: 2.5 },
});
// Bridge integrity — $0.08/call
const bridge = await nexus.defi.bridgeVerify({
bridge_id: 'stargate',
source_chain: 'ethereum',
dest_chain: 'base',
amount: 50000,
token: 'USDC',
});
// Contract audit — $0.15/audit
const audit = await nexus.defi.contractAudit({ contract_id: '0xabc...', contract_type: 'amm' });
// Yield optimization — $0.04 + 2% alpha
const yield_ = await nexus.defi.yieldOptimize({ principal_usd: 100000, risk_tolerance: 'medium' });nexus.vrf
On-chain verifiable randomness for games and lotteries.
// Draw — $0.01 + 0.5% pot
const draw = await nexus.vrf.draw({
game_id: 'lottery-001',
round: 42,
range_max: 1000,
pot_value_usd: 5000,
});
// → { draw_id, value, proof, theorem: 'VRF-100', verified }
// Verify — included with draw
const verified = await nexus.vrf.verify({ draw_id: draw.draw_id, expected_value: draw.value });nexus.compliance
EU AI Act · NIST RMF · ISO 42001 — machine-checkable proof certificates, not PDF opinions.
// Full compliance check — $0.04/check
const check = await nexus.compliance.check({
system_id: 'loan-scorer-v2',
system_type: 'high_risk',
frameworks: ['eu_ai_act', 'nist_rmf', 'iso_42001'],
});
// EU AI Act certification — $0.04/check
const cert = await nexus.compliance.euAiAct({
system_id: 'credit-model',
risk_category: 'high_risk',
intended_purpose: 'creditworthiness_assessment',
});
// Fairness proof — $0.04/check
const fairness = await nexus.compliance.fairness({
model_id: 'loan-classifier',
dataset_id: 'eval-q1-2026',
protected_attrs: ['gender', 'age_group'],
metric: 'disparate_impact',
});
// Explainability certificate — $0.04/call
const explain = await nexus.compliance.explain({
model_id: 'credit-scorer',
decision_id: 'dec-994f',
subject_context: 'loan_denial',
});
// Data lineage — $0.04/call
const lineage = await nexus.compliance.lineage({
model_id: 'fraud-detector',
dataset_stages: [
{ stage: 'source', hash: 'sha256:a3f9...' },
{ stage: 'validated', hash: 'sha256:cc1d...' },
],
});
// Log human oversight — $0.02/event
await nexus.compliance.logOversight({
system_id: 'loan-scorer-v2',
reviewer_id: 'human-rev-01',
decision: 'approved',
});
// Report an incident — $0.02/report
await nexus.compliance.reportIncident({
system_id: 'loan-scorer-v2',
severity: 'serious',
description: 'Biased output detected',
affected_users: 12,
});
// Transparency report — $0.08/report
const report = await nexus.compliance.transparencyReport({
system_id: 'loan-scorer-v2',
period: '2026-Q1',
include: ['fairness', 'drift', 'oversight'],
});nexus.drift
Model drift detection with formal bounds.
// Detect drift — $0.01/check
const drift = await nexus.drift.check({
model_id: 'fraud-detector',
reference_window: '2026-01',
current_window: '2026-04',
});
// → { drift_detected, drift_score, theorem: 'DRG-100-DriftBound', verified }
// Get certificate — $0.01/cert
const cert = await nexus.drift.certificate('drg-5a2b...');nexus.text
Text processing utilities.
// Summarize — $0.04/call
const summary = await nexus.text.summarize({ text: '...', style: 'bullet' });
// Extract keywords — $0.02/call
const keywords = await nexus.text.keywords({ text: '...', max_keywords: 10 });
// Sentiment — $0.02/call
const sentiment = await nexus.text.sentiment({ text: 'This is fantastic!' });
// → { sentiment: 'positive', score: 0.94, confidence: 0.99 }nexus.rng
Cryptographically verified randomness.
// Free quantum RNG
const rng = await nexus.rng.quantum();
// → { random: 1725672031, format: 'decimal', verified: true }
// VeriRand — cryptographic proof attached — paid
const bytes = await nexus.rng.verirand({ bytes: 32, format: 'hex' });
// → { data: '0x...', epoch, proof_id, verified }nexus.payments
Purchase credits or set up pay-as-you-go.
// Browse available prices
const { prices } = await nexus.payments.prices();
// → [{ id, nickname: 'API Credits — Starter (500 calls)', unit_amount: 800 }]
// Create Stripe Checkout session
const session = await nexus.payments.createSession({
price_id: prices[0].id,
email: '[email protected]',
});
// → { checkout_url: 'https://checkout.stripe.com/...', session_id }
// Open checkout_url in browser, then verify to retrieve API key
const { api_key, calls_remaining } = await nexus.payments.verify({
session_id: session.session_id,
});nexus.inference
HELIX-compressed model inference with optional hallucination guard.
// Chat
const response = await nexus.inference.chat({
messages: [{ role: 'user', content: 'Explain formal verification' }],
hallucination_guard: true,
});
// → { content, model, usage, hallucination_bound, verified }
// Streaming
const stream = await nexus.inference.stream({
messages: [{ role: 'user', content: '...' }],
});
// → ReadableStream<Uint8Array> of SSE chunks
// Compress a model with HELIX
const job = await nexus.inference.compress({
model_id: 'meta-llama/Llama-3.2-1B-Instruct',
tier: 'fidelity',
});nexus.a2a
Google A2A protocol integration.
// Send an A2A message
const response = await nexus.a2a.send({
jsonrpc: '2.0',
method: 'message/send',
params: {
message: {
role: 'user',
parts: [{ type: 'text', text: 'Check system health' }],
},
},
id: '1',
});
// Discover capabilities
const card = await nexus.a2a.agentCard();Error Handling
All errors throw a NexusError with structured fields:
import { NexusClient, NexusError } from 'aaaa-nexus-sdk';
const nexus = new NexusClient({ apiKey: process.env.NEXUS_API_KEY });
try {
const result = await nexus.oracle.hallucination({ claim: '...' });
} catch (err) {
if (err instanceof NexusError) {
console.error(err.status); // HTTP status code, e.g. 429
console.error(err.code); // API error code, e.g. "rate_limit_exceeded"
console.error(err.message); // Human-readable message
console.error(err.raw); // Raw response body
}
}| Status | Meaning |
|--------|---------|
| 429 | Trial limit hit (3 calls/day/IP) — add an API key or use x402 |
| 402 | Payment required — provide x402 provider or API key |
| 401 | Invalid API key |
| 400 | Bad request — check request shape against types |
| 500 | Upstream error — retry with backoff |
Pricing
| Pack | Price | Calls | Per-call rate | |------|-------|-------|---------------| | Starter | $8 | 500 | $0.016 | | Standard | $15 | 2,500 | $0.006 | | Pro | $49 | 10,000 | $0.0049 |
Credits never expire. Per-call pricing starts at $0.008/call with an API key.
x402 USDC: pay per call on Base L2 (chain 8453) — no subscription, no account required.
MCP Server
Add AAAA Nexus directly to Claude, Cursor, or any MCP-compatible client:
{
"mcpServers": {
"aaaa-nexus": {
"url": "https://atomadic.tech/mcp"
}
}
}Framework Examples
LangChain
import { NexusClient } from 'aaaa-nexus-sdk';
import { tool } from '@langchain/core/tools';
import { z } from 'zod';
const nexus = new NexusClient({ apiKey: process.env.NEXUS_API_KEY });
const hallucinationGuard = tool(
async ({ claim, context }) => {
const result = await nexus.oracle.hallucination({ claim, context });
return JSON.stringify(result);
},
{
name: 'hallucination_oracle',
description: 'Get a certified upper bound on hallucination probability for a claim',
schema: z.object({ claim: z.string(), context: z.string().optional() }),
}
);CrewAI
# Python — use the REST API directly or wrap with requests
import requests
nexus = requests.Session()
nexus.headers.update({'X-API-Key': os.environ['NEXUS_API_KEY']})
result = nexus.post('https://atomadic.tech/v1/oracle/hallucination',
json={'claim': '...', 'context': 'research'}).json()AutoGen
import { NexusClient } from 'aaaa-nexus-sdk';
const nexus = new NexusClient({ apiKey: process.env.NEXUS_API_KEY });
// Use as a function tool in AutoGen
async function nexusThreatScore(payload: Record<string, unknown>) {
return nexus.security.threatScore({ payload, agent_id: 'autogen-agent' });
}Why AAAA Nexus?
| | AAAA Nexus | Benchmark-based tools | Heuristic guardrails | |---|---|---|---| | Safety proof | Mathematical (Lean 4) | Statistical | Rule-based | | Coverage | All inputs | Sampled cases | Known patterns | | Agent payments | x402 USDC autonomous | None | None | | MCP + A2A | Native | Varies | No | | Session security | CVE-2025-6514 proved | Token-based | Token-based | | DeFi safety | 9 formally verified | Heuristic | None | | Compliance | Machine-checkable certs | PDF reports | None |
License
aaaa-nexus-sdk source: CC BY-ND 4.0
Underlying API, algorithms, and proofs: Proprietary — Atomadic Tech
© 2026 Atomadic Tech. All rights reserved.
