Skip to main content

pguard-llm

Prompt version control and A/B testing for LLM applications.

pip install pguard-llm

The Problem

You tweak a prompt. It gets better. You tweak it again. Now you don't remember what changed, which version was best, or how much each version costs to run.

pguard-llm fixes this — version your prompts, run them, compare them.

Quick Start

from pguard import Prompt

p = Prompt("summarize")

# Save versions
p.save("v1", "Summarize this: {text}", description="Simple")
p.save("v2", "In 3 bullet points, summarize: {text}", description="Structured")

# Run against an LLM
result = p.run(
    "v1",
    provider="openai",
    model="gpt-4o",
    api_key="sk-...",
    input_vars={"text": "Your article text here..."}
)

print(result.output)
print(result.cost_usd)
print(result.latency_ms)

# Compare v1 vs v2
comparison = p.compare("v1", "v2")
print(comparison.summary())

Supported Providers

Provider Install Models
OpenAI pip install openai gpt-4o, gpt-4o-mini, ...
Anthropic pip install anthropic claude-sonnet-4, claude-haiku-4
Gemini pip install google-genai gemini-2.5-flash, gemini-1.5-pro

Install with Provider

pip install "pguard-llm[openai]"
pip install "pguard-llm[anthropic]"
pip install "pguard-llm[gemini]"
pip install "pguard-llm[all]"

Storage Backends

# File storage (default) — zero setup
p = Prompt("summarize", storage="file")

# SQLite — better for querying
p = Prompt("summarize", storage="sqlite")

A/B Comparison

comparison = p.compare("v1", "v2")
summary = comparison.summary()

# summary contains:
# - latency_ms: avg latency per version + winner
# - cost_usd: avg cost per version + winner
# - quality_score: avg quality per version + winner
# - tokens_avg: avg tokens per version

CLI

pguard list                        # list all prompts
pguard versions summarize          # list versions
pguard show summarize v1           # show template
pguard runs summarize v1           # show run history
pguard compare summarize v1 v2     # compare versions

RunResult

result.output        # LLM response text
result.cost_usd      # Cost in USD
result.latency_ms    # Latency in milliseconds
result.tokens_in     # Input tokens
result.tokens_out    # Output tokens
result.quality_score # Quality score (0-1)
result.provider      # Provider used
result.model         # Model used

License

MIT

Release files for pguard-llm 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pguard-llm 0.1.3
File Size Uploaded
pguard_llm-0.1.3.tar.gz 16.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pguard-llm 0.1.3
File Interpreter ABI Platform
pguard_llm-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 32.2 kB

Release files / pguard_llm-0.1.3.tar.gz

Download URL pguard_llm-0.1.3.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f6b5e06414ffd7693c248338396358efe09ad38c0d535c8678d9c2ceb62658f9
BLAKE2b-256 checksum
How to use checksums
2484ddef5fc27ba47cf83791cfe854adee4a9b3ab4b018b2a3388c546bc0f1b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / pguard_llm-0.1.3-py3-none-any.whl

Download URL pguard_llm-0.1.3-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ceb52a2bb35a4caa6dd2890371a8740acc13d93f9aa76edfd30a3d6311004af
BLAKE2b-256 checksum
How to use checksums
9092fdd679ae946737d5dfae98138b2fb3052b93ff25a5ef52b34fce61d11ba3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page