Weave Code
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
Can I use this package in Laravel without pulling in Symfony’s entire AI stack?
Yes. The package’s core OpenRouter client can be used independently by injecting Laravel’s `Http` facade or Guzzle instead of Symfony’s `HttpClient`. Avoid Symfony’s `AiClient` abstraction unless you need advanced provider routing. Example: `$client = new Client(Http::macroable());`
How do I configure OpenRouter API keys securely in Laravel?
Store your OpenRouter API key in Laravel’s `.env` under `OPENROUTER_API_KEY` and access it via `config('services.openrouter.api_key')`. For extra security, encrypt the key using Laravel’s `encrypt()` helper or a package like `laravel/env-editor`. Never hardcode keys.
Does this package support streaming responses in Laravel?
Yes, but you’ll need to handle streaming chunks manually. Use Laravel’s event system or queues to process chunks asynchronously. Example: `$client->stream([new ChatMessage('Hello')])->then(fn($chunk) => event(new OpenRouterChunkReceived($chunk)));`
Will this work with Laravel 10+ and Symfony AI’s pre-1.0 version?
Yes, but pin to a specific patch version (e.g., `0.9.0`) to avoid breaking changes. Monitor Symfony’s AI roadmap and OpenRouter’s API updates. If using Laravel’s Http facade, you won’t need Symfony’s full stack, reducing version conflicts.
How do I switch between OpenRouter and other AI providers in Laravel?
Leverage Laravel’s service container to bind multiple providers. For OpenRouter, register it as a service and use dependency injection. Example: `app()->bind(OpenRouterClient::class, fn() => new Client(Http::macroable()));`. For multi-provider logic, extend Symfony’s `Provider` abstraction or build a custom resolver.
Are there Laravel-specific facades or helpers for this package?
No built-in facades, but you can create a Laravel-friendly wrapper. Example: `OpenRouter::chat()` by publishing a facade or using a service class. This hides Symfony-specific syntax while keeping the core functionality intact.
How does OpenRouter’s latency compare to native Laravel AI packages like `laravel-ai`?
Latency depends on OpenRouter’s infrastructure, not the package itself. Benchmark against your preferred providers. For caching, integrate Redis or Laravel’s cache system to store frequent responses (e.g., model listings) and reduce API calls.
Can I use this for reranking search results in Laravel Scout or Algolia?
Yes, but you’ll need custom logic. Use the `rerank` method to fetch scores, then integrate with Scout’s `searchable` traits or Algolia’s API. Example: `$scores = $client->rerank($query, $documents);` and pass results to your search pipeline.
What’s the best way to handle errors or rate limits from OpenRouter?
Wrap API calls in try-catch blocks and use Laravel’s exception handling. For rate limits, implement exponential backoff or queue delayed retries. Example: `try { $response = $client->chat(...); } catch (OpenRouterException $e) { Log::error($e); }`
Are there alternatives to this package for Laravel?
Yes. For OpenRouter-specific needs, consider direct HTTP calls via Laravel’s `Http` facade or a lightweight wrapper like `guzzlehttp/guzzle`. For broader AI support, evaluate `laravel-ai` or `spatie/laravel-ai`, which are Laravel-native and avoid Symfony dependencies entirely.
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky