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

Ai Laravel Package

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.

View on GitHub
Deep Wiki
Context7

The official AI SDK for Laravel.

Frequently asked questions about Ai
How do I install Laravel AI SDK in my Laravel 10+ project?
Run `composer require laravel/ai` in your project directory. The package is fully compatible with Laravel 10+ and requires no additional PHP extensions. Follow the [official documentation](https://laravel.com/docs/ai-sdk) for provider-specific setup instructions.
Which AI providers are officially supported by Laravel AI SDK?
The SDK officially supports OpenAI, Anthropic, Gemini, Azure OpenAI, ElevenLabs, Cohere, Jina, VoyageAI, and OpenRouter. New providers like DeepSeek are added incrementally without breaking changes, so you can adopt them as needed.
Can I customize the database tables for conversations or messages?
Yes, the SDK allows you to configure custom table names for conversations and messages via the `ai` config file. This is useful for multi-tenant applications or compliance requirements, as it decouples the SDK from Laravel’s default conventions.
How does Laravel AI handle errors across different providers?
The SDK includes comprehensive error handling tests for all supported providers (e.g., OpenAI’s rate limits, Anthropic’s pause_turn, Gemini’s safety blocks). Version 0.6.8+ introduces failover logic for streaming failures, reducing runtime crashes in production.
Will Laravel AI SDK work with Laravel Forge or Vapor?
Yes, the SDK integrates seamlessly with Laravel Forge and Vapor. Provider configurations (e.g., API keys for OpenRouter or ElevenLabs) can be managed via environment variables, and the package supports all Laravel-supported database drivers.
How do I build an AI agent with tools and structured output?
Use the `Agent` facade to define tools (e.g., database queries, external APIs) and specify structured output schemas. The SDK handles tool invocation, error propagation, and response parsing automatically. Example workflows are documented [here](https://laravel.com/docs/ai-sdk#agents).
What are the cost implications of using new providers like OpenRouter or ElevenLabs?
New providers may introduce unfamiliar pricing models (e.g., per-minute billing for ElevenLabs audio). Monitor usage via provider dashboards or integrate cost-tracking middleware. The SDK itself doesn’t enforce cost controls but provides hooks for custom validation.
How do I handle failed streams in real-time applications (e.g., chatbots)?
The SDK broadcasts `stream_failed` events when streams interrupt. Set up Laravel Echo or Horizon listeners to trigger fallbacks (e.g., notify users, retry with a backup provider). Example event handling is in the [streaming docs](https://laravel.com/docs/ai-sdk#streaming).
Can I use Laravel AI SDK with Laravel Scout for vector search?
Yes, the SDK’s embedding features (e.g., Gemini context caching) integrate with Laravel Scout. Store embeddings in your Scout index and use Scout’s search methods to retrieve semantically similar content. No additional setup is required beyond Scout’s configuration.
What alternatives exist if I need more control over AI provider integrations?
For custom provider integrations, consider direct API wrappers like Guzzle or dedicated libraries (e.g., `php-ai` for OpenAI). However, Laravel AI SDK’s unified interface reduces boilerplate, and its error-handling tests simplify validation for edge cases like rate limits or malformed responses.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai