api

LemonSlice API utilities for session management.

This module provides helper classes for interacting with the LemonSlice API, including session creation and termination.

class pipecat.transports.lemonslice.api.LemonSliceApi(api_key: str, session: ClientSession)[source]

Bases: object

Helper class for interacting with the LemonSlice API.

Provides methods for creating and managing sessions with LemonSlice avatars.

LEMONSLICE_URL = 'https://lemonslice.com/api/liveai/sessions'
__init__(api_key: str, session: ClientSession)[source]

Initialize the LemonSliceApi client.

Parameters:
  • api_key – LemonSlice API key for authentication.

  • session – An aiohttp session for making HTTP requests.

async create_session(*, agent_image_url: str | None = None, agent_id: str | None = None, agent_image: Image | None = None, agent_prompt: str | None = None, idle_timeout: int | None = None, audio_sample_rate: int | None = None, model: str | None = None, daily_room_url: str | None = None, daily_token: str | None = None, connection_properties: dict[str, Any] | None = None, extra_properties: dict[str, Any] | None = None, api_url: str | None = None) → dict[source]

Create a new session with the specified agent_id, agent_image_url, or agent_image.

Parameters:
  • agent_image_url – URL to an agent image.

  • agent_id – ID of a LemonSlice agent.

  • agent_image – PIL image of the agent.

  • agent_prompt – A high-level system prompt that subtly influences the avatar’s movements, expressions, and emotional demeanor.

  • idle_timeout – Idle timeout in seconds.

  • audio_sample_rate – Sample rate the avatar captures and plays back the audio at. One of 16000, 22050, 24000, 44100 or 48000.

  • model – The LemonSlice model to run the avatar on. Uses the default model when None.

  • daily_room_url – Daily room URL to use for the session.

  • daily_token – Daily token for authenticating with the room.

  • connection_properties – Additional connection properties to pass to the session.

  • extra_properties – Additional properties to pass to the session.

  • api_url – LemonSlice API URL override.

Returns:

Dictionary containing session_id, room_url, and control_url.

Raises:

ValueError – If zero or more than one of agent_id, agent_image_url, or agent_image is provided.

async end_session(session_id: str, control_url: str)[source]

End an existing session.

Parameters:
  • session_id – ID of the session to end.

  • control_url – The control URL from the create_session response.