{"slug": "tkngate-zero-trust-p2p-ateway-for-llm-agents-open-source-written-in-go", "title": "Tkngate Zero-trust P2P ateway for LLM agents (open source, written in Go)", "summary": "Tkngate, an open-source zero-trust P2P gateway for LLM agents written in Go, has released version 2.5.0 with cross-node prompt routing. The tool enforces hard USD circuit breakers, uses ZK-SNARKs for cryptographic prompt security, and provides a self-hosted reverse proxy that prevents runaway agent costs without sending data to third parties.", "body_md": "**Zero-trust P2P gateway for LLM agents**\n\n`v2.5.0 — Cross-Node Prompt Routing`\n\n[Install](#install) •\n[Quick Start](#quick-start) •\n[Why Tkngate?](#why-tkngate) •\n[Features](#features) •\n[Comparison](#vs-the-competition) •\n[Docs](/tkngate/tkngate/blob/main/docs)\n\nEvery developer building with **LangChain, AutoGen, or CrewAI** has experienced the same nightmare: a runaway `while`\n\nloop that burns $50 in OpenAI credits in 10 minutes. You wake up to a surprise bill with no way to explain which agent did it, when, or why.\n\n**Tkngate solves this permanently.**\n\nIt is a single Go binary that sits as a reverse proxy between your agents and your LLM providers (OpenAI, Anthropic, Groq, etc.). It enforces hard USD circuit breakers, inspects every prompt with a ZK-verified AI-WAF, caches redundant reasoning loops for free, and gives you a real-time dashboard — all without sending a single byte of your data to a third party.\n\n```\nYour AI Agent  →  tkngate (localhost:7477)  →  OpenAI / Anthropic / Groq / DeepSeek\n```\n\n\"LiteLLM routes. Portkey observes.Tkngate protects.\"\n\n| Tool | The Gap |\n|---|---|\nLiteLLM |\nRoutes between models. No hard budget limits. Requires Python. |\nPortkey |\nCloud-only. Your prompts go through their servers. |\nHelicone |\nObservability only. Can't stop a runaway agent. |\nOpenRouter |\nYou use their shared keys, not yours. |\nKong AI Gateway |\nEnterprise-only. Requires existing Kong infrastructure. |\n\nNone of them offer **cryptographic prompt security**. None of them have a **P2P key mesh**. All of them either require a cloud account or send your data somewhere.\n\n| Feature | Tkngate |\nLiteLLM | Portkey | Helicone |\n|---|---|---|---|---|\n| Single binary (no Python, no Docker) | ✅ | ❌ | ❌ | ❌ |\n| 100% self-hosted, no data leaves your machine | ✅ | ✅ | ❌ | ❌ |\nZK-SNARK AI-WAF attestations |\n✅ | ❌ | ❌ | ❌ |\nGlobal P2P Mesh Network (libp2p) |\n✅ | ❌ | ❌ | ❌ |\nP2P encrypted key mesh (DRR) |\n✅ | ❌ | ❌ | ❌ |\n| Hard USD per-session circuit breakers | ✅ | ❌ | ||\n| Shadow Mode A/B traffic splitting | ✅ | ❌ | ❌ | ❌ |\n| Multi-tenant RBAC + Organizations | ✅ | ✅ | ✅ | ❌ |\n| Semantic cache (save up to 80%) | ✅ | ❌ | ❌ | ❌ |\n| Embedded real-time dashboard | ✅ | ❌ | ✅ (cloud) | ✅ (cloud) |\n| Prometheus metrics export | ✅ | ✅ |\n\nEvery competitor routes prompts in plain text. Tkngate is the **only LLM proxy** that uses ZK-SNARKs (Groth16 BN254) to mathematically prove a prompt is safe **without ever reading the prompt content**. Enable it with one config flag:\n\n```\nmesh:\n  strict_zkp_mode: true\ngo build -o tkngate && ./tkngate serve\n```\n\nThat's it. No `pip install`\n\n. No Docker Compose. No cloud account. No data leaving your machine. SQLite is the only storage engine by default.\n\nTkngate lets you donate your spare API quota into a cryptographically secured pool. Keys are encrypted with **AES-256-GCM** and never exposed in plaintext, even to other nodes in the mesh. A **Deficit Round-Robin (DRR)** algorithm ensures free-riders are throttled automatically.\n\nMost tools let you *monitor* spend. Tkngate lets you *stop* it. The moment a session or global budget is breached, the connection is terminated — not after the next billing cycle, **right now, at the byte level**.\n\nFork a percentage of live traffic to a second provider and compare outputs and costs — with **zero changes to your agent code**. Like Canary Deployments for LLMs.\n\nTkngate nodes automatically discover each other worldwide via **Kademlia DHT** and locally via **mDNS**. Reputation updates and fraud alerts are broadcast in real-time using **GossipSub** with cryptographic signatures. An **Anti-Sybil Decay** loop continuously penalises idle nodes to prevent adversaries from building dormant proxy armies.\n\n```\np2p:\n  enabled: true\n  listen_port: 7479\n  enable_relay: true\n  enable_mdns: true\n  max_peers: 100\n```\n\nThe built-in React dashboard (`http://localhost:7478`\n\n) shows real-time WAF intercepts, ZKP attestation counts, mesh capacity, budget zones, and per-key spend — all served from the binary itself. The **Mesh** tab now features a full **Peer Reputation Leaderboard** with trust score bars, tier badges (🏆 PREMIUM / ✓ TRUSTED / ● NEW), a Fairness Engine health indicator, and network-wide violation tracking.\n\nRun `./tkngate`\n\nwith no arguments to launch a beautiful interactive menu. Browse organizations, check budgets, donate API keys, view connected P2P peers, test upstream providers, or launch the demo — all without memorising CLI flags.\n\n```\n# Clone & build\ngit clone https://github.com/tkngate/tkngate.git\ncd tkngate\ngo build -o tkngate\n\n# Configure\ncp tkngate.example.yaml tkngate.yaml\n# Edit tkngate.yaml with your provider API keys\n\n# Generate a master key (required for the dashboard)\n./tkngate generate-master-key\n\n# Run\n./tkngate serve\n```\n\nThe proxy starts on `localhost:7477`\n\n. The telemetry dashboard opens at `localhost:7478`\n\n.\n\nPoint your existing agent at tkngate — no code rewrites needed:\n\n``` python\n# Python (OpenAI SDK)\nfrom openai import OpenAI\nclient = OpenAI(\n    api_key=\"your-tkngate-virtual-key\",\n    base_url=\"http://localhost:7477/v1\"\n)\njs\n// Node.js (OpenAI SDK)\nconst openai = new OpenAI({\n  apiKey: \"your-tkngate-virtual-key\",\n  baseURL: \"http://localhost:7477/v1\"\n});\n# Via interactive menu\n./tkngate\n# → Select \"peers (Global P2P Mesh)\"\n\n# Or directly\n./tkngate peers list\n```\n\nIf you want to see the dashboard in action without pointing real agent traffic at it, you can use the built-in demo traffic generators. These scripts simulate live traffic, WAF intercepts, and reputation slashing without consuming any real API credits.\n\nYou can launch the demo in three ways:\n\n**Interactive Menu**(Recommended): Run`./tkngate`\n\nand select`demo (Simulate Live Traffic)`\n\n. This starts the proxy, the dashboard, and the demo traffic generator simultaneously.**CLI Flag**: Run`./tkngate serve --demo`\n\n. This performs the exact same action as the interactive menu.**Standalone**: Run`./tkngate demo`\n\nor`python demo_traffic.py`\n\nif you just want to generate background traffic to an isolated database.\n\n*Note: The demo scripts safely create and write to a separate budget_demo.db file, ensuring your real configuration and budget limits are never altered.*\n\n**Asymmetric End-to-End Encryption (E2EE)**— Zero-trust prompt encryption using Ed25519-to-X25519 Diffie-Hellman key exchange** Latency-Aware Peer Selection**— dynamically route LLM prompts to the fastest available peer in the global mesh** Cross-Node Prompt Routing**— offload excess traffic to trusted mesh peers when your local rate limits are exhausted** Deficit Round Robin (DRR)**— fair, weighted routing across all nodes in the mesh** Enterprise Budget Guard**— hard USD limits per-session and globally, with GREEN/AMBER/RED zone alerts** Semantic Caching**— up to 80% savings on repeated or similar prompts (in-memory or Redis)** Dynamic AI-WAF**— intercepts prompt injections, PII leaks, and jailbreaks before they hit your provider** ZK-SNARK Attestations**— cryptographic proof of prompt safety using Groth16 BN254 circuits** Shadow Mode**— silently mirror a percentage of traffic to a second model for evaluation** Universal Fallback**— if OpenAI returns 5xx, auto-retry on Anthropic or DeepSeek transparently** Context Compressor**— strip whitespace and comments from code-heavy prompts (up to 40% token reduction)** Multi-Tenant RBAC**— Virtual Keys with per-org budgets and provider restrictions** Prometheus Export**— native metrics at`/metrics`\n\nfor Grafana, Datadog, or New Relic**Embedded Dashboard**— real-time React UI served from the binary itself, no Node.js required** Peer Reputation Leaderboard**— live dashboard table ranking mesh nodes by trust score with tier badges and violation counts** Stake-and-Slash Reputation**— mesh nodes that route malicious prompts get their trust score slashed automatically** Interactive CLI**— beautiful TUI menu for managing everything without memorising flags\n\nTkngate natively exports Prometheus metrics at `http://localhost:7478/metrics`\n\n. Hook it into any observability stack:\n\n```\n# prometheus.yml\nscrape_configs:\n  - job_name: 'tkngate'\n    static_configs:\n      - targets: ['localhost:7478']\n```\n\nKey metrics:\n\n`tkngate_budget_spent_usd_total`\n\n— total enterprise API cost`tkngate_virtual_key_spend_usd_total`\n\n— spend per virtual key`tkngate_active_connections`\n\n— in-flight requests`tkngate_cache_hits_total`\n\n— semantic cache hits`tkngate_waf_intercepts_total`\n\n— requests blocked by the AI-WAF\n\nAs of `v2.0.0`\n\n, Tkngate features a full **Stake-and-Slash Reputation Engine** for peer-to-peer enterprise pooling. Instead of a single bottleneck API key, teams donate multiple keys into a shared pool governed by game theory:\n\n**Deficit Round Robin (DRR):** Free-riders who consume without donating are automatically throttled.**Stake-and-Slash Reputation:** Nodes route clean prompts → trust increases. Nodes route flagged prompts → trust is slashed. Low-trust nodes lose access to premium high-TPM keys.**ZK-SNARK Verification:** In`strict_zkp_mode`\n\n, every key access requires a valid zero-knowledge proof, making it impossible to abuse the mesh.**Global libp2p Networking (v2.4.0):** Nodes discover each other worldwide via**Kademlia DHT**, locally via** mDNS**, and broadcast reputation updates in real-time via** GossipSub**with Ed25519-signed messages. An** Anti-Sybil Decay**loop continuously penalises idle nodes.\n\n| Topic | Link |\n|---|---|\n| CLI Reference & Architecture |\n|\n\n[docs/budgeting.md](/tkngate/tkngate/blob/main/docs/budgeting.md)[docs/drr-mesh.md](/tkngate/tkngate/blob/main/docs/drr-mesh.md)[docs/virtual-keys.md](/tkngate/tkngate/blob/main/docs/virtual-keys.md)[docs/rate-limiting.md](/tkngate/tkngate/blob/main/docs/rate-limiting.md)[docs/cli-reference.md#waf](/tkngate/tkngate/blob/main/docs/cli-reference.md)Apache 2.0", "url": "https://wpnews.pro/news/tkngate-zero-trust-p2p-ateway-for-llm-agents-open-source-written-in-go", "canonical_source": "https://github.com/tkngate/tkngate", "published_at": "2026-07-17 16:33:00+00:00", "updated_at": "2026-07-17 16:51:30.786262+00:00", "lang": "en", "topics": ["ai-tools", "ai-infrastructure", "ai-safety", "ai-agents", "ai-ethics"], "entities": ["Tkngate", "LangChain", "AutoGen", "CrewAI", "OpenAI", "Anthropic", "Groq", "DeepSeek"], "alternates": {"html": "https://wpnews.pro/news/tkngate-zero-trust-p2p-ateway-for-llm-agents-open-source-written-in-go", "markdown": "https://wpnews.pro/news/tkngate-zero-trust-p2p-ateway-for-llm-agents-open-source-written-in-go.md", "text": "https://wpnews.pro/news/tkngate-zero-trust-p2p-ateway-for-llm-agents-open-source-written-in-go.txt", "jsonld": "https://wpnews.pro/news/tkngate-zero-trust-p2p-ateway-for-llm-agents-open-source-written-in-go.jsonld"}}