laravel/ai
Laravel AI SDK offers a unified, Laravel-friendly API for OpenAI, Anthropic, Gemini, and more. Build agents with tools and structured output, generate images, transcribe/synthesize audio, and create embeddings—all through one consistent interface.
Image::of(), Embeddings::for(), SimilaritySearch::usingModel()), reducing runtime errors from malformed requests. This aligns with production-grade reliability, especially for APIs or public-facing features.Strict attribute, allowing granular control over API response validation (e.g., enforcing choices array structure).InsufficientCreditsException for OpenRouter and DeepSeek, improving error clarity for billing-related failures.providerOptions for AWS Bedrock, enabling fine-grained control over reasoning content and parameters.Conversation and ConversationMessage models now respect configured database connections, enabling multi-database setups (e.g., read replicas, sharding).@throws Documentation: Clarifies exceptions for image generation, embeddings, and transcription, improving maintainability.providerOptions handling across Bedrock, OpenRouter, and OpenAI-shaped providers simplifies cross-provider logic.Strict attribute is opt-in, teams using loose OpenAI responses (e.g., legacy code) may need to audit and update calls to avoid runtime failures.providerOptions may require testing with AWS Bedrock’s specific parameter constraints.image+text restrictions could expose teams to unexpected API behavior if not validated.Strict mode globally or opt-in selectively for critical paths (e.g., payments, compliance workflows)?ai.php or rely on Laravel’s defaults?InsufficientCreditsException for domain-specific billing recovery (e.g., fallback providers)?image+text removal doesn’t break existing workflows (e.g., DALL·E prompts)?Strict mode compatibility; identify legacy loose-response calls.AI::fake() for critical paths (e.g., embeddings, image generation).composer.json to v0.7.0; configure ai.php for database connections and strict mode.providerOptions consistently (e.g., Bedrock, OpenRouter).InsufficientCreditsException (e.g., fallback providers).choices validation).ai.php.| Phase | Task | Dependencies |
|---|---|---|
| Discovery | Inventory AI calls using loose OpenAI responses; audit attachment usage. | Business requirements |
| Setup | Update composer.json to v0.7.0; configure ai.php for strict mode and DB connections. |
Laravel app (10+) |
| Validation | Run PHPStan; test input validations with AI::fake(). |
CI pipeline, test data |
| Pilot | Enable attachment rehydration for non-critical conversations. | Sandbox environment |
| Core Rollout | Migrate provider options to providerOptions; |
How can I help you explore Laravel packages today?