---
title: prefactor_livekit package
editUrl: true
head: []
template: doc
sidebar:
  hidden: false
  attrs: {}
pagefind: true
draft: false
---

# prefactor_livekit package

Prefactor LiveKit integration package.

### *class* prefactor_livekit.LiveKitToolSchemaConfig(span_type: str, input_schema: dict[str, ~typing.Any], result_schema: dict[str, ~typing.Any] = <factory>)

Bases: `object`

Configuration for a tool-specific LiveKit span schema.

#### input_schema *: dict[str, Any]*

#### result_schema *: dict[str, Any]*

#### span_type *: str*

### *class* prefactor_livekit.PrefactorLiveKitSession(client: [PrefactorCoreClient](../../core/reference/prefactor_core.client.md#prefactor_core.client.PrefactorCoreClient) | None = None, agent_id: str = 'livekit-agent', agent_name: str | None = None, instance: [AgentInstanceHandle](../../core/reference/prefactor_core.managers.agent_instance.md#prefactor_core.managers.agent_instance.AgentInstanceHandle) | None = None, tool_schemas: Mapping[str, [LiveKitToolSchemaConfig](prefactor_livekit.schemas.md#prefactor_livekit.schemas.LiveKitToolSchemaConfig) | Mapping[str, Any]] | None = None)

Bases: `object`

High-level LiveKit session wrapper for Prefactor tracing.

#### *async* attach(session: AgentSession[Any]) → [AgentInstanceHandle](../../core/reference/prefactor_core.md#prefactor_core.AgentInstanceHandle)

Attach to an existing LiveKit session.

#### *async* close() → None

Flush pending tasks and release wrapper-owned resources.

#### *async* ensure_initialized() → [AgentInstanceHandle](../../core/reference/prefactor_core.managers.agent_instance.md#prefactor_core.managers.agent_instance.AgentInstanceHandle)

Initialize and return the active Prefactor instance.

#### *classmethod* from_config(api_url: str, api_token: str, agent_id: str = 'livekit-agent', agent_name: str | None = None, schema_registry: [SchemaRegistry](../../core/reference/prefactor_core.schema_registry.md#prefactor_core.schema_registry.SchemaRegistry) | None = None, include_livekit_schemas: bool = True, tool_schemas: Mapping[str, [LiveKitToolSchemaConfig](prefactor_livekit.schemas.md#prefactor_livekit.schemas.LiveKitToolSchemaConfig) | Mapping[str, Any]] | None = None) → [PrefactorLiveKitSession](prefactor_livekit.session.md#prefactor_livekit.session.PrefactorLiveKitSession)

Create a wrapper from raw configuration.

#### *async* start(session: AgentSession[Any], agent: Agent, \*\*kwargs: Any) → Any

Attach and delegate to `AgentSession.start()`.

### prefactor_livekit.compile_livekit_agent_schema(tool_schemas: Mapping[str, [LiveKitToolSchemaConfig](prefactor_livekit.schemas.md#prefactor_livekit.schemas.LiveKitToolSchemaConfig) | Mapping[str, Any]] | None = None) → tuple[dict[str, Any], dict[str, str]]

Compile built-in and tool-specific LiveKit schemas.

### prefactor_livekit.register_livekit_schemas(registry: [SchemaRegistry](../../core/reference/prefactor_core.schema_registry.md#prefactor_core.schema_registry.SchemaRegistry), tool_schemas: Mapping[str, [LiveKitToolSchemaConfig](prefactor_livekit.schemas.md#prefactor_livekit.schemas.LiveKitToolSchemaConfig) | Mapping[str, Any]] | None = None) → dict[str, str]

Register LiveKit schemas in a schema registry.

## Submodules

* [prefactor_livekit.schemas module](prefactor_livekit.schemas.md)
  * [`LiveKitToolSchemaConfig`](prefactor_livekit.schemas.md#prefactor_livekit.schemas.LiveKitToolSchemaConfig)
    * [`LiveKitToolSchemaConfig.input_schema`](prefactor_livekit.schemas.md#prefactor_livekit.schemas.LiveKitToolSchemaConfig.input_schema)
    * [`LiveKitToolSchemaConfig.result_schema`](prefactor_livekit.schemas.md#prefactor_livekit.schemas.LiveKitToolSchemaConfig.result_schema)
    * [`LiveKitToolSchemaConfig.span_type`](prefactor_livekit.schemas.md#prefactor_livekit.schemas.LiveKitToolSchemaConfig.span_type)
  * [`compile_livekit_agent_schema()`](prefactor_livekit.schemas.md#prefactor_livekit.schemas.compile_livekit_agent_schema)
  * [`register_livekit_schemas()`](prefactor_livekit.schemas.md#prefactor_livekit.schemas.register_livekit_schemas)
* [prefactor_livekit.session module](prefactor_livekit.session.md)
  * [`PrefactorLiveKitSession`](prefactor_livekit.session.md#prefactor_livekit.session.PrefactorLiveKitSession)
    * [`PrefactorLiveKitSession.attach()`](prefactor_livekit.session.md#prefactor_livekit.session.PrefactorLiveKitSession.attach)
    * [`PrefactorLiveKitSession.close()`](prefactor_livekit.session.md#prefactor_livekit.session.PrefactorLiveKitSession.close)
    * [`PrefactorLiveKitSession.ensure_initialized()`](prefactor_livekit.session.md#prefactor_livekit.session.PrefactorLiveKitSession.ensure_initialized)
    * [`PrefactorLiveKitSession.from_config()`](prefactor_livekit.session.md#prefactor_livekit.session.PrefactorLiveKitSession.from_config)
    * [`PrefactorLiveKitSession.start()`](prefactor_livekit.session.md#prefactor_livekit.session.PrefactorLiveKitSession.start)