Skip to main content
Version: v0 (preview)

Quickstart

Install

pip install kelhe

Set your API key (or pass api_key= directly):

export KELHE_API_KEY="sk_kelhe_..."

Guard a tool

Wrap any tool your agent calls with guard(). Its behavior is unchanged — Kelhe just scores the action first. This example uses the OpenAI Agents adapter; the other frameworks are the same one-line wrapper.

from kelhe import Kelhe
from kelhe.adapters.openai_agents import guard
from agents import Agent

kelhe = Kelhe() # reads KELHE_API_KEY; observe-only by default

def issue_refund(amount: int, customer: str) -> str:
"Issue a refund to a customer."
return f"refunded ${amount} to {customer}"

agent = Agent(
name="billing",
instructions="process approved customer refunds",
tools=[guard(kelhe, issue_refund)],
)

Observe, then enforce

Start in Observe mode (the default): every action is scored and logged, but nothing is ever blocked. When you trust the scores, switch to Enforce and set the threshold to block at.

from kelhe import Kelhe, Mode

kelhe = Kelhe() # observe: score + log only
kelhe = Kelhe(mode=Mode.ENFORCE, risk_threshold=7.0) # block actions scoring >= 7

That's the whole loop: same code, one flag flips watching into blocking. Next, see how scoring works or wire up your framework — OpenAI Agents, LangGraph, CrewAI, AutoGen.