Skip to main content
Perplexity

Search documentation

Type to search this documentation.

On this pageOverview

Perplexity with LiveKit Agents

Perplexity's Agent API is compatible with the OpenAI Responses API, so it works as a drop-in LLM for LiveKit Agents through livekit-plugins-openai's openai.responses.LLM class, pointed at Perplexity's base URL.

Bash
pip install "livekit-agents" "livekit-plugins-openai"

Set your Perplexity API key as an environment variable and pass it to the constructor:

Bash
export PERPLEXITY_API_KEY="your_api_key_here"

Get API Key

Generate your API key from the Perplexity dashboard.

Use openai.responses.LLM anywhere a LiveKit AgentSession expects an LLM:

Python
import os

from livekit.agents import Agent, AgentSession
from livekit.plugins import openai, silero

session = AgentSession(
    llm=openai.responses.LLM(
        model="openai/gpt-5.6-sol",
        base_url="https://api.perplexity.ai/v1",   # SDK appends /responses -> POST /v1/responses
        api_key=os.environ["PERPLEXITY_API_KEY"],  # required: constructor does not read PERPLEXITY_API_KEY
    ),
    stt=openai.STT(),
    tts=openai.TTS(),
    vad=silero.VAD.load(),
)

agent = Agent(
    instructions="You are a helpful voice assistant. Use web search to answer with up-to-date information.",
    tools=[openai.tools.WebSearch()],  # Perplexity's built-in web_search tool
)

# Run the session inside your LiveKit room entrypoint

Because the Agent API is OpenAI-Responses-compatible, the OpenAI plugin talks to https://api.perplexity.ai/v1 with no other changes.

openai.responses.LLM needs two settings to target Perplexity - base_url and an explicit api_key (the constructor does not read PERPLEXITY_API_KEY on its own):

Python
import os

from livekit.plugins import openai

llm = openai.responses.LLM(
    model="openai/gpt-5.6-sol",
    base_url="https://api.perplexity.ai/v1",
    api_key=os.environ["PERPLEXITY_API_KEY"],
)

Perplexity's built-in tools (like web_search, shown in the Quick Start) attach to the Agent, not to the LLM.

The integration works with any model exposed through the Perplexity Agent API, addressed as provider/model (for example openai/gpt-5.6-sol). See the full list on our models page.

Need help with the integration?

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu