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 Chat Laravel Package

symfony/ai-chat

Symfony AI Chat is a lightweight package for building chat-style AI features in Symfony apps. It provides simple abstractions to connect to LLM providers, manage messages and context, and integrate conversational workflows with clean, framework-friendly APIs.

View on GitHub
Deep Wiki
Context7

PHP library for building chats with agents.

Frequently asked questions about Ai Chat
Can I use Symfony AI Chat in Laravel 10+ for a production chatbot?
Yes, but with caution. The package is experimental and lacks Symfony’s backward compatibility guarantees. Test thoroughly in staging, monitor LLM API limits, and use Laravel’s queue system for async workloads. For production, pair it with a message store (e.g., Redis or Doctrine) to persist conversations reliably.
How do I connect Symfony AI Chat to OpenAI or another LLM provider?
Use Symfony’s `HttpClient` or Laravel’s `Http` client to call LLM APIs. Wrap the API calls in a custom `Tool` class implementing `ToolInterface`, then register it with your agent. Example: `new OpenAITool($httpClient, 'your-api-key')`. The package abstracts the LLM interaction but requires manual provider setup.
Will this work with Laravel’s authentication system for user-specific chat history?
Absolutely. Use Laravel’s auth middleware on chat routes and bind a message store (e.g., `symfony/ai-redis-message-store`) to persist conversations per user. Example: `$store->setUserId(auth()->id())`. Combine this with Laravel’s cache or session for temporary storage during active sessions.
Are there Laravel-specific tools (e.g., database queries, Eloquent models) for agents?
Not out of the box, but you can create custom tools. Extend `ToolInterface` and use Eloquent or Laravel’s query builder inside. Example: `class DatabaseTool implements ToolInterface { public function execute(string $query): mixed { return DB::select($query); } }`. Register it with your agent for dynamic database interactions.
How do I handle failed API calls or rate limits from LLMs in a Laravel app?
Leverage Laravel’s exception handling and Symfony’s retry logic. Wrap LLM calls in a `try-catch` block, log failures with Laravel’s logging, and use exponential backoff via `symfony/messenger` or Laravel Queues. For rate limits, implement a fallback tool or queue delayed retries.
Can I use this for multi-turn conversations (e.g., support bots) with context memory?
Yes, the package supports context-aware agents. Configure a message store (e.g., Redis) to persist conversation history, then inject it into your agent. Example: `$agent->setMessageStore($redisStore)`. For long-term memory, pair it with Laravel’s database or cache for structured data.
What’s the best way to integrate this with Laravel Blade for a chat UI?
Symfony AI Chat returns JSON by default, so create a Blade component or controller that fetches responses and renders them. Use Laravel’s `json_decode()` to process agent outputs, then loop through messages in Blade. Example: `@foreach($messages as $message) <div>{{ $message['content'] }}</div> @endforeach`. Style it with Alpine.js or Livewire for reactivity.
Are there alternatives to Symfony AI Chat for Laravel that are more stable?
If stability is critical, consider Laravel-specific packages like `laravel-ai` (by BeyondCode) or `ai-chatbot-laravel`. These are tailored for Laravel’s ecosystem and may offer better integration with Eloquent, queues, and auth. However, Symfony AI Chat provides more modularity for complex agent workflows if you’re comfortable with experimental tech.
How do I test Symfony AI Chat in Laravel with PHPUnit?
Mock the LLM provider and message store dependencies. Use PHPUnit’s `createMock()` to simulate API responses, then test agent logic in isolation. Example: `$mockTool = $this->createMock(ToolInterface::class); $mockTool->method('execute')->willReturn('test'); $agent->addTool($mockTool);`. Test controllers with Laravel’s HTTP tests for end-to-end validation.
What’s the performance impact of using Symfony AI Chat in high-traffic Laravel apps?
Performance depends on LLM API calls and message store latency. Profile with Laravel Debugbar and optimize by caching frequent responses (e.g., `Cache::remember`). For async workloads, offload agent tasks to Laravel Queues with `symfony/messenger`. Monitor queue depth and LLM rate limits under load to avoid bottlenecks.
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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor