> ## 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.

# Quickstart

> Begin with a guide on the fastest path to a successful outcome

Follow these steps to generate API credentials and execute a compression request.

***

## 1. Create API Key

Generate an API key in the [Curtly Dashboard](https://curtly.dev/dashboard?tab=keys). Secret keys use the `ctly_live_` prefix.

***

## 2. Execute Request

Send a `POST` request to `https://curtly.dev/api/v1/compress` with your API key:

<CodeGroup>
  ```bash cURL theme={"dark"}
  curl -X POST https://curtly.dev/api/v1/compress \
    -H "Authorization: Bearer ctly_live_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "You are a database engineer. Please make sure that you write valid JSON: {\"status\": \"ok\"}",
      "mode": "balanced",
      "protectCodeBlocks": true,
      "protectJson": true
    }'
  ```

  ```typescript TypeScript theme={"dark"}
  import { Curtly } from '@curtly/sdk';

  const curtly = new Curtly({
    apiKey: process.env.CURTLY_API_KEY || 'ctly_live_YOUR_API_KEY',
  });

  const result = await curtly.compress({
    prompt: 'You are a database engineer. Please make sure that you write valid JSON: {"status": "ok"}',
    mode: 'balanced',
    protectCodeBlocks: true,
    protectJson: true,
  });

  console.log(result.compressed);
  // Output: "Role: database engineer. Write valid JSON: {"status": "ok"}"
  ```

  ```python Python theme={"dark"}
  from curtly import Curtly

  client = Curtly(api_key="ctly_live_YOUR_API_KEY")

  response = client.compress(
      prompt='You are a database engineer. Please make sure that you write valid JSON: {"status": "ok"}',
      mode="balanced",
      protect_code_blocks=True,
      protect_json=True,
  )

  print(response.compressed)
  ```
</CodeGroup>

***

## 3. Response Structure

The endpoint returns the compressed string along with execution telemetry:

```json 200 OK theme={"dark"}
{
  "success": true,
  "compressed": "Role: database engineer. Write valid JSON: {\"status\": \"ok\"}",
  "stats": {
    "mode": "balanced",
    "originalTokens": 24,
    "finalTokens": 12,
    "savedTokens": 12,
    "savedPercent": 50.0,
    "tokenizerUsed": "cl100k_base",
    "latencyMs": 1.48,
    "stageBreakdown": {
      "deterministicSaved": 7,
      "densitySaved": 5,
      "protectedItemsCount": 1
    },
    "protectedItems": {
      "codeBlocks": 0,
      "jsonBlocks": 1,
      "variables": 0
    },
    "integrityPassed": true
  }
}
```
