API Reference

REST API endpoints for prompt adaptation, model discovery, and account management. All endpoints accept and return JSON.

Base URL: https://api.refrase.cc/v1

POST /api/adapt

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

Request Body

{
  "prompt": "You are a helpful assistant...",
  "model": "claude-sonnet-4-20250514",
  "task": "chat",           // optional
  "user_prompt": "Hello"    // optional
}

Response

{
  "adapted": "...",
  "original": "...",
  "changes": [
    {
      "type": "modify",
      "description": "Added XML structure tags",
      "before": "...",
      "after": "...",
      "reason": "Claude performs better with XML-delimited sections"
    }
  ],
  "model": { "id": "...", "name": "...", "provider": "..." },
  "metadata": {
    "duration_ms": 230,
    "rules_applied": 4,
    "task": "chat"
  }
}

SDK Usage

python

GET /api/models

List all supported models with their capabilities and optimization rules.

Response

[
  {
    "id": "claude-sonnet-4-20250514",
    "name": "Claude Sonnet 4",
    "provider": "anthropic",
    "capabilities": ["xml_tags", "thinking", "tool_use"]
  },
  ...
]

SDK Usage

python

GET /api/models/:id

Get details for a single model, including its full rule set.

Response

{
  "id": "claude-sonnet-4-20250514",
  "name": "Claude Sonnet 4",
  "provider": "anthropic",
  "capabilities": ["xml_tags", "thinking", "tool_use"],
  "rules": [
    {
      "id": "xml-structure",
      "description": "Wrap sections in XML tags",
      "priority": 1
    }
  ]
}

GET /api/benchmarks

Retrieve benchmark data comparing model performance with and without prompt optimization.

POST /api/share

Create a shareable link for a prompt adaptation result.

Request Body

{
  "prompt": "...",
  "adapted": "...",
  "model": "claude-sonnet-4-20250514",
  "changes": [...]
}

Response

{
  "id": "abc123",
  "url": "https://refrase.cc/s/abc123"
}

SDK Usage

python

GET /api/share/:id

Retrieve a previously shared prompt adaptation.

Authenticated Endpoints

The following endpoints require authentication via a Bearer token in the Authorization header.

Authentication Example

python
GET /api/usage

Get current usage stats and remaining quota for your account.

GET /api/dashboard

Get aggregated dashboard data including adaptation history and usage trends.

GET /api/prompts

List all saved prompts for the authenticated user.

POST /api/prompts

Save a new prompt to the user's library.

DELETE /api/prompts/:id

Delete a saved prompt by ID.

POST /api/track

Track a usage event (e.g., adaptation applied, prompt copied).