Palbase ai · API
/ai/chats/{chat_id}/pipePipe the chat into a channel
Writes the chat's stream into a channel of the project's realtime from now on — a gateway's, durable — as the platform: the members' messages, the turns, the answer as it is written (gathered into a few writes a second), the tools and subagents, each the channel's event chat {type, id?, part_id, at?, data}, under an id of its own so a retry is kept once. The types: message (a ChatMessage, as the agent got it), turn ({response_id, status: running|waiting|completed|failed|canceled|timed_out|budget_exceeded, user_id, solo, goal: {goal_id, role: work|verify, seq} — a turn of the chat's goal, waiting: {reason: approval|tool_output|subagents|message, text_offset, approval_id, tool_call_id, tool_name, input}, end: completed|failed|stopped|budget_exceeded — as the turn's event says it, error: {code, message, retryable}}), text ({response_id, offset, text}: the agent's answer as it is written, at its byte offset), reset ({response_id, offset}: discard the answer past offset), thinking ({response_id, run_id, step_id, text}: the model's reasoning as it thinks, when the agent shows it — thinking: visible), tool ({response_id, run_id, call_id, name, status: running|awaiting_output|awaiting_approval|approved|denied|expired|completed|failed|canceled, text_offset, input, output, image_count, is_error, approval_id, agent_response_id, …}), agent ({run_id, response_id, parent_response_id, name, required, status, text_offset}: a subagent at work), advisor ({response_id, run_id, seq, kind: step|final|ask, verdict: none|heads_up|answer|unreadable, rule, message, question, told}: the agent's advisor read its work — after a step, at its answer, which waits for it, or because the agent asked; told: the agent was told at its next step), goal ({goal_id, kind: set|updated|turn_started|judged|verified|status_changed|cleared, goal: {objective, rubric, status, stop_code, stop_reason, phase, max_turns, max_cost_usd}, role, seq, response_id, run_id, verdict, reason, missing, from, to, code}: the chat's goal's words), voice ({voice_id, user_id, delegation, status: started|closed, seconds, close_reason}: the chat's live voice began or ended), transcript ({id, voice_id, role: user|assistant, user_id, author_name, text, final, created_at}: a line it said either way — the chat's history's message of kind voice, by its id), seen ({response_id, offset, bytes}: the journal moved past what was handed already — it took those bytes of the answer then, the time of the text handed ahead of it), skipped ({part_id, type, seq, before_seq, after_seq, response_id, offset, bytes, reason: too_large|not_taken}: told in the place of a part the channel could not carry — past what a write to realtime carries even cut, or one realtime did not take — naming it by its part_id and type, under its sequence (seq; a page of the chat's past read before before_seq ends with it), or an answer's text by its offset: read it from a page of the chat's past), and — first, in a fork's channel — history ({forked_from: {chat_id, before_message}, part, parts, items: [{role: user|assistant, message_id, client_id, author, author_name, text, metadata, created_at, response_id, text_truncated, attachments}]}: what the fork began with, a few items a part, a long text cut in its part, its id h and the part's place). Every part carries its part_id, its own id, and is known by it, kept once — but an answer's text and its resets, which are placed by their offsets, in the order they come, and never deduplicated by part_id: where another of the platform's servers goes on with the stream it tells the last seconds of the answer again, its text cut otherwise and its resets, under part_ids told before; a part the journal told as it happened has the journal's sequence as its id too (a skipped part, the sequence of the part it stands for), and an answer's text and its resets, a part told again late (a message or a turn the stream passed before it was recorded), a fork's history and a voice's end the module recorded have none; every part of the journal its time (at: when the journal took it, RFC 3339 in UTC to the microsecond at a fixed width, 2026-11-28T06:36:15.321369Z, so its text sorts as its time — a voice's end: when its record says it ended), the same on a page of the chat's past; an answer's text read from the replica writing it, ahead of the journal, has none (the seen part after it does), and a fork's history none; text_offset says where in the answer a tool or subagent part happened. The project's backend is not in the stream: the gateway's members hear the chat from realtime, and one that was away is given what it missed there. Put again with the same channel it goes on where it is — one realtime refused is tried again; with another, from the chat's start, and nothing more is written into the one before. The project's server's alone.
Called by a signed-in user of your app, with their token and the publishable key; or your server, with the project's secret key.
Path
chat_idstring · requiredThe chat's id.Request body
topicstring · requiredA channel of the project's realtime (not one of the platform's: roles:, flags:, iap:, payments:, payment_intent:, messaging:, calls:, consents:, debug:, nor phoenix, realtime's heartbeat).curl -X PUT "https://<your-ref>.palbase.studio/ai/chats/<chat_id>/pipe" \
-H "apikey: $PALBASE_SECRET_KEY" \
-H "content-type: application/json" \
-d '{"topic":"string"}'Responses
200The pipe
400The request is malformed, or names what this module does not offer (the error names which)
401No valid credential
403A publishable key or a user's session: everything here is the project's server's, called with the secret key
404No such response, job or provider in this project
503The model service or the database did not answer; retry shortly
defaultAn error: the envelope names it (`error`) and explains it (`error_description`).
Operation PutChatPipe of ai's contract.