refactor(openrouter): extract org model logic and use it in models API route#2326
Merged
chrarnoldus merged 17 commits intomainfrom Apr 13, 2026
Merged
refactor(openrouter): extract org model logic and use it in models API route#2326chrarnoldus merged 17 commits intomainfrom
chrarnoldus merged 17 commits intomainfrom
Conversation
Contributor
Author
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 files)
Reviewed by gpt-5.4-20260305 · 824,986 tokens |
…emove tRPC call from route
chrarnoldus
reviewed
Apr 12, 2026
marius-kilocode
approved these changes
Apr 13, 2026
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
Extracts the organization-aware model-listing logic (enterprise deny-list filtering, org-level BYOK, custom LLMs) from the `listAvailableModels` tRPC procedure into a shared helper `getAvailableModelsForOrganization` in `apps/web/src/lib/organizations/organization-models.ts`.
The `/api/openrouter/models` REST endpoint now uses this helper when the request includes an `x-kilocode-organizationid` header (i.e. `getUserFromAuth` returns an `organizationId`), so org members get the same filtered, org-aware model list through the REST API as they do via tRPC.
Changes:
Verification
pnpm typecheck— no errors.Visual Changes
N/A
Reviewer Notes
The extracted helper returns `null` when the organization is not found; the REST route falls back to the global list in that case (preserving the previous behavior), while the tRPC procedure still throws `NOT_FOUND` as before.