palbaseDocs

Palbase ai · API

POST/ai/chats/{chat_id}/handoff

Teleport a chat session to a new execution target

Atomically moves the chat session to a new compute/executor target (serverless, cloud, pool, or machine; palbase or acp), increments target_generation to fence superseded runners, and broadcasts session.handed_off.

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

toobject · required
when"idle" | "after_turn" | "now" · optionalWhen to cut over. `idle` (default): at once, refused with `turn_in_progress` while a turn runs. `after_turn`: at once when no turn runs; while one runs the handoff is kept (`pending_handoff` on the chat's execution) and applied when that turn has ended, and in any case before the chat's next turn starts, so that turn runs on the new target. How long that is: a message sent while the turn runs joins that turn, so the handoff waits for both; and a run Palbase starts in the chat by itself keeps the handoff pending until that run has settled. A handoff asked for again while one is pending takes its place. The target is resolved again when the handoff is applied: one that no longer resolves, such as a pool deleted since, is dropped, `pending_handoff` is cleared and the chat stays where it is. `now`: the running turn is stopped and the chat moved.
grace_secondsinteger · optionalGrace window in seconds for parking an active turn when when=now.
idempotency_keystring · optionalCaller idempotency key so retries return the same generation without double-teleporting.
curl
curl -X POST "https://<your-ref>.palbase.studio/ai/chats/<chat_id>/handoff" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"to":{"compute":{"kind":"serverless"},"executor":{"kind":"palbase"}}}'

Responses

200Handoff committed or queued

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

409The response's state refuses it

413The body is larger than the route takes

503The model service or the database did not answer; retry shortly

defaultAn error: the envelope names it (`error`) and explains it (`error_description`).

Operation HandoffChat of ai's contract.