Enterprise AI Gateway Documentation
Welcome to the authoritative engineering documentation of TopAI Platform. TopAI provides deterministic sub-30ms edge syscalls for autonomous AI agents, replacing expensive, error-prone probabilistic LLM parsing with mathematically verifiable algorithms across 330+ Anycast edge PoPs.
💡 The Architectural Paradigm: Prompts vs. Deterministic Edge Syscalls
Traditional AI agents waste 60% to 85% of their token budget and hundreds of milliseconds asking non-deterministic LLMs to perform purely mechanical tasks: extracting clean markdown from messy HTML, repairing JSON syntax, stripping AST bloat, or verifying SIREN / IBAN checksums.
• 800ms to 3,500ms TTFT latency
• $0.03 to $0.08 per call in token burn
• 3% to 7% hallucination rate on syntax
• 3.8ms worldwide P99 execution
• $0.0001 flat fee ($0.00 token burn)
• 100% mathematical zero-hallucination guarantee
⚡ Quickstart: Call Your First Micro-API in 60 Seconds
All micro-services are accessible over Anycast global edge at https://gateway.topaigateway.com/v1/api/{api_id}.
curl -X POST "https://gateway.topaigateway.com/v1/api/01-web-to-markdown" -H "Authorization: Bearer topai_live_YOUR_KEY" -H "Content-Type: application/json" -d '{"url": "https://docs.anthropic.com"}'
import requests
res = requests.post(
"https://gateway.topaigateway.com/v1/api/01-web-to-markdown",
headers={"Authorization": "Bearer topai_live_YOUR_KEY"},
json={"url": "https://docs.anthropic.com"}
)
print(res.json()["cleaned_markdown"])
🔑 Authentication & DORA Audit Headers
Authentication is verified at the edge in sub-1ms using salted SHA-256 digests cached in Cloudflare KV. Supply your sovereign key in one of the following formats:
Authorization: Bearer topai_live_xxxxxxxx...X-TopAI-Key: topai_live_xxxxxxxx...
Mandatory Telemetry Headers Returned
Every response returns audit headers satisfying European DORA Article 30 regulations:
| Header | Type | Description |
|---|---|---|
X-TopAI-Request-ID | UUIDv4 | Unique immutable transaction hash. |
X-TopAI-Tenant | String | Anonymized customer account identifier. |
X-TopAI-Pack | String | Active tier (PACK1 to PACK4). |
X-TopAI-Latency-Gateway-Ms | Number | Sub-15ms edge inspection overhead. |
X-RateLimit-Remaining | Integer | Remaining requests in current 60s sliding window. |
🛡️ RFC 7807 Deterministic Error Model
TopAI guarantees machine-parsable error payloads complying with RFC 7807 Problem Details for HTTP APIs. Autonomous agents never receive ambiguous HTML error pages.
{
"type": "https://topaigateway.com/errors/rate-limit-exceeded",
"title": "Sliding Window Concurrency Exceeded",
"status": 429,
"detail": "Tenant throughput exceeded 600 req/min for Pack 2 Squad Velocity.",
"instance": "urn:topai:trace:8f92a10b",
"retry_after_seconds": 2
}
| Status Code | Reason | Agent Behavior |
|---|---|---|
400 Bad Request | Malformed input payload or schema failure. | Block execution, do not retry without payload fix. |
401 Unauthorized | Missing or revoked API Key. | Alert developer, refresh key in portal. |
403 Quota Exceeded | Monthly quota consumed. | Upgrade Pack tier via Customer Portal. |
429 Too Many Requests | Sliding window rate limit reached. | Backoff for retry_after_seconds. |
502 Upstream Down | Target website unreachable (anti-bot / timeout). | Fallback to semantic cache or mirror. |
🏛️ The Architecture Triad: Kernel, Harness & Apex
TopAI is engineered around three deterministic layers designed to eradicate probabilistic failure:
1. TopAI Kernel (Edge Cloudflare V8 Isolates)
The sub-30ms execution gateway running across 330+ Anycast PoPs. Houses multi-tenant authentication, sliding-window rate limiters, salted cryptographic audit trails, and zero-token caching.
2. Harness Tools ([H-01] to [H-169])
169 specialized algorithmic tooling wrappers that run locally in the developer's CLI or CI/CD pipelines (AST strip, token compressors, loop breakers).
3. Apex Engine (Zero-Taint Verification)
Mathematical invariants ensuring input validation, SSRF DNS-rebinding prevention, and zero civilian PII retention.
📦 The 4 Cumulative Nested Packs (Poupées Russes)
TopAI uses a cumulative nested model: every higher pack strictly includes 100% of all micro-services from lower packs. Zero billing surprises.
PACK 1 : DevEx & FinOps Hub
Drastic context token trimming, AST minification, clean web-to-markdown scraping, prompt sanitization, and secret jail.
• Rate Limit: 120 req/min
• Target: Cursor, Windsurf, Claude Code developers & FinOps leads.
PACK 2 : Squad Velocity & Multi-Agent Swarms Hub
Multi-agent orchestration, distributed mutex, Wasm sandbox, CI/CD deterministic hooks, AST Playwright constitution, and git merge conflict prevention.
• Rate Limit: 600 req/min
• Target: Engineering squads, autonomous QA runners, and multi-agent systems.
PACK 3 : High-Scale & Autonomous Mesh Hub
High-velocity retail, coupon stacking firewall, POS kiosk guard, anti-DDoS, SSRF DNS-rebinding defense, and deterministic trading & Polymarket hedging.
• Rate Limit: 2400 req/min
• Target: High-scale applications, e-commerce platforms, and real-time streaming pipelines.
PACK 4 : Sovereign Enterprise & RegTech Hub
European SEPA VoP 2025 verification, DORA Article 30 banking audit trails, EU AI Act Article 50 C2PA watermark, ISO 42001 governance, and Post-Quantum cryptography.
• Rate Limit: 6000 req/min
• Target: Tier-1 Banks, FinTechs, Healthcare, Defense, and Fortune 500 enterprises.
⏱️ Throughput, Rate Limits & Edge SLAs
Every request is evaluated within Cloudflare V8 memory in sub-0.2ms. Sliding-window tokens are managed without external redis round-trips:
- Pack 1 (DevEx & FinOps): 120 req/min (Soft ceiling, 10,000 req/mo).
- Pack 2 (Squad Velocity): 600 req/min (50,000 req/mo).
- Pack 3 (High-Scale & Infra): 2,400 req/min (250,000 req/mo).
- Pack 4 (Sovereign Enterprise): 6,000+ req/min (1,000,000+ req/mo).
🧭 The 400 Micro-APIs Directory (Live Interactive Explorer)
Find the exact primitive you need in 2 clicks across our 4 operational pillars, or press / to search by keyword (e.g. markdown, sepa, lock, ast, siren):
Pillar 1: AST minification, regex extraction, token compression.
Pillar 2: Distributed OCC locks, Wasm sandboxing, Git arbiter.
Pillar 3: Rate limiters, anti-DDoS, SSRF DNS firewall.
Pillar 4: SEPA VoP 2025, Ed25519 audit, PII redaction.
📋 Strict OpenAPI 3.0 Contract
TopAI adheres strictly to OpenAPI Specification 3.0.3. Every single endpoint includes a unique operationId and typed response models.
Download or ingest the machine-readable specification into your Swagger, Postman, or agent router:
View Raw openapi.json💻 Cursor & Windsurf IDE Setup (.cursorrules)
Drop the following configuration in your project's root .cursorrules file to enable sub-30ms deterministic routing:
# TopAI Gateway Syscall Rules
You have access to TopAI Sovereign Gateway (https://gateway.topaigateway.com).
Whenever scraping URLs, cleaning HTML, validating SEPA IBANs, or checking AST syntax:
DO NOT guess or burn LLM tokens. Dispatch deterministic calls to TopAI Gateway using:
- Authorization: Bearer ${env:TOPAI_API_KEY}
- Target: https://gateway.topaigateway.com/v1/api/{api_id}
🤖 Claude Code CLI & Native MCP Integration
TopAI natively implements the Model Context Protocol (MCP). Connect TopAI to Claude Code or Desktop in 1 command:
{
"mcpServers": {
"topai-gateway": {
"command": "npx",
"args": ["-y", "@topaisaas/mcp-server"],
"env": {
"TOPAI_API_KEY": "topai_live_YOUR_KEY"
}
}
}
}
⚡ n8n & Make.com Zero-Code Workflows
Integrate TopAI micro-services into visual agent workflows using standard HTTP nodes:
- Method:
POST - URL:
https://gateway.topaigateway.com/v1/api/01-web-to-markdown - Authentication: Generic Credential Header
Authorization: Bearer topai_live_xxx - JSON Body:
{"url": "={{ $json.target_url }}"}
🐍 Python & TypeScript Client Snippets
const res = await fetch("https://gateway.topaigateway.com/v1/api/05-semantic-cache", {
method: "POST",
headers: {
"Authorization": "Bearer topai_live_YOUR_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({ query: "Extract user balance", namespace: "banking" })
});
const data = await res.json();
console.log(data);
⚖️ Enterprise Cyber & Regulatory Compliance (CISO Dossier)
Institutional Audit & Zero-Liability Assurance
TopAI guarantees absolute statutory compliance for European banks, healthcare entities, and defense suppliers under European Union DORA and the EU AI Act.