Weave 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 Gemini

Laravel Gemini Laravel Package

hosseinhezami/laravel-gemini

Integrate Google Gemini into Laravel with text, image, video, and audio generation, embeddings, streaming, file management, caching, and safety settings. Configurable, production-ready, Laravel 10+.

View on GitHub
Deep Wiki
Context7

A production-ready Laravel package to integrate with the Google Gemini API. Supports text, image, video, audio, long-context, structured output, files, caching, function-calling and understanding capabilities.

Frequently asked questions about Laravel Gemini
How do I install and configure the laravel-gemini package?
Install it with composer require hosseinhezami/laravel-gemini, then publish the config file using php artisan vendor:publish --tag=gemini-config. Add GEMINI_API_KEY to your .env file. All settings live in config/gemini.php, including base_uri, timeout, retry_policy, logging, stream, and caching defaults. The default base URI points at https://generativelanguage.googleapis.com/v1beta/.
Which Laravel versions does laravel-gemini support?
The package advertises Laravel 10 and above in its compatibility badge and relies only on the standard Laravel HTTP client and service container. That keeps dependencies minimal and makes it easy to reason about in a conventional Laravel app. Because the documentation does not publish a detailed version matrix or CI results, verify it against your exact Laravel version before committing.
What Gemini capabilities does laravel-gemini support?
It covers text generation with context and history, image generation and understanding, video generation and analysis, audio synthesis and transcription, document processing, embeddings, file management, streaming responses, safety settings, and caching, plus structured output and function calling. Each capability maps to different Gemini models and HTTP methods such as generateContent, predict, and predictLongRunning. Validate only the capabilities you actually plan to use, since per-capability behavior is not documented in detail.
How do I generate text with Google Gemini in a Laravel app using this package?
Use the Gemini facade to get a text builder, chain its configuration methods, and receive a Response object that exposes content(), model(), usage(), requestId(), and save(). The builders are stateless per call, so each request is configured explicitly. For maintainability, wrap the facade behind your own interface, such as AiTextGenerator, instead of calling Gemini:: directly in controllers.
Does laravel-gemini support embeddings and structured output?
Yes, embeddings generation and structured output are both listed features alongside the text and media capabilities. Structured output depends on Gemini schema handling, so test invalid-schema responses and confirm how errors are surfaced before relying on it in production. For embeddings, plan how you will store vectors and whether provider-side caching affects your storage costs.
How do I stream Gemini responses with laravel-gemini?
Streaming is configured through stream.chunk_size, which defaults to 1024, and stream.timeout, which is expressed in milliseconds and defaults to 1000. The package performs SSE proxying, so confirm your stack handles PHP-FPM output buffering and nginx X-Accel-Buffering correctly. Streaming is one of the highest-complexity code paths in the package, so test it end to end in an environment that mirrors production.
Can I use a different Gemini API key per user or tenant at runtime?
Yes, the package provides a setApiKey() runtime override in addition to the api_key config value and GEMINI_API_KEY environment variable. That makes it suitable for multi-tenant or per-user key scenarios in SaaS applications. Be careful that runtime keys are never written to logs, especially if you enable the package's request logging.
What is the default retry policy in laravel-gemini and should I change it?
The shipped defaults are retry_policy.max_retries of 30 with a retry_delay of 1000 milliseconds, plus a 30 second request timeout. Thirty retries is unusually high for billing-sensitive Gemini calls and can produce very long request tails while masking upstream failures. Override it to a small number such as two or three and handle quota errors explicitly.
How does laravel-gemini surface Gemini API errors like quota limits or safety blocks?
The available documentation does not describe typed exceptions for quota exhaustion, safety blocks, or invalid schemas, so errors are most likely surfaced through Laravel's HTTP client exceptions. Test each capability you adopt and inspect the raw response payloads to confirm what you receive. Consider wrapping calls in your own adapter so you can normalize errors into domain-specific exceptions.
Is hosseinhezami/laravel-gemini production-ready and actively maintained?
It is presented as production-ready and has a recent release, but it has roughly 135 stars, zero dependents, and effectively a single maintainer, so long-term maintenance is unproven. The provided materials also show no test-suite signal, which matters for complex paths like streaming, video polling, and file lifecycle management. Treat it as a Gemini-only adapter rather than a multi-provider abstraction, and keep the facade behind an internal interface so you can mock it in tests or swap it if the package goes stale.
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.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource