API Reference
The Trunkate API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
Base URL: https://api.trunkate.ai/v1
Optimize
Submit a verbose prompt to be mathematically optimized.
POST /optimizeRequest Body
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | The natural language prompt to optimize. |
budget | number | No | The maximum target token count. Default: 1000. |
mode | string | No | strict or relaxed. Default: relaxed. |
Response
{
"text": "The optimized prompt here...",
"stats": {
"original_tokens": 120,
"optimized_tokens": 45,
"reduction": 62.5
},
"latency_ms": 12
}Example
cURL
curl https://api.trunkate.ai/v1/optimize \
-H "Authorization: Bearer $TRUNKATE_API_KEY" \
-d '{
"prompt": "Please kindly implement a binary search tree in order to help me...",
"budget": 500
}'Last updated on