Guide: Analyze API
Evaluate prompt health, calculate clarity and specificity scores, and generate automated prompt optimization suggestions with POST /v1/analyze.
Endpoint Overview
POST /v1/analyze evaluates raw prompts before model dispatch. It computes a prompt health score across three pillars: Clarity, Specificity, and Safety.
If the prompt is underspecified (such as "email John"), the endpoint suggests concrete gap-fillers like target persona, desired tone, and deliverable format.
Under the hood, /v1/analyze runs T0 deterministic scans concurrently with a fast T1 inference pass, falling back automatically via the degradation ladder if inference latency exceeds 250ms.
Request Parameters
The request payload accepts the following fields:
- prompt (string, required): The raw user prompt, between 1 and 65,536 characters.
- sequenceId (string, optional): Client-generated tracking identifier to correlate multiple revisions of the same draft prompt.
- destinationHost (string, optional): Downstream model provider hostname for latency tracking and telemetry.
Code Examples (curl, TypeScript, Python)
The examples below demonstrate analyzing a brief draft prompt to receive health diagnostics and improvement suggestions:
curl -s -X POST http://localhost:3000/v1/analyze \
-H "Content-Type: application/json" \
-H "Authorization: Bearer test-token" \
-d '{
"prompt": "email John about the contract renewal terms"
}'Response & Health Scores
The response returns a structured JSON object with diagnostic health scores and actionable suggestions:
- health.clarity (0-100): Measures grammatical completeness and whether the core task is clearly stated.
- health.specificity (0-100): Evaluates detail density, such as entities, deadlines, and format constraints.
- health.safety (0-100): Derived from detected credentials, sensitive personal data, or adversarial markers.
- suggestions (array of strings): Recommended prompt revisions to improve output quality.
- degradationTier (string): The tier that serviced the request (T0, T1, or T2).