Compress
curl --request POST \
--url https://api.scaledown.xyz/compress/raw/ \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"context": "<string>",
"prompt": "<string>",
"scaledown": {
"rate": "<string>"
}
}
'import requests
url = "https://api.scaledown.xyz/compress/raw/"
payload = {
"context": "<string>",
"prompt": "<string>",
"scaledown": { "rate": "<string>" }
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({context: '<string>', prompt: '<string>', scaledown: {rate: '<string>'}})
};
fetch('https://api.scaledown.xyz/compress/raw/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.scaledown.xyz/compress/raw/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'context' => '<string>',
'prompt' => '<string>',
'scaledown' => [
'rate' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.scaledown.xyz/compress/raw/"
payload := strings.NewReader("{\n \"context\": \"<string>\",\n \"prompt\": \"<string>\",\n \"scaledown\": {\n \"rate\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.scaledown.xyz/compress/raw/")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"context\": \"<string>\",\n \"prompt\": \"<string>\",\n \"scaledown\": {\n \"rate\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.scaledown.xyz/compress/raw/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"context\": \"<string>\",\n \"prompt\": \"<string>\",\n \"scaledown\": {\n \"rate\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"compressed_prompt": "<string>",
"original_prompt_tokens": 123,
"compressed_prompt_tokens": 123,
"successful": true,
"latency_ms": 123,
"request_metadata": {
"compression_time_ms": 123,
"compression_rate": "<string>",
"prompt_length": 123,
"compressed_prompt_length": 123
}
}Compress
Compress
Compress a prompt and context to reduce token usage while preserving semantic meaning.
POST
/
compress
/
raw
/
Compress
curl --request POST \
--url https://api.scaledown.xyz/compress/raw/ \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"context": "<string>",
"prompt": "<string>",
"scaledown": {
"rate": "<string>"
}
}
'import requests
url = "https://api.scaledown.xyz/compress/raw/"
payload = {
"context": "<string>",
"prompt": "<string>",
"scaledown": { "rate": "<string>" }
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({context: '<string>', prompt: '<string>', scaledown: {rate: '<string>'}})
};
fetch('https://api.scaledown.xyz/compress/raw/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.scaledown.xyz/compress/raw/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'context' => '<string>',
'prompt' => '<string>',
'scaledown' => [
'rate' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.scaledown.xyz/compress/raw/"
payload := strings.NewReader("{\n \"context\": \"<string>\",\n \"prompt\": \"<string>\",\n \"scaledown\": {\n \"rate\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.scaledown.xyz/compress/raw/")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"context\": \"<string>\",\n \"prompt\": \"<string>\",\n \"scaledown\": {\n \"rate\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.scaledown.xyz/compress/raw/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"context\": \"<string>\",\n \"prompt\": \"<string>\",\n \"scaledown\": {\n \"rate\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"compressed_prompt": "<string>",
"original_prompt_tokens": 123,
"compressed_prompt_tokens": 123,
"successful": true,
"latency_ms": 123,
"request_metadata": {
"compression_time_ms": 123,
"compression_rate": "<string>",
"prompt_length": 123,
"compressed_prompt_length": 123
}
}Overview
The/compress/raw/ endpoint compresses your prompt and context, reducing token count while maintaining the semantic integrity needed for high-quality AI responses. Compression ratios of 50–70% are typical, with no meaningful degradation in downstream model output quality.
Request
string
required
Background information, instructions, or supporting text that provides context for the prompt. This is the content most aggressively compressed - structure and meaning are preserved, but redundancy is removed.
string
required
The main query or question to send to your AI model. Kept intact where possible to preserve intent.
object
required
Compression configuration.
Show scaledown fields
Show scaledown fields
string | number
required
Compression aggressiveness. Use
"auto" to let ScaleDown pick the optimal rate based on content, or pass a number between 0 and 1 to set a fixed target ratio (e.g. 0.5 = compress to 50% of original tokens).Response
string
The compressed output, ready to pass directly to your AI model in place of the original context and prompt.
number
Token count of the original input.
number
Token count of the compressed output.
boolean
Whether the compression completed successfully.
number
End-to-end request latency in milliseconds.
object
Error responses
| Status | Meaning |
|---|---|
400 Bad Request | Malformed request body or missing required fields. |
401 Unauthorized | Missing or invalid x-api-key. |
429 Too Many Requests | Rate limit exceeded. Back off and retry. |
500 Internal Server Error | Compression service unavailable. |
Authentication
Include your API key in every request using thex-api-key header.
-H "x-api-key: <your-api-key>"
Examples
Auto compression
curl -X POST https://api.scaledown.xyz/compress/raw/ \
-H "Content-Type: application/json" \
-H "x-api-key: <your-api-key>" \
-d '{
"context": "ScaleDown is a context engineering platform. It compresses AI prompts while preserving semantic integrity...",
"prompt": "Summarize what ScaleDown does in one sentence.",
"scaledown": {
"rate": "auto"
}
}'
import requests
response = requests.post(
"https://api.scaledown.xyz/compress/raw/",
headers={"x-api-key": "<your-api-key>"},
json={
"context": "ScaleDown is a context engineering platform. It compresses AI prompts while preserving semantic integrity...",
"prompt": "Summarize what ScaleDown does in one sentence.",
"scaledown": {"rate": "auto"},
},
)
print(response.json())
const response = await fetch("https://api.scaledown.xyz/compress/raw/", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": "<your-api-key>",
},
body: JSON.stringify({
context: "ScaleDown is a context engineering platform. It compresses AI prompts while preserving semantic integrity...",
prompt: "Summarize what ScaleDown does in one sentence.",
scaledown: { rate: "auto" },
}),
});
const data = await response.json();
{
"compressed_prompt": "ScaleDown: context engineering platform, compresses AI prompts, preserves semantic integrity.\n\nSummarize what ScaleDown does in one sentence.",
"original_prompt_tokens": 150,
"compressed_prompt_tokens": 65,
"successful": true,
"latency_ms": 2341,
"request_metadata": {
"compression_time_ms": 2341,
"compression_rate": "auto",
"prompt_length": 425,
"compressed_prompt_length": 189
}
}
Fixed compression rate
Pass a number forrate when you need a guaranteed token budget.
curl -X POST https://api.scaledown.xyz/compress/raw/ \
-H "Content-Type: application/json" \
-H "x-api-key: <your-api-key>" \
-d '{
"context": "...",
"prompt": "What are the key points?",
"scaledown": {
"rate": 0.4
}
}'
import requests
response = requests.post(
"https://api.scaledown.xyz/compress/raw/",
headers={"x-api-key": "<your-api-key>"},
json={
"context": "...",
"prompt": "What are the key points?",
"scaledown": {"rate": 0.4},
},
)
print(response.json())
const response = await fetch("https://api.scaledown.xyz/compress/raw/", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": "<your-api-key>",
},
body: JSON.stringify({
context: "...",
prompt: "What are the key points?",
scaledown: { rate: 0.4 },
}),
});
const data = await response.json();
Notes
"auto"rate is recommended for most use cases. Fixed rates below0.3may noticeably affect output quality on dense technical content.- The
compressed_promptfield is a single string - pass it as the full prompt to your downstream model, replacing bothcontextandprompt. - Token counts are estimated using the same tokenizer as the target model family. Exact counts may vary slightly depending on the model you use downstream.
Authorizations
Body
application/json