What is Invariant Gateway?
Invariant Gateway is Un proxy LLM que observa y depura lo que hacen tus agentes de IA. Las trazas se guardan en Invariant Explorer para que puedas revisarlas más tarde. It sits in the Guardrails & Security category of the Evaluation & Production Ops tools and is open-source, written in Python and licensed Apache-2.0.
Resumen
Invariant Gateway es un servicio de código abierto de Invariant Labs que se sitúa entre tu agente de IA y su proveedor de LLM. Actúa como proxy: en lugar de llamar directamente a OpenAI, Anthropic o Gemini, tu cliente apunta su URL base a Gateway, que reenvía la petición y registra lo que ha ocurrido. Las trazas se guardan en Invariant Explorer para que puedas revisarlas más tarde.
Está pensado para desarrolladores que crean sistemas agénticos y necesitan ver qué envían y reciben sus agentes en tiempo de ejecución. Como funciona a nivel de LLM, captura las conversaciones de chat habituales, las llamadas a herramientas y las interacciones de computer use sin que tengas que reescribir la lógica de tu agente.
Como herramienta de barrera de protección (guardrail) y de observabilidad, Gateway se centra en la visibilidad y la depuración. Admite el protocolo MCP sobre E/S estándar, Server-Sent Events y Streamable HTTP, y reenvía las respuestas en streaming, así que encaja delante de agentes que se comunican tanto con APIs de modelos como con servidores MCP.
Qué hace
- Configuración en una sola línea: apunta la URL base de tu cliente LLM a Gateway y añade una cabecera, sin reescribir código
- Intercepta las llamadas a nivel de LLM para depurar y analizar en distintos proveedores
- Captura las llamadas a herramientas y las interacciones de computer use, no solo el chat normal
- Compatibilidad con el protocolo MCP sobre E/S estándar, Server-Sent Events y Streamable HTTP
- Reenvía las peticiones y transmite las respuestas a OpenAI, Anthropic, Gemini y otros proveedores
- Almacena y organiza las trazas de ejecución en Invariant Explorer
Primeros pasos
La forma más rápida de usar Gateway es el endpoint alojado de Explorer: mantén tu cliente actual, pero cambia su URL base y añade la cabecera Invariant-Authorization. El ejemplo siguiente usa el cliente de Anthropic.
Apunta tu cliente al Gateway
Configura tu cliente de Anthropic (o de OpenAI/Gemini) para que envíe las peticiones a través de la URL base de Gateway, incluyendo tu clave de API de Invariant en la cabecera Invariant-Authorization. Sustituye el nombre del conjunto de datos por el tuyo; si no existe, se crea automáticamente.
from httpx import Client
from anthropic import Anthropic
client = Anthropic(
http_client=Client(
headers={
"Invariant-Authorization": "Bearer your-invariant-api-key"
},
),
base_url="https://explorer.invariantlabs.ai/api/v1/gateway/{add-your-dataset-name-here}/anthropic",
)Usa tu cliente como de costumbre
Haz las llamadas exactamente como lo harías normalmente. Gateway reenvía cada petición al proveedor, devuelve la respuesta en streaming y registra la traza en Invariant Explorer.
O ejecuta Gateway en local
Para alojarlo tú mismo en lugar de usar el endpoint alojado, descarga y ejecuta la imagen de Docker publicada. Sirve Gateway en http://localhost:8005/api/v1/gateway/.
docker pull --platform linux/amd64 ghcr.io/invariantlabs-ai/invariant-gateway/gateway:latest
docker run -p 8005:8005 -e PORT=8005 --platform linux/amd64 ghcr.io/invariantlabs-ai/invariant-gateway/gateway:latestCommands and code are distilled from the project's own documentation — always check the repositorio oficial para lo último.
Cuándo usarlo
- Depurar un agente de varios pasos inspeccionando los prompts exactos, las llamadas a herramientas y las respuestas que generó en tiempo de ejecución
- Añadir observabilidad a un agente que usa servidores MCP por stdio, SSE o Streamable HTTP
- Trazar y organizar las interacciones con LLM de OpenAI, Anthropic y Gemini desde un único lugar
- Revisar el comportamiento de computer use o de llamadas a herramientas cuando un agente hace algo inesperado
How Invariant Gateway compares
Invariant Gateway alongside other open-source guardrails & security tools AI/TLDR tracks, ranked by GitHub stars.
| Herramienta | Estrellas | Qué hace |
|---|---|---|
| SkillSpector | ★ 28.3k | Security scanner for AI agent skills that checks a skill for prompt injection, data exfiltration, privilege escalation and supply-chain risks before you install it. |
| Presidio | ★ 12.1k | An open-source framework for detecting, redacting, masking, and anonymizing personal data (PII) across text, images, and structured data using NER models, regex, and rule-based recognizers. |
| Failproof AI | ★ 10.5k | A hook-based CLI and Rust daemon that listens to every event from 12 agent harnesses such as Claude Code, Codex and Cursor, and blocks, warns or steers the agent with one policy API, with optional cloud tracing and failure audits. |
| Guardrails AI | ★ 7.7k | A Python framework that wraps LLM calls with composable input/output validators (from the Guardrails Hub) to check structure, type, and safety risks before responses reach users. |
| NeMo Guardrails | ★ 7.6k | NVIDIA's toolkit for adding programmable rails to LLM chat apps, using the Colang language to control dialog flow and block jailbreaks, prompt injection, and off-topic answers. |
| BLA (Blind LLM Agents) | ★ 7.3k | An open-source CLI and MCP server that hardens the apps, WASM modules, databases and model files you ship so AI reverse-engineering agents such as REA hit resource budgets and follow decoys, without changing runtime behaviour. |
| dcg (Destructive Command Guard) | ★ 6.4k | A Rust pre-tool hook for coding agents that inspects each shell or git command before it runs and blocks the destructive ones, with an explanation and a safer alternative. |
| Invariant Gateway | ★ 83 | Un proxy LLM que observa y depura lo que hacen tus agentes de IA |

