Invariant Gateway
LLM proxy that traces AI agent interactions with LLM providers and sends them to Invariant Explorer for observation and debugging.
At a Glance
About Invariant Gateway
Invariant Gateway is an open-source, Apache-2.0 licensed LLM proxy from Invariant Labs that sits between AI agents and LLM providers such as OpenAI, Anthropic and Gemini. It automatically traces agent interactions and stores them in Invariant Explorer so teams can observe and debug agent behavior. Setup typically means pointing an LLM client's base URL at the Gateway.
What It Is
Gateway is a lightweight, zero-configuration intermediary that forwards requests and streamed responses to LLM providers while recording the traffic as traces. Because it intercepts at the LLM level, it captures tool calling and computer use interactions as well as MCP traffic over stdio, Server-Sent Events and Streamable HTTP. Traces are organized into datasets in Invariant Explorer, which is created automatically if it does not exist.
Integration Paths
Developers change the base URL and add an Invariant API key header in clients for the OpenAI Chat Completions API, the Anthropic Messages API, and Gemini generateContent and streamGenerateContent. The README also shows setups for OpenAI Swarm, LiteLLM and Microsoft Autogen. For non-developers, it documents configuring existing agents such as OpenHands and SWE-agent, using an API key format that embeds the Invariant key because SWE-agent does not support custom headers.
Running It Yourself
Gateway can run locally from the repository using Docker via run.sh, or from a published Docker image on port 8005. A self-hosted instance pushes traces to the public Explorer by default, and the INVARIANT_API_URL setting in .env can point it at a local Explorer. For MCP, the Gateway proxies calls to an MCP server, and blocking or logging guardrails can be set per project in Explorer.
Community Discussions
Be the first to start a conversation about Invariant Gateway
Share your experience with Invariant Gateway, ask questions, or help others learn from your insights.
Pricing
Open Source (Apache-2.0)
Invariant Gateway core is licensed under Apache License 2.0 and can be self-hosted at no charge.
- Apache License 2.0 licensed source code
- LLM proxy for OpenAI, Anthropic and Gemini
- MCP protocol support (stdio, SSE, Streamable HTTP)
- Run the gateway locally
Capabilities
Key Features
- Single-line setup by changing the LLM base URL
- LLM-level interception of agent traffic
- Tool calling and computer use support
- MCP support over stdio, SSE and Streamable HTTP
- Forwarding and streaming to OpenAI, Anthropic and Gemini
- Traces stored in Invariant Explorer
- Guardrails for MCP calls (blocking or logging)
- Self-hosting via Docker
