Python SDK
Install and use the Refrase Python package to optimize prompts from your Python applications.
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