Skip to content

LLM Perplexity

Jdaie Lin edited this page Mar 3, 2026 · 1 revision

Perplexity AI offers an OpenAI-compatible LLM API with built-in real-time web search. Models such as sonar and sonar-pro can answer questions using up-to-date information from the web without any extra integration work on your part.


Get a Perplexity API Key

  1. Sign in or create an account at https://www.perplexity.ai/.
  2. Navigate to Settings → API (or visit https://www.perplexity.ai/settings/api).
  3. Generate a new API key and copy it.

Full API documentation is available at https://docs.perplexity.ai.


Configure Whisplay AI Chatbot to use Perplexity

Set LLM_SERVER=perplexity in your .env file:

LLM_SERVER=perplexity

PERPLEXITY_API_KEY=your_perplexity_api_key

# Default model is "sonar". For web-augmented reasoning, try "sonar-pro" or "sonar-reasoning".
# PERPLEXITY_LLM_MODEL=sonar

# Tool/function calling is only supported on select models (e.g. sonar-pro).
# Set to true to enable. Default is false.
# PERPLEXITY_ENABLE_TOOLS=false

Available Models

Model Web Search Tool Calling Notes
sonar Default. Fast, lightweight, online search.
sonar-pro Advanced search + function/tool calling.
sonar-reasoning Chain-of-thought reasoning with search.
sonar-reasoning-pro Chain-of-thought reasoning with tool support.

For the latest model list and capabilities, refer to the official Perplexity models documentation.


Tool Calling

Whisplay supports tool/function calling (e.g. image generation, camera capture) when the LLM backend supports it. With Perplexity, tool calling requires a compatible model and PERPLEXITY_ENABLE_TOOLS=true.

Example configuration with sonar-pro and tools enabled:

LLM_SERVER=perplexity

PERPLEXITY_API_KEY=your_perplexity_api_key
PERPLEXITY_LLM_MODEL=sonar-pro
PERPLEXITY_ENABLE_TOOLS=true

Note: If you enable tools on a model that does not support them (e.g. sonar), the API will return an error. Keep PERPLEXITY_ENABLE_TOOLS=false (the default) when using basic sonar or sonar-reasoning models.


Combining with Other Services

Perplexity is used only as the LLM backend. You can pair it with any supported ASR and TTS provider. Example:

ASR_SERVER=openai
LLM_SERVER=perplexity
TTS_SERVER=openai

PERPLEXITY_API_KEY=your_perplexity_api_key
PERPLEXITY_LLM_MODEL=sonar-pro
PERPLEXITY_ENABLE_TOOLS=true

Full .env Reference

Variable Required Default Description
PERPLEXITY_API_KEY Yes (none) Your Perplexity API key
PERPLEXITY_LLM_MODEL No sonar Model name (see table above)
PERPLEXITY_ENABLE_TOOLS No false Enable tool/function calling (requires a compatible model)

Notes

  • Perplexity models always query the web for recent information, which makes them excellent for questions about current events or real-time data.
  • Chat history is maintained within a session and automatically reset after the idle timeout (configurable via CHAT_HISTORY_RESET_TIME).
  • Chat history is also saved to data/chathistory/ for debugging purposes.

Clone this wiki locally