feat (provider/gateway): add provider routing sort options#14311
Merged
Conversation
98d80f4 to
e08b30d
Compare
e08b30d to
f0ed336
Compare
f0ed336 to
f4f0cc0
Compare
f4f0cc0 to
a5a005e
Compare
dancer
approved these changes
Apr 10, 2026
|
🚀 Published in:
|
ghost
pushed a commit
that referenced
this pull request
Apr 16, 2026
## Background The AI Gateway provider needed the ability to sort providers by performance and cost metrics to optimize routing decisions based on specific criteria like cost efficiency, response speed, or throughput. ## Changes Added a new `sort` option to the AI Gateway provider that allows sorting providers by: - `'cost'` - lowest input cost per token first - `'ttft'` - lowest time-to-first-token first - `'tps'` - highest tokens-per-second first When specified, the gateway tries the best-scoring provider first and falls back through the rest in sorted order. When combined with the existing `order` option, user-specified providers are promoted to the front while remaining providers follow the sorted order. ## Manual Verification ## Checklist - [ ] Tests have been added / updated (for bug fixes / features) - [x] Documentation has been added / updated (for bug fixes / features) - [x] A _patch_ changeset for relevant packages has been added (for bug fixes / features - run `pnpm changeset` in the project root) - [x] I have reviewed this pull request (self-review)
|
✅ Backport PR created: #14508 |
ghost
pushed a commit
that referenced
this pull request
Apr 16, 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.

Background
The AI Gateway provider needed the ability to sort providers by performance and cost metrics to optimize routing decisions based on specific criteria like cost efficiency, response speed, or throughput.
Changes
Added a new
sortoption to the AI Gateway provider that allows sorting providers by:'cost'- lowest input cost per token first'ttft'- lowest time-to-first-token first'tps'- highest tokens-per-second firstWhen specified, the gateway tries the best-scoring provider first and falls back through the rest in sorted order. When combined with the existing
orderoption, user-specified providers are promoted to the front while remaining providers follow the sorted order.Manual Verification
Checklist
pnpm changesetin the project root)