Skip to content

ButterIX v1 is out: versions, multiple languages, Ask AI, and a per-site MCP server, all built in. →

Ask AI chat (SSE)

POSThttps://butterix-sites.butterix.com/_biti/ai/chat

Searches the site's docs and streams an answer with numbered citations. The response is text/event-stream, with these events in order:

EventData
sources[{ n, title, heading?, url }] cited sources
text{ t } a piece of text (many times)
done{ model, sig?, notice? }
error{ message, code? }

done.sig is the server's signature for this turn; send it back with the matching assistant message in follow-ups. Turns without a valid signature aren't passed to the model as context. Questions clearly unrelated to the docs get no generated answer: text is a fixed note and done is { model: null, notice: "offtopic" }. When the site reaches its daily limit, only related docs are returned and done is { model: null, notice: "budget" }.

Requirements on the hosted platform:

  • Requests must come from the site's own pages (Origin matches the site and Sec-Fetch-Site is same-origin); otherwise 403.
  • Sites built with a recent version must also send a session token in the X-Biti-AI-Token header. If it's missing or expired you get 401 (code: "ai_token"); fetch a new one and retry.

Rate limits: 12 per minute and 200 per day per IP (per /64 for IPv6); 60 per minute and 1000 per day per network (/24 for IPv4, /48 for IPv6); at most 2 answers at a time per IP. Returns 404 when the site has Ask AI turned off, and 503 when no key is configured or the monthly quota is used up. Because requests must be same-origin, Try it on API reference pages can't call this endpoint.

Headers

X-Biti-AI-TokenstringOptional

Session token (required for sites built with a recent version on the hosted platform)

Request

This endpoint expects an object.
messageslist of objectsRequired

Conversation history; the last message must be from user

roleenumRequired
Allowed values:
contentstringRequired<=12000 characters

user messages can have up to 512 characters

sigstringOptional

For assistant messages: the signature returned by that turn's done event

localestringOptional

Answer language; the site's first language by default

Response

Event stream · Server-sent events stream.

Errors