Add OpenRouter as a configurable AI provider with Gemini fallback#191
Add OpenRouter as a configurable AI provider with Gemini fallback#191
Conversation
Co-authored-by: na-trium-144 <100704180+na-trium-144@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
my-code | f7185cd | Commit Preview URL Branch Preview URL |
Mar 13 2026, 03:54 PM |
|
@copilot openrouterのapiに直接fetchするのではなく、sdkライブラリを使って。 |
Co-authored-by: na-trium-144 <100704180+na-trium-144@users.noreply.github.com>
|
@copilot gemini.tsとopenrouter.tsの内容を1つのファイルの1つのgenerateContent関数にまとめて、環境変数で分岐するのもそこで行うようにしてほしい。 |
… function Co-authored-by: na-trium-144 <100704180+na-trium-144@users.noreply.github.com>
Done in 9a28d39. |
|
@copilot 環境変数でセミコロン区切りとかでモデルを複数指定できるようにし、エラー時にフォールバックされるようにしてほしい。openrouterのapiはmodelsパラメーターにarrayを渡すと自動でフォールバックしてくれるようですが、openai sdkはそれに対応していない気がするのでsdkは使わず直接fetchするようにしてよいです。 |
…atic fallback Co-authored-by: na-trium-144 <100704180+na-trium-144@users.noreply.github.com>
Done in a259c8b. The OpenRouter path in
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
chatActions.tswas hardwired to Gemini. Add OpenRouter as an alternative provider, selected automatically via environment variables.Changes
app/actions/gemini.tsgenerateContentfunction now handles both providers internally:OPENROUTER_API_KEYandOPENROUTER_MODELare both set → calls OpenRouter via directfetchtohttps://openrouter.ai/api/v1/chat/completionsOPENROUTER_MODELaccepts a semicolon-separated list of models (e.g.model-a;model-b;model-c); the list is passed as themodelsarray to OpenRouter, which automatically falls back to the next model on error{ text: string }consistently from both pathsapp/actions/chatActions.tsgenerateContentfrom./gemini; no local selector function neededapp/actions/openrouter.ts(removed)gemini.tsSet both
OPENROUTER_API_KEYandOPENROUTER_MODELto switch to OpenRouter; omit either to keep using Gemini unchanged.💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.