Open
Conversation
Adds an optional OpenRouter dropdown to the companion panel so users can route voice requests through OpenRouter (Sonnet, Opus, ChatGPT, Grok, Gemini, Qwen) instead of Claude direct. Default behavior is unchanged — OpenRouter is opt-in. - New /openrouter-chat route on the Cloudflare Worker proxy - New OpenRouterAPI.swift client using OpenAI-compatible streaming format - Provider-aware routing in CompanionManager - OpenRouter model picker dropdown in CompanionPanelView Requires OPENROUTER_API_KEY worker secret to be set and worker redeploy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional OpenRouter dropdown to the companion panel so users can route voice requests through OpenRouter (Sonnet, Opus, ChatGPT, Grok, Gemini, Qwen) instead of Claude direct. Default behavior is unchanged — OpenRouter is opt-in.
Changes
Cloudflare Worker (
worker/src/index.ts)/openrouter-chatroute that proxies tohttps://openrouter.ai/api/v1/chat/completionsOPENROUTER_API_KEYin theEnvinterfaceSwift app
OpenRouterAPI.swift— OpenAI-compatible streaming client (parseschoices[0].delta.contentSSE events, usesimage_urldata URIs for vision)CompanionManager: newselectedOpenRouterModel(persisted to UserDefaults),isUsingOpenRoutercomputed property, andanalyzeImageStreamingWithActiveProvider()helper that routes to the right clientCompanionPanelView: new "OpenRouter" row with a dropdown menu (Off / Sonnet / Opus / ChatGPT / Grok / Gemini / Qwen). Selecting an OpenRouter model deselects the Claude direct buttons; selecting a Claude direct button clears OpenRouter.Setup (required before this works)
Merging this PR requires a worker redeploy and a new secret:
cd worker npx wrangler secret put OPENROUTER_API_KEY npx wrangler deployWithout the secret, selecting an OpenRouter model will error — but the default (Claude direct) keeps working, so the blast radius of "merged but not deployed" is low.
Design notes
selectedOpenRouterModel(separate key fromselectedClaudeModel) so the two pickers don't clobber each other.CompanionPanelView.openRouterModels. Easy to edit if you want different defaults.Test plan
🌐 OpenRouter streaming request:when OpenRouter is active, and🌐 Claude streaming request:when it's off