- Can I use ai-gateway-bundle in a Laravel project, or is it strictly for Symfony?
- This bundle is designed for Symfony, not Laravel. While it leverages Symfony’s ecosystem (Flex, Doctrine, Symfony AI), Laravel projects would require significant abstraction or a wrapper layer. For Laravel, consider alternatives like Laravel AI SDKs or custom middleware for proxying requests.
- How do I install and configure the bundle in a Symfony 6.4+ project?
- Run `composer require ai-gateway/ai-gateway-bundle` and enable it in `config/bundles.php`. Configure providers (OpenAI, Anthropic) via CLI (`php bin/console aigw:provider:create`) or the dashboard. Set up API keys and model aliases in the dashboard or via YAML config under `config/packages/ai_gateway.yaml`.
- Does the bundle support custom AI providers beyond OpenAI and Anthropic?
- Yes, the bundle supports custom providers if they conform to OpenAI’s API format. Use the CLI (`php bin/console aigw:provider:create`) to define new providers with their base URLs and authentication methods. For non-standard APIs, you may need to extend the `GatewayInterface` or use middleware.
- How does the model fallback chain work, and can I customize failure handling?
- Model fallback chains route requests to multiple providers sequentially. If a provider fails (e.g., rate limit, error), the bundle logs the failure and moves to the next model in the chain. Customize failure handling by extending the `Chain` class or configuring alerts (e.g., Slack, Prometheus) in the dashboard’s notification settings.
- Is the dashboard secure enough for production, or do I need additional auth layers?
- The dashboard includes basic token authentication (`DASHBOARD_TOKEN`). For stricter security, integrate Symfony’s firewall or use OAuth2. Avoid exposing the dashboard publicly; restrict access via IP whitelisting or VPN. For GDPR compliance, encrypt API keys and logs at rest.
- How does cost tracking work, and can I set per-team or per-model budgets?
- Cost tracking logs tokens used, duration, and provider-specific pricing per request. Budgets can be configured globally or per API key in the dashboard. The bundle doesn’t enforce budgets natively but provides data for custom validation logic (e.g., middleware to block requests when limits are exceeded).
- Will this bundle work with Laravel’s HTTP clients (Guzzle, Symfony HTTP Client) without issues?
- No, this bundle is Symfony-specific and won’t integrate directly with Laravel’s HTTP clients. Use it as a standalone service: configure your Laravel app to proxy AI requests to the Symfony bundle’s `/v1` endpoint. Alternatively, wrap the bundle’s logic in a Laravel package for tighter integration.
- What’s the performance impact of using this bundle in high-traffic applications?
- The bundle adds minimal overhead for caching (SHA-256) and auth checks, but rate limiting and logging may introduce latency. Benchmark with your expected load (e.g., 10K RPS). For scaling, deploy multiple instances behind a load balancer and use Redis for shared rate limiting. Avoid SQLite in production due to concurrency limits.
- Can I migrate an existing Laravel app using direct OpenAI SDK calls to this bundle?
- Yes, but you’ll need to replace SDK calls with HTTP requests to the bundle’s `/v1` endpoint. Use the same request/response format as OpenAI’s API. For Laravel, create a facade or service to abstract the bundle’s URL. Test thoroughly, as some SDK features (e.g., streaming) may require adjustments.
- Are there alternatives to this bundle for Symfony/Laravel that offer similar functionality?
- For Symfony, alternatives include custom middleware or packages like `symfony/ux-live-component` for streaming, but none offer the same unified gateway pattern. In Laravel, consider `spatie/laravel-ai` (for SDKs) or `guzzlehttp/guzzle` with middleware for proxying. For enterprise use, evaluate commercial APIs like Together.ai or custom solutions.