- How do I install symfony/ai-mistral-platform in a Laravel application?
- Install it with Composer alongside the Symfony AI core packages, then bind the Mistral client and provider abstractions into Laravel's service container. Because this is a Symfony AI bridge rather than a Laravel package, there is no Laravel auto-discovery, so you register a small service provider yourself. Put your API key and endpoint in config/ai.php or a dedicated config file and resolve the client from the container in your services.
- Does this package work with Laravel, or is it Symfony-only?
- The package targets Symfony AI, but its low-coupling design means Laravel can host it without major refactoring. It relies on PSR-18 HTTP clients and Symfony's ClientInterface and Provider abstractions, which Laravel's container can resolve and inject into facades or services. In practice you write a thin Laravel service provider and config mapping rather than a full rewrite.
- Which PHP and Laravel versions does symfony/ai-mistral-platform support?
- There is no Laravel-specific version constraint because the package is a framework-agnostic Symfony AI bridge, currently tracking the Symfony AI v0.15.x line. Check the composer.json PHP and symfony/* requirements before adopting it in an existing app. In general it runs on modern PHP 8.x with a PSR-18 compatible HTTP client available in your project.
- How do I configure the Mistral API key and endpoint in Laravel?
- Define MISTRAL_API_KEY and optionally MISTRAL_ENDPOINT in your .env file, with the endpoint defaulting to https://api.mistral.ai. Map those values into a providers.mistral entry in config/ai.php that references the Mistral client class. Then inject the client or chat client into your services through Laravel's container instead of hardcoding credentials.
- Does symfony/ai-mistral-platform support streaming chat responses?
- Yes, chat completions can be streamed through the Symfony AI streaming abstractions, including the DeltaInterface for semantic chunk handling. In Laravel you can consume the stream in a controller or a queued job, but queue middleware may be needed when you want real-time chunk processing rather than batched output. For simple use cases, request a non-streamed completion and skip the streaming plumbing entirely.
- How does OCR document processing work with this Mistral bridge?
- The bridge exposes Mistral's OCR endpoint, so you can send document media and get extracted content back through the same Symfony AI client interface you use for chat. You pass the file through the client rather than building your own multipart HTTP call. The package ships test fixtures including a public-domain document.pdf you can use to validate your pipeline before pointing it at real customer documents.
- Why did max_output_tokens change to max_tokens in version 0.15.0?
- Version 0.15.0 replaced the shared canonical max_output_tokens option with each bridge's own wire field, so Mistral requests now use max_tokens. This improves fidelity because the bridge no longer performs lossy translation of your options. The trade-off is portability: if you keep one provider-agnostic config, add a small translator service that maps your canonical setting to the correct wire field per provider.
- How do I test my Mistral integration without making real API calls?
- Mock the PSR-18 HTTP client or the chat client interface in your Laravel tests so no network traffic leaves the suite. The package includes test fixtures under Tests/Fixtures with binary media content, including a public-domain document.pdf suitable for OCR scenarios. Assert on the request payload and the parsed response rather than on live model output, which is non-deterministic.
- How can I track token usage and cost per Mistral model in Laravel?
- TokenUsage carries the serving model name, so you can compute per-model, per-request costs in your own application layer. A common pattern is a pricing map, a cost calculator service bound in the container, and an event listener that records usage to your logging or metrics channel. Because the bridge does not touch TokenUsage in recent releases, this wiring stays stable across upgrades.
- Can I route between Mistral and other providers from the same Laravel app?
- Yes, the Provider abstraction still allows dynamic routing between Mistral and other Symfony AI bridges for fallback or cost-based selection. The caveat is that provider-agnostic option objects no longer cover output-length control uniformly since the v0.15.0 wire-field rename. Keep a translation layer in your integration code so call sites never reference a wire field directly, and evaluate alternatives such as a direct Mistral SDK only if you need a single-provider setup.