Skip to content

Use laravel/ai default provider for OpenRouter - #221

Draft
paulocastellano wants to merge 1 commit into
mainfrom
cursor/openrouter-via-ai-default-031b
Draft

Use laravel/ai default provider for OpenRouter#221
paulocastellano wants to merge 1 commit into
mainfrom
cursor/openrouter-via-ai-default-031b

Conversation

@paulocastellano

Copy link
Copy Markdown
Contributor

Summary

OpenRouter is a first-class provider in the Laravel AI SDK (docs): set OPENROUTER_API_KEY and use openrouter as the configured provider. No custom driver wiring is needed.

Our agents were blocking that path. Each one overrode provider() with:

match (config('ai.default')) {
    'openai' => Lab::OpenAI,
    'anthropic' => Lab::Anthropic,
    default => Lab::Gemini,
};

So AI_TEXT_PROVIDER=openrouter was remapped to Gemini. Per the SDK, when an agent omits provider(), Promptable already falls back to config('ai.default').

Changes

  • Remove the duplicated provider() overrides from all AI agents.
  • Gate text-AI availability (BrandAnalyzerRunner, shared aiEnabled) on ai.providers.{default}.key via App\Support\AiConfiguration.
  • Document OPENROUTER_API_KEY / openrouter in .env.example.
  • Add/update tests for OpenRouter availability and that agents no longer override provider().

Usage

AI_TEXT_PROVIDER=openrouter
AI_TEXT_MODEL=openai/gpt-4o-mini
OPENROUTER_API_KEY=sk-or-v1-...

Related: #216 (alternative approach that patches each match instead of using the SDK default).

Open in Web Open in Cursor 

Agents no longer override provider() with a hardcoded openai/anthropic/gemini
match that silently remapped openrouter (and any other configured driver) to
Gemini. Promptable already falls back to config('ai.default'), and laravel/ai
ships a first-class OpenRouter driver.

Gate text-AI availability on ai.providers.{default}.key, document
OPENROUTER_API_KEY, and cover OpenRouter in unit/feature tests.

Co-authored-by: Paulo Castellano <hello@paulocastellano.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants