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_here

Optimize Prompt

POST/api/v1/optimize

Response

{
  "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

promptstringrequired

Your system prompt (20-2000 words)

test_queriesstring[]

Questions to test quality preservation (recommended, max 3)

Response Fields

successboolean

true if optimization succeeded

statusstring

"OK" = success, "ROLLED_BACK" = quality too low (original preserved), "BLOCKED" = prompt already optimized

optimized_promptstring

The optimized system prompt

reduction_percentnumber

Word count reduction percentage

judge_scorenumber

AI Judge quality score (1-10). Minimum 7 for approval.

judge_detailsstring

Breakdown of Judge testing (queries tested, individual scores)

complexitystring

"LOW", "MEDIUM", or "HIGH" — affects adaptive floor

floor_wordsnumber

Minimum words the engine will keep (adaptive floor protection)

tokens_saved_per_requestnumber

Tokens saved per API call

monthly_savings_usdnumber

Estimated monthly savings at 1k req/day

variants_testednumber

Total mutation variants tested across all rounds

dna_genesnumber

Active DNA genes in the system

new_genestring | null

Newly discovered compression gene (if any)

engine_versionstring

Engine version (currently v3.1)

processing_time_secondsnumber

Total processing time

Rate Limits

Free2 req/hour, 3 agents, 3 opt/month
Builder ($29)10 req/hour, 10 agents
Team ($79)100 req/hour, 25 agents
Scale ($199)1000 req/hour, 100 agents, SLA

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"
    done

LangChain

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)