Skip to main content

Sifaka

Simple AI text improvement through research-backed critique with complete observability

Python License Version CI/CD Coverage PyPI Documentation

What is Sifaka?

Sifaka improves AI-generated text through iterative critique using research-backed techniques. Instead of hoping your AI output is good enough, Sifaka provides a transparent feedback loop where AI systems validate and improve their own outputs.

Core Value: See exactly how AI improves your text through research-backed techniques with complete audit trails.

Installation

# Install from PyPI
pip install sifaka

# Or with uv
uv pip install sifaka

Quick Start

1. Set up your API key

Sifaka requires an LLM API key. Set one of these environment variables:

export OPENAI_API_KEY="your-api-key"     # For OpenAI (GPT-4, etc.)
# or
export ANTHROPIC_API_KEY="your-api-key"  # For Claude
# or
export GEMINI_API_KEY="your-api-key"     # For Google Gemini
# or
export GROQ_API_KEY="your-api-key"       # For Groq
# or (for local Ollama - no API key needed)
export OLLAMA_BASE_URL="http://localhost:11434/v1"  # Optional, defaults to localhost

Or create a .env file in your project:

OPENAI_API_KEY=your-api-key

Using Ollama (Local LLMs):

from sifaka import improve_sync, Config
from sifaka.core.config import LLMConfig

# Use Ollama with specific model (must set critic_model too!)
config = Config(
    llm=LLMConfig(
        provider="ollama",
        model="mistral:latest",
        critic_model="mistral:latest"  # Important: set this to use Ollama for critiques
    )
)
result = improve_sync("Climate change is bad.", config=config)

2. Use Sifaka

from sifaka import improve_sync

# Simple one-liner
result = improve_sync("Climate change is bad.")
print(result.final_text)

📚 Full Documentation →

Key Features

  • 🔬 Research-Backed: Implements Reflexion, Constitutional AI, Self-Refine, and more
  • 👁️ Complete Observability: Full audit trail of every improvement
  • 🎯 Simple API: One function does everything you need
  • 💾 Memory-Safe: Bounded history prevents memory leaks
  • ⚡ Fast: Minimal dependencies, maximum performance

Documentation

Getting Started

User Guides

Architecture & Development

Examples

Research Foundation

Sifaka implements these peer-reviewed techniques:

Development

git clone https://github.com/sifaka-ai/sifaka
cd sifaka
pip install -e ".[dev]"
pytest

See CONTRIBUTING.md for development guidelines.

License

MIT License - see LICENSE file for details.

Metadata

Release files for sifaka 0.2.0

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

Source distribution (sdist)

Source distribution for sifaka 0.2.0
File Size Uploaded Provenance
sifaka-0.2.0.tar.gz 185.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sifaka 0.2.0
File Interpreter ABI Platform
sifaka-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 411.2 kB

Release files / sifaka-0.2.0.tar.gz

Download URL sifaka-0.2.0.tar.gz
Size 185.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1140de131dfea322bfe721d3e21beec767d079cefc8619018d5d04c418364403
BLAKE2b-256 checksum
How to use checksums
85f0ab3b9da1e7c0cc746e6a0488235f2ccb6dcea1cfa53454556cc3558d7cab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / sifaka-0.2.0-py3-none-any.whl

Download URL sifaka-0.2.0-py3-none-any.whl
Size 226.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f09f9f7e9fb79512cb50037e88c7e58ab90cbb082b30892392a29a29f4cd7888
BLAKE2b-256 checksum
How to use checksums
d6c7a39f8b9cd1e271e4f2eca509ca96f4ffefe366e09cfcb68966a4d9e19e21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Security for sifaka 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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