Skip to Content
API Reference

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 /optimize

Request Body

ParameterTypeRequiredDescription
promptstringYesThe natural language prompt to optimize.
budgetnumberNoThe maximum target token count. Default: 1000.
modestringNostrict 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 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