When developing real-time, multimodal AI applications, monitoring two key factors is crucial: performance (latency) and LLM/TTS usage. Performance impacts user experience, while usage can affect operational costs. Pipecat offers built-in metrics for both, which can be enabled with straightforward configuration options.

Enabling performance metrics

Set enable_metrics=True in PipelineParams when creating a task:

Example config
task = PipelineTask(
            pipeline,
            PipelineParams(
                ...
                enable_metrics=True,
                ...
            ),
        )

Once enabled, Pipecat logs the following metrics:

MetricDescription
TTFBTime To First Byte in seconds
Processing TimeTime taken by the service to respond in seconds
Sample output
AnthropicLLMService#0 TTFB: 0.8378312587738037
CartesiaTTSService#0 processing time: 0.0005071163177490234
CartesiaTTSService#0 TTFB: 0.17177796363830566
AnthropicLLMService#0 processing time: 2.4927797317504883

Limiting TTFB responses

If you only want the first TTFB measurement for each service, you can optionally pass report_only_initial_ttfb=True in PipelineParams:

Example config
task = PipelineTask(
            pipeline,
            PipelineParams(
                ...
                enable_metrics=True,
                report_only_initial_ttfb=True,
                ...
            ),
        )

Note: enable_metrics=True is required for this setting to have an effect.

Enabling LLM/TTS Usage Metrics

Set enable_usage_metrics=True in PipelineParams when creating a task:

Example config
task = PipelineTask(
            pipeline,
            PipelineParams(
                ...
                enable_usage_metrics=True,
                ...
            ),
        )

Pipecat will log the following as applicable:

MetricDescription
LLM UsageNumber of prompt and completion tokens used
TTS UsageNumber of characters processed
Sample output
CartesiaTTSService#0 usage characters: 65
AnthropicLLMService#0 prompt tokens: 104, completion tokens: 53

Note: Usage metrics are recorded per interaction and do not represent running totals.