> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pipecat.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# SIP Transport

> Native SIP calling with SIPTransport, SIPConnection, and SIPParams: dial-in, dial-out, DTMF, transfers, and video.

## 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`](https://docs.pipecat.ai/api-reference/server/services/transport/daily), so a bot can switch between the two by changing the constructor and params.

The transport is one half of the endpoint. A [`SIPConnection`](#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.

> [card] [baresip-python](https://pypi.org/project/baresip-python/)
>
> The SIP stack the transport is built on

> [card] [Development Runner](https://docs.pipecat.ai/api-reference/server/utilities/runner/guide.md#sip-transport-sip)
>
> Run a SIP bot locally with `-t sip`

## Installation

```bash theme={null}
uv add "pipecat-ai[sip]"
```

The `sip` extra installs [baresip-python](https://pypi.org/project/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](https://learn.microsoft.com/windows/wsl/), where the Linux wheel applies.

## Prerequisites

A SIP account to register with, or a Daily domain to provision one on. With the [development runner](https://docs.pipecat.ai/api-reference/server/utilities/runner/guide.md#sip-transport-sip), a bot with no configured account gets a temporary Daily SIP client (`DAILY_API_KEY`). See [`DailyRESTHelper`](https://docs.pipecat.ai/api-reference/server/utilities/daily/rest-helper) 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](https://docs.pipecat.ai/api-reference/server/utilities/runner/guide.md#sip-transport-sip) covers the other two account sources, a Daily SIP trunk and a plain SIP account on any registrar.

## Configuration

```python theme={null}
from pipecat.transports.sip.connection import SIPConnection
from pipecat.transports.sip.transport import SIPParams, SIPTransport
```

### SIPTransport

**connection** `SIPConnection` *required*

The SIP account and stack settings the call runs over. A connection belongs to
one transport instance.

**params** `SIPParams | None` (default: None)

Transport configuration. Defaults to `SIPParams()`.

**input\_name** `str | None` (default: None)

Optional name for the input processor.

**output\_name** `str | None` (default: None)

Optional name for the output processor.

### SIPParams

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

| Parameter | Type | Default | Description |
| - | - | - | - |
| `auto_answer` | `bool` | `True` | Answer inbound calls as they arrive, accepting video when a video direction is enabled. When `False`, the call keeps ringing until you call `connection.answer()` or `connection.reject()`. |
| `trunk` | `str \| None` | `None` | Domain (or `host:port`) that turns a `phoneNumber` dial-out into `sip:+E164@trunk`. Without it, dial-out requires a full `sipUri`. |
| `audio_out_10ms_chunks` | `int` | `2` | Number of 10 ms chunks per outbound audio buffer. The default sends 20 ms buffers, matching typical RTP packet time. |

### 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`.

**user** `str` *required*

The user part of `sip:user@domain`.

**domain** `str` *required*

Registration domain. May carry a port.

**password** `str` (default: "")

Authentication password. May be empty.

**auth\_user** `str | None` (default: None)

Digest username, when the credential store keys it differently from `user`
(credential-list trunks).

**transport** `str` (default: "udp")

SIP transport: `"udp"`, `"tcp"`, or `"tls"`.

**registrar** `str | None` (default: None)

Outbound proxy to register through, when it is not the domain itself.

**reg\_interval** `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.

**audio\_codecs** `tuple | None` (default: None)

Codec preference order by stack name, for example `("opus/48000/2",
    "PCMU/8000/1")`. `None` uses the stack default.

**dtmf\_mode** `str` (default: "rtpevent")

How DTMF is sent: `"rtpevent"`, `"info"`, or `"auto"`.

**extra\_params** `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.

**jitter\_buffer\_mode** `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.

**jitter\_buffer\_ms** `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.

**net\_interface** `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.

**expose\_headers** `tuple` (default: ())

SIP header names whose values are included in call events. Runtime-wide.

**max\_concurrent\_calls** `int | None` (default: 2)

Simultaneous-call cap for the process; further inbound INVITEs are refused
with 486. `None` means unlimited. Runtime-wide.

**rtp\_timeout** `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.

**instance\_id** `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.

**video\_size** `tuple` (default: (640, 480))

Video width and height for both directions. Runtime-wide.

**video\_fps** `float` (default: 30.0)

Transmit frame rate. Runtime-wide.

**video\_bitrate** `int` (default: 1000000)

VP8 encoder target in bits per second. Runtime-wide.

**native\_log\_level** `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.

**sip\_trace** `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.

**route\_inbound** `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

```python theme={null}
connection = SIPConnection(user="1001", domain="sip.example.com", password="...")
transport = SIPTransport(
    connection,
    SIPParams(audio_in_enabled=True, audio_out_enabled=True),
)

@transport.event_handler("on_dialin_ready")
async def on_dialin_ready(transport, aor):
    print(f"Registered as {aor}")

@transport.event_handler("on_client_connected")
async def on_client_connected(transport, participant):
    ...
```

### Dial-out

```python theme={null}
@transport.event_handler("on_connected")
async def on_connected(transport, data=None):
    session_id, error = await transport.start_dialout({"sipUri": "sip:1002@sip.example.com"})
    if error:
        print(error)
```

### 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:

```python theme={null}
from pipecat.runner.utils import create_transport

transport_params = {
    "sip": lambda: SIPParams(audio_in_enabled=True, audio_out_enabled=True),
}

async def bot(runner_args):
    transport = await create_transport(runner_args, transport_params)
```

### 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

```python theme={null}
await transport.start_dialout(settings=None) -> tuple[str, str | None]
```

Places a call and returns `(session_id, error)`. `settings` takes:

| Key | Description |
| - | - |
| `sipUri` | Direct SIP target. |
| `phoneNumber` | Phone number, used with `SIPParams.trunk`. |
| `video` | `True` offers send and receive video. A direction string offers that direction; `"inactive"` negotiates video without activating it. |
| `headers` | Dict of extra INVITE headers. |

Returns an error when the transport already has an active call.

### stop\_dialout

```python theme={null}
await transport.stop_dialout(participant_id) -> str | None
```

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

### send\_dtmf

```python theme={null}
await transport.send_dtmf(settings) -> str | None
```

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

```python theme={null}
await transport.sip_refer(settings) -> str | None
```

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

```python theme={null}
await transport.sip_attended_transfer(settings) -> str | None
```

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

```python theme={null}
await transport.sip_call_transfer(settings) -> str | None
```

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

### Video control

```python theme={null}
await transport.set_video_direction(direction) -> str | None
await transport.add_video() -> str | None
await transport.remove_video() -> str | None
await transport.request_keyframe() -> None
```

`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:

| Direction | Bot sends video | Bot receives video | Typical use |
| - | - | - | - |
| `"sendrecv"` | yes | yes | Bring video up; what `add_video()` sends. |
| `"sendonly"` | yes | no | Send video to a caller who sends none. |
| `"recvonly"` | no | yes | Watch the caller (vision) without sending anything back. |
| `"inactive"` | no | no | Pause video and keep it negotiated; what `remove_video()` sends. |

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](https://docs.pipecat.ai/api-reference/server/utilities/runner/guide.md#debugging-a-sip-bot) 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.

| Event | Arguments | Description |
| - | - | - |
| `on_connected` | `transport` | The connection is up. |
| `on_left` | `transport` | The connection closed. |
| `on_before_leave` | `transport` | About to leave. Synchronous. |
| `on_error` | `transport, error` | A transport error occurred. |
| `on_call_state_updated` | `transport, state` | The call state changed: `"ringing"`, `"established"`, or `"closed"`. |
| `on_dialin_ready` | `transport, aor` | The account registered; `aor` is the registered address-of-record. |
| `on_dialin_connected` | `transport, data` | An inbound call was established. |
| `on_dialin_stopped` | `transport, data` | An inbound call ended. `data["reason"]` is `"transferred"` after a transfer. |
| `on_dialin_error` | `transport, data` | An inbound call could not be answered. |
| `on_dialin_warning` | `transport, data` | An audio warning on an inbound call. |
| `on_dialout_connected` | `transport, data` | An outbound call is ringing at the far end. |
| `on_dialout_answered` | `transport, data` | An outbound call was answered. |
| `on_dialout_stopped` | `transport, data` | An outbound call ended, including one that closed before it connected. |
| `on_dialout_error` | `transport, data` | An outbound call failed. |
| `on_dialout_warning` | `transport, data` | An audio warning on an outbound call. |
| `on_dtmf_event` | `transport, data` | A DTMF digit was received. `data["tone"]` is the digit. |
| `on_first_participant_joined` | `transport, participant` | The call was established; fires once per call, before `on_participant_joined`. |
| `on_participant_joined` | `transport, participant` | A call was established. |
| `on_client_connected` | `transport, participant` | A call was established; a `ClientConnectedFrame` is pushed downstream. |
| `on_participant_left` | `transport, participant, reason` | A call ended; `reason` is `"leftCall"`. |
| `on_client_disconnected` | `transport, participant` | An established call ended. |
| `on_participant_updated` | `transport, participant` | The peer put the call on hold or resumed it, or video was renegotiated. |
| `on_call_quality_stats` | `transport, stats` | Final call quality statistics, fired when a call closes. |

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`.

```python theme={null}
@transport.event_handler("on_dialout_stopped")
async def on_dialout_stopped(transport, data):
    print(f"Call {data['sessionId']} ended: {data['reason']}")
```

### 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.

| Event | Arguments | Description |
| - | - | - |
| `connected` | `connection` | The connection is up. |
| `disconnected` | `connection` | The connection closed. |
| `registered` | `connection, aor` | The account registered. |
| `incoming` | `connection, data` | An inbound call arrived and is ringing. |
| `call_progress` | `connection, data` | A call is ringing. |
| `call_established` | `connection, data` | A call was established. |
| `call_closed` | `connection, data` | A call closed. |
| `call_failed` | `connection, data` | An outbound call failed. |
| `dtmf` | `connection, digit_event, session_id` | A DTMF digit was received. |
| `remote_hold` | `connection, data` | The peer put the call on hold or resumed it. |
| `renegotiated` | `connection, data` | Media was renegotiated mid-call (video added, removed, changed). |
| `audio_warning` | `connection, warning, direction, session_id` | An audio warning on a call. |
| `media_restarted` | `connection, kind` | A media stream restarted. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.