Prisma

Quickstart

Instrument an AI app and validate every response against your own policy metric — in about 5 minutes

Prisma validates the interactions your systems produce against policies you define. This quickstart instruments a small LLM app and checks every response against a policy metric you write with the 4-prompt pattern — Prisma's core building block. You won't change your model code; you add a few lines and let instrumentation do the rest.

Prefer to start from a file?

This quickstart covers a live AI application. To evaluate an existing dataset of transcripts (CSV) instead, see the Files & Jobs API.

Before you start

  • A running Prisma deployment (self-hosted or in your VPC). New to deployment? See Self-hosting.
  • A Prisma API key. In your Prisma instance, open Organization Settings → API Keys and click Generate API Key (pq_prisma_sk_…, shown once). See Installation & Setup.
  • Python 3.10+ and an LLM app to instrument. This example uses Gemini.

Install the SDK

Install the Prisma SDK alongside an instrumentor for your LLM library. The SDK wires up tracing; the instrumentor captures each model call.

pip install palqee-prisma-ai google-genai openinference-instrumentation-google-genai
uv pip install palqee-prisma-ai google-genai openinference-instrumentation-google-genai

Using OpenAI or Anthropic instead? Any OpenInference or OpenLLMetry instrumentor works the same way (e.g. openinference-instrumentation-openai).

Configure your environment

Point the SDK at your deployment with two environment variables.

export PALQEE_PRISMA_API_KEY="pq_prisma_sk_…"
export PALQEE_PRISMA_BASE_URL="https://prisma.your-company.com"

# Credentials for the LLM you call — Gemini in this example
export GEMINI_API_KEY="…"

Your workspace is resolved server-side from the API key — you never pass it.

Encode a policy and instrument your app

Define what compliant means for your use case as a policy metric, attach it in init(), then turn on instrumentation. After that, your existing app code is unchanged.

import palqee_prisma_ai
from palqee_prisma_ai import Evaluators
from google import genai
from openinference.instrumentation.google_genai import GoogleGenAIInstrumentor

# 1. Encode your policy with the 4-prompt pattern.
billing_policy = Evaluators.custom(
    name="billing-resolution",
    options=["compliant", "non_compliant"],
    score_assignments={"compliant": 1.0, "non_compliant": 0.0},
    evaluation_system_prompt=(
        "You are a contact-center QA reviewer. A response is compliant only if the "
        "agent acknowledges the customer's issue AND states a concrete next step. "
        "Classify the response as one of: {evaluation_options}."
    ),
    evaluation_human_prompt=(
        "Customer: {query}\n"
        "Agent: {response}\n"
        "Does the response comply with the policy? Choose one of {evaluation_options}."
    ),
    reeval_system_prompt=(
        "You are re-reviewing a borderline case, guided by prior expert decisions. "
        "Classify the response as one of: {evaluation_options}."
    ),
    reeval_human_prompt=(
        "Customer: {query}\n"
        "Agent: {response}\n"
        "Relevant prior expert decisions:\n{context}\n"
        "Give your final classification: {evaluation_options}."
    ),
)

# 2. Connect to Prisma and attach the policy. This creates a project + run
#    and configures tracing in one call.
palqee_prisma_ai.init(
    "billing-support",
    evaluators=[billing_policy],
)

# 3. Auto-instrument your LLM client — the only line tying your app to Prisma.
GoogleGenAIInstrumentor().instrument()

# 4. Your normal application code. This call is now traced and validated.
client = genai.Client()
response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="I was charged twice for my subscription this month — can you sort it out?",
    config={
        "system_instruction": (
            "You are a billing support agent. Acknowledge the customer's issue "
            "and tell them the concrete next step you will take."
        )
    },
)

# Prisma validates this reply against your policy. Print it to see what was judged.
print(response.text)

See the results

Prisma reads the customer message as {query} and the model's reply as {response}, then applies your billing-resolution policy. A reply that acknowledges the issue and gives a concrete next step scores compliant; one that does neither scores non_compliant.

Open the billing-support project → Overview. Your run appears under Validation Runs with the billing-resolution metric; the Validations count rises as interactions are checked, and the Ambiguous column flags ones Prisma can't decide confidently. Ambiguous cases become HITL Requests ("awaiting expert review"); the expert decisions they produce are catalogued under Controls — Prisma's metamemory — and reused on later validations.

What just happened

  1. You encoded a business rule as a policy metric — not a generic "relevance" score, but your definition of a compliant billing interaction.
  2. init() resolved a project and run and configured OpenTelemetry; the instrumentor captured each LLM call as a trace.
  3. Prisma validated every interaction against your policy automatically — moving you from sampling to 100% coverage.
  4. Ambiguous cases were routed to human review. That expert feedback is catalogued as controls in Prisma's metamemory (HSCM) and reused on future validations — so ambiguous rates fall over time.

You set two options (compliant, non_compliant) and a score_assignments map giving each a value from 0.0 to 1.0 — that's what turns a label into a metric you can track and aggregate. Every option needs a score. Don't score ambiguous: Prisma adds and scores that one itself when confidence is low, routing the case to an expert. Custom policy metrics accept 2–5 options.

What's next

On this page