[DEPRECATED] 리전 기반 라우팅
[DEPRECATED] 리전 기반 라우팅 (Region-based Routing)
info
이 기능은 deprecated예요. 대신 Tag Based Routing을 사용하세요.
특정 고객을 eu 전용 모델로 라우팅해요. 고객에 allowed_model_region을 지정하면, LiteLLM은 허용된 리전(즉 'eu')에 없는 모델 그룹의 모델을 모두 필터링해요.
출처: 문서
본문
코드 보기 (See Code)
1. 리전 사양으로 고객 생성
litellm end-user 객체를 사용해요.
end-user는 openai chat completion/embedding 호출에서 litellm에 'user' 파라미터를 전달해 추적/식별할 수 있어요.
curl -X POST --location 'http://0.0.0.0:4000/end_user/new' \
--header "Authorization: Bearer ***" \
--header 'Content-Type: application/json' \
--data '{
"user_id" : "ishaan-jaff-45",
"allowed_model_region": "eu", # 👈 SPECIFY ALLOWED REGION='eu'
}'
2. 모델 그룹에 eu 모델 추가
모델 그룹에 eu 모델을 추가하세요. 각 모델에 리전을 지정하려면 region_name 파라미터를 사용하세요.
지원되는 리전은 'eu'와 'us'예요.
model_list:
- model_name: gpt-5.6-luna
litellm_params:
model: azure/gpt-5.6-luna # 👈 EU azure model
api_base: https://my-endpoint-europe-berri-992.openai.azure.com/
api_key: os.environ/AZURE_EUROPE_API_KEY
region_name: "eu"
- model_name: gpt-5.6-luna
litellm_params:
model: azure/chatgpt-v-2
api_base: https://openai-gpt-4-test-v-1.openai.azure.com/
api_version: "2023-05-15"
api_key: os.environ/AZURE_API_KEY
region_name: "us"
router_settings:
enable_pre_call_checks: true # 👈 IMPORTANT
프록시 시작:
litellm --config /path/to/config.yaml
3. 테스트!
프록시에 간단한 chat completions 호출을 해보세요. 응답 헤더에서 반환된 api base를 볼 수 있어요.
curl -X POST --location 'http://localhost:4000/chat/completions' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ***" \
--data '{
"model": "gpt-5.6-luna",
"messages": [
{
"role": "user",
"content": "what is the meaning of the universe? 1234"
}],
"user": "ishaan-jaff-45" # 👈 USER ID
}'
응답 헤더의 예상 API Base
x-litellm-api-base: "https://my-endpoint-europe-berri-992.openai.azure.com/"
x-litellm-model-region: "eu" # 👈 CONFIRMS REGION-BASED ROUTING WORKED
FAQ
그 리전에 사용 가능한 모델이 없으면 어떻게 되나요?
라우터는 지정된 리전에 없는 모델을 필터링하므로, 해당 리전에 모델이 없으면 사용자에게 오류로 반환돼요.