Skip to main content

Python wrapper for the promptfoo CLI - LLM testing, red teaming, and security evaluation

Project description

Promptfoo: LLM evals & red teaming

PyPI version Python versions npm downloads MIT license Discord


📦 About this Python package

This is a lightweight wrapper that installs promptfoo via pip. It requires Node.js 20+ and executes npx promptfoo@latest under the hood.

💡 If you have Node.js installed, we recommend using npx promptfoo@latest directly for better performance:

npx promptfoo@latest init
npx promptfoo@latest eval

See the main project for the official npm package.

🐍 Use this pip wrapper when you:

  • Need to install via pip for Python-only CI/CD environments
  • Want to manage promptfoo with poetry/pipenv/pip alongside Python dependencies
  • Work in environments where pip packages are easier to approve than npm

promptfoo is a developer-friendly local tool for testing LLM applications. Stop the trial-and-error approach - start shipping secure, reliable AI apps.

Website · Getting Started · Red Teaming · Documentation · Discord

Installation

Requirements

  • Python 3.9+ (for this wrapper)
  • Node.js 20+ (required to run promptfoo)

Install from PyPI

pip install promptfoo

Alternative: Use npx (Recommended)

If you have Node.js installed, you can skip the wrapper and use npx directly:

npx promptfoo@latest init
npx promptfoo@latest eval

This is faster and gives you direct access to the latest version.

Quick Start

# Install
pip install promptfoo

# Initialize project
promptfoo init

# Run your first evaluation
promptfoo eval

See Getting Started (evals) or Red Teaming (vulnerability scanning) for more.

What can you do with Promptfoo?

  • Test your prompts and models with automated evaluations
  • Secure your LLM apps with red teaming and vulnerability scanning
  • Compare models side-by-side (OpenAI, Anthropic, Azure, Bedrock, Ollama, and more)
  • Automate checks in CI/CD
  • Review pull requests for LLM-related security and compliance issues with code scanning
  • Share results with your team

Here's what it looks like in action:

prompt evaluation matrix - web viewer

It works on the command line too:

prompt evaluation matrix - command line

It also can generate security vulnerability reports:

gen ai red team

Why Promptfoo?

  • 🚀 Developer-first: Fast, with features like live reload and caching
  • 🔒 Private: LLM evals run 100% locally - your prompts never leave your machine
  • 🔧 Flexible: Works with any LLM API or programming language
  • 💪 Battle-tested: Powers LLM apps serving 10M+ users in production
  • 📊 Data-driven: Make decisions based on metrics, not gut feel
  • 🤝 Open source: MIT licensed, with an active community

How This Wrapper Works

This Python package is a thin wrapper that:

  1. Checks if Node.js is installed
  2. Executes npx promptfoo@latest <your-args> (or uses globally installed promptfoo if available)
  3. Passes through all arguments and environment variables
  4. Returns the same exit code

The actual promptfoo logic runs via the official TypeScript package from npm. All features and commands work identically.

Python-Specific Usage

With pip

pip install promptfoo
promptfoo eval

With poetry

poetry add --group dev promptfoo
poetry run promptfoo eval

With requirements.txt

echo "promptfoo>=0.2.0" >> requirements.txt
pip install -r requirements.txt
promptfoo eval

In CI/CD (GitHub Actions example)

- name: Setup Node.js
  uses: actions/setup-node@v4
  with:
    node-version: "20"

- name: Install promptfoo
  run: pip install promptfoo

- name: Run red team tests
  run: promptfoo redteam run

Learn More

Troubleshooting

"ERROR: promptfoo requires Node.js"

The wrapper needs Node.js to run. Install it:

  • macOS: brew install node
  • Ubuntu/Debian: sudo apt install nodejs npm
  • Windows: Download from https://nodejs.org/
  • Any OS: Use nvm

Slow First Run

The first time you run promptfoo, npx downloads the latest version from npm (typically ~50MB). Subsequent runs use the cached version and are fast.

To speed this up, install promptfoo globally:

npm install -g promptfoo

The Python wrapper will automatically use the global installation when available.

Version Pinning

By default, this wrapper uses npx promptfoo@latest. To pin a specific version:

export PROMPTFOO_VERSION=0.95.0
promptfoo --version

Or install a specific version globally:

npm install -g promptfoo@0.95.0

Contributing

We welcome contributions! Check out our contributing guide to get started.

Join our Discord community for help and discussion.

For wrapper-specific issues: Report them in this repository For promptfoo features/bugs: Report in the main project

License

MIT License - Same as promptfoo

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

promptfoo-0.1.2.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

promptfoo-0.1.2-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file promptfoo-0.1.2.tar.gz.

File metadata

  • Download URL: promptfoo-0.1.2.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for promptfoo-0.1.2.tar.gz
Algorithm Hash digest
SHA256 06e023e37e0759cd5adda8882bba1ae030b2794cc4b5647e860c002522e01beb
MD5 2cdde569588b79bb5a05f5d40fa0ee62
BLAKE2b-256 2f81a53be0316dfc993c71b9eb9e47de4441e3cf05b0e9b0e7cb5de4189ad1ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for promptfoo-0.1.2.tar.gz:

Publisher: release-please.yml on promptfoo/promptfoo-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file promptfoo-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: promptfoo-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for promptfoo-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f7fae350f77602193baeb03b8df9103e61467e7cc9b22dce1d5e4eba21232dd5
MD5 a10d1aa62f77a239e78eb94cd337d0f7
BLAKE2b-256 30ff6f208ca089cfcbf2efbeadbbf162ebc71326fcb85ff96d0291ba6491f48b

See more details on using hashes here.

Provenance

The following attestation bundles were made for promptfoo-0.1.2-py3-none-any.whl:

Publisher: release-please.yml on promptfoo/promptfoo-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page