Skip to content

Commit fbd5f5c

Browse files
committed
Add more docs.
1 parent 4ab71d4 commit fbd5f5c

File tree

10 files changed

+495
-29
lines changed

10 files changed

+495
-29
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Browser Use Integration
2+
3+
[Browser Use](https://github.com/browser-use/browser-use) is the easiest way to connect your AI agents with the browser.
4+
5+
You can easily modify the Browser Use setup to use the Invariant Gateway.
6+
7+
## Getting the Invariant API Key
8+
9+
Visit the [Explorer Documentation](https://explorer.invariantlabs.ai/docs/explorer) to learn how to obtain your own API key.
10+
11+
Browser Use does not support custom headers, so you **cannot** pass the Invariant API Key via `Invariant-Authorization` header. However, **there is a workaround** using the Invariant Gateway.
12+
13+
14+
## Adjust the API Key Format
15+
16+
Instead of setting your LLM Provider's API Key normally, modify the environment variable as follows:
17+
18+
```bash
19+
export OPENAI_API_KEY={your-openai-api-key};invariant-auth={your-invariant-api-key}
20+
export ANTHROPIC_API_KEY={your-anthropic-api-key};invariant-auth={your-invariant-api-key}
21+
```
22+
23+
## Code
24+
25+
```python
26+
import asyncio
27+
28+
from browser_use import Agent
29+
from dotenv import load_dotenv
30+
from langchain_openai import ChatOpenAI
31+
32+
load_dotenv()
33+
34+
35+
async def main():
36+
agent = Agent(
37+
task="Go to Reddit, search for 'browser-use', click on the first post and return the first comment.",
38+
llm=ChatOpenAI(
39+
model="gpt-4o",
40+
base_url="https://explorer.invariantlabs.ai/api/v1/gateway/{add-your-dataset-name-here}/openai",
41+
),
42+
)
43+
result = await agent.run()
44+
print(result)
45+
46+
47+
asyncio.run(main())
48+
```
49+
> **Note:** Do not include the curly braces `{}`.
50+
51+
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.
52+
53+
This will automatically trace your agent interactions in Invariant Explorer.
54+
55+
56+
## Explore other integrations
57+
58+
<div class='tiles'>
59+
60+
<a href="../microsoft-autogen" class='tile'>
61+
<span class='tile-title'>Microsoft AutoGen Integration →</span>
62+
<span class='tile-description'>Enhance and debug your Microsoft AutoGen agents effortlessly using the Gateway.</span>
63+
</a>
64+
65+
66+
<a href="../openai-swarm" class='tile'>
67+
<span class='tile-title'>OpenAI Swarm Integration →</span>
68+
<span class='tile-description'>Enhance and debug your OpenAI Swarm agents effortlessly using the Gateway.</span>
69+
</a>
70+
71+
<a href="../openhands" class='tile'>
72+
<span class='tile-title'>OpenHands Integration →</span>
73+
<span class='tile-description'>Streamline the development and debugging of OpenHands applications with the Gateway.</span>
74+
</a>
75+
76+
<a href="../swe-agent" class='tile'>
77+
<span class='tile-title'>SWE-agent Integration →</span>
78+
<span class='tile-description'>Streamline the development and debugging of SWE-agent applications with the Gateway.</span>
79+
</a>
80+
</div>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Microsoft AutoGen Integration
2+
3+
[Microsoft AutoGen]((https://github.com/microsoft/autogen)) is an open-source programming framework for building AI agents and facilitating cooperation among multiple agents to solve tasks.
4+
5+
You can easily modify the AutoGen setup to use the Invariant Gateway.
6+
7+
## Getting the Invariant API Key
8+
9+
Visit the [Explorer Documentation](https://explorer.invariantlabs.ai/docs/explorer) to learn how to obtain your own API key.
10+
11+
## Code
12+
```python
13+
import asyncio
14+
from autogen_agentchat.agents import AssistantAgent
15+
from autogen_ext.models.openai import OpenAIChatCompletionClient
16+
17+
import os
18+
from httpx import AsyncClient
19+
20+
async def main() -> None:
21+
client = OpenAIChatCompletionClient(
22+
model="gpt-4o",
23+
http_client=AsyncClient(headers={"Invariant-Authorization": "Bearer " + os.getenv("INVARIANT_API_KEY", "")}),
24+
base_url="https://explorer.invariantlabs.ai/api/v1/gateway/weather-swarm-agent/openai",
25+
)
26+
agent = AssistantAgent("assistant", client)
27+
print(await agent.run(task="Say 'Hello World!'"))
28+
29+
30+
asyncio.run(main())
31+
# Output: "Hello World!"
32+
```
33+
34+
This will automatically trace your agent interactions in Invariant Explorer.
35+
36+
## Explore other integrations
37+
38+
<div class='tiles'>
39+
40+
<a href="../openai-swarm" class='tile'>
41+
<span class='tile-title'>OpenAI Swarm Integration →</span>
42+
<span class='tile-description'>Enhance and debug your OpenAI Swarm agents effortlessly using the Gateway.</span>
43+
</a>
44+
45+
<a href="../openhands" class='tile'>
46+
<span class='tile-title'>OpenHands Integration →</span>
47+
<span class='tile-description'>Streamline the development and debugging of OpenHands applications with the Gateway.</span>
48+
</a>
49+
50+
<a href="../swe-agent" class='tile'>
51+
<span class='tile-title'>SWE-agent Integration →</span>
52+
<span class='tile-description'>Streamline the development and debugging of SWE-agent applications with the Gateway.</span>
53+
</a>
54+
55+
<a href="../browser-use" class='tile'>
56+
<span class='tile-title'>Browser Use Integration →</span>
57+
<span class='tile-description'>Optimize and troubleshoot your Browser Use applications with Invariant Gateway.</span>
58+
</a>
59+
60+
61+
</div>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# OpenAI Swarm Integration
2+
3+
[OpenAI Swarm](https://github.com/openai/swarm) relies on OpenAI's Python client, the setup is very similar to the standard OpenAI integration:
4+
5+
## Getting the Invariant API Key
6+
7+
Visit the [Explorer Documentation](https://explorer.invariantlabs.ai/docs/explorer) to learn how to obtain your own API key.
8+
9+
## Code
10+
11+
```python
12+
from swarm import Swarm, Agent
13+
from openai import OpenAI
14+
from httpx import Client
15+
import os
16+
17+
client = Swarm(
18+
client=OpenAI(
19+
http_client=Client(headers={"Invariant-Authorization": "Bearer " + os.getenv("INVARIANT_API_KEY", "")}),
20+
base_url="https://explorer.invariantlabs.ai/api/v1/gateway/weather-swarm-agent/openai",
21+
)
22+
)
23+
24+
25+
def get_weather():
26+
return "It's sunny."
27+
28+
29+
agent = Agent(
30+
name="Agent A",
31+
instructions="You are a helpful agent.",
32+
functions=[get_weather],
33+
)
34+
35+
response = client.run(
36+
agent=agent,
37+
messages=[{"role": "user", "content": "What's the weather?"}],
38+
)
39+
40+
print(response.messages[-1]["content"])
41+
# Output: "It seems to be sunny."
42+
```
43+
44+
This will automatically trace your agent interactions in Invariant Explorer.
45+
46+
## Explore other integrations
47+
48+
<div class='tiles'>
49+
50+
<a href="../microsoft-autogen" class='tile'>
51+
<span class='tile-title'>Microsoft AutoGen Integration →</span>
52+
<span class='tile-description'>Enhance and debug your Microsoft AutoGen agents effortlessly using the Gateway.</span>
53+
</a>
54+
55+
<a href="../openhands" class='tile'>
56+
<span class='tile-title'>OpenHands Integration →</span>
57+
<span class='tile-description'>Streamline the development and debugging of OpenHands applications with the Gateway.</span>
58+
</a>
59+
60+
<a href="../swe-agent" class='tile'>
61+
<span class='tile-title'>SWE-agent Integration →</span>
62+
<span class='tile-description'>Streamline the development and debugging of SWE-agent applications with the Gateway.</span>
63+
</a>
64+
65+
<a href="../browser-use" class='tile'>
66+
<span class='tile-title'>Browser Use Integration →</span>
67+
<span class='tile-description'>Optimize and troubleshoot your Browser Use applications with Invariant Gateway.</span>
68+
</a>
69+
70+
</div>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# OpenHands Integration
2+
3+
[OpenHands](https://github.com/All-Hands-AI/OpenHands) (formerly OpenDevin) is a platform for software development agents powered by AI.
4+
5+
You can easily modify the OpenHands setup to use the Invariant Gateway.
6+
7+
## Getting the Invariant API Key
8+
9+
Visit the [Explorer Documentation](https://explorer.invariantlabs.ai/docs/explorer) to learn how to obtain your own API key.
10+
11+
OpenHands does not support custom headers, so you **cannot** pass the Invariant API Key via `Invariant-Authorization` header. However, **there is a workaround** using the Invariant Gateway.
12+
13+
## Adjust the API Key Format
14+
15+
Instead of setting your LLM Provider's API Key normally, modify the environment variable as follows:
16+
17+
```bash
18+
export OPENAI_API_KEY={your-openai-api-key};invariant-auth={your-invariant-api-key}
19+
export ANTHROPIC_API_KEY={your-anthropic-api-key};invariant-auth={your-invariant-api-key}
20+
```
21+
22+
## Modify the API Base
23+
24+
Enable the `Advanced Options` toggle under settings and update the `Base URL` to the following
25+
26+
```
27+
https://explorer.invariantlabs.ai/api/v1/gateway/{add-your-dataset-name-here}/openai
28+
```
29+
30+
<img src="../../assets/openhands-integration.png" style="height: 400px !important; display: block; margin: 0 auto;"/>
31+
32+
> **Note:** Do not include the curly braces `{}`.
33+
34+
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.
35+
36+
This will automatically trace your agent interactions in Invariant Explorer.
37+
38+
## Explore other integrations
39+
40+
<div class='tiles'>
41+
42+
<a href="../microsoft-autogen" class='tile'>
43+
<span class='tile-title'>Microsoft AutoGen Integration →</span>
44+
<span class='tile-description'>Enhance and debug your Microsoft AutoGen agents effortlessly using the Gateway.</span>
45+
</a>
46+
47+
<a href="../openai-swarm" class='tile'>
48+
<span class='tile-title'>OpenAI Swarm Integration →</span>
49+
<span class='tile-description'>Enhance and debug your OpenAI Swarm agents effortlessly using the Gateway.</span>
50+
</a>
51+
52+
<a href="../swe-agent" class='tile'>
53+
<span class='tile-title'>SWE-agent Integration →</span>
54+
<span class='tile-description'>Streamline the development and debugging of SWE-agent applications with the Gateway.</span>
55+
</a>
56+
57+
<a href="../browser-use" class='tile'>
58+
<span class='tile-title'>Browser Use Integration →</span>
59+
<span class='tile-description'>Optimize and troubleshoot your Browser Use applications with Invariant Gateway.</span>
60+
</a>
61+
62+
</div>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# SWE-agent Integration
2+
3+
[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.
4+
5+
You can easily modify the SWE-agent setup to use the Invariant Gateway.
6+
7+
## Getting the Invariant API Key
8+
9+
Visit the [Explorer Documentation](https://explorer.invariantlabs.ai/docs/explorer) to learn how to obtain your own API key.
10+
11+
SWE-agent does not support custom headers, so you **cannot** pass the Invariant API Key via `Invariant-Authorization` header. However, **there is a workaround** using the Invariant Gateway.
12+
13+
14+
## Adjust the API Key Format
15+
16+
Instead of setting your LLM Provider's API Key normally, modify the environment variable as follows:
17+
18+
```bash
19+
export OPENAI_API_KEY={your-openai-api-key};invariant-auth={your-invariant-api-key}
20+
export ANTHROPIC_API_KEY={your-anthropic-api-key};invariant-auth={your-invariant-api-key}
21+
```
22+
23+
## Modify the API Base
24+
25+
Run `sweagent` with the following additional flag:
26+
27+
```bash
28+
--agent.model.api_base=https://explorer.invariantlabs.ai/api/v1/gateway/{add-your-dataset-name-here}/openai
29+
```
30+
31+
> **Note:** Do not include the curly braces `{}`.
32+
33+
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.
34+
35+
This will automatically trace your agent interactions in Invariant Explorer.
36+
37+
## Explore other integrations
38+
39+
<div class='tiles'>
40+
41+
<a href="../microsoft-autogen" class='tile'>
42+
<span class='tile-title'>Microsoft AutoGen Integration →</span>
43+
<span class='tile-description'>Enhance and debug your Microsoft AutoGen agents effortlessly using the Gateway.</span>
44+
</a>
45+
46+
<a href="../openai-swarm" class='tile'>
47+
<span class='tile-title'>OpenAI Swarm Integration →</span>
48+
<span class='tile-description'>Enhance and debug your OpenAI Swarm agents effortlessly using the Gateway.</span>
49+
</a>
50+
51+
<a href="../openhands" class='tile'>
52+
<span class='tile-title'>OpenHands Integration →</span>
53+
<span class='tile-description'>Streamline the development and debugging of OpenHands applications with the Gateway.</span>
54+
</a>
55+
56+
<a href="../browser-use" class='tile'>
57+
<span class='tile-title'>Browser Use Integration →</span>
58+
<span class='tile-description'>Optimize and troubleshoot your Browser Use applications with Invariant Gateway.</span>
59+
</a>
60+
61+
</div>
172 KB
Loading

0 commit comments

Comments
 (0)