Perplexity Sonar API with citations

function

Perplexity Sonar API with support of citations and search customization.

yazon
@yazon
·
a year ago
701
4
5.1K
Updated a year ago
Created Mar 5, 2025
perplexity_sonar_api_with_citations.py
Python · 215 lines
"""
title: Perplexity Sonar Manifold Pipe.

author: yazon
author_url: https://github.com/open-webui/open-webui/discussions/11212
funding_url: https://github.com/open-webui
version: 0.2.2
"""

import json
import logging
from collections.abc import AsyncGenerator, Awaitable, Callable

Perplexity Sonar Manifold Pipe

This Open WebUI pipe integrates with Perplexity AI's Sonar models, enabling advanced search and language understanding capabilities.

It supports:

  • Streaming responses for real-time interaction.
  • Automatic citation handling to display sources for information.
  • Customizable search parameters, including recency filters (month, week, day, hour) and search context size (low, medium, high).
  • Access to various Perplexity Sonar models like Sonar, Sonar Pro, Sonar Reasoning, and Sonar Deep Research, plus an offline model.

To use this pipe, a PERPLEXITY_API_KEY must be configured in the pipe's settings (valves).


1