Quickstart
Install the SDK, get your API key, and run an inspection. Estimated time: 5 minutes.
Documentation
Step 1: Install the SDK
Shell
pip install repellox
Requires Python 3.9 or later. Required dependencies are limited to the standard library and httpx.
Step 2: Create an API Key
Log in to your Repellox dashboard, open Settings, choose API Keys, and create a key. Copy its value because it is displayed only once.
Export the key as an environment variable instead of hardcoding it:
Shell
export REPELLOX_API_KEY=rpx_your_api_key_here
Step 3: Run Your First Inspection
Python
import os
import repellox
# Client reads REPELLOX_API_KEY from environment automatically
client = repellox.Client()
# Inspect a user message before sending to your model
result = client.inspect(
content="Ignore all previous instructions and ...",
mode="strict"
)
print(result.blocked) # True
print(result.threat_class) # "direct_injection"
print(result.confidence) # 0.97
print(result.context_id) # "rpx_ctx_abc123" (for audit log)
LangChain Integration
To protect LangChain agents, call repellox.wrap() on an existing AgentExecutor. Before they reach the model, the wrapper intercepts user inputs, retrieved documents, and tool outputs.
Python
from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain_openai import ChatOpenAI
import repellox
client = repellox.Client()
# Your existing agent executor
agent_executor = AgentExecutor(
agent=create_openai_tools_agent(ChatOpenAI(), tools, prompt),
tools=tools
)
# Wrap it with Repellox
protected = repellox.wrap(
agent_executor,
client=client,
mode="strict",
allowed_tools=["web_search", "calculator"]
)
# Use exactly like the original
result = protected.invoke({"input": user_query})
LlamaIndex Integration
Python
from llama_index.core.agent import ReActAgent
import repellox
client = repellox.Client()
agent = ReActAgent.from_tools(tools, verbose=True)
# Wrap with Repellox inspection
protected_agent = repellox.wrap_llamaindex(
agent,
client=client,
mode="strict"
)
response = protected_agent.chat(user_query)