From 9fd420d929b198e05449bfef89e2a499322e0219 Mon Sep 17 00:00:00 2001 From: BenoitCote Date: Tue, 30 Jun 2026 15:31:22 -0700 Subject: [PATCH 1/5] adding endpoint slug mapping variable --- inference_gateway/settings.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inference_gateway/settings.py b/inference_gateway/settings.py index 9e532bf7..018c359b 100644 --- a/inference_gateway/settings.py +++ b/inference_gateway/settings.py @@ -127,6 +127,11 @@ # Load maintenance notices to be displayed for individual clusters MAINTENANCE_ERROR_NOTICES = json.loads(os.getenv("MAINTENANCE_ERROR_NOTICES", "{}")) +# Endpoint slug mapping to reroute legacy slugs to their latest value +LEGACY_ENDPOINT_SLUG_MAPPING = json.loads(os.getenv("LEGACY_ENDPOINT_SLUG_MAPPING", "{}")) +for key, value in LEGACY_ENDPOINT_SLUG_MAPPING.items(): + LEGACY_ENDPOINT_SLUG_MAPPING[key] = str(value).strip() + # Allowed hosts ALLOWED_HOSTS = textfield_to_strlist(os.getenv("ALLOWED_HOSTS", "*")) From 1d4009b432e4544d7ff01be4c8972aace3a2facb Mon Sep 17 00:00:00 2001 From: BenoitCote Date: Tue, 30 Jun 2026 15:33:20 -0700 Subject: [PATCH 2/5] formatting --- inference_gateway/settings.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inference_gateway/settings.py b/inference_gateway/settings.py index 018c359b..876d49bb 100644 --- a/inference_gateway/settings.py +++ b/inference_gateway/settings.py @@ -128,7 +128,9 @@ MAINTENANCE_ERROR_NOTICES = json.loads(os.getenv("MAINTENANCE_ERROR_NOTICES", "{}")) # Endpoint slug mapping to reroute legacy slugs to their latest value -LEGACY_ENDPOINT_SLUG_MAPPING = json.loads(os.getenv("LEGACY_ENDPOINT_SLUG_MAPPING", "{}")) +LEGACY_ENDPOINT_SLUG_MAPPING = json.loads( + os.getenv("LEGACY_ENDPOINT_SLUG_MAPPING", "{}") +) for key, value in LEGACY_ENDPOINT_SLUG_MAPPING.items(): LEGACY_ENDPOINT_SLUG_MAPPING[key] = str(value).strip() From a7e4ae3669807dac287f7cf120df4391d5ef6881 Mon Sep 17 00:00:00 2001 From: BenoitCote Date: Tue, 30 Jun 2026 15:33:52 -0700 Subject: [PATCH 3/5] enabled slug mapping for model name only --- resource_server_async/endpoints/endpoint.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/resource_server_async/endpoints/endpoint.py b/resource_server_async/endpoints/endpoint.py index fe3c8ea4..22487d70 100644 --- a/resource_server_async/endpoints/endpoint.py +++ b/resource_server_async/endpoints/endpoint.py @@ -7,13 +7,14 @@ from django.forms.models import model_to_dict from django.utils.text import slugify -from inference_gateway.settings import MODEL_DETAILS_KEYS +from inference_gateway.settings import LEGACY_ENDPOINT_SLUG_MAPPING, MODEL_DETAILS_KEYS from resource_server_async.cache import get_redis_client from resource_server_async.rate_limiters import TokenLimiterCheck, TokenRateLimiter from ..auth import check_permission as auth_utils_check_permission from ..errors import ( BatchUnavailable, + EndpointError, EndpointNotFound, Unauthorized, ) @@ -196,6 +197,8 @@ def build_token_limiter( async def load_adapter(cls, cluster: str, framework: str, model: str) -> Self: """Extract the endpoint from the database and return its underlying adapter object.""" endpoint_slug = slugify(f"{cluster} {framework} {model.lower()}") + if endpoint_slug in LEGACY_ENDPOINT_SLUG_MAPPING: + endpoint_slug = LEGACY_ENDPOINT_SLUG_MAPPING[endpoint_slug] if (adapter := _adapter_cache.get(endpoint_slug)) is not None: assert isinstance(adapter, cls) @@ -229,6 +232,10 @@ async def load_adapter(cls, cluster: str, framework: str, model: str) -> Self: raise AssertionError( f"Endpoint adapter {db_endpoint.endpoint_adapter} is not an instance of {cls.__name__}" ) + if endpoint.cluster != cluster or endpoint.framework != framework: + raise EndpointError( + "Endpoint mapping cannot alter 'cluster' or 'framework'." + ) _adapter_cache[endpoint_slug] = endpoint return endpoint From dbdf8bcad0ef0a2317526f8253820aa4789fb64e Mon Sep 17 00:00:00 2001 From: BenoitCote Date: Tue, 30 Jun 2026 15:34:35 -0700 Subject: [PATCH 4/5] overwriting payload.model in case there was a endpoint slug mapping --- resource_server_async/services.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resource_server_async/services.py b/resource_server_async/services.py index bad417b5..7f596836 100644 --- a/resource_server_async/services.py +++ b/resource_server_async/services.py @@ -288,6 +288,9 @@ async def submit_openai_inference_request( f"endpoint_slug: {endpoint.endpoint_slug} - user: {context.user.username}" ) + # Overwrite variables in case it has been updated + payload.model = endpoint.model + # Block access if the user is not allowed to use the endpoint endpoint.check_permission(context.user) From f5c5dcc948719ac2021137544b36b9552f4ae787 Mon Sep 17 00:00:00 2001 From: BenoitCote Date: Tue, 30 Jun 2026 15:35:53 -0700 Subject: [PATCH 5/5] updated comment --- resource_server_async/services.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resource_server_async/services.py b/resource_server_async/services.py index 7f596836..2d36fb90 100644 --- a/resource_server_async/services.py +++ b/resource_server_async/services.py @@ -288,7 +288,7 @@ async def submit_openai_inference_request( f"endpoint_slug: {endpoint.endpoint_slug} - user: {context.user.username}" ) - # Overwrite variables in case it has been updated + # Overwrite model name in case it has been updated via endpoint slug mapping payload.model = endpoint.model # Block access if the user is not allowed to use the endpoint