- Can I use this package directly in Laravel, or is it strictly for Symfony?
- This package is designed for Symfony but can be adapted to Laravel with minimal effort. Replace Symfony’s HttpClient with Laravel’s HTTP facade or Guzzle, bind services via `AppServiceProvider`, and create facades for seamless integration. The core functionality (prompt formatting, API calls) is stack-agnostic.
- How do I handle API authentication (keys/OAuth) in Laravel?
- Configure API keys via Laravel’s `.env` file or `config/services.php` and pass them to the client during initialization. The package supports standard HTTP auth methods, so you can use Laravel’s `Http` facade or a PSR-18 client like Guzzle to manage credentials.
- Does this package support real-time streaming responses (e.g., for chat apps)?
- The package does not explicitly document streaming support, but Meta’s Llama API may offer it. Check the [Llama 3.3 prompt format docs](https://github.com/meta-llama/llama-models/blob/main/models/llama3_3/prompt_format.md) for streaming capabilities. For Laravel, you’d need to extend the client to handle chunked responses.
- What Laravel versions are officially supported?
- The package itself doesn’t enforce Laravel version constraints, but it relies on Symfony components that may have dependencies. Test with Laravel 10.x or 11.x and ensure compatibility with the Symfony AI ecosystem. No official Laravel test suite exists, so manual validation is required.
- How do I integrate this with Laravel’s Queue system for async AI tasks?
- Wrap the AI client calls in a Laravel job (e.g., `GenerateContentJob`) and dispatch it to a queue. The package’s core logic remains unchanged—just ensure the job’s `handle()` method uses the adapted client. This works for batch processing like content generation.
- Are there alternatives for Llama integration in Laravel if this package is too immature?
- Yes. For direct Llama API access, use Laravel’s HTTP client with Meta’s [official API docs](https://llama.com/api). For higher-level abstractions, consider `php-ai/php-ai` (multi-provider) or `ollama-php/ollama` (local model support). These avoid Symfony dependencies entirely.
- How do I customize prompts beyond Llama’s static formats (e.g., Blade templates)?
- Pre-process prompts in Laravel before passing them to the package. Use Blade directives in your templates, then pass the rendered string to the client. For dynamic data (e.g., user context), inject it via Laravel’s service container or facades before calling the AI.
- What’s the retry/fallback strategy for API failures?
- The package doesn’t include built-in retry logic, but you can integrate Laravel’s `retry` helper or a package like `spatie/laravel-retryable` to handle transient failures. For fallbacks, extend the client to switch to a secondary provider (e.g., OpenAI) if Meta’s API fails.
- Can I deploy Llama models locally (e.g., Ollama) instead of using Meta’s cloud API?
- The package targets Meta’s cloud API, but you can bypass it by using a custom client that points to Ollama or a local endpoint. Replace the HTTP client with a direct connection to your local model server, ensuring the prompt format matches Llama’s requirements.
- How do I test this package in a Laravel project?
- Mock the HTTP client (e.g., with Laravel’s `Http::fake()`) to test responses without hitting Meta’s API. For integration tests, use a test API key and validate prompt formatting. Since there’s no Laravel-specific test suite, focus on edge cases like malformed prompts or API timeouts.