Skip to content

Add OpenRouter as a new AI provider#12626

Draft
RemiKalbe wants to merge 5 commits intogitbutlerapp:masterfrom
RemiKalbe:master
Draft

Add OpenRouter as a new AI provider#12626
RemiKalbe wants to merge 5 commits intogitbutlerapp:masterfrom
RemiKalbe:master

Conversation

@RemiKalbe
Copy link

@RemiKalbe RemiKalbe commented Feb 28, 2026

🧢 Changes

Add OpenRouter as a new AI provider. OpenRouter exposes an OpenAI-compatible API, so the frontend reuses OpenAIClient with the OpenRouter base URL. The model name is a free-form text input since OpenRouter supports hundreds of models in provider/model format (e.g. openai/gpt-4.1-mini).

Frontend: new OpenRouter variant in ModelKind, config keys, secret handle, service methods, settings panel with API key and model inputs, and two new tests.

Backend: new OpenRouterProvider following the LM Studio pattern which implements OpenAIClientProvider + LLMClient, reads API key from secret storage with OPENROUTER_API_KEY env var fallback.

CSP: added https://openrouter.ai to connect-src.

🎫 Affected issues

Fixes: #12070

Preview

CleanShot 2026-02-27 at 16 26 46@2x

@vercel
Copy link

vercel bot commented Feb 28, 2026

@RemiKalbe is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eaa15c57d3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Adds checks to verify that retrieved API keys are not empty or solely whitespace. This prevents attempts to use invalid credentials, improving reliability.
@Byron
Copy link
Collaborator

Byron commented Feb 28, 2026

Thanks a lot for contributing!

At first glance it does look like a run-of-the-mill integration that might do the trick, but I didn't test it locally, nor am I aware of any gotchas to look out for.

Hence, let's pass this on to @estib-vega for proper validation.

PS: pnpm begood should fix the frontend lint errors, cargo fmt will do the same to the backend, cargo clippy --workspace --all-targets should do the rest.

@Byron
Copy link
Collaborator

Byron commented Feb 28, 2026

@codex review

@Byron Byron marked this pull request as draft February 28, 2026 04:12
@Byron Byron requested a review from estib-vega February 28, 2026 04:12
Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e05843155

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


return new OpenAIClient(
openRouterKey,
openRouterModelName as OpenRouterModelName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate OpenRouter model name before constructing client

buildClient() force-casts openRouterModelName to OpenRouterModelName without any runtime check, while the settings UI accepts arbitrary free-form text for that field. If a user saves an invalid value (for example missing the provider/model format), configuration still appears valid and failures only surface as downstream OpenRouter API errors during generation. Add a format check (or fallback to the default model) before creating OpenAIClient so misconfiguration is caught deterministically.

Useful? React with 👍 / 👎.

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.

Support OpenRouter as AI Provider

2 participants