input.format and output.format when you create or update it, or inline via session.update.
Most agents can leave this alone — the defaults are the highest quality. Change it mainly for telephony. For how to actually stream and play the audio bytes, see Stream audio.
Input and output encodings are independent and can differ. Both default to audio/pcm (24 kHz) if omitted.
For telephony, use
audio/pcmu or audio/pcma (8 kHz) to match the phone network and avoid resampling. See Connect to Twilio for a full phone integration.
Set format.encoding under input and output. You can also pass an explicit sample_rate inside format:
Set the volume separately — see Volume. When configured inline via
session.update, output.format is immutable after session.ready and must be set on your first update.