11// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22// SPDX-License-Identifier: Apache-2.0
33
4+ use std:: env:: var;
45use std:: sync:: Arc ;
56use std:: time:: Duration ;
67
@@ -132,6 +133,23 @@ impl HttpService {
132133 }
133134}
134135
136+ /// Environment variable to set the metrics endpoint path (default: `/metrics`)
137+ static HTTP_SVC_METRICS_PATH_ENV : & str = "DYN_HTTP_SVC_METRICS_PATH" ;
138+ /// Environment variable to set the models endpoint path (default: `/v1/models`)
139+ static HTTP_SVC_MODELS_PATH_ENV : & str = "DYN_HTTP_SVC_MODELS_PATH" ;
140+ /// Environment variable to set the health endpoint path (default: `/health`)
141+ static HTTP_SVC_HEALTH_PATH_ENV : & str = "DYN_HTTP_SVC_HEALTH_PATH" ;
142+ /// Environment variable to set the live endpoint path (default: `/live`)
143+ static HTTP_SVC_LIVE_PATH_ENV : & str = "DYN_HTTP_SVC_LIVE_PATH" ;
144+ /// Environment variable to set the chat completions endpoint path (default: `/v1/chat/completions`)
145+ static HTTP_SVC_CHAT_PATH_ENV : & str = "DYN_HTTP_SVC_CHAT_PATH" ;
146+ /// Environment variable to set the completions endpoint path (default: `/v1/completions`)
147+ static HTTP_SVC_CMP_PATH_ENV : & str = "DYN_HTTP_SVC_CMP_PATH" ;
148+ /// Environment variable to set the embeddings endpoint path (default: `/v1/embeddings`)
149+ static HTTP_SVC_EMB_PATH_ENV : & str = "DYN_HTTP_SVC_EMB_PATH" ;
150+ /// Environment variable to set the responses endpoint path (default: `/v1/responses`)
151+ static HTTP_SVC_RESPONSES_PATH_ENV : & str = "DYN_HTTP_SVC_RESPONSES_PATH" ;
152+
135153impl HttpServiceConfigBuilder {
136154 pub fn build ( self ) -> Result < HttpService , anyhow:: Error > {
137155 let config: HttpServiceConfig = self . build_internal ( ) ?;
@@ -148,32 +166,39 @@ impl HttpServiceConfigBuilder {
148166 let mut all_docs = Vec :: new ( ) ;
149167
150168 let mut routes = vec ! [
151- metrics:: router( registry, None ) ,
152- super :: openai:: list_models_router( state. clone( ) , None ) ,
153- super :: health:: health_check_router( state. clone( ) , None ) ,
169+ metrics:: router( registry, var( HTTP_SVC_METRICS_PATH_ENV ) . ok( ) ) ,
170+ super :: openai:: list_models_router( state. clone( ) , var( HTTP_SVC_MODELS_PATH_ENV ) . ok( ) ) ,
171+ super :: health:: health_check_router( state. clone( ) , var( HTTP_SVC_HEALTH_PATH_ENV ) . ok( ) ) ,
172+ super :: health:: live_check_router( state. clone( ) , var( HTTP_SVC_LIVE_PATH_ENV ) . ok( ) ) ,
154173 ] ;
155174
156175 if config. enable_chat_endpoints {
157176 routes. push ( super :: openai:: chat_completions_router (
158177 state. clone ( ) ,
159178 config. request_template . clone ( ) , // TODO clone()? reference?
160- None ,
179+ var ( HTTP_SVC_CHAT_PATH_ENV ) . ok ( ) ,
161180 ) ) ;
162181 }
163182
164183 if config. enable_cmpl_endpoints {
165- routes. push ( super :: openai:: completions_router ( state. clone ( ) , None ) ) ;
184+ routes. push ( super :: openai:: completions_router (
185+ state. clone ( ) ,
186+ var ( HTTP_SVC_CMP_PATH_ENV ) . ok ( ) ,
187+ ) ) ;
166188 }
167189
168190 if config. enable_embeddings_endpoints {
169- routes. push ( super :: openai:: embeddings_router ( state. clone ( ) , None ) ) ;
191+ routes. push ( super :: openai:: embeddings_router (
192+ state. clone ( ) ,
193+ var ( HTTP_SVC_EMB_PATH_ENV ) . ok ( ) ,
194+ ) ) ;
170195 }
171196
172197 if config. enable_responses_endpoints {
173198 routes. push ( super :: openai:: responses_router (
174199 state. clone ( ) ,
175200 config. request_template ,
176- None ,
201+ var ( HTTP_SVC_RESPONSES_PATH_ENV ) . ok ( ) ,
177202 ) ) ;
178203 }
179204
0 commit comments