# Repository Briefing: NeuralTrust/TrustGate
> Source: https://repoforai.com/repo/NeuralTrust/TrustGate (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/NeuralTrust/TrustGate
- **Official Docs / Website**: https://docs.neuraltrust.ai
- **Category**: Agents & Frameworks (智能体与框架)
- **Primary Language**: Go
- **License**: Apache-2.0
- **Engineering Health**: A+ (88/100 · Maintenance 35/35 · Adoption 13/25 · Releases 20/20 · License 20/20)
- **Latest Release**: v1.2.0 (2026-12-01) — https://github.com/NeuralTrust/TrustGate/releases
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: Docker, Self-Hosted, MCP, API
- **Momentum**: 32 ★ total (+1 24h / +24 7d) · 7 forks
- **Topics**: `agent-gateway`, `ai-gateway`, `anthropic`, `golang`, `guardrails`, `llm-gateway`, `llm-proxy`, `llm-router`, `llm-routing`, `mcp`, `mcp-gateway`, `mcp-security`
- **When to Use**: Best for: Platform teams governing multiple model providers and agent tools, with a need for shared identity, per-caller budgets, failover and traceability. Skip if: A single provider's native API meets your needs, you cannot operate an additional gateway and its backing services, or you need an inference engine rather than a proxy.

## Overview
```text
### Architecture & Core Mechanics
TrustGate builds one Go binary from `cmd/trustgate/`; the supplied `go.mod` declares Go 1.27.4. The default process serves the LLM proxy on 8081. The `admin`, `mcp` and `agent` modes serve ports 8080, 8082 and 8084 respectively, while `run` combines only admin and proxy for a single node. Separate processes let teams scale model, tool and agent traffic independently. The admin plane owns migrations and configuration and can sync that configuration to data planes without giving them direct PostgreSQL access. The proxy uses Redis.

Incoming traffic is resolved to an application and caller before the gateway applies policies and dispatches upstream. The LLM proxy handles dialect conversion and streaming, the MCP plane aggregates tools, and the agent plane forwards A2A traffic. `pkg/api/` contains handlers and middleware, `pkg/app/` contains routing, authorization and protocol services, and `pkg/infra/` contains provider and policy adapters, persistence, config sync and telemetry. Policy stages run before requests, before responses and on streams.

### Key Capabilities & Differentiators
The LLM plane targets 17 provider options, including OpenAI, Anthropic, Azure OpenAI, Bedrock and Google Vertex AI, plus OpenAI-compatible backends such as vLLM and Ollama. Clients can use OpenAI Chat Completions or Responses, Anthropic Messages, Gemini or Vertex AI, Cohere Chat or native Bedrock dialects. Routing includes trigger-based fallback with an attempt budget, smart routing across two or three ordered models, and round-robin, weighted, least-connections, random or semantic balancing. A provider failure mid-stream is surfaced as an error event in the client dialect instead of a seemingly complete result.

MCP aggregates MCP servers and OpenAPI services behind one endpoint with per-user upstream credentials. A2A 0.3 and 1.0 support pinned agent cards, task ownership and delegated identity. Application keys, OIDC claim rules and mTLS feed application- or caller-level rate limits, token or dollar budgets and model or tool allowlists. Policies can enforce or observe, with throttling available for rate limits. Semantic caching, external guardrails and per-gateway OTLP exports round out the shared policy and telemetry layer.

### Trade-offs & Limitations
Compared with calling the OpenAI API directly, TrustGate trades a shorter request path and direct access to native provider behavior for centrally enforced identity, budgets, failover and tool policy. A familiar API dialect lowers migration effort, but is not a guarantee of cross-provider feature parity. Test tool-call semantics, stream events and endpoint-specific fields before switching a route. Retries on the same provider are disabled by default; when enabling retries or fallback, budget for additional upstream attempts, latency and potential charges.

The shared gateway also becomes a service that teams must monitor and operate. Private-network egress is allowed by default; set `OUTBOUND_ALLOW_PRIVATE_NETWORKS=false` when untrusted users can configure upstreams, and review network controls independently. Raw OTLP exporters can carry payloads, and cloud models or guardrails can still receive data from a self-hosted gateway. The gateway and admin API are Apache-2.0; evaluate paid NeuralTrust platform features such as SSO, RBAC and longer retention separately from the gateway's application-level OIDC support.

### Hardware & Deployment Guide
For evaluation, start from a checkout with `make up`, then verify `/healthz` on the admin, proxy and MCP ports and use `examples/curl-first-request/first-request.sh` with a valid OpenAI credential. The supplied `docker-compose.yaml` itself defines PostgreSQL 16 Alpine and Redis 7 Alpine; the full quick-start workflow also launches the TrustGate planes. `.env.example` covers the `DB_*` and `REDIS_*` settings, and admin JWT signing requires a `SERVER_SECRET_KEY` of at least 32 bytes. Bind or network-restrict the admin API, configure its TLS or put it behind a controlled TLS ingress, and replace the sample database credentials rather than exposing the Compose database and Redis ports as-is.

For separate plane deployment, `k8s/` contains Kustomize bases and overlays. Go gateway capacity should be tested against concurrency, streaming duration, policy stages and telemetry volume; model-serving GPU requirements are separate. Release v1.1.0 added per-dimension rate limiting, `Retry-After` support and caps on parallel requests. v1.2.0 added client addresses to request spans; review collection, access and retention rules for those traces.
```

## Key Capabilities
```text
- Process isolation: One Go binary exposes admin, LLM proxy, MCP and A2A modes on ports 8080, 8081, 8082 and 8084.
- API compatibility: The proxy translates supported OpenAI, Anthropic, Gemini, Vertex AI, Cohere and Bedrock dialects, including streaming.
- Routing controls: Fallback chains use triggers and an attempt budget; smart routing keeps a conversation on one model until a turn warrants an upgrade.
- Tool and agent governance: MCP aggregates native servers and OpenAPI tools with per-user upstream credentials; A2A tracks task ownership.
- Identity and policy: OIDC claim rules and mTLS complement application keys, caller-scoped quotas and model or tool allowlists.
- Telemetry: Per-gateway OTLP exports report caller, model, token usage, cost and latency; raw-class exports can include payloads.
```

## Quick Start / Clone
```bash
curl -fsSL https://raw.githubusercontent.com/NeuralTrust/TrustGate/main/scripts/install.sh | bash
```
