feat(openrouter): Add provider selection and prioritization support#1373
Merged
joshua-mo-143 merged 9 commits into0xPlaygrounds:mainfrom Feb 16, 2026
Merged
feat(openrouter): Add provider selection and prioritization support#1373joshua-mo-143 merged 9 commits into0xPlaygrounds:mainfrom
joshua-mo-143 merged 9 commits into0xPlaygrounds:mainfrom
Conversation
Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
…Router docs - Rename `allow` to `only` (hard allowlist per API spec) - Add `allow_fallbacks: boolean` for controlling fallback behavior - Add `require_parameters: boolean` for strict parameter support - Move `data_collection` from nested `require` to top-level - Add `zdr: boolean` for Zero Data Retention - Remove `Quality` from ProviderSort (not in spec) - Move `quantizations` from nested `require` to top-level - Add `preferred_min_throughput` with percentile support - Add `preferred_max_latency` with percentile support - Add `max_price` struct for hard price ceilings - Support complex `sort` object with `by` and `partition` - Remove `ProviderRequire` struct (fields should be top-level) - Update tests to match new API (24 tests passing) - Update example to match official documentation examples Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
…sary comments - Add 14 new edge case tests for better coverage - Test DataCollection::default(), Quantization::Unknown, SortPartition variants - Test PercentileThresholds::default() and all four percentile fields - Test LatencyThreshold variants (Simple and Percentile) - Test MaxPrice with all fields and default values - Test ProviderPreferences::default() for all None fields - Test ProviderSort::from implementations - Test ProviderSortConfig without partition - Test deserialization of complex sort object - Test preferred_max_latency serialization - Test empty arrays for order and quantizations - Remove "// Example N from docs:" comments from tests - Remove section divider from test module - Clean up example file comments Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
…pseek-v3.2 Update example to use deepseek/deepseek-v3.2 model with its actual providers: - DeepInfra, DeepSeek, Chutes, AtlasCloud for provider ordering - Google Vertex for blocklist example - Fp8 quantization (most providers use fp8) - Realistic price ceiling ($0.30/$0.50) matching provider prices - Throughput threshold (15 tps) matching DeepSeek providers Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
…cture feat(openrouter): Add provider selection and prioritization support
Collaborator
|
Looks OK to me. Needs |
Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
Fix cargo fmt formatting issues in openrouter provider files
Contributor
Author
|
@joshua-mo-143 Hello, I've fixed the issue, the checks pass now. |
Contributor
Author
|
Can we get this merged? |
Collaborator
Hey, apologies for late response. I'll be merging today as it'll be release day today so anything that is ready-ish to be merged will be merged in 😄 |
Open
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.
Add OpenRouter Provider Selection and Prioritization
Description
Implements OpenRouter's Provider Routing API, enabling fine-grained control over which providers handle requests.
Motivation: I personally, and many others (probably) need a more fine-grained control over what model providers we want to use. For an example, my personal use case is only using providers with Zero Data Retention policy and FP8, while sorting for throughput.
Provider Selection Controls:
order- Provider priority orderingonly- Hard allowlistignore- Blocklistallow_fallbacks- Fail-closed behavior controlCompatibility & Policy Filters:
require_parameters- Strict parameter supportdata_collection- Allow/deny data collectionzdr- Zero Data Retention endpoints onlyPerformance & Cost Preferences:
sort- By price/throughput/latency (supports complex partition config for multi-model)preferred_min_throughput/preferred_max_latency- Simple or percentile thresholdsmax_price- Hard price ceiling (prompt/completion/request/image)Quantization Filter:
quantizations- Filter by int4/int8/fp8/fp16/bf16/fp32Examples in:
rig/rig-core/examples/openrouter_provider_selection.rsType of change
Testing
openrouter_provider_selection.rs) demonstrating all features with deepseek/deepseek-v3.2rig/rig-core/examples/openrouter_provider_selection.rs