- Can I use symfony/ai-voyage-platform directly in a Laravel app without Symfony?
- Yes, but you’ll need to bridge Symfony’s dependency injection (DI) with Laravel’s container. Use Laravel’s `AppServiceProvider` to bind Symfony services or adopt PHP-DI as a neutral container. The package’s Provider abstraction helps abstract Voyage-specific logic, but Symfony dependencies (like `symfony/ai`) may require polyfills like `php-http/guzzle9-adapter` for HTTP clients.
- What Laravel versions does this package support?
- The package itself doesn’t enforce Laravel version constraints, but it depends on Symfony components (e.g., `symfony/ai` v2.0+). Ensure your Laravel app (8.0+) can host Symfony services via DI adapters. Test thoroughly, as Symfony’s evolution may introduce compatibility gaps. For Laravel 10+, check for breaking changes in Symfony AI’s roadmap.
- How do I cache Voyage embeddings in Laravel to reduce API costs?
- Use Laravel’s caching drivers (Redis, file, etc.) to store embeddings after generation. For high-throughput apps, queue embedding requests with Laravel Queues and cache results with a TTL (e.g., 24 hours). The package doesn’t include built-in caching, so implement middleware or a service layer to wrap Voyage API calls and persist responses.
- Is there a way to fallback to a local model if Voyage’s API fails?
- Yes, leverage the Provider abstraction to route requests between Voyage and alternative providers (e.g., OpenAI or a local embedding model). Configure a fallback chain in your Symfony/Laravel service provider. For example, catch API exceptions and delegate to a secondary provider using dependency injection. Test failover logic during integration.
- How do I integrate Voyage embeddings with a vector database like Meilisearch or TypeORM Spatial?
- First, generate embeddings using the package’s API client (e.g., `client->embed()`). Then, serialize the vector arrays (e.g., `float[]`) into your database schema. For Meilisearch, use its vector search capabilities directly. For TypeORM Spatial, ensure your model fields match the embedding dimensions (e.g., `float[]` or `json`). Libraries like `spatie/laravel-ai` can simplify Laravel-specific vector storage.
- What’s the performance impact of using this package vs. Voyage’s direct SDK?
- The package adds minimal overhead for embedding generation but introduces Symfony DI layers, which may slow cold starts. Benchmark your use case by comparing direct SDK calls (e.g., Voyage’s Python/JS SDK) to this bridge. For production, cache embeddings aggressively (Redis) and consider batching requests to reduce API latency. Profile memory usage if processing large documents.
- Are there Laravel-specific helpers or Facades to simplify usage?
- The package is Symfony-centric, so you’ll need to create Laravel wrappers. For example, build a Facade to abstract Symfony’s `ClientInterface` or convert Symfony Messages to Laravel Collections. Contribute these back to the package or maintain them in your app. Tools like `laravel-ai` or custom traits can further simplify integration.
- How do I handle API rate limits or quota errors from Voyage?
- Implement Laravel Middleware to monitor HTTP response codes (e.g., `429 Too Many Requests`) and enforce exponential backoff. Use Voyage’s API keys with rate-limiting libraries like `symfony/http-client`’s retry strategies. For critical apps, integrate with Laravel Telescope to track usage patterns and set budget alerts before hitting quota limits.
- What alternatives exist for Voyage embeddings in Laravel?
- Consider Voyage’s direct SDK (Python/JS) for lightweight projects, or Laravel-native packages like `spatie/laravel-ai` (for OpenAI/Anthropic) or `tighten/laravel-ai` (for Hugging Face). If you need multimodal support, evaluate local models (e.g., Sentence Transformers) or cloud providers like AWS Bedrock. The Provider abstraction here lets you swap Voyage for alternatives with minimal code changes.
- How do I test this package in a Laravel CI pipeline?
- Mock the Voyage API responses using Laravel’s HTTP testing helpers (e.g., `Http::fake()`) or PHPUnit’s HTTP client mocks. Test edge cases like API failures, rate limits, and embedding serialization. For Symfony-specific services, use Laravel’s container bindings to inject mocks. Ensure your tests cover the Provider abstraction’s fallback logic and caching layers.