Skip to main content

Pipecat observer SDK for capturing latency, transcript, and usage data from pipecat and pipecat-flows pipelines.

Project description

tuner-pipecat-sdk

tuner-pipecat-sdk is a lightweight observer SDK for pipecat and pipecat-flows. It captures flow transitions, latency signals, transcript segments, and usage metadata, then sends a structured CallPayload to the Tuner API when a call ends.

Requirements

  • Python 3.10–3.13.
  • Do not use Python 3.14 for installs yet: Pipecat pulls onnxruntime~=1.23.2 and numba without 3.14 wheels → errors like No matching distribution found for onnxruntime.
  • This SDK depends on pipecat-ai>=0.0.105.

Installation

pip install tuner-pipecat-sdk

To use pipecat-flows, install with the flows extra:

pip install tuner-pipecat-sdk[flows]

Quick Start Example


Plain Pipecat — Observer

Use Observer when your pipeline manages context directly via OpenAILLMContext.

import uuid
from pipecat.processors.aggregators.llm_context import LLMContext
from tuner_pipecat_sdk import Observer

context = LLMContext()

observer = Observer(
    api_key="YOUR_TUNER_API_KEY",
    workspace_id=42,
    agent_id="my-agent",
    call_id=str(uuid.uuid4()),
    base_url="https://api.usetuner.ai",
    asr_model="deepgram/nova-3",
    llm_model="gpt-4o-mini",
    tts_model="cartesia/sonic",
)

# Required: attach the LLM context before running the pipeline
observer.attach_context(context)
observer.attach_turn_tracking_observer(turn_tracker)

Pipecat Flows — FlowsObserver

Use FlowsObserver when your pipeline is managed by pipecat-flows and a FlowManager.

import uuid
from tuner_pipecat_sdk import FlowsObserver

observer = FlowsObserver(
    api_key="YOUR_TUNER_API_KEY",
    workspace_id=42,
    agent_id="my-agent",
    call_id=str(uuid.uuid4()),
    base_url="https://api.usetuner.ai",
    asr_model="deepgram/nova-3",
    llm_model="gpt-4o-mini",
    tts_model="cartesia/sonic",
)

# Required: attach the flow manager before running the pipeline
observer.attach_flow_manager(flow_manager)
observer.attach_turn_tracking_observer(turn_tracker)

Pipeline Setup

Place the observer after TTS in your pipeline (same for both observer types):

Pipeline([
    transport.input(),
    stt,
    context_aggregator.user(),
    llm,
    tts,
    observer,
    transport.output(),
    context_aggregator.assistant(),
])

Enable metrics on the pipeline task so latency and usage fields are populated:

from pipecat.pipeline.task import PipelineTask
from pipecat.pipeline.pipeline_params import PipelineParams
from pipecat.observers.turn_tracking_observer import TurnTrackingObserver

turn_tracker = TurnTrackingObserver()

task = PipelineTask(
    pipeline,
    params=PipelineParams(
        observers=[observer.latency_observer, turn_tracker],
        enable_metrics=True,
        enable_usage_metrics=True,
    ),
)

Without these flags the observer will log warnings and LLM/TTS metric fields will be absent from the payload. For more example check https://github.com/usetuner/tuner-pipecat-sdk-python/tree/main/examples

Observer Parameters

Both Observer and FlowsObserver accept the same constructor parameters:

Parameter Type Default Description
api_key str Tuner API key
workspace_id int Tuner workspace ID
agent_id str Agent identifier
call_id str Unique call ID (use uuid4())
base_url str http://localhost:8000 Tuner API base URL
call_type str "web_call" Call type label
recording_url str "pipecat://no-recording" Recording URL if available
asr_model str "" ASR model name (e.g. deepgram/nova-3)
llm_model str "" LLM model name (e.g. gpt-4o-mini)
tts_model str "" TTS model name (e.g. cartesia/sonic)
debug bool False Log full transcript at flush

Disconnection Reason

Pass a disconnection_reason_resolver callable to the observer to record why a call ended. The resolver is called at flush time and should return a string or None.

from tuner_pipecat_sdk.models import DisconnectReason

observer = Observer(
    ...
    disconnection_reason_resolver=lambda: DisconnectReason.USER_HANGUP,
)

Use the built-in constants from DisconnectReason or pass a custom string:

Constant Value
DisconnectReason.USER_HANGUP "user_hangup"
DisconnectReason.AGENT_HANGUP "agent_hangup"
DisconnectReason.ERROR "error"
DisconnectReason.TIMEOUT "timeout"
DisconnectReason.UNKNOWN "unknown"

For dynamic resolution (e.g. when the reason is only known at call end):

_reason = None

def resolve_reason() -> str | None:
    return _reason

observer = Observer(..., disconnection_reason_resolver=resolve_reason)

# Later, when you know the reason:
_reason = DisconnectReason.AGENT_HANGUP

Public API

  • tuner_pipecat_sdk.Observer — for plain pipecat pipelines
  • tuner_pipecat_sdk.FlowsObserver — for pipecat-flows pipelines
  • tuner_pipecat_sdk.TunerConfig

Payload and transcript schemas are available under tuner_pipecat_sdk.models.

To build the project

folow the steps in setup_guide.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tuner_pipecat_sdk-0.1.1.tar.gz (971.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tuner_pipecat_sdk-0.1.1-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file tuner_pipecat_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: tuner_pipecat_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 971.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for tuner_pipecat_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f3e4a3d381c608a6bf005aa4d34cb9f4bfdb222d3e573e16cb3687aa053d63d9
MD5 aea8435ba8c06abcddede6e39dd44c0b
BLAKE2b-256 615a8ccf13b4803b93723115b937778bd62de7b208433a1d8a7b5d6defcd75a8

See more details on using hashes here.

File details

Details for the file tuner_pipecat_sdk-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for tuner_pipecat_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b7ec09b217459488797bbd71715455973505db0ea780d676ff76bb0e643c4c61
MD5 4997b228349dc5154652a8b735210930
BLAKE2b-256 46a10a5f73a4d4bddf2597407b0d0a4d8571ad80cffe8648767900ed409ed5f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page