LiveKit

LiveKit Agents is an open-source framework for Python and Node.js that handles production-grade voice and multimodal AI applications. The framework provides abstractions for routing realtime media through AI pipelines, supporting STT-LLM-TTS voice workflows and speech-to-speech models across providers.

This guide covers routing telemetry from LiveKit Agents to InteractiveAI for monitoring, debugging, and evaluating realtime voice AI applications.

Prerequisites

  • InteractiveAI account with API credentials

  • LiveKit account and API credentials

  • LLM provider credentials (OpenAI, Ollama, or other supported provider)


Configuration

Set your InteractiveAI credentials as environment variables:

INTERACTIVEAI_PUBLIC_KEY="pk-ia-..."
INTERACTIVEAI_SECRET_KEY="sk-ia-..."
INTERACTIVEAI_HOST="https://app.interactiveai.com"

Enabling Telemetry

LiveKit Agents includes native OpenTelemetry support. Configure a tracer provider using set_tracer_provider in your entrypoint function to route spans to InteractiveAI.

import base64
import os

from livekit.agents.telemetry import set_tracer_provider

def setup_interactiveai(
    host: str | None = None, 
    public_key: str | None = None, 
    secret_key: str | None = None
):
    from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
    from opentelemetry.sdk.trace import TracerProvider
    from opentelemetry.sdk.trace.export import BatchSpanProcessor

    public_key = public_key or os.getenv("INTERACTIVEAI_PUBLIC_KEY")
    secret_key = secret_key or os.getenv("INTERACTIVEAI_SECRET_KEY")
    host = host or os.getenv("INTERACTIVEAI_HOST")

    if not public_key or not secret_key or not host:
        raise ValueError(
            "INTERACTIVEAI_PUBLIC_KEY, INTERACTIVEAI_SECRET_KEY, and INTERACTIVEAI_HOST must be set"
        )

    auth_string = base64.b64encode(f"{public_key}:{secret_key}".encode()).decode()
    os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = f"{host.rstrip('/')}/api/public/otel"
    os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {auth_string}"

    trace_provider = TracerProvider()
    trace_provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
    set_tracer_provider(trace_provider)

async def entrypoint(ctx: JobContext):
    setup_interactiveai()
    
    # Agent session setup continues here
    # ...

Complete Example

A full implementation with agent, tool usage, and session metadata:


Trace Visibility

The InteractiveAI platform displays:

  • Complete conversation flows with turn-by-turn breakdown

  • LLM requests with prompts, completions, and latency

  • Speech-to-text and text-to-speech conversion times

  • Function tool invocations and results

  • Session metadata and performance metrics

Last updated

Was this helpful?