Compare LLM prompts side by side โ no config, no dashboard, just a table
Project description
compare-prompts
Compare LLM prompts side by side. No config files. No dashboards. No signup.
๐ฆ View on PyPI | ๐ View on GitHub
pip install compare-prompts
What is this?
You have two prompts. You changed one word. Did it actually change anything?
- Running them manually takes 30 minutes of eyeballing
- Setting up promptfoo requires YAML config and predefined "correct" answers
- Platforms like Braintrust/LangSmith require signup and send data to a dashboard
compare-prompts is the missing middle ground โ run it in your script, get a table in your terminal in seconds:
Prompt Comparison Results
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
original concise
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
avg length (tokens) 187 61 (-67%)
tone empathetic (61%) analytical (54%) ยท cautious
uses lists 67% 33%
uses headers 33% 0%
avg cost (USD) $0.0021 $0.0009
refusal rate 0% 0%
reading level high school middle school
avg sentence length 18.3 words 9.1 words (-50%)
๐ก Tip: Want to see the full raw responses? Add show_outputs=True to your compare() function
Each column is a prompt. Each row is a measured behavioral difference. No guessing.
Quickstart
Step 1 โ Install
pip install compare-prompts
Step 2 โ Get an API key
Already have a
.envfile with an API key? Skip this step entirely โ compare-prompts will pick it up automatically.
You need an API key for whichever provider you want to use. Create a .env file in your project root:
OPENAI_API_KEY=sk-...
compare-prompts reads .env files automatically. No extra setup.
| Provider | Where to get a key | Env variable | Free? |
|---|---|---|---|
| OpenAI | platform.openai.com/api-keys | OPENAI_API_KEY |
No |
| Anthropic | console.anthropic.com | ANTHROPIC_API_KEY |
No |
| Google Gemini | aistudio.google.com/apikey | GEMINI_API_KEY |
Yes |
| Groq | console.groq.com/keys | GROQ_API_KEY |
Yes |
| DeepSeek | platform.deepseek.com | DEEPSEEK_API_KEY |
No |
| Ollama | ollama.com | None needed | Yes (local) |
New here? Groq and Google Gemini both have free tiers โ great for trying this out without spending anything.
Step 3 โ Create your comparison file
Generate a starter file by running:
python -m compare_prompts init
This creates a test_prompts.py file in your directory. Open it up, and you'll see a template that looks like this:
from compare_prompts import compare
compare(
prompts={
# Each key is a label shown in the table column.
# Each value is the system prompt you want to test.
"original": "You are a helpful assistant.",
"concise": "You are a concise helpful assistant.",
},
inputs=[
# These are the user messages sent to each prompt.
# Use real questions your users actually ask for the most useful results.
"Explain what a database is.",
"What is recursion?",
"Write a short poem about coding.",
],
model="gpt-4o-mini" # โ change this to match your provider
)
How to edit this file:
- prompts: Swap the example text with the actual prompts you want to compare.
- inputs: Add the test questions you want to evaluate those prompts against.
- model: Change the model string to match your provider. See the Supported models section below for the exact strings to use for OpenAI, Groq, Gemini, etc.
(Note: If you don't want to use the init command, you can also just create test_prompts.py manually and paste the code above into it.)
Step 4 โ Run it
python test_prompts.py
Too slow? If you have many prompts or inputs, add
use_async=Trueto run all API calls in parallel. See Faster execution with async below.
Want to see the actual responses? Add
show_outputs=Trueto print the raw LLM output below the table. See See raw outputs below.
Step 5 โ Read the table
Running 2 prompts x 3 inputs = 6 calls... (Tip: too slow? Add use_async=True to your compare() function)
Prompt Comparison Results
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
avg length (tokens) 187 61 (-67%)
tone empathetic (61%) analytical (54%) ยท cautious
uses lists 67% 33%
uses headers 33% 0%
avg cost (USD) $0.0021 $0.0009 (-57%)
refusal rate 0% 0%
reading level high school middle school
avg sentence length 18.3 words 9.1 words (-50%)
๐ก Tip: Want to see the full raw responses? Add show_outputs=True to your compare() function
Numbers in parentheses are diffs from the first (baseline) prompt.
The tone column shows the dominant tone and its confidence. When a second tone is also strong, it appears after ยท โ e.g. analytical (54%) ยท cautious means primarily analytical with a notable cautious undertone.
What it measures
| Metric | What it tells you |
|---|---|
| avg length (tokens) | How verbose each prompt makes the model |
| tone | Dominant writing style. 9 categories: technical, formal, analytical, casual, empathetic, humorous, encouraging, cautious, assertive |
| uses lists | % of responses that used bullet points or numbered lists |
| uses headers | % of responses that used markdown headers |
| uses code blocks | % of responses that used fenced code blocks |
| avg cost (USD)* | Estimated cost per API call based on token usage |
| refusal rate | % of responses that refused to answer |
| reading level | elementary / middle school / high school / college |
| avg sentence length | Average words per sentence |
Cost calculation requires the full install: pip install "compare-prompts[all]"
Supported models
compare-prompts natively supports the top providers with no extra dependencies:
compare(..., model="gpt-4o-mini") # OpenAI
compare(..., model="gpt-4o") # OpenAI
compare(..., model="anthropic/claude-3-5-haiku-20241022") # Anthropic
compare(..., model="anthropic/claude-3-5-sonnet-20241022")# Anthropic
compare(..., model="gemini/gemini-2.0-flash") # Google Gemini (free tier)
compare(..., model="groq/llama-3.3-70b-versatile") # Groq (free tier)
compare(..., model="ollama/llama3") # Ollama (local, free)
compare(..., model="deepseek/deepseek-chat") # DeepSeek
Need an enterprise model? Install the full package to unlock 2,600+ additional models (Azure, AWS Bedrock, Vertex AI, OpenRouter, etc.) via LiteLLM:
pip install "compare-prompts[all]"
Full list: models.litellm.ai
More options
Compare more than 2 prompts
Every prompt gets its own column. Numbers show the diff from the first (baseline) prompt:
compare(
prompts={
"baseline": "You are a helpful assistant.",
"concise": "You are a concise helpful assistant.",
"formal": "You are a professional formal assistant.",
"friendly": "You are a warm friendly assistant.",
},
inputs=["your test questions"],
)
See raw outputs
Print each LLM response below the table, grouped by input:
compare(
prompts={...},
inputs=[...],
show_outputs=True,
)
Faster execution with async
Run all API calls concurrently โ useful when you have many prompt ร input combinations:
compare(
prompts={...},
inputs=[...],
use_async=True,
)
Using it in an existing project
If you already have prompts defined in your code, just import them directly. No need to copy-paste:
your-project/
โโโ main.py โ don't touch this
โโโ prompts.py โ don't touch this
โโโ .env โ don't touch this (already has your API key)
โโโ test_prompts.py โ create this one new file
from compare_prompts import compare
from prompts import PROMPT_V1, PROMPT_V2
compare(
prompts={"v1": PROMPT_V1, "v2": PROMPT_V2},
inputs=["your test questions here"],
model="gpt-4o-mini"
)
Why not promptfoo?
promptfoo is excellent. Use it if you need CI/CD integration, red-teaming, or assertion-based testing with predefined "correct" answers.
compare-prompts is for when you just want to run prompts right now and see how they behave differently โ no YAML, no config, no web server. Just a table in your terminal.
Contributing & Future Plans
Features planned for future versions:
- Interactive Wizard Mode:
python -m compare_prompts wizardโ set up a comparison interactively in the terminal, no Python file needed - Export to CSV / JSON: Save results with
export="results.csv" - Custom Metrics: Inject your own scoring functions via
custom_metrics=[my_scorer] - Live Streaming: See LLM responses stream in while waiting for the final table
- Local Caching: Skip the API call if you've already run the exact same prompt
.gitignoregenerator: Auto-add.envto.gitignoreoninitso you don't accidentally leak your keys
All contributions are welcome โ whether it's one of the above or your own idea. Open a PR.
โญ If you find this useful, a star on GitHub goes a long way! โญ
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file compare_prompts-0.3.1.tar.gz.
File metadata
- Download URL: compare_prompts-0.3.1.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
172065c77875ed0459e585301610d1dff6d24470f4b799c9e299e9f9c65265e5
|
|
| MD5 |
ddf386145299f2f3364c07f5de154aed
|
|
| BLAKE2b-256 |
0fe9869aff5e796f2d8d3802eaa220304a304fea0290e47a139ec201f9e1f7ee
|
Provenance
The following attestation bundles were made for compare_prompts-0.3.1.tar.gz:
Publisher:
publish.yml on OmarMashal0/compare-prompts
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
compare_prompts-0.3.1.tar.gz -
Subject digest:
172065c77875ed0459e585301610d1dff6d24470f4b799c9e299e9f9c65265e5 - Sigstore transparency entry: 1818202370
- Sigstore integration time:
-
Permalink:
OmarMashal0/compare-prompts@a251eec2773613fc33e99a6ebc2695a1fe5ad41f -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/OmarMashal0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a251eec2773613fc33e99a6ebc2695a1fe5ad41f -
Trigger Event:
release
-
Statement type:
File details
Details for the file compare_prompts-0.3.1-py3-none-any.whl.
File metadata
- Download URL: compare_prompts-0.3.1-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f52f891200b0c69c68bc917415d1e2625edc8576c00c1025a83dd1ead65fec9
|
|
| MD5 |
55c49da5d71599c8db6ec0cc6cf727c5
|
|
| BLAKE2b-256 |
05e70705c9516057377f8859802ecb39ebeae0e935574e0361f206447121d5ae
|
Provenance
The following attestation bundles were made for compare_prompts-0.3.1-py3-none-any.whl:
Publisher:
publish.yml on OmarMashal0/compare-prompts
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
compare_prompts-0.3.1-py3-none-any.whl -
Subject digest:
4f52f891200b0c69c68bc917415d1e2625edc8576c00c1025a83dd1ead65fec9 - Sigstore transparency entry: 1818202387
- Sigstore integration time:
-
Permalink:
OmarMashal0/compare-prompts@a251eec2773613fc33e99a6ebc2695a1fe5ad41f -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/OmarMashal0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a251eec2773613fc33e99a6ebc2695a1fe5ad41f -
Trigger Event:
release
-
Statement type: