Prompt Compression
Shorten a prompt towards a requested reduction while aiming to preserve its meaning. Returns the shorter text and estimated savings.
Pay by wallet (x402) AI-generated
prompt-compress Example
Example answer
{
"original_tokens": 14,
"removed_content": [
"This is a test",
"for"
],
"compressed_prompt": "Automated capability testing input.",
"compressed_tokens": 9,
"preserved_instructions": [
"Identify this as test input",
"Recognize it's for automated capability testing"
],
"actual_reduction_percent": 36
} Inputs
| Field | Type | Required | What it is |
|---|---|---|---|
prompt_text | string | Yes | — |
target_reduction_percent | integer | No | Default 30 |
Output fields
How reliably each field appears in a successful answer.
| Field | Type | Appears |
|---|---|---|
original_tokens | integer | Always (present in every successful answer) |
compressed_prompt | string | Always (present in every successful answer) |
compressed_tokens | integer | Always (present in every successful answer) |
actual_reduction_percent | integer | Always (present in every successful answer) |
How to call it
The same tool through each route. MCP clients reach it through Strale’s server at https://api.strale.io/mcp; the call below is what the agent sends.
# Needs an API key. max_price_cents caps what this call may cost.
curl -X POST https://api.strale.io/v1/do \
-H "Authorization: Bearer $STRALE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"capability_slug": "prompt-compress",
"inputs": {
"prompt_text": "You are a helpful AI assistant. Please help me write a comprehensive function that validates email addresses using a robust regex pattern, handling edge cases like internationalized addresses, plus-sign addressing, and subdomain TLDs."
},
"max_price_cents": 3
}' {
"tool": "strale_execute",
"arguments": {
"slug": "prompt-compress",
"inputs": {
"prompt_text": "You are a helpful AI assistant. Please help me write a comprehensive function that validates email addresses using a robust regex pattern, handling edge cases like internationalized addresses, plus-sign addressing, and subdomain TLDs."
},
"max_price_cents": 3
}
} import { Strale } from "straleio";
const strale = new Strale({ apiKey: process.env.STRALE_API_KEY! });
const result = await strale.do({
capability_slug: "prompt-compress",
inputs: {
"prompt_text": "You are a helpful AI assistant. Please help me write a comprehensive function that validates email addresses using a robust regex pattern, handling edge cases like internationalized addresses, plus-sign addressing, and subdomain TLDs."
},
max_price_cents: 3,
}); import os
from straleio import Strale, DoRequest
strale = Strale(api_key=os.environ["STRALE_API_KEY"])
result = strale.do(DoRequest(
capability_slug="prompt-compress",
inputs={
"prompt_text": "You are a helpful AI assistant. Please help me write a comprehensive function that validates email addresses using a robust regex pattern, handling edge cases like internationalized addresses, plus-sign addressing, and subdomain TLDs.",
},
max_price_cents=3,
)) # No account. The first request answers 402 with the price in USDC;
# an x402 client pays it from your wallet and repeats the request.
curl -i 'https://api.strale.io/x402/v2/prompt-compress?prompt_text=You+are+a+helpful+AI+assistant.+Please+help+me+write+a+comprehensive+function+that+validates+email+addresses+using+a+robust+regex+pattern%2C+handling+edge+cases+like+internationalized+addresses%2C+plus-sign+addressing%2C+and+subdomain+TLDs.' Limitations
Compression can remove important context
Compression may remove context that appears redundant but is semantically important for specific AI tasks
What to do instead: Test compressed prompts against your original to verify output quality is maintained before switching
Related tools
- Agent Trace Analysis €0.20
- API Docs Generator €0.20
- API Mock Responses €0.05
- Changelog Generator €0.03
- Code Converter €0.05
- Commit Message Generator €0.05