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
Quick Start
API Reference
refrase.adapt(prompt, model, task, user_prompt)
Adapt a system prompt for a specific model and task type.
| Parameter | Type | Description |
|---|---|---|
prompt | str | The system prompt to optimize |
model | str | Target model identifier |
task | TaskType | Optional. Task type for context-aware optimization |
user_prompt | str | Optional. 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