Skip to main content

Prompts Aligned to Guidelines and Normalization System for OpenAI, Anthropic, xAI, and Google models

Project description

PAGANS - Prompt Optimization Framework

PAGANS Logo

PyPI version Python 3.12+ License: MIT Build Test Lint

PAGANS (Prompts Aligned to Guidelines and Normalization System) is a prompt optimization framework for LLM applications. It adapts prompts to the target model family automatically so the same prompt can perform better across OpenAI, Anthropic, Google, and xAI model series through OpenRouter.

✨ Features

  • 🚀 Fast prompt optimization for production workflows
  • 🎯 Family-aware optimization for OpenAI, Anthropic, Google, and xAI models
  • 🔍 Automatic model-family detection from short and provider-prefixed names
  • ⚡ Async-first API for single, compare, and batch operations
  • 🧠 Built-in caching to reduce repeated optimization cost
  • 🛠️ CLI support for optimize, compare, and batch workflows
  • 🔗 Unified OpenRouter integration path

Installation

pip install pagans

Quick Start

import asyncio
from pagans import PAGANSOptimizer


async def main() -> None:
    async with PAGANSOptimizer() as optimizer:
        result = await optimizer.optimize(
            prompt="Write a robust retry policy for external API calls.",
            target_model="openai/gpt-4o",
        )
        print(result.optimized)


asyncio.run(main())

Required environment variable:

export OPENROUTER_API_KEY="your-openrouter-api-key"

Optional environment variables:

export OPENROUTER_BASE_URL="https://openrouter.ai/api/v1"
export PAGANS_OPTIMIZER_MODEL="openai/gpt-4o-mini"

CLI

PAGANS installs a CLI as pagans.

pagans optimize --prompt "Explain quantum computing for beginners" --target-model gpt-4o
pagans compare \
  --prompt "Design an event-driven order system" \
  --models "gpt-4o,claude-sonnet-4,gemini-2.5-pro"
pagans batch --prompts-file ./prompts.txt --target-model gemini-2.5-pro

🎯 Model Family Series

PAGANS optimizes prompts for these model families and series:

  • OpenAI GPT series
  • Anthropic Claude series
  • Google Gemini series
  • xAI Grok series

PAGANS detects the target model family and applies the matching optimization strategy automatically.

Links

License

MIT

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

pagans-0.1.3.tar.gz (335.4 kB view details)

Uploaded Source

Built Distribution

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

pagans-0.1.3-py3-none-any.whl (40.3 kB view details)

Uploaded Python 3

File details

Details for the file pagans-0.1.3.tar.gz.

File metadata

  • Download URL: pagans-0.1.3.tar.gz
  • Upload date:
  • Size: 335.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pagans-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f04eab13acc55576ef51bc813edd07e0d701d24ae1d671b9d55c5c9e2e0eaeee
MD5 6fcf7d3d56e4b1f0640b3088160dd076
BLAKE2b-256 68e209f2a8cbe194822e3b01e4faa8778e87a25529c85550935512b148e5f362

See more details on using hashes here.

File details

Details for the file pagans-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pagans-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pagans-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e58ecc9629037f53022e2195e70b3d83ef8d69529ebe119d8ec6bbae4291a385
MD5 40a4e5957a13920c64bd268e8a347aad
BLAKE2b-256 d951d1f6ba607a835916878bc1894c16f9559c88f27999af5e0ab3a396a39648

See more details on using hashes here.

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