PHPackages                             sepehr-mohseni/exaravel - 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. [Search &amp; Filtering](/categories/search)
4. /
5. sepehr-mohseni/exaravel

ActiveLibrary[Search &amp; Filtering](/categories/search)

sepehr-mohseni/exaravel
=======================

Laravel wrapper for the Exa.ai API

v1.0.0(5mo ago)3183↓93.3%MITPHPPHP ^8.2CI passing

Since Jan 16Pushed 5mo agoCompare

[ Source](https://github.com/sepehr-mohseni/exaravel)[ Packagist](https://packagist.org/packages/sepehr-mohseni/exaravel)[ Docs](https://github.com/sepehr-mohseni/exaravel)[ RSS](/packages/sepehr-mohseni-exaravel/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (8)Versions (2)Used By (0)

Exaravel
========

[](#exaravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bb9b48985f1d3979480f05b32dc34c989f7570e420d58ee1ec474002015fea1f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7365706568722d6d6f6873656e692f657861726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sepehr-mohseni/exaravel)[![Tests](https://camo.githubusercontent.com/6d97f4d174f4da06d4021a31b23bb44a00465f561e314095bce205f8ed47f4d0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7365706568722d6d6f6873656e692f657861726176656c2f74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/sepehr-mohseni/exaravel/actions/workflows/tests.yml)[![PHPStan](https://camo.githubusercontent.com/fa7d257d0c5c1cf237ac3490ef3a5561626b17fcb0a8547c01b0bb8746554e60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://phpstan.org/)[![License](https://camo.githubusercontent.com/30dded04829cf3a840d69a5f927357f1b56197ac9cef53a53addcc860c728cfe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7365706568722d6d6f6873656e692f657861726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sepehr-mohseni/exaravel)

A high-performance, strictly-typed, and enterprise-grade Laravel wrapper for the [Exa.ai](https://exa.ai) v2.1 API.

Features
--------

[](#features)

- 🚀 **PHP 8.2+** with Asymmetric Visibility and Property Hooks (PHP 8.4)
- 🔧 **Fluent Builder Pattern** for maximum IDE discoverability
- 🛡️ **Strictly Typed DTOs** - No raw arrays reach the end-user
- 🔄 **Automatic Retries** with exponential backoff for 429 and 5xx errors
- 📊 **Laravel Context Integration** for enterprise observability
- 🔑 **Multi-Connection Support** for managing multiple API keys
- ✅ **PHPStan Level 9** compliant

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 10.x, 11.x, or 12.x

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

[](#installation)

```
composer require sepehr-mohseni/exaravel
```

Publish the configuration file:

```
php artisan vendor:publish --tag=exaravel-config
```

Add your API key to your `.env` file:

```
EXA_API_KEY=your-api-key-here
```

Usage
-----

[](#usage)

### Search

[](#search)

```
use Sepehr_Mohseni\Exaravel\Facades\Exa;
use Sepehr_Mohseni\Exaravel\Enums\SearchType;
use Sepehr_Mohseni\Exaravel\Enums\Category;

// Basic search
$results = Exa::search('Laravel best practices')->get();

// Advanced search with fluent builder
$results = Exa::search('Machine learning frameworks')
    ->type(SearchType::Neural)
    ->category(Category::GitHub)
    ->numResults(20)
    ->includeDomains(['github.com', 'gitlab.com'])
    ->excludeDomains(['stackoverflow.com'])
    ->startPublishedDate('2024-01-01')
    ->endPublishedDate(new DateTime('now'))
    ->withContents(text: true, highlights: true)
    ->withAutoprompt()
    ->get();

// Iterate over results
foreach ($results as $result) {
    echo $result->title . ' - ' . $result->url . PHP_EOL;
}

// Get first result directly
$firstResult = Exa::search('PHP 8.4 features')->first();
```

### Find Similar

[](#find-similar)

```
// Find content similar to a URL
$results = Exa::findSimilar('https://laravel.com/docs/eloquent')
    ->numResults(10)
    ->excludeSourceDomain()
    ->category(Category::ResearchPaper)
    ->withContents(text: true, summary: true)
    ->get();
```

### Get Contents

[](#get-contents)

```
// Retrieve full content for specific document IDs
$contents = Exa::contents(['doc-id-1', 'doc-id-2', 'doc-id-3'])
    ->withText(maxCharacters: 10000)
    ->withMarkdown()
    ->withHighlights(perUrl: 3)
    ->withSummary('What are the key points?')
    ->get();

foreach ($contents as $content) {
    echo $content->title . PHP_EOL;
    echo $content->getPreferredContent(); // Returns markdown if available, otherwise text
}
```

### Answer (Agentic Endpoint)

[](#answer-agentic-endpoint)

```
// Get a direct answer with citations
$response = Exa::answer('What are the new features in PHP 8.4?')
    ->numResults(5)
    ->neural()
    ->includeDomains(['php.net', 'wiki.php.net'])
    ->systemPrompt('You are a PHP expert. Provide detailed technical explanations.')
    ->get();

echo $response->answer;

foreach ($response->citations as $citation) {
    echo "Source: {$citation->url}" . PHP_EOL;
}

// Get just the answer text
$answerText = Exa::answer('Explain Laravel service providers')->text();
```

### Working with Results

[](#working-with-results)

```
$results = Exa::search('Laravel packages')->get();

// Collection-like methods
$urls = $results->urls();
$titles = $results->titles();

// Filter results
$highScoring = $results->filter(fn ($result) => $result->score > 0.8);

// Map results
$summaries = $results->map(fn ($result) => [
    'title' => $result->title,
    'url' => $result->url,
]);

// Check results
if ($results->isEmpty()) {
    echo 'No results found';
}

echo "Found {$results->count()} results";
```

### Multiple Connections

[](#multiple-connections)

Configure multiple API keys in `config/exaravel.php`:

```
'connections' => [
    'default' => [
        'api_key' => env('EXA_API_KEY'),
    ],
    'premium' => [
        'api_key' => env('EXA_PREMIUM_API_KEY'),
        'timeout' => 60,
    ],
],
```

Use a specific connection:

```
$results = Exa::using('premium')
    ->search('Complex query')
    ->get();

// Or use a custom API key on the fly
$results = Exa::withApiKey('custom-key')
    ->search('Query')
    ->get();
```

### Error Handling

[](#error-handling)

```
use Sepehr_Mohseni\Exaravel\Exceptions\AuthenticationException;
use Sepehr_Mohseni\Exaravel\Exceptions\RateLimitException;
use Sepehr_Mohseni\Exaravel\Exceptions\InsufficientCreditsException;
use Sepehr_Mohseni\Exaravel\Exceptions\ValidationException;

try {
    $results = Exa::search('query')->get();
} catch (AuthenticationException $e) {
    // Invalid API key
} catch (RateLimitException $e) {
    // Rate limit exceeded
    $retryAfter = $e->retryAfter; // seconds to wait
} catch (InsufficientCreditsException $e) {
    // Need more API credits
} catch (ValidationException $e) {
    // Invalid request parameters
    $errors = $e->errors;
}
```

### Livecrawl Mode

[](#livecrawl-mode)

```
use Sepehr_Mohseni\Exaravel\Enums\LivecrawlMode;

$results = Exa::search('Latest tech news')
    ->livecrawl(LivecrawlMode::Always, timeout: 10000)
    ->get();
```

Configuration
-------------

[](#configuration)

```
// config/exaravel.php

return [
    'api_key' => env('EXA_API_KEY'),
    'base_url' => env('EXA_BASE_URL', 'https://api.exa.ai'),
    'timeout' => env('EXA_TIMEOUT', 30),
    'connect_timeout' => env('EXA_CONNECT_TIMEOUT', 10),

    'retry' => [
        'times' => env('EXA_RETRY_TIMES', 3),
        'sleep_milliseconds' => env('EXA_RETRY_SLEEP', 500),
        'when' => [429, 500, 502, 503, 504],
    ],

    'default_search_type' => env('EXA_DEFAULT_SEARCH_TYPE', 'auto'),
    'default_num_results' => env('EXA_DEFAULT_NUM_RESULTS', 10),

    'logging' => [
        'enabled' => env('EXA_LOGGING_ENABLED', false),
        'channel' => env('EXA_LOGGING_CHANNEL', 'stack'),
    ],
];
```

Testing
-------

[](#testing)

```
composer test
```

Run static analysis:

```
composer analyse
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Sepehr Mohseni](https://github.com/sepehr-mohseni)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance70

Regular maintenance activity

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

170d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ee4894771ae3ecf9a2d11f98128ea6ee1b75f545f2c1f96928592b80c1013b9a?d=identicon)[sepehr-mohseni](/maintainers/sepehr-mohseni)

---

Top Contributors

[![sepehr-mohseni](https://avatars.githubusercontent.com/u/64346646?v=4)](https://github.com/sepehr-mohseni "sepehr-mohseni (4 commits)")

---

Tags

searchlaravelaiweb-search semantic-searchexaexa.ai

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sepehr-mohseni-exaravel/health.svg)

```
[![Health](https://phpackages.com/badges/sepehr-mohseni-exaravel/health.svg)](https://phpackages.com/packages/sepehr-mohseni-exaravel)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/scout

Laravel Scout provides a driver based solution to searching your Eloquent models.

1.7k55.0M618](/packages/laravel-scout)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M203](/packages/laravel-ai)[api-platform/laravel

API Platform support for Laravel

58171.8k14](/packages/api-platform-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

811334.1k3](/packages/defstudio-telegraph)

PHPackages © 2026

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