Getting Started
Install
Requires Python ≥ 3.11. uv is the recommended package manager.
uv add janus-security
Optional extras for providers and adapters:
uv add "janus-security[anthropic]" # Anthropic Claude
uv add "janus-security[google]" # Google Gemini
uv add "janus-security[langchain]" # LangChain adapter
uv add "janus-security[adk]" # Google ADK adapter
uv add "janus-security[all]" # Everything
Install from source:
git clone https://github.com/your-org/janus
cd janus
uv pip install -e .
To build docs locally (from the project root): uv sync --extra docs then uv run mkdocs serve.
Quick Demo (Under 5 Minutes)
Web app (split-panel, recommended):
uv pip install -e ".[langchain,dev]"
uv pip install fastapi "uvicorn[standard]" websockets pyyaml authzed grpcutil
cd demos && docker compose up -d && cd .. # only needed for Demo 5
uv run uvicorn demos.app:app --reload
Open http://localhost:8000, select a scenario, and click Start Demo. See Demo for details.
CLI (single scenario):
uv run python -m examples.run demo1_poisoned_readme --protected
This runs the Poisoned README scenario: Janus blocks read_file on .env and fetch_url to attacker URLs. See Demo for all scenarios and the web app.
Minimal Example
from janus import JanusAgent
agent = JanusAgent(
model="openai/gpt-4o",
api_key="sk-...", # or set OPENAI_API_KEY
use_builtin_tools=True,
policy="policies.json",
system_prompt="You are a helpful coding assistant.",
)
response = agent.run("List the Python files in the project.")
print(response)
Create a policies.json file that allows the tools your agent needs. See Policy Reference for format.
How to Run Examples
Scenarios and the demo framework live under examples/. Two scenarios are implemented: demo1_poisoned_readme and demo5_taint_cascade.
-
Install: From the project root, ensure dependencies are installed (see Demo or
demos/README.mdfor the full list, includinglangchain,authzed,grpcutilfor PDE). -
CLI: Run a scenario via the runner:
bash
uv run python -m examples.run <scenario_name> [--protected | --unprotected]
Example: uv run python -m examples.run demo1_poisoned_readme --protected
- Demo 5 (PDE/SpiceDB): Start SpiceDB first:
bash
cd demos && docker compose up -d && cd ..
uv run python -m examples.run demo5_taint_cascade --protected
-
Web app: Run the split-panel demo with
uv run uvicorn demos.app:app --reloadand open http://localhost:8000. See Demo anddemos/README.md. -
Tests: Run the example test suite with
uv run pytest tests/test_examples/ -v.