File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed
Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 2828)
2929from vllm_router .experimental import get_feature_gates , initialize_feature_gates
3030from vllm_router .parsers .parser import parse_args
31+ from vllm_router .routers .anthropic_router import anthropic_router
3132from vllm_router .routers .batches_router import batches_router
3233from vllm_router .routers .files_router import files_router
3334from vllm_router .routers .main_router import main_router
@@ -287,6 +288,7 @@ def initialize_all(app: FastAPI, args):
287288
288289app = FastAPI (lifespan = lifespan )
289290app .include_router (main_router )
291+ app .include_router (anthropic_router )
290292app .include_router (files_router )
291293app .include_router (batches_router )
292294app .include_router (metrics_router )
Original file line number Diff line number Diff line change 1+ # Copyright 2024-2025 The vLLM Production Stack Authors.
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+ from fastapi import APIRouter , BackgroundTasks , Request
15+
16+ from vllm_router .log import init_logger
17+ from vllm_router .services .request_service .request import route_general_request
18+
19+ logger = init_logger (__name__ )
20+ anthropic_router = APIRouter ()
21+
22+
23+ @anthropic_router .post ("/v1/messages" )
24+ async def route_anthropic_messages (request : Request , background_tasks : BackgroundTasks ):
25+ """Route Anthropic-compatible messages requests to the backend."""
26+ return await route_general_request (request , "/v1/messages" , background_tasks )
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ class ModelType(enum.Enum):
7373 score = "score"
7474 transcription = "transcription"
7575 vision = "vision"
76+ messages = "messages"
7677
7778 @staticmethod
7879 def get_url (model_type : str ):
@@ -89,6 +90,8 @@ def get_url(model_type: str):
8990 return "/v1/score"
9091 case ModelType .transcription :
9192 return "/v1/audio/transcriptions"
93+ case ModelType .messages :
94+ return "/v1/messages"
9295
9396 @staticmethod
9497 def get_test_payload (model_type : str ):
@@ -112,6 +115,17 @@ def get_test_payload(model_type: str):
112115 return {"query" : "Hello" , "documents" : ["Test" ]}
113116 case ModelType .score :
114117 return {"encoding_format" : "float" , "text_1" : "Test" , "test_2" : "Test2" }
118+ case ModelType .messages :
119+ return {
120+ "messages" : [
121+ {
122+ "role" : "user" ,
123+ "content" : "Hello" ,
124+ }
125+ ],
126+ "temperature" : 0.0 ,
127+ "max_tokens" : 3 ,
128+ }
115129 case ModelType .transcription :
116130 if _SILENT_WAV_BYTES is not None :
117131 logger .debug ("=====Silent WAV Bytes is being used=====" )
You can’t perform that action at this time.
0 commit comments