Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Laravel Package

grok-php/laravel

Laravel integration for the GrokPHP client. Add Grok AI chat and vision to Laravel apps with a clean facade API, configurable defaults (model, temperature, timeout), streaming responses, and simple install via artisan. Supports Laravel 10–12, PHP 8.2+.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package via Composer and run the php artisan grok:install command to publish config and set up environment variables. Update your .env with a valid Grok API key: GROK_API_KEY=sk-.... Start using the GrokAI facade for basic chat or vision requests—no service provider bootstrapping needed beyond auto-discovery.

Implementation Patterns

Use GrokAI::chat() for standard conversation flows, passing structured messages and ChatOptions for model selection (e.g., Model::GROK_2), temperature, and streaming. For multi-modal tasks like analyzing uploaded images, use GrokAI::vision()->analyze($urlOrPath, $prompt). Integrate into jobs, commands, or middleware for async or on-demand AI processing—such as automatically tagging user-uploaded content or summarizing long-form inputs. Configure defaults in config/grok.php to set fallback models, timeouts, and retry behavior project-wide.

Gotchas and Tips

⚠️ The vision endpoint only accepts image-capable models (grok-2-vision* or grok-vision-beta)—passing text-only models like GROK_2 with image payloads throws a clear GrokException. Always wrap calls in try/catch for GrokException and check for network or rate-limit errors. Use stream: true in ChatOptions for real-time UX in chat interfaces, but note streaming responses require frontend adaptability (e.g., SSE or WebSockets). Update GROK_API_KEY in .env before running tests—env values aren’t inherited from phpunit.xml unless explicitly declared. For caching or mock testing, extend the GrokClient or use Laravel’s App::swap() in phpunit.xml’s bootstrap. Finally, keep an eye on model enums (e.g., GROK_2_LATEST) as Grok’s API evolves—use Model::GROK_2_VISION_LATEST only when you need the newest vision features.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests