{"openapi":"3.0.3","info":{"title":"AI Prompt Optimizer API","version":"2.0.0","description":"Deterministic prompt analysis: token estimation, filler detection, clarity scoring, and rewriting. No LLM calls — runs entirely on edge, sub-10ms latency."},"servers":[{"url":"https://api.lazy-mac.com/ai-prompt-optimizer"}],"paths":{"/health":{"get":{"summary":"Health check","operationId":"healthCheck","responses":{"200":{"description":"Service health","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"service":{"type":"string"},"ts":{"type":"string","format":"date-time"}}}}}}}}},"/optimize":{"post":{"summary":"Optimize a prompt — remove filler, compress verbosity, return token savings","operationId":"optimizePost","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["prompt"],"properties":{"prompt":{"type":"string","maxLength":32000,"description":"The prompt text to optimize"}}}}}},"responses":{"200":{"description":"Optimized prompt with analysis","content":{"application/json":{"schema":{"type":"object","properties":{"original":{"type":"string"},"optimized":{"type":"string"},"token_estimate":{"type":"object","properties":{"original":{"type":"integer"},"optimized":{"type":"integer"},"saved":{"type":"integer"},"savings_pct":{"type":"number"}}},"analysis":{"type":"object"}}}}}},"400":{"description":"Bad request"}}},"get":{"summary":"Optimize a prompt (GET, query param)","operationId":"optimizeGet","parameters":[{"name":"prompt","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Optimized prompt with analysis"},"400":{"description":"Missing prompt param"}}}},"/analyze":{"post":{"summary":"Analyze a prompt for issues, clarity score, and improvement suggestions","operationId":"analyzePost","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["prompt"],"properties":{"prompt":{"type":"string","maxLength":32000}}}}}},"responses":{"200":{"description":"Prompt analysis","content":{"application/json":{"schema":{"type":"object","properties":{"prompt_length":{"type":"integer"},"token_estimate":{"type":"integer"},"issues":{"type":"array"},"suggestions":{"type":"array"},"metrics":{"type":"object"}}}}}},"400":{"description":"Bad request"}}},"get":{"summary":"Analyze a prompt (GET)","operationId":"analyzeGet","parameters":[{"name":"prompt","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Prompt analysis"},"400":{"description":"Bad request"}}}},"/estimate-tokens":{"post":{"summary":"Estimate token count — single prompt or batch up to 50","operationId":"estimateTokensPost","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"prompt":{"type":"string","description":"Single prompt"},"texts":{"type":"array","items":{"type":"string"},"maxItems":50,"description":"Batch of texts (max 50)"}}}}}},"responses":{"200":{"description":"Token estimate(s)"},"400":{"description":"Bad request"}}},"get":{"summary":"Estimate token count (GET)","operationId":"estimateTokensGet","parameters":[{"name":"prompt","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Token estimate"},"400":{"description":"Bad request"}}}},"/compare":{"post":{"summary":"Compare two prompts — winner by clarity score + token delta","operationId":"comparePost","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["prompt_a","prompt_b"],"properties":{"prompt_a":{"type":"string","maxLength":32000},"prompt_b":{"type":"string","maxLength":32000}}}}}},"responses":{"200":{"description":"Comparison result with winner","content":{"application/json":{"schema":{"type":"object","properties":{"prompt_a":{"type":"object"},"prompt_b":{"type":"object"},"comparison":{"type":"object","properties":{"winner":{"type":"string","enum":["prompt_a","prompt_b","tie"]},"token_delta":{"type":"integer"},"clarity_delta":{"type":"integer"},"reason":{"type":"string"}}}}}}}},"400":{"description":"Bad request"}}}},"/mcp":{"get":{"summary":"MCP server info (browser-friendly)","operationId":"mcpGet","responses":{"200":{"description":"MCP server metadata"}}},"post":{"summary":"MCP endpoint (JSON-RPC 2.0)","operationId":"mcpPost","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"jsonrpc":{"type":"string"},"method":{"type":"string"},"id":{"type":"integer"},"params":{"type":"object"}}}}}},"responses":{"200":{"description":"JSON-RPC response"}}}}}}