SWE-agent Integration
SWE-agent allows your preferred language model (e.g., GPT-4o or Claude Sonnet 3.5) to autonomously utilize tools for various software engineering tasks, such as fixing issues in real GitHub repositories.
You can easily modify the SWE-agent setup to use the Invariant Gateway.
Getting the Invariant API Key
Visit the Explorer Documentation to learn how to obtain your own API key.
Adjust the API Key Format
SWE-agent does not support custom headers, so you cannot pass the Invariant API Key via the Invariant-Authorization
header as usual.
However, you can still use Gateway by relying on its support for secret key concatenation.
Instead of setting your LLM Provider's API Key normally, modify the environment variable as follows:
export OPENAI_API_KEY={your-openai-api-key};invariant-auth={your-invariant-api-key}
export ANTHROPIC_API_KEY={your-anthropic-api-key};invariant-auth={your-invariant-api-key}
Modify the API Base
Run sweagent
with the following additional flag:
--agent.model.api_base=https://explorer.invariantlabs.ai/api/v1/gateway/{add-your-dataset-name-here}/openai
Note: Do not include the curly braces
{}
.
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.
This will automatically trace your agent interactions in Invariant Explorer.