Skip to main content
Refrase
  • Pricing
Star
OverviewPython SDKTypeScript SDKAPI ReferenceMCP ServerBrowser ExtensionContributing

Python SDK

The refrase Python package — install with pip install refrase.

Heads up: this is the v0.x deterministic SDK

The published refrasepackage applies prompt-pattern adaptations locally from a static rules table. It works offline and requires no API key, but it's not the same engine as the LLM-powered refrase.cc/enhance (which reads each model's full documentation and rewrites prompts via Claude Haiku 4.5 — that's the version our research measured).

v1.0 of the package will be rewritten as an API client that calls the Refrase API with an API key — same engine as the web app. Until then this page documents the v0.x behavior.

Installation

bash
pip install refrase

Quick Start

python
import refrase

result = refrase.adapt(
    prompt="Explain quantum computing in simple terms",
    model="claude-sonnet-4-20250514",
    task="chat",
    user_prompt="What is quantum computing?",
)

print(result.adapted)   # The optimized prompt
print(result.changes)   # List of changes made
print(result.model)     # Target model info

API Reference

refrase.adapt(prompt, model, task, user_prompt)

Adapt a system prompt for a specific model and task type.

ParameterTypeDescription
promptstrThe system prompt to optimize
modelstrTarget model identifier
taskTaskTypeOptional. Task type for context-aware optimization
user_promptstrOptional. Example user message for calibration

Returns an AdaptResult object.

refrase.list_models()

Returns a list of all supported model configurations as dictionaries containing id, name, provider, and capabilities.

TaskType Enum

class TaskType(str, Enum):
    CHAT = "chat"
    CODE = "code"
    ANALYSIS = "analysis"
    CREATIVE = "creative"
    EXTRACTION = "extraction"
    SUMMARIZATION = "summarization"

Change Dataclass

@dataclass
class Change:
    type: str        # "add" | "remove" | "modify" | "reorder"
    description: str # Human-readable explanation
    before: str      # Original text (empty for additions)
    after: str       # Modified text (empty for removals)
    reason: str      # Why this change improves the prompt
Refrase

Your prompts, upgraded.

Product

  • Enhance
  • Extension
  • API
  • MCP

Research

  • Papers
  • Methodology
  • Benchmarks
  • Models

Company

  • Blog
  • Changelog
  • Pricing
  • Docs
  • GitHub
Privacy Policy·Terms of Service·All Systems Operational

© 2026 Refrase. All rights reserved.