Overview

Frame serializers are components that convert between Pipecat’s internal frame format and external protocols or formats. They’re essential when integrating with third-party services or APIs that have their own message formats.

Core Responsibilities

Serializers handle:

  1. Serialization: Converting Pipecat frames to external formats or protocols
  2. Deserialization: Converting external messages to Pipecat frames
  3. Protocol-specific behaviors: Managing unique aspects of each integration

Available Serializers

Pipecat includes serializers for popular voice and communications platforms:

Custom Serializers

You can create custom serializers by implementing the FrameSerializer base class:

from pipecat.serializers.base_serializer import FrameSerializer, FrameSerializerType
from pipecat.frames.frames import Frame, StartFrame

class MyCustomSerializer(FrameSerializer):
    @property
    def type(self) -> FrameSerializerType:
        return FrameSerializerType.TEXT  # or BINARY

    async def setup(self, frame: StartFrame):
        # Initialize with pipeline configuration
        pass

    async def serialize(self, frame: Frame) -> str | bytes | None:
        # Convert Pipecat frame to external format
        pass

    async def deserialize(self, data: str | bytes) -> Frame | None:
        # Convert external data to Pipecat frame
        pass