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

Client Laravel Package

google-gemini-php/client

Community-maintained PHP API client for Google's Gemini AI API. Send text, image, video, and audio prompts, hold multi-turn chats, stream responses, call functions, generate images and speech, and manage files and cached content.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • AI/ML Integration Roadmap:

    • Structured Output as a Product Primitive: JSON Schema support for structured output and function declarations turns Gemini from a "text generator" into a reliable data source. This unblocks features that require deterministic, machine-parseable responses—form filling, extraction pipelines, classification, agent routing—without brittle prompt engineering or post-hoc regex parsing.
    • Enterprise Document Intelligence at Scale: importFile() and getOperation() for file search stores mean bulk ingestion of document corpora with asynchronous operation tracking. This directly supports RAG-style internal search, contract/claims repositories, and knowledge base products where one-at-a-time uploads were previously a blocker.
    • Agentic & Hybrid Workflows: Server-side tool invocations, multimodal function responses, and the streamed chat history fix (thoughts, function calls, and tool calls preserved as separate parts with thoughtSignature) make multi-turn tool-calling agents viable. This is the difference between a demo and a production agent loop.
    • Vision Cost/Quality Tuning: Per-part media resolution and ImageConfig::$imageSize let you trade image fidelity against token spend per request—material for high-volume vision use cases (receipts, screenshots, document scans) where uniform high resolution is wasteful.
    • Observability & Governance: New response metadata (responseId, modelStatus, finishMessage, urlContextMetadata, serviceTier) enables auditability, incident triage, and tier-based routing (e.g., premium vs. standard service tiers). This is table stakes for customer-facing or regulated deployments.
    • Build vs. Buy: Still narrows the case for proprietary SDKs or custom wrappers. The package now covers structured output, tooling, media control, and file store management—the features most likely to force a build. MIT license preserves exit optionality.
    • Testability as a Delivery Lever: ClientFake support for startChat() (multi-turn and streamed) means AI features can be covered in CI rather than manually validated. This lowers QA cost and regression risk on every subsequent release.
  • Multi-Channel AI Use Cases (Updated):

    • Structured Extraction: "Parse this invoice into a fixed schema," "classify this ticket by category and severity," "extract clauses from this contract"—now first-class rather than prompt-dependent.
    • Location-Based Services: Maps Tool for context-aware responses (e.g., "best café near me with outdoor seating," "route me to the nearest hospital").
    • Enterprise Search & RAG: File search stores with bulk import for internal document retrieval ("find all contracts signed in Q2 2025," "summarize this PDF and highlight key clauses").
    • Agentic Automation: Chained tool workflows where the model invokes server-side tools and returns multimodal results (e.g., "analyze this sales report, identify trends, plot them on a customer-region map").
    • Regulatory Compliance: Automated document classification (GDPR, HIPAA) and structured data extraction from unstructured sources, with responseId and finishMessage supporting audit trails.

When to Consider This Package

  • Adopt if:

    • Your platform baseline is PHP 8.2+. This is now a hard requirement; PHP 8.1 projects stay pinned to 2.7.x and will not receive these capabilities.
    • Your roadmap depends on structured output (JSON Schema) for extraction, classification, or downstream automation where free-text responses are unusable.
    • You need multi-turn agents with tool calling—server-side tool invocations, multimodal function responses, and the corrected streamed chat history are the enabling pieces.
    • You are building document intelligence requiring bulk file ingestion and async operation tracking (importFile(), getOperation()).
    • You want AI features covered by automated tests; ClientFake now supports startChat(), including streamed and multi-turn flows.
    • You are running vision workloads where per-part media resolution and imageSize materially affect unit economics.
    • You prioritize open-source agility and community-driven development (active contributor base, MIT license).
  • Look Elsewhere if:

    • You are stuck on PHP 8.1 or below and cannot schedule an upgrade—upstream development has moved past you.
    • Your project requires real-time streaming with low-latency optimizations beyond HTTP; consider WebSocket-based approaches or Google's official SDK.
    • You need fine-tuning or custom model deployment (Gemini official SDK or Vertex AI).
    • Your stack is non-PHP (Python/JavaScript), where native libraries offer superior tooling support.
    • Enterprise SLAs or official Google support are contractual requirements—this remains community-maintained.
    • You require advanced security features (VPC peering, private endpoints) not covered here.
  • Upgrade Gating (2.8.0 specifics):

    • No public signature changes, so the code-level upgrade is low-risk—but budget time for behavioral verification, not API migration.
    • Error handling: Streamed 5xx responses with a JSON error body now throw ErrorException rather than TransporterException. Any catch blocks or retry logic keyed to the old type must be reviewed before rollout.
    • Chat history shape: $chat->history[$i]->parts may differ from prior versions. If you persist, replay, or assert on chat history (logs, snapshots, fixtures, analytics), validate compatibility first.
    • String matching on errors: text() and parts() ValueError messages now append finish/block reasons. Do not parse these messages programmatically.
    • Recommended path: upgrade PHP runtime → run a pilot on structured output and file search → verify streaming error paths → then scale.

How to Pitch It (Stakeholders)

For Executives: "The 2.8.0 release moves this Laravel package from 'AI text generation' to production-grade AI infrastructure. Three things matter commercially: structured output via JSON Schema lets us build features that consume AI responses as reliable data rather than prose; bulk file ingestion for search stores makes enterprise document intelligence practical at scale; and new response metadata plus service-tier controls give us the observability and cost governance required for customer-facing deployments. The tradeoff is a PHP 8.2+ requirement—a platform upgrade, not a code rewrite, since no public signatures changed. With an MIT license, active community delivery, and now-real automated test coverage via ClientFake, this is a low-risk, high-leverage foundation for [specific initiative, e.g., 'smart search,' 'claims automation,' or 'compliance classification']."

For Engineering: *"Key updates in 2.8.0:

  • Structured output: JSON Schema for both responses and function declarations—removes the fragility of prompt-enforced JSON.
  • Agentic tooling: Server-side tool invocations and multimodal function responses; streamed chat history now preserves thoughts, function calls, tool calls, and thoughtSignature as separate parts, which fixes next-turn rejection after a streamed function call.
  • File search at scale: importFile() and getOperation() for bulk ingestion with async operation polling.
  • Media cost control: Per-part media resolution and ImageConfig::$imageSize.
  • Observability: responseId, modelStatus, finishMessage, urlContextMetadata, serviceTier.
  • Testing: ClientFake now supports startChat(), including multi-turn and streamed chats.
  • Hard requirement: PHP 8.2+. PHP 8.1 stays on 2.7.x. Behavior changes to check before merging:
  • Streamed 5xx with a JSON error body now throws ErrorException, not TransporterException—audit retry/catch logic.
  • $chat->history[$i]->parts structure changed—validate anything that persists or asserts on history.
  • ValueError messages from text()/parts() now include finish/block reasons—don't match on message strings.
  • Minor fixes worth noting: API errors wrapped in a list are now detected; files/ prefixed filenames accepted; usage metadata without a total token count is tolerated. Plan: bump the runtime, run the suite against ClientFake-backed tests, pilot one structured-output flow and one file-search flow, then expand. Watch Google-side pricing for file search and Maps Tool invocations."*

For Product Teams: *"This release removes three constraints that were limiting what we could ship. First, structured output means we can trust AI responses as data—so form autofill, extraction, and classification features become straightforward builds rather than research spikes. Second, bulk document import means we can onboard an entire contract or knowledge corpus instead of dribbling files in one at a time. Third, multi-turn tool calling now works reliably across streaming, which is what separates a chatbot demo from an actual agent. Prioritize use cases where these are decisive:

  • Extraction & Classification: invoices, claims, contracts, tickets—anything needing a fixed schema.
  • Enterprise Search: internal knowledge bases, legal and medical document repositories.
  • Geospatial: travel, logistics, real estate.
  • Hybrid: 'analyze this report, extract key locations, plot them.' One planning note: PHP 8.2+ is now required, so confirm the platform upgrade lands before committing dates. Also budget for Google-side usage costs on file search and Maps Tool—start small, measure per-feature unit economics, then scale."*
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.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator