LLM judge guardrail

class opik.guardrails.guards.llm_judge.LLMJudge(name: str, instructions: str, model: str)

Bases: Guard

Guard that validates text against a natural-language policy using an LLM as a judge.

The judge runs in the SDK and calls the Opik chat completions endpoint, which uses the LLM provider configured in your Opik workspace. It does not require the guardrails backend. The judge call is logged as a nested LLM span under the guardrail span.

local: bool = True
validate_local(text: str, client: Opik) List[ValidationResult]

Run this guard locally in the SDK. Only called for guards with local = True.

Parameters:
  • text – Text to validate

  • client – Opik client, used to reach Opik backend endpoints

Returns:

List of validation results produced by this guard