Skip to content

API Reference

AIGuard exposes both a Typer-based CLI and a small Python SDK.

CLI

CommandPurpose
aiguard project initCreate aiguard.yaml in the current directory.
aiguard evaluateRun all enabled evaluation modules.
aiguard evaluate adversarialRun adversarial attack suite only.
aiguard evaluate hallucinationRun hallucination detection only.
aiguard monitorStart the monitoring API + UI.
aiguard pipelineStart the background evaluation pipeline.
aiguard devStart pipeline + monitoring API + UI together.
aiguard review serveStart the human review server.
aiguard storage migrateApply pending storage migrations.
aiguard ci githubPrint a GitHub Actions workflow.
aiguard ci gitlabPrint a GitLab CI configuration.

SDK

aiguard.configure(...)

One-time configuration. Optional — the SDK auto-reads aiguard.yaml.

python
aiguard.configure(
    sampling_rate=1.0,     # 0.0 – 1.0
    queue_max_size=10_000,
    project="my-project",
)

aiguard.chat(...)

Drop-in wrapper around litellm.completion.

python
response = aiguard.chat(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}],
    metadata={"feature": "chat-ui"},
)
# Returns the original litellm response unmodified.

TraceEvent

Dataclass passed to every trace handler. Key fields:

  • trace_id: str
  • timestamp: datetime
  • model: str
  • input: list[Message]
  • output: Message
  • latency_ms: int
  • tokens: TokenUsage
  • metadata: dict