From 2d04bbf9409fb34852b20026b94fdae0ddc7ca8b Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 13:56:49 +0100 Subject: [PATCH 01/34] update readme --- README.md | 90 ++++++++++++++++++++++++----------- resources/images/overview.svg | 48 +++++++++++++++++++ 2 files changed, 109 insertions(+), 29 deletions(-) create mode 100644 resources/images/overview.svg diff --git a/README.md b/README.md index ef4d9c8..6902278 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,36 @@ -# **Invariant Proxy** +
+

Invariant Gateway

-Invariant Proxy is a lightweight Docker service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic). It captures and forwards agent interactions to the [Invariant Explorer](https://explorer.invariantlabs.ai/), enabling seamless debugging, visualization, and exploration of traces. +LLM proxy to secure and debug what your AI agents are doing. -![Invariant Proxy Diagram](resources/images/invariant-proxy.png) +
---- +Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic) and automatically captures, forwards and secures agent interactions as traces in the [Invariant Explorer](https://explorer.invariantlabs.ai/) -## **Why Use Invariant Proxy?** -- ✅ **Intercept AI interactions** for better debugging and analysis. -- ✅ **Seamlessly forward API requests** to OpenAI, Anthropic, and other LLM providers (**supports streaming responses too**). -- ✅ **Works with AI Agent platforms and systems** like OpenHands, SWE-agent, etc. -- ✅ **Automatically store and organize traces** in the Invariant Explorer. +This enables seamless debugging, visualization and security scanning of agentic behavior. ---- + +
+
-## **Getting Started** +
+Invariant Proxy Diagram +
-### **Run the Proxy Locally** -To start the Invariant Proxy, run: +
+
-```bash -bash run.sh build && bash run.sh up -``` +- [x] **Single Line Setup**: Just change the base URL of your LLM provider to the Invariant Gateway. +- [x] **Intercepts agents on an LLM-level** for better debugging and analysis. +- [x] **Tool Calling and Computer Use Support** to capture all forms of agentic interactions. +- [x] **Seamless forwarding and LLM streaming** to OpenAI, Anthropic, and other LLM providers. +- [x] **Store and organize runtime traces** in the Invariant Explorer. -This will launch the proxy at [http://localhost:8005/api/v1/proxy/](http://localhost:8005/api/v1/proxy/docs/). +## **Quickstart for Users** -### **Set Up an Invariant API Key** -1. Follow the instructions [here](https://explorer.invariantlabs.ai/docs/explorer/api/client-setup/) to obtain an API key. This allows the proxy to push traces to [Invariant Explorer](https://explorer.invariantlabs.ai). +Looking to observe and secure AI agents in your organization? See our [quickstart guide for users](https://explorer.invariantlabs.ai/docs/explorer/Explorer_API/1_client_setup/) to get started. ---- +## **Quickstart for Developers** ## **Integration Guides** @@ -75,19 +77,29 @@ This will launch the proxy at [http://localhost:8005/api/v1/proxy/](http://local ``` > **Note:** Do not include the curly braces `{}`. If the dataset does not exist in Invariant Explorer, it will be created before adding traces. + --- -## **OpenHands Integration** +## **Quickstart for Users** + +If you are not building an agent yourself but would like to observe and secure AI agents in your organization, you can do so by configuring the agents to use the Gateway. + +See below for example integrations with popular agents. + +### **OpenHands Integration** + [OpenHands](https://github.com/All-Hands-AI/OpenHands) (formerly OpenDevin) is a platform for software development agents powered by AI. -### **How to Integrate OpenHands with Invariant Proxy** +#### **How to Integrate OpenHands with Invariant Proxy** + +##### **Step 1: Modify the API Base** -#### **Step 1: Modify the API Base** Enable the `Advanced Options` toggle under settings and update the `Base URL`: -#### **Step 2: Adjust the API Key Format** +##### **Step 2: Adjust the API Key Format** + Set the API Key using the following format: ```text @@ -100,13 +112,15 @@ The Invariant Proxy extracts the `invariant-auth` field from the API key and cor --- -## **SWE-agent Integration** +### **SWE-agent Integration** + [SWE-agent](https://github.com/SWE-agent/SWE-agent) allows your preferred language model (e.g., GPT-4o or Claude Sonnet 3.5) to autonomously utilize tools for various tasks, such as fixing issues in real GitHub repositories. -### **Using SWE-agent with Invariant Proxy** +#### **Using SWE-agent with Invariant Proxy** + SWE-agent does not support custom headers, so you **cannot** pass the Invariant API Key via `Invariant-Authorization`. However, **there is a workaround** using the Invariant Proxy. -#### **Step 1: Modify the API Base** +##### **Step 1: Modify the API Base** Run `sweagent` with the following flag: @@ -116,7 +130,8 @@ Run `sweagent` with the following flag: > **Note:** Do not include the curly braces `{}`. -#### **Step 2: Adjust the API Key Format** +##### **Step 2: Adjust the API Key Format** + Instead of setting your API Key normally, modify the environment variable as follows: ```bash @@ -130,15 +145,32 @@ This setup ensures that SWE-agent works seamlessly with Invariant Proxy, maintai --- +### **Run the Gateway Locally** + +To start the Invariant Gateway, run: + +```bash +bash run.sh build && bash run.sh up +``` + +This will launch the proxy at [http://localhost:8005/api/v1/proxy/](http://localhost:8005/api/v1/proxy/docs/). + +### **Set Up an Invariant API Key** + +1. Follow the instructions [here](https://explorer.invariantlabs.ai/docs/explorer/api/client-setup/) to obtain an API key. This allows the proxy to push traces to [Invariant Explorer](https://explorer.invariantlabs.ai). + +--- + ## **Development** ### **Pushing to Local Explorer** + By default the proxy points to the Production Explorer instance. To point it to your local Explorer instance, modify the `INVARIANT_API_URL` value inside `.env`. Follow instructions in `.env` on how to point to the local instance. ### **Run Tests** + To run tests, execute: ```bash ./run.sh tests ``` - diff --git a/resources/images/overview.svg b/resources/images/overview.svg new file mode 100644 index 0000000..25a62dc --- /dev/null +++ b/resources/images/overview.svg @@ -0,0 +1,48 @@ + + + Group 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 8efbc059af18040048e1785ec9d7ed32d9013f1a Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 13:58:26 +0100 Subject: [PATCH 02/34] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6902278..6db3731 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,9 @@ -Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic) and automatically captures, forwards and secures agent interactions as traces in the [Invariant Explorer](https://explorer.invariantlabs.ai/) +Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic). -This enables seamless debugging, visualization and security scanning of agentic behavior. +This gives you insights into what your agents are doing, and automatically captures and forwards agent interactions as traces to the [Invariant Explorer](https://explorer.invariantlabs.ai/)
From 07ad26221c0a99ffcd5374556a857b2b593f201b Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 13:58:55 +0100 Subject: [PATCH 03/34] update readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6db3731..9cfc0b4 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ Looking to observe and secure AI agents in your organization? See our [quickstar ## **Quickstart for Developers** +To get started with Gateway, follow the integration guides below depending on the LLM provider you are using. + ## **Integration Guides** ### **🔹 OpenAI Integration** From b12e99bc2efaad2f7ea77ebf41b022bdef11d54c Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 13:59:28 +0100 Subject: [PATCH 04/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9cfc0b4..b3a0daf 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic). -This gives you insights into what your agents are doing, and automatically captures and forwards agent interactions as traces to the [Invariant Explorer](https://explorer.invariantlabs.ai/) +This gives you insights into what your agents are doing, and automatically captures and forwards agent interactions as traces to the [Invariant Explorer](https://explorer.invariantlabs.ai/).
From e2b3829098ef16ea15c09b00a3dcbd2fcdf18a1d Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:01:19 +0100 Subject: [PATCH 05/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b3a0daf..a68bcfa 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic). -This gives you insights into what your agents are doing, and automatically captures and forwards agent interactions as traces to the [Invariant Explorer](https://explorer.invariantlabs.ai/). +Gateway automatically captures and forwards agent interactions as traces to the [Invariant Explorer](https://explorer.invariantlabs.ai/), giving you insights into what your agents are doing.
From 7c936eeced75ffcf674bc8d1a79bcae7065522be Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:01:54 +0100 Subject: [PATCH 06/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a68bcfa..a515905 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic). -Gateway automatically captures and forwards agent interactions as traces to the [Invariant Explorer](https://explorer.invariantlabs.ai/), giving you insights into what your agents are doing. +Gateway automatically traces agent interactions and stores them in the [Invariant Explorer](https://explorer.invariantlabs.ai/), giving you insights into what your agents are doing.
From ed2ca7cbd690e2cfc65b9352b183778393876d20 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:02:53 +0100 Subject: [PATCH 07/34] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a515905..040e7c2 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ To get started with Gateway, follow the integration guides below depending on th "Invariant-Authorization": "Bearer your-invariant-api-key" }, ), - base_url="http://localhost:8005/api/v1/proxy/{add-your-dataset-name-here}/openai", + base_url="https://explorer.invariantlabs.ai/api/v1/proxy/{add-your-dataset-name-here}/openai", ) ``` @@ -74,7 +74,7 @@ To get started with Gateway, follow the integration guides below depending on th "Invariant-Authorization": "Bearer your-invariant-api-key" }, ), - base_url="http://localhost:8005/api/v1/proxy/{add-your-dataset-name-here}/anthropic", + base_url="https://explorer.invariantlabs.ai/api/v1/proxy/{add-your-dataset-name-here}/anthropic", ) ``` From a5fbfdaedde9204828c646df6353e1e62de0d335 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:03:30 +0100 Subject: [PATCH 08/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 040e7c2..1131fad 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ SWE-agent does not support custom headers, so you **cannot** pass the Invariant Run `sweagent` with the following flag: ```bash ---agent.model.api_base=http://localhost:8005/api/v1/proxy/{add-your-dataset-name-here}/openai +--agent.model.api_base=https://explorer.invariantlabs.ai/api/v1/proxy/{add-your-dataset-name-here}/openai ``` > **Note:** Do not include the curly braces `{}`. From 67830f30ea21372f7778fd5b048186bfaac20d91 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:03:52 +0100 Subject: [PATCH 09/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1131fad..2f840d6 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ See below for example integrations with popular agents. ##### **Step 1: Modify the API Base** -Enable the `Advanced Options` toggle under settings and update the `Base URL`: +Enable the `Advanced Options` toggle under settings and update the `Base URL` to `https://explorer.invariantlabs.ai/api/v1/proxy/{add-your-dataset-name-here}/openai`. From 58f7ccf7c94c29ff7ed97bce26b092321d48f128 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:04:13 +0100 Subject: [PATCH 10/34] update readme --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f840d6..cc14692 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,11 @@ See below for example integrations with popular agents. ##### **Step 1: Modify the API Base** -Enable the `Advanced Options` toggle under settings and update the `Base URL` to `https://explorer.invariantlabs.ai/api/v1/proxy/{add-your-dataset-name-here}/openai`. +Enable the `Advanced Options` toggle under settings and update the `Base URL` to the following + +``` +https://explorer.invariantlabs.ai/api/v1/proxy/{add-your-dataset-name-here}/openai +``` From 5a5d1cfb84a3d6317e1d5f0dc37e4ef27c8b2b6b Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:07:09 +0100 Subject: [PATCH 11/34] update readme --- resources/images/overview.svg | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/resources/images/overview.svg b/resources/images/overview.svg index 25a62dc..0deb4f1 100644 --- a/resources/images/overview.svg +++ b/resources/images/overview.svg @@ -1,8 +1,8 @@ - + Group 10 - + @@ -41,8 +41,20 @@ - - + + + + + + + + + + + + + + \ No newline at end of file From 101bfc4b21630feec00f056095cc03fc002101dc Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:08:37 +0100 Subject: [PATCH 12/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc14692..b86447a 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Gateway automatically traces agent interactions and stores them in the [Invarian ## **Quickstart for Users** -Looking to observe and secure AI agents in your organization? See our [quickstart guide for users](https://explorer.invariantlabs.ai/docs/explorer/Explorer_API/1_client_setup/) to get started. +Looking to observe and secure AI agents in your organization? See our [quickstart guide for users](#quickstart-for-users) to get started. ## **Quickstart for Developers** From d4a6a62da0035388e906e0a184b8e19d4ccee1eb Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:09:09 +0100 Subject: [PATCH 13/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b86447a..26debda 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ To get started with Gateway, follow the integration guides below depending on th --- -## **Quickstart for Users** +## Quickstart for Users If you are not building an agent yourself but would like to observe and secure AI agents in your organization, you can do so by configuring the agents to use the Gateway. From 98483775b88212c559955189624c3ac08d1a97ab Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:09:40 +0100 Subject: [PATCH 14/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 26debda..c260356 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Gateway automatically traces agent interactions and stores them in the [Invarian - [x] **Seamless forwarding and LLM streaming** to OpenAI, Anthropic, and other LLM providers. - [x] **Store and organize runtime traces** in the Invariant Explorer. -## **Quickstart for Users** +## **Quickstart for Organizations** Looking to observe and secure AI agents in your organization? See our [quickstart guide for users](#quickstart-for-users) to get started. From a317293ae043bf801a33593519690ad558c4882f Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:12:58 +0100 Subject: [PATCH 15/34] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c260356..906f4fd 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,11 @@ Gateway automatically traces agent interactions and stores them in the [Invarian - [x] **Seamless forwarding and LLM streaming** to OpenAI, Anthropic, and other LLM providers. - [x] **Store and organize runtime traces** in the Invariant Explorer. -## **Quickstart for Organizations** +## **User Quickstart** Looking to observe and secure AI agents in your organization? See our [quickstart guide for users](#quickstart-for-users) to get started. -## **Quickstart for Developers** +## **Quickstart for Security Teams and Users** To get started with Gateway, follow the integration guides below depending on the LLM provider you are using. From e8a21c07339d79fb976ea2080eb3dfd76c9f92bd Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:13:19 +0100 Subject: [PATCH 16/34] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 906f4fd..20dcb77 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,11 @@ Gateway automatically traces agent interactions and stores them in the [Invarian - [x] **Seamless forwarding and LLM streaming** to OpenAI, Anthropic, and other LLM providers. - [x] **Store and organize runtime traces** in the Invariant Explorer. -## **User Quickstart** +## **Quickstart for Teams and Users** Looking to observe and secure AI agents in your organization? See our [quickstart guide for users](#quickstart-for-users) to get started. -## **Quickstart for Security Teams and Users** +## **Quickstart for Developers** To get started with Gateway, follow the integration guides below depending on the LLM provider you are using. From b71940fac8daaee07329c0d8311bc52388d6923d Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:38:45 +0100 Subject: [PATCH 17/34] update readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 20dcb77..1b7d48d 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Looking to observe and secure AI agents in your organization? See our [quickstar ## **Quickstart for Developers** -To get started with Gateway, follow the integration guides below depending on the LLM provider you are using. +To add Gateway to your agentic system, simply follow the integration guides below depending on the LLM provider you are using. ## **Integration Guides** @@ -151,9 +151,9 @@ This setup ensures that SWE-agent works seamlessly with Invariant Proxy, maintai --- -### **Run the Gateway Locally** +## **Run the Gateway Locally** -To start the Invariant Gateway, run: +First, clone this repository. To start the Invariant Gateway, run: ```bash bash run.sh build && bash run.sh up From 5ae767c6e15d9bb1f501e50cb25fde40b036e272 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:40:31 +0100 Subject: [PATCH 18/34] update readme --- README.md | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1b7d48d..d07bd3c 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,11 @@ Invariant Gateway is a lightweight _zero-configuration_ service that acts as an Gateway automatically traces agent interactions and stores them in the [Invariant Explorer](https://explorer.invariantlabs.ai/), giving you insights into what your agents are doing. -

-Invariant Proxy Diagram +Invariant Gateway Diagram

@@ -41,7 +40,7 @@ To add Gateway to your agentic system, simply follow the integration guides belo 1. Follow [these steps](https://platform.openai.com/docs/quickstart#create-and-export-an-api-key) to obtain an OpenAI API key. 2. **Modify OpenAI Client Setup** - Instead of connecting directly to OpenAI, configure your `OpenAI` client to use the proxy: + Instead of connecting directly to OpenAI, configure your `OpenAI` client to use Gateway: ```python from httpx import Client @@ -53,7 +52,7 @@ To add Gateway to your agentic system, simply follow the integration guides belo "Invariant-Authorization": "Bearer your-invariant-api-key" }, ), - base_url="https://explorer.invariantlabs.ai/api/v1/proxy/{add-your-dataset-name-here}/openai", + base_url="https://explorer.invariantlabs.ai/api/v1/gateway/{add-your-dataset-name-here}/openai", ) ``` @@ -74,7 +73,7 @@ To add Gateway to your agentic system, simply follow the integration guides belo "Invariant-Authorization": "Bearer your-invariant-api-key" }, ), - base_url="https://explorer.invariantlabs.ai/api/v1/proxy/{add-your-dataset-name-here}/anthropic", + base_url="https://explorer.invariantlabs.ai/api/v1/gateway/{add-your-dataset-name-here}/anthropic", ) ``` @@ -92,14 +91,14 @@ See below for example integrations with popular agents. [OpenHands](https://github.com/All-Hands-AI/OpenHands) (formerly OpenDevin) is a platform for software development agents powered by AI. -#### **How to Integrate OpenHands with Invariant Proxy** +#### **How to Integrate OpenHands with Invariant Gateway** ##### **Step 1: Modify the API Base** Enable the `Advanced Options` toggle under settings and update the `Base URL` to the following ``` -https://explorer.invariantlabs.ai/api/v1/proxy/{add-your-dataset-name-here}/openai +https://explorer.invariantlabs.ai/api/v1/gateway/{add-your-dataset-name-here}/openai ``` @@ -114,7 +113,7 @@ Set the API Key using the following format: > **Note:** Do not include the curly braces `{}`. -The Invariant Proxy extracts the `invariant-auth` field from the API key and correctly forwards it to Invariant Explorer while sending the actual API key to OpenAI or Anthropic. +The Invariant Gateway extracts the `invariant-auth` field from the API key and correctly forwards it to Invariant Explorer while sending the actual API key to OpenAI or Anthropic. --- @@ -122,16 +121,16 @@ The Invariant Proxy extracts the `invariant-auth` field from the API key and cor [SWE-agent](https://github.com/SWE-agent/SWE-agent) allows your preferred language model (e.g., GPT-4o or Claude Sonnet 3.5) to autonomously utilize tools for various tasks, such as fixing issues in real GitHub repositories. -#### **Using SWE-agent with Invariant Proxy** +#### **Using SWE-agent with Invariant Gateway** -SWE-agent does not support custom headers, so you **cannot** pass the Invariant API Key via `Invariant-Authorization`. However, **there is a workaround** using the Invariant Proxy. +SWE-agent does not support custom headers, so you **cannot** pass the Invariant API Key via `Invariant-Authorization`. However, **there is a workaround** using the Invariant Gateway. ##### **Step 1: Modify the API Base** Run `sweagent` with the following flag: ```bash ---agent.model.api_base=https://explorer.invariantlabs.ai/api/v1/proxy/{add-your-dataset-name-here}/openai +--agent.model.api_base=https://explorer.invariantlabs.ai/api/v1/gateway/{add-your-dataset-name-here}/openai ``` > **Note:** Do not include the curly braces `{}`. @@ -147,7 +146,7 @@ export ANTHROPIC_API_KEY={your-anthropic-api-key}|invariant-auth: {your-invarian > **Note:** Do not include the curly braces `{}`. -This setup ensures that SWE-agent works seamlessly with Invariant Proxy, maintaining compatibility while enabling full functionality. 🚀 +This setup ensures that SWE-agent works seamlessly with Invariant Gateway, maintaining compatibility while enabling full functionality. 🚀 --- @@ -159,11 +158,11 @@ First, clone this repository. To start the Invariant Gateway, run: bash run.sh build && bash run.sh up ``` -This will launch the proxy at [http://localhost:8005/api/v1/proxy/](http://localhost:8005/api/v1/proxy/docs/). +This will launch Gateway at [http://localhost:8005/api/v1/gateway/](http://localhost:8005/api/v1/gateway/docs/). ### **Set Up an Invariant API Key** -1. Follow the instructions [here](https://explorer.invariantlabs.ai/docs/explorer/api/client-setup/) to obtain an API key. This allows the proxy to push traces to [Invariant Explorer](https://explorer.invariantlabs.ai). +1. Follow the instructions [here](https://explorer.invariantlabs.ai/docs/explorer/api/client-setup/) to obtain an API key. This allows the gateway to push traces to [Invariant Explorer](https://explorer.invariantlabs.ai). --- @@ -171,7 +170,7 @@ This will launch the proxy at [http://localhost:8005/api/v1/proxy/](http://local ### **Pushing to Local Explorer** -By default the proxy points to the Production Explorer instance. To point it to your local Explorer instance, modify the `INVARIANT_API_URL` value inside `.env`. Follow instructions in `.env` on how to point to the local instance. +By default Gateway points to the public Explorer instance at `explorer.invariantlabs.ai`. To point it to your local Explorer instance, modify the `INVARIANT_API_URL` value inside `.env`. Follow instructions in `.env` on how to point to the local instance. ### **Run Tests** From cde920fceee08c564928b8096fd28f092d7ffd4d Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:41:02 +0100 Subject: [PATCH 19/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d07bd3c..4a44343 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Gateway automatically traces agent interactions and stores them in the [Invarian ## **Quickstart for Teams and Users** -Looking to observe and secure AI agents in your organization? See our [quickstart guide for users](#quickstart-for-users) to get started. +Looking to observe and secure AI agents in your organization? See our [no-code quickstart guide for users](#quickstart-for-users) to get started. ## **Quickstart for Developers** From 47570a8c5d81e97e8adf5369c9c8cefaea050e52 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:46:54 +0100 Subject: [PATCH 20/34] update readme --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ examples/swarm_agent.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 examples/swarm_agent.py diff --git a/README.md b/README.md index 4a44343..8d02584 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,45 @@ To add Gateway to your agentic system, simply follow the integration guides belo > **Note:** Do not include the curly braces `{}`. If the dataset does not exist in Invariant Explorer, it will be created before adding traces. +### **🔹 OpenAI Swarm Integration** + +Integrating directly with a specific agent framework is also supported, simply by configuring the underlying LLM client. + +For instance, [OpenAI Swarm](https://github.com/openai/swarm) relies on OpenAI's Python client, the setup is very similar to the standard OpenAI integration: + +```python +from swarm import Swarm, Agent +from openai import OpenAI +from httpx import Client +import os + +client = Swarm( + client=OpenAI( + http_client=Client(headers={"Invariant-Authorization": "Bearer " + os.getenv("INVARIANT_API_KEY", "")}), + base_url="https://explorer.invariantlabs.ai/api/v1/proxy/weather-swarm-agent/openai", + ) +) + + +def get_weather(): + return "It's sunny." + + +agent = Agent( + name="Agent A", + instructions="You are a helpful agent.", + functions=[get_weather], +) + +response = client.run( + agent=agent, + messages=[{"role": "user", "content": "What's the weather?"}], +) + +print(response.messages[-1]["content"]) +# Output: "It seems to be sunny." +``` + --- ## Quickstart for Users diff --git a/examples/swarm_agent.py b/examples/swarm_agent.py new file mode 100644 index 0000000..ecf2f28 --- /dev/null +++ b/examples/swarm_agent.py @@ -0,0 +1,34 @@ +from swarm import Swarm, Agent +from openai import OpenAI +from httpx import Client +import os + +client = Swarm( + client=OpenAI( + http_client=Client( + headers={ + "Invariant-Authorization": "Bearer " + + os.getenv("INVARIANT_API_KEY", "") + } + ), + base_url="https://explorer.invariantlabs.ai/api/v1/proxy/weather-swarm-agent/openai", + ) +) + + +def get_weather(): + return "It's sunny." + + +agent = Agent( + name="Agent A", + instructions="You are a helpful agent.", + functions=[get_weather], +) + +response = client.run( + agent=agent, + messages=[{"role": "user", "content": "What's the weather?"}], +) + +print(response.messages[-1]["content"]) From 4d410085bd2e265585fdccbd7e939643c430c118 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:47:07 +0100 Subject: [PATCH 21/34] update readme --- examples/swarm_agent.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 examples/swarm_agent.py diff --git a/examples/swarm_agent.py b/examples/swarm_agent.py deleted file mode 100644 index ecf2f28..0000000 --- a/examples/swarm_agent.py +++ /dev/null @@ -1,34 +0,0 @@ -from swarm import Swarm, Agent -from openai import OpenAI -from httpx import Client -import os - -client = Swarm( - client=OpenAI( - http_client=Client( - headers={ - "Invariant-Authorization": "Bearer " - + os.getenv("INVARIANT_API_KEY", "") - } - ), - base_url="https://explorer.invariantlabs.ai/api/v1/proxy/weather-swarm-agent/openai", - ) -) - - -def get_weather(): - return "It's sunny." - - -agent = Agent( - name="Agent A", - instructions="You are a helpful agent.", - functions=[get_weather], -) - -response = client.run( - agent=agent, - messages=[{"role": "user", "content": "What's the weather?"}], -) - -print(response.messages[-1]["content"]) From ecdccb058a82cac855438195b419ba1ea7a7702f Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:49:08 +0100 Subject: [PATCH 22/34] update readme --- README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8d02584..47aaee4 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ -
-

Invariant Gateway

+# Invariant Gateway -LLM proxy to secure and debug what your AI agents are doing. - -
+**LLM proxy to secure and debug what your AI agents are doing.** Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic). From 81426840dfe15a93c633630138cdcfc2686754ee Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:49:59 +0100 Subject: [PATCH 23/34] update readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 47aaee4..0fa4ed9 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,8 @@ This setup ensures that SWE-agent works seamlessly with Invariant Gateway, maint ## **Run the Gateway Locally** +You can also operate your own instance of the Gateway, to ensure privacy and security. + First, clone this repository. To start the Invariant Gateway, run: ```bash From 6bf0e0f83ec7ae8b7aa83d8edb550b3b9956d411 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:51:13 +0100 Subject: [PATCH 24/34] update readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0fa4ed9..ed3cb7c 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ **LLM proxy to secure and debug what your AI agents are doing.** +[Documentation](https://explorer.invariantlabs.ai/docs) + Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic). Gateway automatically traces agent interactions and stores them in the [Invariant Explorer](https://explorer.invariantlabs.ai/), giving you insights into what your agents are doing. From 550051e566b37174823550c20e3eb31a5b64264a Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:51:34 +0100 Subject: [PATCH 25/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ed3cb7c..a6ac22f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ **LLM proxy to secure and debug what your AI agents are doing.** -[Documentation](https://explorer.invariantlabs.ai/docs) +[Documentation](https://explorer.invariantlabs.ai/docs) | [Quickstart for Users](#quickstart-for-users) | [Quickstart for Developers](#quickstart-for-developers) Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic). From 3547c3d92c480ddc776c454ee114033d45fe8215 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:52:02 +0100 Subject: [PATCH 26/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a6ac22f..36f0335 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Looking to observe and secure AI agents in your organization? See our [no-code q ## **Quickstart for Developers** -To add Gateway to your agentic system, simply follow the integration guides below depending on the LLM provider you are using. +To add Gateway to your agentic system, follow onf of the integration guides below, depending on the LLM provider. ## **Integration Guides** From 2a6e4072d4ae4f2b1ab1c368d3219e893abf48b8 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:52:42 +0100 Subject: [PATCH 27/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 36f0335..6fe24bb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ **LLM proxy to secure and debug what your AI agents are doing.** -[Documentation](https://explorer.invariantlabs.ai/docs) | [Quickstart for Users](#quickstart-for-users) | [Quickstart for Developers](#quickstart-for-developers) +[Documentation](https://explorer.invariantlabs.ai/docs/gateway) | [Quickstart for Users](#quickstart-for-users) | [Quickstart for Developers](#quickstart-for-developers) Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic). From 0aed1cc74cea0b56539de739601d0ecb77db68b2 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:54:00 +0100 Subject: [PATCH 28/34] update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6fe24bb..0f892d4 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic). Gateway automatically traces agent interactions and stores them in the [Invariant Explorer](https://explorer.invariantlabs.ai/), giving you insights into what your agents are doing. +This enables you to observe, debug and scan for security issues in your agents.

From cb31ef35d3a44bdeabebccbf2fe842ec8482ebe4 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:54:13 +0100 Subject: [PATCH 29/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f892d4..c203e0c 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic). Gateway automatically traces agent interactions and stores them in the [Invariant Explorer](https://explorer.invariantlabs.ai/), giving you insights into what your agents are doing. -This enables you to observe, debug and scan for security issues in your agents. +This enables you to _observe, debug and scan for security issues_ in your agents.

From 393a74c7abd2ef15df8ab193c40b7bac5d04ffa2 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:55:09 +0100 Subject: [PATCH 30/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c203e0c..3c41491 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic). Gateway automatically traces agent interactions and stores them in the [Invariant Explorer](https://explorer.invariantlabs.ai/), giving you insights into what your agents are doing. -This enables you to _observe, debug and scan for security issues_ in your agents. +This enables you to _observe, debug and scan for security issues_ in your agents, using the [Invariant Stack for secure and reliable agents](https://github.com/invariantlabs-ai/invariant).

From ab0365c369261adfdbfbdf0caa1755d9126e4c1d Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:56:01 +0100 Subject: [PATCH 31/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c41491..cd7fa0f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic). Gateway automatically traces agent interactions and stores them in the [Invariant Explorer](https://explorer.invariantlabs.ai/), giving you insights into what your agents are doing. -This enables you to _observe, debug and scan for security issues_ in your agents, using the [Invariant Stack for secure and reliable agents](https://github.com/invariantlabs-ai/invariant). +This enables you to _observe and debug_ in your agents in [Invariant Explorer](https://explorer.invariantlabs.ai/).

From 0544209023a88936f9d74fa69e30d2f59cc14357 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:56:15 +0100 Subject: [PATCH 32/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cd7fa0f..2f49e85 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Invariant Gateway -**LLM proxy to secure and debug what your AI agents are doing.** +**LLM proxy to observe and debug what your AI agents are doing.** [Documentation](https://explorer.invariantlabs.ai/docs/gateway) | [Quickstart for Users](#quickstart-for-users) | [Quickstart for Developers](#quickstart-for-developers) From f95acd8474d7e4574a72a8295fddab579a1046e6 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:56:37 +0100 Subject: [PATCH 33/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f49e85..e99cfa5 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Invariant Gateway is a lightweight _zero-configuration_ service that acts as an intermediary between AI Agents and LLM providers (such as OpenAI and Anthropic). Gateway automatically traces agent interactions and stores them in the [Invariant Explorer](https://explorer.invariantlabs.ai/), giving you insights into what your agents are doing. -This enables you to _observe and debug_ in your agents in [Invariant Explorer](https://explorer.invariantlabs.ai/). +This enables you to _observe and debug_ your agents in [Invariant Explorer](https://explorer.invariantlabs.ai/).

From fd7b7711c10a7db68ab8ae47e0edac777846767f Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Wed, 5 Mar 2025 14:57:09 +0100 Subject: [PATCH 34/34] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e99cfa5..5224504 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ This enables you to _observe and debug_ your agents in [Invariant Explorer](http - [x] **Intercepts agents on an LLM-level** for better debugging and analysis. - [x] **Tool Calling and Computer Use Support** to capture all forms of agentic interactions. - [x] **Seamless forwarding and LLM streaming** to OpenAI, Anthropic, and other LLM providers. -- [x] **Store and organize runtime traces** in the Invariant Explorer. +- [x] **Store and organize runtime traces** in the [Invariant Explorer](https://explorer.invariantlabs.ai/). ## **Quickstart for Teams and Users**