Skip to main content

Overview

SIPTransport makes a pipeline a SIP endpoint. The bot registers a SIP account (or dials through a registration-less trunk), answers inbound calls, places outbound calls, and exchanges audio, video, and DTMF with the pipeline. Its events and call-control methods use the same names as the dial-in and dial-out surface of DailyTransport, so a bot can switch between the two by changing the constructor and params. The transport is one half of the endpoint. A SIPConnection holds the SIP side: the account, the stack settings, and one call. The transport holds the pipeline side: frames in and out, and the events a bot handles. Each SIPTransport handles one call and owns the connection it is given. To hold several conversations on one account, create several transports, each with its own connection; more than two at a time also needs max_concurrent_calls raised on every connection.

baresip-python

The SIP stack the transport is built on

Development Runner

Run a SIP bot locally with -t sip

Installation

The sip extra installs baresip-python, the SIP stack, as a binary wheel: no compiler and no system SIP software are needed. Wheels exist for Linux (x86_64, aarch64) and macOS (Apple Silicon and Intel) on Python 3.11 to 3.14. There is no Windows wheel; on Windows, run the bot under WSL2, where the Linux wheel applies.

Prerequisites

A SIP account to register with, or a Daily domain to provision one on. With the development runner, a bot with no configured account gets a temporary Daily SIP client (DAILY_API_KEY). See DailyRESTHelper to create SIP clients yourself. The fastest way to hear the transport is that zero-configuration path: with DAILY_API_KEY set, python bot.py -t sip -d provisions a temporary SIP client, logs its dialable URI (Created Daily SIP client: sip:pipecat-<id>@<domain>.sip-us.daily.co), and deletes it when the bot exits. Dial that URI from any SIP softphone and the bot answers. The runner guide covers the other two account sources, a Daily SIP trunk and a plain SIP account on any registrar.

Configuration

SIPTransport

SIPConnection
required
The SIP account and stack settings the call runs over. A connection belongs to one transport instance.
SIPParams | None
default:"None"
Transport configuration. Defaults to SIPParams().
str | None
default:"None"
Optional name for the input processor.
str | None
default:"None"
Optional name for the output processor.

SIPParams

SIPParams extends TransportParams; the fields below are the ones it adds or overrides.

SIPConnection

A SIPConnection is the SIP endpoint itself: the account (user@domain and its credentials), the registration or trunk behaviour, the process-wide stack settings, and one call at a time. The transport does not create it, because the connection is also the application’s handle on the SIP side of the call: a bot with auto_answer=False answers or declines on it (connection.answer(), connection.reject()), connection.aor is the registered address, connection.final_stats holds the close-time statistics, and consult_connection() produces the second leg an attended transfer dials on. Its constructor arguments are plain types; the underlying binding never appears in application code. One connection serves one transport instance, since the transport binds its handlers to the connection it is given. Connections that share a user and domain share one registration: an inbound call goes to the first idle connection, and a call that finds every connection busy is refused with 486. Those connections must agree on transport, registrar, password, auth_user, audio_codecs, dtmf_mode, and extra_params. All parameters are keyword-only. Parameters marked runtime-wide configure the SIP stack the whole process shares; the first connection to connect fixes them, and a later connection that disagrees raises ValueError.
str
required
The user part of sip:user@domain.
str
required
Registration domain. May carry a port.
str
default:"\"\""
Authentication password. May be empty.
str | None
default:"None"
Digest username, when the credential store keys it differently from user (credential-list trunks).
str
default:"\"udp\""
SIP transport: "udp", "tcp", or "tls".
str | None
default:"None"
Outbound proxy to register through, when it is not the domain itself.
int
default:"240"
Seconds between registration refreshes. A refresh goes out at about 90% of the interval and, over TCP or TLS, keeps the connection inbound calls arrive on open through a NAT. The default (a refresh every 216 s) fits common cloud NAT idle timeouts; lower it for a NAT that drops idle connections sooner. 0 disables registration (trunk mode): the connection never sends REGISTER and dials targets directly. A SIP server then cannot route inbound calls to the bot, so dial-in works only when the peer reaches the bot’s listening socket directly, and on_dialin_ready never fires.
tuple | None
default:"None"
Codec preference order by stack name, for example ("opus/48000/2", "PCMU/8000/1"). None uses the stack default.
str
default:"\"rtpevent\""
How DTMF is sent: "rtpevent", "info", or "auto".
tuple | None
default:"None"
Raw baresip account parameters, each a "key=value" string appended verbatim to the SIP address-of-record, for account directives Pipecat does not model. For media-NAT traversal, ("medianat=stun", "stunserver=stun:HOST:PORT") advertises the address a STUN server reports, which reaches the bot through an endpoint-independent NAT. Behind a symmetric NAT (such as an AWS NAT Gateway) that address is unreachable: the call needs a peer that latches onto the bot’s RTP source address, or medianat=turn with a TURN server.
str | None
default:"None"
Receive jitter buffer: "off", "fixed", or "adaptive". With no mode and no jitter_buffer_ms, the buffer is fixed at 40-60 ms. The buffer holds media before the transport reads it, so its size adds to turn latency. A fixed buffer costs its minimum on every packet; an adaptive buffer widens under jitter and does not narrow again for the rest of the call. A packet arriving later than the minimum plus one packet time is discarded. Runtime-wide.
tuple | None
default:"None"
(min, max) in milliseconds for a fixed or adaptive buffer. Given alone, it selects "fixed". Not accepted with "off". Runtime-wide.
str | None
default:"None"
Restrict the stack to one local interface, by name or address, for example "127.0.0.1" for a registrar on loopback or one address of a multi-homed host. None lets the OS pick the source address per destination. Runtime-wide.
tuple
default:"()"
SIP header names whose values are included in call events. Runtime-wide.
int | None
default:"2"
Simultaneous-call cap for the process; further inbound INVITEs are refused with 486. None means unlimited. Runtime-wide.
int
default:"0"
Seconds without received RTP after which a call is closed with reason "rtp stream error". Held and send-only streams are not checked. 0 disables detection. Runtime-wide.
str | None
default:"None"
A canonical lowercase UUID identifying this endpoint across restarts (RFC 5626 +sip.instance), so a supporting registrar replaces a restarted bot’s stale registration. None sends no instance parameter. Runtime-wide.
tuple
default:"(640, 480)"
Video width and height for both directions. Runtime-wide.
float
default:"30.0"
Transmit frame rate. Runtime-wide.
int
default:"1000000"
VP8 encoder target in bits per second. Runtime-wide.
str
default:"\"warning\""
Lowest severity captured from the native SIP stack’s logging: "debug", "info", "warning", or "error". Records appear in Pipecat’s log output. Runtime-wide.
bool
default:"False"
Log every SIP message sent and received, verbatim. The trace contains call metadata and digest authentication material, so leave it off in production. Runtime-wide.
bool
default:"True"
Whether inbound calls on the account are routed to this connection. Set it to False for a connection that only places calls.

Usage

Dial-in

Dial-out

Creating the transport with the runner

Under the development runner, or on Pipecat Cloud, create_transport() builds the connection from the runner arguments, so the bot code is the same everywhere:

Video

Calls made or answered with a video direction enabled carry VP8 video. Video crosses the pipeline as RGB InputImageRawFrame and OutputImageRawFrame. With video_out_enabled, the transport sets the call’s video size and frame rate from video_out_width, video_out_height, and video_out_framerate. A peer that declines video leaves a working audio call.

Methods

All call-control methods return an error description as a str, or None on success. They do not raise.

start_dialout

Places a call and returns (session_id, error). settings takes: Returns an error when the transport already has an active call.

stop_dialout

Hangs up the dial-out call whose session id is participant_id.

send_dtmf

Sends DTMF tones on the active call. settings takes tones (the digits), and optionally sessionId and method ("telephone-event" or "sip-info"). The wire method is set by the connection’s dtmf_mode; a method that does not match it returns an error.

sip_refer

Sends a SIP REFER that asks the caller to call settings["toEndPoint"] (blind transfer). On success the call closes. Takes an optional sessionId.

sip_attended_transfer

Dials settings["toEndPoint"] on a consult leg, waits for it to answer, then sends a REFER with a Replaces header so the two peers connect directly. Both of the bot’s legs close, and the active call’s close is reported with reason "transferred". If the transfer fails, the original call resumes. Takes an optional sessionId. sip_refer() and sip_attended_transfer() need a peer that processes REFER, such as a SIP PBX or registrar (FreeSWITCH, Asterisk, Kamailio), not a carrier PSTN trunk.

sip_call_transfer

Always returns an error; Daily’s cloud-mediated transfer has no SIP equivalent. Use sip_refer() or sip_attended_transfer().

Video control

set_video_direction() changes the active call’s video mid-call by sending a re-INVITE; the audio call is untouched while the far end answers it. The direction is the bot’s side of the SDP: Three conditions apply. The call must already carry a video stream, dialed with a video setting or answered to a video offer; a plain audio call cannot grow one, and the method returns an error. Right after the call is established the stack may answer “retry shortly”, because the ACK of the first offer is still in flight; the requested direction is kept, so calling again a moment later converges. And the far end decides: a peer that declines the re-INVITE leaves the previous direction in force and the method returns the stack’s error. When a renegotiation completes, on_participant_updated fires on the transport, and the connection’s renegotiated and media_restarted events fire as well; a consumer that caches frame geometry should re-read it after media_restarted("video"). add_video() and remove_video() are set_video_direction("sendrecv") and set_video_direction("inactive"). request_keyframe() asks the far end for a video keyframe, for a consumer that joins mid-stream and wants a decodable picture sooner than the next natural keyframe; it returns nothing.

Notes

  • Transfers: A transfer that succeeds closes the bot’s side of the call. sip_call_transfer is not supported.
  • Trunk mode: reg_interval=0 is independent of SIPParams.trunk, which only builds sip:+E164@trunk URIs from phoneNumber. PSTN trunking typically uses both. Treat on_connected as the ready signal, since on_dialin_ready does not fire.
  • DTMF: Received digits that are not keypad entries (A-D) fire on_dtmf_event but produce no InputDTMFFrame.
  • Debugging: sip_trace and native_log_level on the connection (SIP_TRACE and SIP_NATIVE_LOG_LEVEL under the runner) show the signaling and the stack’s view of it; the symptom table in the runner guide covers registration failures, one-way audio, and trunk calls that never arrive.
  • Differences from DailyTransport: on_connected carries no payload, so cross-transport handlers should accept data=None. Dial-out has no per-call callerId, codecs, or videoSettings; use the connection’s user, audio_codecs, and video_size. Rooms, on_app_message, transcription, and recording events do not exist on this transport.

Event Handlers

The names follow DailyTransport, so one bot can serve both transports. The differences:
  • Only on SIPTransport: on_call_quality_stats, the close-time media statistics of a call (duration, packets, loss, jitter, round-trip time). Daily has no equivalent.
  • Only on DailyTransport, never fired here: on_joined, on_app_message, on_active_speaker_changed, on_network_connection_status_updated, and the recording and transcription events (on_recording_started, on_recording_stopped, on_recording_error, on_transcription_message, on_transcription_stopped, on_transcription_error). A handler registered for one of them on a SIPTransport is never called, so a bot written for both transports keeps working.
  • Same name, different payload or timing: on_connected carries no data here (accept data=None); on_participant_updated reports hold, resume, and video renegotiation rather than Daily’s participant property changes; on_first_participant_joined fires once per call, since each call is its own session.
Dial event data dicts carry sessionId and sipCallId. Dial-in data adds sipFrom, sipTo, and sipHeaders; dial-out data adds origin and destination; error and warning data carries errorMsg.

SIPConnection Events

SIPConnection has its own event handlers, registered with connection.add_event_handler(name, handler). Most bots use the transport’s events above; the connection’s incoming event is how a bot with auto_answer=False answers or declines a call.