API reference
Insights
Chat answers a question. Insights answers the question nobody asked: what should someone looking at this scope notice today?
POST /v1/insights
Request
curl -X POST https://api.trytether.ge/v1/insights \
-H "X-Api-Key: $TETHER_SECRET_KEY" \
-H "X-Tether-Scope-Id: 9" \
-H "Content-Type: application/json" \
-d '{ "daysBack": 30, "maxItems": 20 }'
| Field | Type | Default | Notes |
|---|---|---|---|
daysBack | integer | 30 | The window meta.time_range reports, ending now (7 to 120). |
maxItems | integer | 20 | Accepted and ignored: insights reads no rows (see below). |
prompt | string | — | Optional steer: "focus on cost" rather than a free-form question. Its language decides the reply language when the pack does not. It reaches the model with its line breaks; past 12,000 characters (Chat:MaxPromptChars) it is cut, and the model is told so. |
includeContext | boolean | true | Accepted and ignored: insights offers no tools and loads nothing either way. |
organizationId, locationId | integer | — | Ignored. Scope comes from the credential. |
Response
The same document as /v1/chat — same content_type, same block types, same
validation and repair path. A reply that breaks the contract is repaired, or replaced by a short
safe message, and meta.fallback.mode says which (schema_repair, fallback_text); the model's
raw text never reaches a block. A failed provider call is a 200 with meta.fallback.mode: "provider_error".
{
"content_type": "application/vnd.tether.blocks.v1+json",
"version": "tether.blocks.v1",
"title": "Last 30 days",
"blocks": [
{ "type": "kpi", "id": "headline", "items": [
{ "label": "Open requests", "value": 41, "delta": 0.12, "intent": "negative" },
{ "label": "Resolved", "value": 118, "delta": 0.03, "intent": "positive" }
] },
{ "type": "text", "id": "note", "variant": "body",
"markdown": "Open requests rose 12% while resolutions rose 3%." }
],
"meta": {
"time_range": { "start": "2026-07-21", "end": "2026-08-20" },
"customer_language": "en",
"reply_language": "en"
}
}
The model is given the same instructions as on a chat turn: your domain pack's tone line, the
reply-language rule, the injection guard and the child-safety floor. meta.customer_language and
meta.reply_language are set as on chat. The block schema is sent to the model as a hint, not in
strict mode; the engine's validator is what holds the contract.
Two differences from a chat response worth knowing:
- There is no
session_id. An insights call is not a conversation and does not continue one. pending_actionsis not populated. Insights does not stage writes — an unprompted analysis is the wrong place to propose a mutation nobody asked for.
What it is for
Dashboard panels. A block of analysis on a page someone already looks at every morning.
Scheduled digests. Call it on a cron, render the blocks into email or a chat message.
Onboarding. A new user opening an empty product surface gets something to react to.
Because the response is the same typed contract as chat, the renderer you already wrote for chat renders it unchanged.
Cost
An insights call is an ordinary billable turn against the same ledger, budget breaker and tier ceilings as chat. It is usually more expensive than a typical chat turn: the analysis window is wider and the answer is longer.
Two consequences worth planning for:
- Do not call it per page view. Compute it on a schedule and cache the document; it describes a 30-day window, so it does not change between refreshes of a page.
- It counts against the same caps. A nightly digest across every scope of every tenant can trip a daily budget ceiling that conversational traffic never came near. See Cost and quotas.
When a cap has tripped, the call makes no model call and returns the same 200 document chat
returns, with no session_id:
{
"content_type": "application/vnd.tether.blocks.v1+json",
"version": "tether.blocks.v1",
"title": "AI budget reached",
"blocks": [
{ "type": "text", "id": "budget_exceeded_1", "variant": "body",
"markdown": "The AI assistant has reached its usage budget for now. It will be available again when the budget window resets — your data and all other features keep working." }
],
"meta": {
"time_range": { "start": "2026-07-21", "end": "2026-08-20" },
"customer_language": "unknown",
"reply_language": "unknown"
}
}
With no prompt and no reply language set in the pack, both language fields are unknown.
A digest job should look for the block id budget_exceeded_1 and skip rendering, rather than
mail the refusal. The free plan's request quota refuses insights with 429 plan_quota_exceeded
once chat has used the day's requests; an insights call is not itself counted toward that
quota, though its spend counts toward the plan's dollar cap.
Scope
Insights is scoped exactly like chat: the tenant comes from the key, and X-Tether-Scope-Id
narrows it. Omitting the scope header produces a tenant-wide analysis, which is meaningful for
some domains and noise for others.
For a per-site digest, call once per site with the scope header set. The results are not
comparable across scopes unless you asked for the same daysBack.