PHPackages                             shipfastlabs/toolkit-perplexity - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. shipfastlabs/toolkit-perplexity

ActiveLibrary[API Development](/categories/api)

shipfastlabs/toolkit-perplexity
===============================

Perplexity tools for the Laravel AI SDK - Search and Ask (Sonar)

00PHP

Since Jun 7Pushed 2d agoCompare

[ Source](https://github.com/shipfastlabs/toolkit-perplexity)[ Packagist](https://packagist.org/packages/shipfastlabs/toolkit-perplexity)[ RSS](/packages/shipfastlabs-toolkit-perplexity/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

shipfastlabs/toolkit-perplexity
===============================

[](#shipfastlabstoolkit-perplexity)

[![Latest Version](https://camo.githubusercontent.com/b07afcb742a6e9c833e25b74a1f4d2637d25e5344e5f5021a284d01c741e92b4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73686970666173746c6162732f746f6f6c6b69742d706572706c65786974792e737667)](https://packagist.org/packages/shipfastlabs/toolkit-perplexity)[![Total Downloads](https://camo.githubusercontent.com/abc2398b997b6eaa67defb7ab84d83affd7b1d1c6067dd606e7a7e4e0008d4d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73686970666173746c6162732f746f6f6c6b69742d706572706c65786974792e737667)](https://packagist.org/packages/shipfastlabs/toolkit-perplexity)

> Perplexity tools for the Laravel AI SDK - Search and Ask (Sonar)

Part of the [shipfastlabs/toolkit](https://github.com/shipfastlabs/toolkit) catalog of reusable AI tools for the Laravel AI SDK.

Installation
------------

[](#installation)

```
composer require shipfastlabs/toolkit-perplexity
```

Usage
-----

[](#usage)

Register every Perplexity tool at once with the `Perplexity` helper:

```
use Shipfastlabs\Toolkit\Perplexity\Perplexity;

$tools = Perplexity::all(); // Collection
```

Or add individual tools to an agent's `tools()`:

```
use Shipfastlabs\Toolkit\Perplexity\PerplexitySearch;
use Shipfastlabs\Toolkit\Perplexity\PerplexityAsk;

$tools = [
    new PerplexitySearch,
    new PerplexityAsk,
];
```

Tools
-----

[](#tools)

### PerplexitySearch

[](#perplexitysearch)

Search the web for real-time information and get a ranked list of sources. Uses the [Perplexity Search API](https://docs.perplexity.ai/api-reference/search-post).

ParameterTypeRequiredDescription`query`stringyesThe search query to look up on the web.`max_results`integernoMaximum number of results to return (1-20). Defaults to 10.`search_recency_filter`stringnoRestrict results to a recent window: `"hour"`, `"day"`, `"week"`, `"month"`, or `"year"`. No filter by default.### PerplexityAsk

[](#perplexityask)

Ask a question and get a direct, cited answer grounded in a live web search using Perplexity's [Sonar models](https://docs.perplexity.ai/api-reference/chat-completions-post). The response includes the answer text plus the `search_results` and `citations` used.

ParameterTypeRequiredDescription`query`stringyesThe question to ask Perplexity.`model`stringnoSonar model: `"sonar"`, `"sonar-pro"`, `"sonar-reasoning"`, `"sonar-reasoning-pro"`, or `"sonar-deep-research"`. Defaults to `"sonar"`.`search_mode`stringno`"web"` for the open web, `"academic"` for scholarly sources, or `"sec"` for SEC filings. Defaults to `"web"`.Provider setup
--------------

[](#provider-setup)

Both tools read their API key from Laravel's `services` config and their optional defaults from the `ai` config.

### 1. Add the Perplexity service to `config/services.php`

[](#1-add-the-perplexity-service-to-configservicesphp)

```
// config/services.php

return [

    // ... existing services ...

    'perplexity' => [
        'key' => env('PERPLEXITY_API_KEY'),
    ],

];
```

### 2. Add toolkit defaults to `config/ai.php`

[](#2-add-toolkit-defaults-to-configaiphp)

```
// config/ai.php

return [

    // ... existing laravel/ai config ...

    'toolkit' => [
        'perplexity' => [
            'search' => [
                'max_results' => (int) env('PERPLEXITY_SEARCH_MAX_RESULTS', 10),
                'recency' => env('PERPLEXITY_SEARCH_RECENCY'),
            ],
            'ask' => [
                'model' => env('PERPLEXITY_ASK_MODEL', 'sonar'),
                'search_mode' => env('PERPLEXITY_ASK_SEARCH_MODE', 'web'),
            ],
        ],
    ],

];
```

### 3. Add environment variables to `.env`

[](#3-add-environment-variables-to-env)

```
PERPLEXITY_API_KEY=pplx-your-key-here

# Search defaults
PERPLEXITY_SEARCH_MAX_RESULTS=10
PERPLEXITY_SEARCH_RECENCY=

# Ask defaults
PERPLEXITY_ASK_MODEL=sonar
PERPLEXITY_ASK_SEARCH_MODE=web
```

Config keyEnv varDefaultDescription`services.perplexity.key``PERPLEXITY_API_KEY`-**Required.** Your Perplexity API key.`ai.toolkit.perplexity.search.max_results``PERPLEXITY_SEARCH_MAX_RESULTS``10`Default search results (1-20).`ai.toolkit.perplexity.search.recency``PERPLEXITY_SEARCH_RECENCY`-Default recency filter (`hour`/`day`/`week`/`month`/`year`).`ai.toolkit.perplexity.ask.model``PERPLEXITY_ASK_MODEL``"sonar"`Default Sonar model.`ai.toolkit.perplexity.ask.search_mode``PERPLEXITY_ASK_SEARCH_MODE``"web"`Default search mode (`web`/`academic`/`sec`).Safety
------

[](#safety)

- Both tools validate required inputs before calling the API.
- `max_results` is clamped to its valid 1-20 range.
- `model`, `search_mode`, and `search_recency_filter` are validated against allow-lists, falling back to safe defaults.
- API errors are caught and returned as friendly string messages.
- Requires a valid Perplexity API key.

Perplexity API
--------------

[](#perplexity-api)

These tools use the [Perplexity API](https://docs.perplexity.ai). You'll need an API key from your [Perplexity account settings](https://www.perplexity.ai/account/api).

Full API reference:

- [Search Endpoint](https://docs.perplexity.ai/api-reference/search-post)
- [Chat Completions Endpoint](https://docs.perplexity.ai/api-reference/chat-completions-post)

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31663512?v=4)[Pushpak Chhajed](/maintainers/pushpak1300)[@pushpak1300](https://github.com/pushpak1300)

---

Top Contributors

[![pushpak1300](https://avatars.githubusercontent.com/u/31663512?v=4)](https://github.com/pushpak1300 "pushpak1300 (1 commits)")

---

Tags

ailaravellaravel-aitool

### Embed Badge

![Health badge](/badges/shipfastlabs-toolkit-perplexity/health.svg)

```
[![Health](https://phpackages.com/badges/shipfastlabs-toolkit-perplexity/health.svg)](https://phpackages.com/packages/shipfastlabs-toolkit-perplexity)
```

###  Alternatives

[facebook/php-business-sdk

PHP SDK for Facebook Business

90923.5M35](/packages/facebook-php-business-sdk)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[botman/driver-telegram

Telegram driver for BotMan

93452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
