- Can I use this package directly in Laravel without Symfony dependencies?
- No, this package requires Symfony AI (≥v0.8.0). For Laravel, use **spatie/laravel-ai** (v1.0+) as a bridge or abstract the provider layer in Laravel’s service container to decouple Symfony dependencies. This lets you swap providers later if needed.
- How do I configure Scaleway API keys securely in Laravel?
- Store keys in Laravel’s `.env` (e.g., `SCALEWAY_API_KEY`) and bind them to the Symfony AI client via Laravel’s service provider. Use `config(['services.scaleway' => env('SCALEWAY_API_KEY')])` or leverage Laravel’s binding system for runtime injection.
- Does this support real-time streaming responses like OpenAI’s SDK?
- Yes, via Symfony AI’s `DeltaInterface`. In Laravel, process streams with events or queues. Example: `$client->chat()->stream()->onDelta(fn($delta) => Log::info($delta->getContent()));`. For async handling, dispatch a job to queue the streamed chunks.
- What Laravel versions and PHP versions are officially supported?
- The package depends on Symfony AI, which supports PHP 8.2+. Laravel compatibility isn’t explicitly stated, but it works with Laravel 10+ via **spatie/laravel-ai** (tested with Laravel 10/11). For older Laravel, abstract the provider layer manually.
- How do I handle retries or fallback to OpenAI if Scaleway fails?
- Use Laravel’s **spatie/laravel-http-middlewares** for retries (e.g., exponential backoff) or implement a multi-provider strategy. Wrap the Symfony client in a Laravel service that falls back to another provider (e.g., `guzzlehttp/guzzle` for OpenAI) on failure.
- Are there performance benchmarks for Scaleway vs. OpenAI in Laravel?
- No official benchmarks exist, but Scaleway’s regional endpoints (e.g., `fr-par`, `nl-ams`) may reduce latency for EU/US users. Test with Laravel’s `benchmark()` helper or tools like **Blackfire** to compare response times for your workload (e.g., embeddings vs. chat).
- Can I use this for embeddings (vector search) in Laravel?
- Yes, Scaleway’s OpenAI-compatible API supports embeddings. Use the `embeddings()` method in Laravel via the Symfony client. For production, batch requests with Laravel queues to optimize costs and performance (e.g., `EmbeddingJob::dispatch($texts)->onQueue('embeddings')`).
- What’s the cost difference between Scaleway and OpenAI for Laravel apps?
- Scaleway often offers lower token costs (check their [pricing](https://www.scaleway.com/en/generative-ai/pricing/)). Compare your Laravel app’s usage (e.g., 10k tokens/month) and model needs (e.g., `gpt-4o` vs. Scaleway’s equivalent). Use Laravel’s `config()` to dynamically switch providers based on cost.
- How do I monitor Scaleway API errors or token usage in Laravel?
- Log errors with Laravel’s `Log::error()` or send them to **Sentry/Datadog**. Track token usage by wrapping the client in a Laravel middleware or service that increments a counter (e.g., `Cache::increment('scaleway_tokens_used')`).
- Are there alternatives to this package for Laravel + Scaleway?
- No direct Laravel-native alternative exists yet. Options include: 1) **Custom wrapper** around Scaleway’s raw API (e.g., `Guzzle`), 2) **Symfony AI + spatie/laravel-ai**, or 3) Wait for a Laravel-specific Scaleway package. The Symfony bridge is the most feature-complete for now.