PHPackages                             apsbd/grok-laravel - 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. apsbd/grok-laravel

ActiveLibrary[API Development](/categories/api)

apsbd/grok-laravel
==================

Seamlessly integrate Grok AI into Laravel applications with an elegant, developer-friendly package. Leverage powerful AI models for chat, automation, and NLP while maintaining Laravel's expressive simplicity.

v1.0.0(1y ago)08MITPHPPHP ^8.2 || ^8.3 || ^8.4

Since Jul 1Pushed 1y agoCompare

[ Source](https://github.com/apsbd/grok-laravel)[ Packagist](https://packagist.org/packages/apsbd/grok-laravel)[ Docs](https://github.com/grok-php/laravel)[ GitHub Sponsors](https://github.com/thefeqy)[ RSS](/packages/apsbd-grok-laravel/feed)WikiDiscussions main Synced today

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

🧠 **Grok AI Laravel**
=====================

[](#-grok-ai-laravel)

[![GrokAI Laravel](assets/images/grok-laravel.png)](assets/images/grok-laravel.png)

A **Laravel integration for the [GrokPHP Client](https://github.com/grok-php/client)**, designed to effortlessly incorporate Grok AI into Laravel applications with a clean and intuitive API.
Utilize **advanced AI models** for **chat, automation, and natural language processing**, all while preserving Laravel's simplicity and elegance.

[![Latest Version](https://camo.githubusercontent.com/3d83709ebd47f764512f6b61ca6cf5b6c28bcf6a2da076dcb1ae71fb59b9935a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67726f6b2d7068702f6c61726176656c)](https://packagist.org/packages/grok-php/laravel)[![PHP Version](https://camo.githubusercontent.com/187240af044d09d5b14a1d9d9ebdf3f7a993e4c7bc09bdb46b4ba661a891bf5b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d626c7565)](https://php.net)[![Laravel Version](https://camo.githubusercontent.com/93554d1ac44e7880097a6bd117e99f90c33ddf03dcf0a37f3047fa50b8aaa4d2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302532422d726564)](https://laravel.com)[![Total Downloads](https://camo.githubusercontent.com/3eab8c6d22f602244b3b1aae8d44d464ee11930c7ebfde1910b762a899a02da3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67726f6b2d7068702f6c61726176656c)](https://packagist.org/packages/grok-php/laravel)[![GitHub Workflow Status](https://github.com/grok-php/laravel/actions/workflows/run-tests.yml/badge.svg)](https://github.com/grok-php/laravel/actions/workflows/run-tests.yml/badge.svg)[![License](https://camo.githubusercontent.com/88e1dabf4d223df0950e0985948e231325fefca9fa7fe9e446cf8b1c5e9d9e47/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e)](LICENSE)

---

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Quick Start](#quick-start)
    - [Chat API](#chat-api)
    - [Vision Analysis](#vision-analysis-image-recognition)
    - [Error Handling](#error-handling)
- [Available Grok AI Models](#available-grok-ai-models)
- [Streaming Responses](#streaming-responses)
- [Testing](#testing)
- [Security](#security)
- [Contributing](#contributing)
- [License](#license)

---

Features
--------

[](#features)

- **Seamless Laravel Integration** – Works with Laravel 10, 11, and 12
- **Simple API Client** – Access Grok AI models with a clean and intuitive API
- **Supports Chat &amp; Vision** – Send both text and image-based requests
- **Streaming Capable** – Enable real-time AI responses
- **Configurable Defaults** – Set model, temperature, and timeout via config

---

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

[](#installation)

Install via Composer:

```
composer require grok-php/laravel
```

After installation, run the setup command:

```
php artisan grok:install
```

This command will:

- Publish the configuration file (`config/grok.php`).
- Add necessary environment variables to `.env`.

Add your API key in `.env`:

```
GROK_API_KEY=your-api-key
```

---

Quick Start
-----------

[](#quick-start)

### Chat API

[](#chat-api)

```
use GrokPHP\Laravel\Facades\GrokAI;
use GrokPHP\Client\Config\ChatOptions;
use GrokPHP\Client\Enums\Model;

$response = GrokAI::chat(
    [['role' => 'user', 'content' => 'Hello Grok!']],
    new ChatOptions(model: Model::GROK_2)
);

echo $response->content();
```

### Vision Analysis (Image Recognition)

[](#vision-analysis-image-recognition)

```
$response = GrokAI::vision()->analyze(
    'https://example.com/sample.jpg',
    'Describe this image'
);

echo $response->content();
```

### Error Handling

[](#error-handling)

All errors are wrapped in the `GrokException` class:

```
use GrokPHP\Client\Exceptions\GrokException;

try {
    $response = GrokAI::chat(
        [['role' => 'user', 'content' => 'Hello!']]
    );
    echo $response->content();
} catch (GrokException $e) {
    echo "Error: " . $e->getMessage();
}
```

---

Available Grok AI Models
------------------------

[](#available-grok-ai-models)

Model EnumAPI Model NameDescription`Model::GROK_VISION_BETA`grok-vision-betaExperimental vision-enabled model`Model::GROK_2_VISION`grok-2-visionAdvanced multi-modal vision model`Model::GROK_2_VISION_LATEST`grok-2-vision-latestLatest iteration of Grok vision models`Model::GROK_2_VISION_1212`grok-2-vision-1212Enhanced vision model with performance improvements`Model::GROK_2_1212`grok-2-1212Optimized chat model`Model::GROK_2`grok-2Default general-purpose Grok model`Model::GROK_2_LATEST`grok-2-latestLatest iteration of Grok-2`Model::GROK_BETA`grok-betaExperimental beta modelDefault model used: `Model::GROK_2`

---

Streaming Responses
-------------------

[](#streaming-responses)

Enable real-time AI responses by setting `stream: true`:

```
$response = GrokAI::chat(
    [['role' => 'user', 'content' => 'Tell me a story']],
    new ChatOptions(model: Model::GROK_2, stream: true)
);
```

Streaming is useful for chatbots, assistants, and real-time applications.

---

Testing
-------

[](#testing)

To run PHPUnit tests, copy the `phpunit.xml.dist` file to `phpunit.xml` and set your API key.

```
cp phpunit.xml.dist phpunit.xml
```

```

```

Now, run the tests:

```
composer test
```

---

Security
--------

[](#security)

If you discover a security vulnerability, please report it via email:

---

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

[](#contributing)

Check out [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to contribute.

---

License
-------

[](#license)

This package is open-source software licensed under the [MIT License](LICENSE).

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance50

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

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

367d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1383bea70dae51718729f7689b10663cd1ed70d76ad7743f1077e32b833ac7d1?d=identicon)[apsbd](/maintainers/apsbd)

---

Top Contributors

[![thefeqy](https://avatars.githubusercontent.com/u/44809366?v=4)](https://github.com/thefeqy "thefeqy (39 commits)")

---

Tags

REST APInlpApi Wrappermachine learningtext-processingartificial intelligencenatural language processingai apiai clientAI SDKDeep learninggenerative-aiai-integrationai-developer-toolsai chatbotGrok AIPHP AI SDKLarge Language ModelAI Text GenerationAI-powered ApplicationsLanguage ModelAI Research

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/apsbd-grok-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/apsbd-grok-laravel/health.svg)](https://phpackages.com/packages/apsbd-grok-laravel)
```

###  Alternatives

[grok-php/laravel

Seamlessly integrate Grok AI into Laravel applications with an elegant, developer-friendly package. Leverage powerful AI models for chat, automation, and NLP while maintaining Laravel's expressive simplicity.

1673.9k](/packages/grok-php-laravel)[grok-php/client

Grok PHP Client is a robust and community-driven PHP client library for seamless integration with Grok AI API, offering efficient access to advanced AI and data processing capabilities.

317.4k4](/packages/grok-php-client)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

46688.8k5](/packages/deepseek-php-deepseek-php-client)[qwen-php/qwen-php-client

robust and community-driven PHP SDK library for seamless integration with the qwen AI API, offering efficient access to advanced AI and data processing capabilities

203.3k1](/packages/qwen-php-qwen-php-client)[softcreatr/php-mistral-ai-sdk

A powerful and easy-to-use PHP SDK for the Mistral AI API, allowing seamless integration of advanced AI-powered features into your PHP projects.

1621.5k](/packages/softcreatr-php-mistral-ai-sdk)[softcreatr/php-perplexity-ai-sdk

A powerful and easy-to-use PHP SDK for the pplx (Perplexity) API, allowing seamless integration of advanced AI-powered features into your PHP projects..

1411.0k](/packages/softcreatr-php-perplexity-ai-sdk)

PHPackages © 2026

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