API Documentation
Integrate prompt optimization into your workflow.
Quick Start
Three lines of code. That's it.
import requests
r = requests.post("https://trimpt.com/api/v1/optimize",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"prompt": "your prompt here", "test_queries": ["test1"]})
print(r.json()["optimized_prompt"])Authentication
Include your API key in the Authorization header. Free tier works without a key (rate-limited by IP).
Authorization: Bearer trm_your_api_key_hereOptimize Prompt
/api/v1/optimizeResponse
{
"success": true,
"status": "OK",
"original_prompt": "You are a customer support...",
"optimized_prompt": "CloudMetrics support agent. Handle...",
"original_words": 96,
"optimized_words": 52,
"reduction_percent": 46,
"judge_score": 7.3,
"judge_details": "Tested 3 queries, scores: [7, 8, 7]",
"complexity": "MEDIUM",
"floor_words": 38,
"tokens_saved_per_request": 57,
"monthly_savings_usd": 5.13,
"variants_tested": 24,
"rounds": 4,
"dna_genes": 30,
"new_gene": "Replace verbose explanations with key:value pairs",
"processing_time_seconds": 18,
"top_strategy": "Essentialist",
"engine_version": "v3.1"
}Parameters
promptstringrequiredYour system prompt (20-2000 words)
test_queriesstring[]Questions to test quality preservation (recommended, max 3)
Response Fields
successbooleantrue if optimization succeeded
statusstring"OK" = success, "ROLLED_BACK" = quality too low (original preserved), "BLOCKED" = prompt already optimized
optimized_promptstringThe optimized system prompt
reduction_percentnumberWord count reduction percentage
judge_scorenumberAI Judge quality score (1-10). Minimum 7 for approval.
judge_detailsstringBreakdown of Judge testing (queries tested, individual scores)
complexitystring"LOW", "MEDIUM", or "HIGH" — affects adaptive floor
floor_wordsnumberMinimum words the engine will keep (adaptive floor protection)
tokens_saved_per_requestnumberTokens saved per API call
monthly_savings_usdnumberEstimated monthly savings at 1k req/day
variants_testednumberTotal mutation variants tested across all rounds
dna_genesnumberActive DNA genes in the system
new_genestring | nullNewly discovered compression gene (if any)
engine_versionstringEngine version (currently v3.1)
processing_time_secondsnumberTotal processing time
Rate Limits
Integration Examples
OpenClaw Skill
Create a SKILL.md that auto-optimizes all skills in your workspace:
---
name: trimpt-optimizer
description: Optimize all your OpenClaw skills to reduce token usage
---
# Trimpt Optimizer
Optimize all SKILL.md files in your workspace.
Usage: /trimpt-optimize
This will scan all skills, send each to Trimpt API, and save optimized versions.CI/CD (GitHub Actions)
- name: Optimize prompts
run: |
for file in prompts/*.txt; do
curl -s -X POST https://trimpt.com/api/v1/optimize \
-H "Authorization: Bearer $TRIMPT_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"prompt\":\"$(cat $file)\"}" \
| jq -r '.optimized_prompt' > "${file%.txt}_optimized.txt"
doneLangChain
from langchain.prompts import PromptTemplate
import requests
TRIMPT_KEY = "your_api_key"
def trimpt_optimize(prompt_text: str) -> str:
r = requests.post("https://trimpt.com/api/v1/optimize",
headers={"Authorization": f"Bearer {TRIMPT_KEY}"},
json={"prompt": prompt_text})
return r.json()["optimized_prompt"]
# Usage
template = PromptTemplate.from_template("...")
optimized = trimpt_optimize(template.template)