Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Ai Open Router Platform

Ai Open Router Platform Laravel Package

symfony/ai-open-router-platform

Symfony AI bridge for the OpenRouter platform. Provides integration for chat completions (including streaming), model listing, and rerank requests via OpenRouter’s API, enabling Symfony apps to access multiple LLM providers through a single gateway.

View on GitHub
Deep Wiki
Context7

OpenRouter platform bridge for Symfony AI

Frequently asked questions about Ai Open Router Platform
What is symfony/ai-open-router-platform and can I use it in a Laravel app?
It is the OpenRouter platform bridge for Symfony AI, exposing chat completions (including streaming), model listing and rerank calls through OpenRouter's API so one gateway can reach many LLM providers. It is a plain Composer package built on PSR interfaces, so nothing stops you from installing it in a Laravel project. The caveat is that its public surface is designed around Symfony AI abstractions such as the platform and client interfaces, so in Laravel you will usually wrap it in a small service class or facade rather than calling it from controllers directly.
How do I install symfony/ai-open-router-platform with Composer?
Run composer require symfony/ai-open-router-platform and let Composer resolve the matching Symfony AI and HTTP client versions. Because the package is a bridge, you normally also need the core Symfony AI package that provides the client and platform contracts, which Composer will pull in if it is declared as a dependency. After installation, register the platform or client in a service provider so Laravel's container can inject it where needed.
Which Laravel and PHP versions are compatible with this package?
Compatibility follows the Symfony release train rather than Laravel itself: the bridge targets Symfony HTTP Client 7.3 or 8.0 and Symfony AI 0.9.x, which means a modern PHP 8.2+ runtime. Any Laravel version running on a supported PHP release can host it, since the package does not depend on Laravel framework code. Always check the composer.json constraints before upgrading PHP or Laravel, and pin versions in production.
How do I configure my OpenRouter API key in Laravel?
Never hardcode the key. Add it to config/services.php as an openrouter entry reading env('OPENROUTER_API_KEY'), store the value in your .env file, and pass it into the client or platform constructor from that config. Cache the config with php artisan config:cache and keep the .env file out of version control. If you need to store keys per tenant in the database, encrypt them with Laravel's encrypt() and decrypt only at request time.
Does the package support streaming chat completions in Laravel?
Yes, streaming is one of the documented capabilities and maps to OpenRouter's streaming endpoint. In Symfony the bridge returns a streaming response object; in Laravel you would iterate the chunks and forward them to the browser using a StreamedResponse, server-sent events or a broadcast event. If you need to process chunks asynchronously, dispatch a queued job per chunk or batch instead of doing heavy work inside the stream loop.
How do I list the models available through OpenRouter?
The bridge exposes the models endpoint described in OpenRouter's API reference, so you can fetch the catalogue of available models and their metadata programmatically. Typical uses are populating an admin dropdown, validating a configured model name, or checking pricing and context limits before a request. Cache the result, for example with Cache::remember for an hour, because the list changes slowly and the call is not free of latency.
Can I make rerank requests with this package?
Yes, rerank is part of the supported surface and follows OpenRouter's rerank endpoint. Reranking is most useful in retrieval pipelines, so in Laravel you would call it after fetching candidate documents from Scout, Algolia, or a vector store and reorder the results before returning them to the user. Keep the candidate set small, since rerank cost and latency scale with the number of documents you send.
Do I need the whole Symfony AI stack to use this package in Laravel?
Strictly speaking the bridge is built on Symfony AI contracts, so you pull those in as a dependency even if you only use chat completions. If you want to avoid that coupling, the pragmatic alternative is to skip the bridge and call OpenRouter's REST API directly with Laravel's Http facade, which removes the Symfony AI dependency entirely. Use the bridge when you value the platform abstraction and provider routing; use raw HTTP when you want the smallest possible dependency footprint.
How do I test OpenRouter calls in a Laravel application without hitting the real API?
Mock at the HTTP boundary: if you call OpenRouter through Laravel's Http facade, Http::fake() lets you return canned chat, model list, or rerank payloads and assert the outgoing request body. If you go through the Symfony client, inject a mock or stub implementation of the platform and client interfaces into your service instead. Either way, keep your own thin wrapper class around the bridge so tests only need to fake one collaborator.
Is symfony/ai-open-router-platform stable enough for production, and what are the alternatives?
Treat it as pre-1.0: Symfony AI is still on 0.9.x, so breaking changes are possible between minor releases, and you should pin an exact patch version and review changelogs before upgrading. Maintenance happens in the main symfony/ai repository, so issues and pull requests go there rather than to this readme repository. Alternatives include calling OpenRouter's REST API directly from Laravel, or using Laravel-oriented AI packages if you want a more native integration; choose based on whether the Symfony platform abstraction earns its weight in your codebase.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console