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

TypeScript SDK

The refrase npm package — install with npm 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
npm install refrase

Quick Start

typescript
import { adapt } from "refrase";

const result = await adapt({
  prompt: "Explain quantum computing in simple terms",
  model: "claude-sonnet-4-20250514",
  task: "chat",
  userPrompt: "What is quantum computing?",
});

console.log(result.adapted);   // The optimized prompt
console.log(result.changes);   // Array of changes made
console.log(result.model);     // Target model info

API Reference

AdaptOptions Interface

interface AdaptOptions {
  /** The system prompt to optimize */
  prompt: string;

  /** Target model identifier */
  model: string;

  /** Optional task type for context-aware optimization */
  task?: TaskType;

  /** Optional example user message for calibration */
  userPrompt?: string;
}

AdaptResult Interface

interface AdaptResult {
  /** The optimized prompt */
  adapted: string;

  /** The original prompt, unchanged */
  original: string;

  /** List of changes made during adaptation */
  changes: Change[];

  /** Target model information */
  model: ModelInfo;

  /** Metadata about the adaptation */
  metadata: {
    duration_ms: number;
    rules_applied: number;
    task: TaskType | null;
  };
}

Change Interface

interface Change {
  /** Type of change: "add" | "remove" | "modify" | "reorder" */
  type: string;

  /** Human-readable explanation */
  description: string;

  /** Original text (empty for additions) */
  before: string;

  /** Modified text (empty for removals) */
  after: string;

  /** Why this change improves the prompt */
  reason: string;
}

TaskType

type TaskType =
  | "chat"
  | "code"
  | "analysis"
  | "creative"
  | "extraction"
  | "summarization";

Listing Models

import { listModels } from "refrase";

const models = await listModels();
// Returns: ModelInfo[]

interface ModelInfo {
  id: string;
  name: string;
  provider: string;
  capabilities: string[];
}
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.