Skip to content

Model Registry

The ModelRegistry provides programmatic access to all available Perplexity AI models.

Model

perplexity_webui_scraper.models.types.Model

Bases: BaseModel

Immutable metadata for a single Perplexity AI model.

ATTRIBUTE DESCRIPTION
id

Canonical string key used to select this model (e.g. "perplexity/best").

TYPE: str

name

Human-readable display name shown in the UI.

TYPE: str

description

Short description of the model's characteristics.

TYPE: str

identifier

Internal Perplexity model identifier sent in the API payload.

TYPE: str

tool_name

MCP tool name used when registering this model as an MCP tool.

TYPE: str

min_tier

Minimum Perplexity subscription required: "pro" or "max".

TYPE: str

mode

API request mode sent in the payload (e.g. "copilot", "search", "research").

TYPE: str


ModelRegistry

perplexity_webui_scraper.models.registry.ModelRegistry

ModelRegistry()

Registry of all available Perplexity AI models.

The registry is populated at instantiation time by reading models.json from the _static package directory via importlib.resources. The singleton MODELS instance is created at module import time.

Usage::

from perplexity_webui_scraper.models import MODELS

model = MODELS.resolve("perplexity/best")
all_models = MODELS.list_all()

Load models from the bundled models.json static asset.

Source code in src/perplexity_webui_scraper/models/registry.py
def __init__(self) -> None:
    """Load models from the bundled ``models.json`` static asset."""
    self._models = {}
    static_pkg = files("perplexity_webui_scraper._static")
    models_file = static_pkg.joinpath("models.json")

    raw: bytes = models_file.read_bytes()  # type: ignore[arg-type]
    data: list[dict[str, object]] = loads(raw)

    for item in data:
        model = Model.model_validate(item)
        self._models[model.id] = model

Functions

resolve

resolve(model_id: str) -> Model

Look up a model by its canonical string ID.

PARAMETER DESCRIPTION
model_id

The model identifier, e.g. "perplexity/best".

TYPE: str

RETURNS DESCRIPTION
Model

The matching :class:Model instance.

RAISES DESCRIPTION
ValueError

If model_id is not registered.

Source code in src/perplexity_webui_scraper/models/registry.py
def resolve(self, model_id: str) -> Model:
    """Look up a model by its canonical string ID.

    Args:
        model_id: The model identifier, e.g. ``"perplexity/best"``.

    Returns:
        The matching :class:`Model` instance.

    Raises:
        ValueError: If ``model_id`` is not registered.
    """
    if model_id in self._models:
        return self._models[model_id]

    available = ", ".join(f'"{m}"' for m in self._models)
    raise ValueError(f"Unknown model {model_id!r}. Available models: {available}")

list_all

list_all() -> list[Model]

Return all registered :class:Model instances in definition order.

RETURNS DESCRIPTION
list[Model]

List of all models loaded from models.json.

Source code in src/perplexity_webui_scraper/models/registry.py
def list_all(self) -> list[Model]:
    """Return all registered :class:`Model` instances in definition order.

    Returns:
        List of all models loaded from ``models.json``.
    """
    return list(self._models.values())