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

Ai Laravel Package

laravel/ai

Unified Laravel API for AI providers like OpenAI, Anthropic, and Gemini. Build intelligent agents with tools and structured output, generate images, synthesize and transcribe audio, and create vector embeddings, all through one consistent, expressive interface.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Verdict: viable for a Laravel-native team building AI features in the next 1–2 quarters, but only under an explicit pre-1.0 discipline (pinned versions, wrapped boundaries, fakes-first testing). Do not treat it as a stable platform dependency yet.

Architecture fit

  • First-party laravel/ai (MIT, Laravel org) with a facade/contracts/trait design: Agent + Promptable, Conversational, HasStructuredOutput, RemembersConversations, plus static entry points (Image::of(), Audio::of(), Transcription::fromPath(), Embeddings::for(), Reranking::of(), Stores::create()). This is idiomatic Laravel — service container resolution (Agent::make(user: $user)), queues, cache, filesystem disks, events, broadcasting. Low conceptual impedance for any team already fluent in Laravel.
  • The package is itself the provider abstraction layer: OpenAI, Anthropic, Gemini, Bedrock, Azure OpenAI, Groq, Mistral, xAI, DeepSeek, OpenRouter, Cohere/Voyage embeddings, plus a generic OpenAI-compatible provider. That eliminates the "build your own adapter" workstream — a substantive schedule saving versus stitching openai-php and anthropic-sdk-php together.
  • Capability coverage is broad and matches typical product roadmaps: chat/agents, tools, provider-hosted tools, MCP, structured output, streaming/SSE, queued generation, image gen, TTS/STT, embeddings + caching, reranking, vector stores, file handling, failover, human-in-the-loop.

Integration feasibility

  • Greenfield: near-zero friction. composer require laravel/ai, publish config, set provider keys, write an agent class. Days, not weeks, to a working vertical slice.
  • Brownfield: the friction is not installation, it is governance — deciding which capability, which provider, and which failure semantics before the first PR.
  • Testability is the standout TPM-relevant feature: first-class fakes for agents/images/audio/transcriptions/embeddings/reranking/files/vector stores, assertPromptedTimes, and queued-generation fakes that still execute then(...) callbacks. This lets CI run without live provider calls and without token spend — a hard requirement for most orgs and rarely available in raw SDKs.

Technical risk (ranked)

  1. Pre-1.0 churn. Version series 0.9.1 → 0.10.0 → 0.10.1 → 0.10.2 → 0.10.3 → 0.11.0 in a tight window, with behavioral changes inside minor bumps: stream errors now throw instead of silently ending (0.11.0), TextDelta::combine streaming gluing fixed (0.9.1), embeddings cache-key collision fixed (0.10.2). Under 0.x semver, every minor can break you.
  2. Portability is not uniform across providers. Structured output behaves differently per provider (Anthropic rejecting JSON Schema constraints, markdown fence stripping on OpenAI-compatible). "Swap providers freely" is an aspiration, not a guarantee — assume a conformance test matrix is your responsibility.
  3. Defaults are not stable. Default Gemini text model changed at least twice (0.10.1, 0.11.0 → gemini-3.7-flash); a DeepSeek model name was deprecated. Never rely on package defaults in production; pin provider + model explicitly per prompt.
  4. Long-tail integration bugs are still surfacing in exactly the areas that hurt in production: streamed usage accounting across tool-call steps, orphaned tool calls in replayed history, unknown local tool call repair, empty Bedrock stream blocks, S3 document reconstruction, MCP request binding. Each is a potential production incident class, not a cosmetic defect.
  5. Ecosystem signal is thin. 1,259 stars with 0 dependents means no public downstream validation and no evidence of large-scale production track record. You are an early adopter.
  6. Docs live outside the repo (laravel.com/docs/ai-sdk), and the in-repo agent skill explicitly instructs: "This package is new. Always search the documentation before implementing any feature. Never guess at APIs." That is a candid admission that the API is not yet self-evident and that LLM/engineer guessing will produce wrong code.

Key questions to resolve before committing

  • What is the provider conformance matrix we actually need (structured output, tool choice, streaming, attachments, web search/fetch, embeddings) — and which provider is primary vs. failover?
  • Is there a published 1.0 / LTS timeline? What is the maintainers' stated breaking-change policy for 0.x minors?
  • What are failover semantics precisely — which status codes/conditions trigger it, is failover mid-run safe, and does conversation state survive a provider switch?
  • Does failover create a data-residency or vendor-terms problem (same prompt content sent to a second provider)?
  • How do we get our own token/cost accounting given historical usage-accounting bugs? Do we trust response->usage or meter independently?
  • PII/retention posture per provider, and does RemembersConversations persistence meet our data-retention and deletion requirements (GDPR/DSAR)?
  • Do we run under PHP-FPM or Octane, and are long-lived streaming/tool-loop requests safe in our runtime?
  • What is the eval/regression harness? Fakes prove wiring, not output quality.

Integration Approach

Stack fit

  • Requires a modern Laravel app; assumes config, cache, queue, filesystem/storage disks, events, broadcasting, and an HTTP client. Everything is composable with existing Laravel infrastructure — no new datastore, no sidecar, no separate service to operate.
  • Secrets management is conventional: provider keys in env/config, per-connection custom headers supported (0.10.3), cross-account Bedrock AssumeRole supported (0.10.0) — which matters if you need per-tenant or per-environment credentials.

Migration path

  • If replacing direct SDK usage (openai-php/*, anthropic-sdk-php, hand-rolled Guzzle), do not do a lift-and-shift. Insert an internal seam first: define your own AssistantGateway/EmbeddingGateway interfaces in your domain layer, implement them with the current SDK, then re-implement behind laravel/ai. This keeps Laravel\Ai\* types from leaking into controllers, jobs, and models, and preserves an exit option.
  • Strangler order by risk, not by enthusiasm: embeddings/transcription first (request/response, no conversation state, cheap to validate), then queued non-user-facing agents, then streaming/broadcast chat, then tools/MCP/vector stores, then failover and human-in-the-loop.
  • Treat provider-specific options and hosted tools as opt-in flags in your own config, never as unconditional code paths — they are the most likely to churn.

Compatibility

  • Pin an exact minor in composer.json (e.g. 0.11.*), not a caret range that can drift into the next breaking minor. Bump deliberately, reading the changelog and running the full suite against fakes.
  • Assume php and Laravel framework minimums will move with the package; verify against your supported PHP matrix before scheduling the upgrade.
  • Bedrock/Azure paths carry extra transitive requirements (AWS SDK version was changed in 0.10.3) — audit if you're on those providers.
  • Gate any dependency on run-context/invocation-id observability (new in 0.11.0) behind an adapter; do not let it become load-bearing across the codebase until it has a few releases of stability.

Sequencing (indicative, one squad)

  1. Spike (1 week): one agent + one structured-output agent + one embeddings call, on a single provider, with fakes in CI and a nightly live smoke job.
  2. Foundation (1–2 weeks): internal gateway interfaces, config/pin policy, cost metering, logging/tracing, error taxonomy.
  3. First production capability (2–3 weeks): queued generation behind a UI affordance; no streaming, no tools.
  4. Streaming + conversation persistence.
  5. Tools/MCP/vector stores, then failover policy.
  6. Human-in-the-loop only if the product requires approvals or irreversible actions.

Operational Impact

Maintenance

  • Expect a standing upgrade tax. Two of the last five releases (0.10.0, 0.11.0) carried behavioral change. Budget roughly 1–2 engineer-days per minor bump for a moderate surface area, and more for any release touching streaming, tool loops, or usage accounting. Assign a named owner; unowned pre-1.0 dependencies rot fast.
  • Changelogs are detailed and honest (bug-fix oriented, named contributors, PR links), which materially lowers triage cost. That is a genuine positive signal about maintainer quality.
  • Community contribution volume is high (many first-time contributors per release). Good for breadth; means quality is uneven across providers — your own conformance tests are the real gate.

Support

  • No commercial SLA. First-party Laravel branding plus a security policy, but support is GitHub issues and community PRs. Your team owns escalation; there is no vendor to call.
  • MIT license means you retain the option to fork or patch locally. Keep the dependency pinned so a local patch stays cheap.
  • Internal support burden is front-loaded: the first team to use the SDK becomes the internal authority for provider quirks. Document them or you will re-learn them per team.

Scaling and cost

  • The primary scaling lever is queue() on agents — move all generation off the request path. That converts provider latency and 429s into queue backlog, which is observable and retryable.
  • Provider rate limits and quotas are yours to manage per provider per environment. Failover improves availability but multiplies the credential/quotas inventory you must maintain.
  • Embeddings caching reduces both spend and latency, but verify cache-key correctness on your batch shapes — there was a collision bug fixed in 0.10.2.
  • Streaming holds worker connections open. Validate against your FPM/Octane worker pool and proxy timeouts before launching a streaming chat UI.
  • Tool loops are unbounded by default in practice: set explicit timeouts (the prompt() call accepts a per-prompt timeout) and cap iterations.

Failure modes to design for explicitly

  • Provider outage / 5xx / Cloudflare-upstream errors → failover path; confirm which conditions trigger it in your pinned version.
  • 429 and usage-limit rejections (Anthropic usage limits trigger failover in 0.11.0) → backoff plus failover, with distinct user-facing messaging.
  • Context-window exceeded and model refusal stop reasons → need mapping to product states, not generic errors.
  • Stream truncation or a mid-stream provider error → since 0.11.0 streams throw rather than silently ending; your UI needs a partial-response recovery path.
  • Malformed structured output (schema rejection, fence-wrapped JSON) → validate and retry once against a stricter prompt before failing.
  • Tool failures/orphaned tool calls/unknown tool calls on replayed history → define a repair policy and log it; silent repair hides correctness problems.
  • Failover mid-run leaving partial conversation state → decide whether to replay or restart the turn.
  • Attachment reconstruction from object storage (S3) failing → test with real storage, not local disk.
  • Long-running queued generations → job timeouts, failed_jobs handling, and idempotency on retry (a retried agent run can double-charge tokens).

Ramp-up

  • No ML expertise required; the prerequisite is Laravel fluency (contracts, container, queues, events) plus provider-domain knowledge. A mid-level Laravel engineer ships a working agent in a day.
  • Realistic ramp: ~1 week to first working feature, ~3–4 weeks to production-grade with observability, cost metering, and error taxonomy.
  • Mitigate the "never guess at APIs" problem operationally: point engineers at the official docs and the in-repo agent skill, and require a docs search before any new capability. Enforce with code review, because generated code that guesses at this API will look plausible and be wrong.
  • Leverage the run-context instrumentation (invocation id threaded through a run, per-step and per-tool reporting, terminal failure reporting) as the backbone of your tracing — but wrap it, and verify against your version before depending on it.

Overall recommendation: proceed to a 1-week spike, not a platform commitment. Gate broader rollout on (a) a pinned version that has survived your own conformance and eval suite, (b) a failover policy you have actually exercised, and (c) an exit seam that keeps Laravel\Ai out of your domain layer. Reassess for full adoption when a 1.0 or LTS commitment appears and dependent-package adoption provides third-party validation.

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.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections