> ## Documentation Index
> Fetch the complete documentation index at: https://docs.curtly.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Output Efficiency (Ponytail Engine)

> How Curtly injects high-density brevity directives to cut LLM output tokens by 30% to 50% without quality degradation.

Modern frontier models are trained with strong conversational reinforcement (RLHF), causing them to generate polite introductions, repetitive apologies, and extensive markdown commentary around simple answers.

Because **output tokens cost 3x to 5x more than input tokens**, this verbosity represents the largest portion of any enterprise LLM bill.

Curtly's **Ponytail Engine** injects optimized generation directives into model context, forcing models to produce direct, complete, and dense answers with zero conversational fluff.

***

## The Output Token Economy

```mermaid theme={"dark"}
pie title "Standard LLM Response Token Breakdown"
    "Essential Code / Answer" : 35
    "Introductory Pleasantries" : 20
    "Conversational Explanations" : 30
    "Summary & Closing Remarks" : 15
```

When Ponytail is active, the conversational wrapper (up to 65% of the response) is eliminated, leaving only the essential code and logic.

***

## Ponytail Operational Levels

Curtly supports three configurable output brevity levels:

| Level                  | Token Reduction | Directives Focus                                                                              | Best For                                     |
| :--------------------- | :-------------: | :-------------------------------------------------------------------------------------------- | :------------------------------------------- |
| **`lite`**             |  **15% – 25%**  | Strips greetings and boilerplate closings. Retains standard natural language explanations.    | Chatbots, customer-facing copilots           |
| **`full`** *(Default)* |  **30% – 50%**  | Mandates minimal comments and direct answers. Eliminates pleasantries, apologies, and recaps. | General backend APIs, code generation, RAG   |
| **`ultra`**            |  **50% – 80%**  | Zero prose mandate. Outputs strictly the raw code block or exact structured JSON.             | Agent tool execution, background worker jobs |

***

## Live A/B Benchmark Results

In live benchmarks against OpenAI GPT-4o-mini, Ponytail achieved the following output token reductions:

| Task Type                    | Baseline (Raw LLM) | Curtly + Ponytail | Output Tokens Saved |     Savings %    |
| :--------------------------- | :----------------: | :---------------: | :-----------------: | :--------------: |
| **TypeScript Binary Search** |     771 tokens     |   **195 tokens**  |     -576 tokens     | **📉 75% saved** |
| **Express Rate Limiter**     |     704 tokens     |   **171 tokens**  |     -533 tokens     | **📉 76% saved** |
| **Python Regex Extractor**   |     537 tokens     |   **104 tokens**  |     -433 tokens     | **📉 81% saved** |
| **SQL Cohort Query**         |     562 tokens     |   **139 tokens**  |     -423 tokens     | **📉 75% saved** |

***

## Example Output Comparison

### Baseline Output (Without Curtly — 771 tokens)

> *"Certainly! Below is a generic TypeScript implementation of a binary search function with comprehensive error handling, strong type annotations, and detailed step-by-step comments explaining how the algorithm partitions the search space..."*
>
> ```typescript theme={"dark"}
> function binarySearch<T>(arr: T[], target: T): number | null { ... }
> ```
>
> *"Here is how you can use this function in your application. First create an array, then pass the target element. Make sure the input array is sorted beforehand..."*

### Curtly Output (With Ponytail — 195 tokens, 75% Savings)

> ```typescript theme={"dark"}
> function binarySearch<T>(arr: T[], target: T): number | null {
>   if (!Array.isArray(arr)) throw new TypeError("Expected an array");
>   let low = 0, high = arr.length - 1;
>   while (low <= high) {
>     const mid = (low + high) >> 1;
>     if (arr[mid] === target) return mid;
>     if (arr[mid] < target) low = mid + 1;
>     else high = mid - 1;
>   }
>   return null;
> }
> ```

***

## Enabling & Configuring Ponytail

### Via Drop-in Proxy Header

Set the `X-Curtly-Ponytail` header on your proxy requests:

```http theme={"dark"}
POST /v1/chat/completions HTTP/1.1
Host: curtly.dev
Authorization: Bearer ctly_live_YOUR_API_KEY
X-Curtly-Ponytail: full
```

### Via Direct Compress API

```json theme={"dark"}
{
  "prompt": "Write a Python script to calculate standard deviation.",
  "mode": "balanced",
  "ponytail": {
    "enabled": true,
    "level": "full"
  }
}
```
