One endpoint. Send text and a room; get back the Qloo-grounded rewrite with every reference's affinity, the verified swaps, and the Room Score. Same rate limits as the site.
text: string, 10–2,500 charactersroom: string, e.g. "Atlanta, ages 45–60" or "fans of Taylor Swift"suggest: optional boolean. When true, lines with no reference may get one, picked only from Qloo's audience snapshot (returned in suggestions, off until accepted)curl -X POST https://YOUR-APP-URL/api/v1/rewrite -H "Content-Type: application/json" -d '{"text": "Mornings with Brewly feel like the opening of a Friends episode.", "room": "Austin, ages 25-34"}'{
"text": "Mornings with Brewly feel like the opening of a Friends episode.",
"room": { "label": "Austin, ages 25-34", "locationQuery": "Austin", "ageBucket": "25_to_29,30_to_34" },
"finalText": "…the sentence with verified swaps applied…",
"llmOnlyText": "…the same text rewritten with no taste data…",
"references": [{
"id": "r1", "surface": "Friends", "start": 50, "end": 57,
"entityId": "…", "entityName": "Friends", "entityType": "urn:entity:tv_show",
"affinity": 0.05, "omitted": true, "status": "weak",
"swap": { "entityName": "…", "affinity": 0.94, "sharedTags": ["…"],
"originalSentence": "…", "rewrittenSentence": "…", "lengthDelta": 0.03, "accepted": true }
}],
"roomScoreBefore": 5, "roomScoreAfter": 94,
"snapshot": { "tv_show": [{ "entityId": "…", "name": "…", "affinity": 0.99 }] },
"qlooCalls": 6, "rounds": 1, "notes": [], "createdAt": "…"
}affinity is Qloo's 0–1 affinity for the room. omitted: true means Qloo resolved the reference but left it out of the room's results (treated as weak).affinity and are excluded from the Room Score.{ "error": "…" } with status 400 (bad input), 429 (rate limit) or 502 (upstream).