Wildcard endpoint proxying + OpenRouter-style provider routing#288
Merged
Wildcard endpoint proxying + OpenRouter-style provider routing#288
Conversation
added 5 commits
April 15, 2026 17:09
- Add endpoint_prefixes to WorkerState and AdminWorkerInfo - Add method and provider_routing to RequestRecord/RequestTransport - Update submit_transport_request with method + provider_routing args - Implement provider routing in worker selection (only/ignore/order/fallbacks) - Replace 3 hardcoded POST routes with single catch-all wildcard handler - Support all HTTP methods (GET/POST/PUT/DELETE/PATCH) - Extract model from JSON body or X-Model header - Extract provider routing from body or X-Provider header
- Add endpoint_prefixes field to WorkerDaemonConfig - Add --endpoint-prefixes CLI flag and ENDPOINT_PREFIXES env var - Add endpoint_prefixes to FileConfig for TOML support - Include endpoint_prefixes in RegisterMessage sent to server - Use request method field for backend forwarding (all HTTP methods)
…d endpoint_prefixes
b1f7f67 to
86fc12c
Compare
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
Replace the three hardcoded POST route handlers (
/v1/chat/completions,/v1/messages,/v1/responses) with a single wildcard catch-all handler that proxies any HTTP method and path to workers. Adds OpenRouter-compatible provider routing preferences so clients can express provider ordering, inclusion/exclusion, and fallback behavior.What changed
Protocol (
modelrelay-protocol)RequestMessagegainsmethod: String(defaults to"POST"for backward compat) andendpoint_pathalready existedRegisterMessage/RegisterAckgainendpoint_prefixes: Vec<String>so workers advertise which paths they handleProviderRoutingstruct withonly,ignore,order,allow_fallbacks,sortfieldsServer core (
modelrelay-server/src/lib.rs)WorkerStatetracksendpoint_prefixesand exposessupports_endpoint()for prefix matchingsubmit_transport_requestacceptsendpoint_path,method, andOption<ProviderRouting>find_eligible_worker_id_with_routingimplements the full routing algorithmHTTP layer (
modelrelay-server/src/http.rs)chat_completions_handler,messages_handler,responses_handlerwildcard_handleras.fallback()— extracts method, full path, headers, bodymodelfield orX-Modelheaderproviderfield orX-Providerheader (JSON)Worker (
modelrelay-worker)WorkerDaemonConfiggainsendpoint_prefixesfield--endpoint-prefixes/ENDPOINT_PREFIXESforward_requestuses dynamic method dispatch instead of hardcoded.post()Backward compatibility
#[serde(default)]/skip_serializing_if— existing workers/clients work unchangedmethoddefaults to"POST",endpoint_prefixesdefaults to empty (accept all)Test plan
🤖 Generated with Claude Code