palbaseDocs

Palbase ai · API

POST/ai/chats/{chat_id}/voice

Start a chat's voice

Starts the chat's live voice: the app's WebRTC offer in, the answer out — the audio then goes between the app and the platform's voice provider. The voice is its member's — the user who starts it, or the member the server starts it for (as): they or the server read, tell and close it, no other member. What the person asks for out loud becomes, by delegation, a turn of the chat as that member whose answer the voice says back (chat, the default), or the event ai.voice.delegated (events). What is said either way is the chat's: transcript parts of its stream and lines of its history (messages of kind voice). One voice talks in a chat at a time: a member's new voice ends the one they left open (closed replaced); another member's live voice is refused (409 voice_active). A user starts at most 5 voices an hour in the project's chats, the server's for them counted as theirs (429 too_many_voices, with Retry-After) — each is the project's spend while it lasts. Its start is the event ai.voice.started. A member whose AI is off in the project (blocked, or a limit of 0) starts none (403 user_ai_blocked); a voice a member starts is their work, its cost recorded as theirs, and one the server starts (as a member or not) is the project'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.

Request body

asstring · optionalThe member the server starts it for (the server's alone): the voice is theirs, and counts toward their starts.
contextstring · optionalWhat the voice knows as the talk opens (the server's alone), after the instructions. Given with the start, it is in the voice's instructions from its first second. Instructions and context are at most 48 KiB together.
delegation"chat" | "events" · optionalWhat becomes of what the person asks for out loud: chat (the default) — a message of the voice's member to the chat's agent, a turn of the chat, whose answer the voice says back; events — the event ai.voice.delegated, for the project's backend to have done and answer with speak (its delegation_id).
instructionsstring · optionalHow the voice speaks (the server's alone), after the chat's agent's own instructions. Given with the start, the voice speaks so from its first second — told after it (instruct), it talks without them until they are in. Instructions and context are at most 48 KiB together.
modelstring · optionalLive voice model (e.g. openai/gpt-live-1, openai/gpt-realtime, openai/gpt-realtime-mini, google/gemini-live-2.5).
transportobject · requiredVoice media transport: webrtc (browser SDP offer) or call (joining a Palbase Calls room).
voicestring · optionalThe voice (the provider's default unless said).
curl
curl -X POST "https://<your-ref>.palbase.studio/ai/chats/<chat_id>/voice" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"transport":{"type":"webrtc"}}'

Responses

201The voice, with the answer

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

429The project's request rate, or the provider's for its connection, is used up — or the project holds as much as it may at once: 32 open streams at one of the module's servers (too_many_streams), 2 pictures being made (too_many_images), 512 MiB of pictures kept here for their day (image_storage_full), or the service — or the project's share of it — holds as much of its requests at once as it takes: their bodies, an embedding request's vectors, the pictures being made (busy). Retry-After says when to try again

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

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

Operation StartChatVoice of ai's contract.