الانتقال إلى المحتوى الرئيسي

POST /api/zeq/agent/page-chat

LLM page-chat bound to a state machine. Replies stream back with the kernel's actual computed values (operators, R(t), phase, proof_digest) and write a ZeqProof envelope to your audit entangled state. This is what the Pulse calls in slug-bound mode.

Auth

Authorization: Bearer zeq_ak_… OR cookie session OR (for visitor- on-hosted-page) CORS-open with the entangled state's Site SDK key attached server-side. The Pulse on /s/<slug>/ and on third-party embeds works without explicit auth — the framework attaches the key at proxy time.

Cost

25 ZEQ per turn atomic. 80% burns, 20% to foundation. If the slug-bound chain's wallet is short, returns HTTP 402 INSUFFICIENT_BALANCE and falls back to a self-heal message in the Pulse (no LLM call upstream).

Request

curl -X POST https://YOUR-FRAMEWORK/api/zeq/agent/page-chat \
-H "Authorization: Bearer zeq_ak_..." \
-H "Content-Type: application/json" \
-d '{
"slug": "zeq07090490306",
"agent_id": null,
"messages": [
{ "role": "user", "content": "What's the precision of operator KO42?" }
],
"credential_id": null
}'

Body

FieldTypeRequiredNotes
slugstringyesChain to bind the chat to.
agent_iduuidnoBind to a specific spawned agent (uses its ZID + memory). Null → chain-default thread.
messagesOpenAI-shape arrayyesLast 20 are kept; older history is summarised server-side.
credential_iduuidnoBYOK credential to use; omit → uses chain's default LLM (Fireworks free or owner's BYOK).
tools_enabledboolnoDefault true. When false, the LLM cannot call framework tools (compute, contracts, transparency).

Response · 200 OK (non-streaming)

{
"ok": true,
"agent_id": "5b7a9c12-...",
"reply": "KO42 enforces ≤0.1% precision against the Zeq metric tensor...",
"operators_invoked": ["KO42"],
"compute_results": [ { "result": {...}, "proof_digest": "abc123..." } ],
"tally_charge": {
"charged": 25,
"burned": 20,
"toFoundation": 5,
"remainingAfter": 118
},
"x_zeq_compliance_envelope": "env_2026-05-10T13:08:32Z_..."
}

The operators_invoked and compute_results arrays surface what the LLM actually called via tools — the Pulse renders these inline as proof cards under each reply.

Streaming response

Set Accept: text/event-stream to receive SSE chunks (data: {delta: "..."} lines). Useful for long replies; the Pulse streams by default.

Errors

StatusCodeCause
400slug_requiredMissing slug.
400messages_requiredEmpty messages array.
402INSUFFICIENT_BALANCEWallet < 25 ZEQ. Falls back to a self-heal message rendered by the Pulse.
404slug_not_foundSlug doesn't resolve.
429RATE_LIMITEDPer-slug quota.

CORS

This endpoint allows wildcard CORS (Access-Control-Allow-Origin: *) because it's the surface the Pulse uses cross-domain. Auth happens via the entangled state's site SDK key, attached server-side at proxy time, so the public origin never sees the key.