VLLM
VLLM
VLLM의 패스스루 엔드포인트를 소개할게요. 자체 호스팅한 VLLM 서버의 프로바이더 고유 엔드포인트를 네이티브 형식 그대로(변환 없이) 호출할 수 있는 기능이에요.
출처: 문서
본문
VLLM 서버 호스트(예: https://my-vllm-server.com)를 프록시를 통해 이렇게 노출해요.
LITELLM_PROXY_BASE_URL/vllm
사용 예시 (Example Usage)
VLLM의 /metrics 엔드포인트를 호출하는 예시예요.
curl -L -X GET 'http://0.0.0.0:4000/vllm/metrics' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer ***" \
빠른 시작 (Quick Start)
VLLM의 /score 엔드포인트를 호출하는 예시를 볼게요. 먼저 config.yaml에 모델을 등록해요. VLLM 서버 전체 API 목록은 VLLM API 참조를 확인해 주세요.
model_list:
- model_name: "my-vllm-model"
litellm_params:
model: hosted_vllm/vllm-1.72
api_base: https://my-vllm-server.com
프록시를 실행해요.
litellm
# RUNNING on http://0.0.0.0:4000
이제 /score 엔드포인트를 호출해요.
curl -X 'POST' \
'http://0.0.0.0:4000/vllm/score' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"model": "my-vllm-model",
"encoding_format": "float",
"text_1": "What is the capital of France?",
"text_2": "The capital of France is Paris."
}'
예시 (Examples)
핵심 아이디어는 단순해요. VLLM API의 호스트를 http://0.0.0.0:4000/vllm로 바꾸면 돼요. 원래 https://my-vllm-server.com을 호출하던 것을 http://0.0.0.0:4000/vllm로 바꾸고, 인증 헤더를 bearer $VLLM_API_KEY 대신 LiteLLM 키(bearer anything 또는 가상 키 bearer LITELLM_VIRTUAL_KEY)로 바꾸면 됩니다.
예시 1: 메트릭스 엔드포인트
LiteLLM 프록시 호출
curl -L -X GET 'http://0.0.0.0:4000/vllm/metrics' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer $LITEL..._KEY' \
VLLM 직접 API 호출 (변환 전)
curl -L -X GET 'https://my-vllm-server.com/metrics' \
-H 'Content-Type: application/json' \
예시 2: chat API
LiteLLM 프록시 호출
curl -L -X POST 'http://0.0.0.0:4000/vllm/chat/completions' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer $LITEL..._KEY' \
-d '{
"messages": [
{
"role": "user",
"content": "I am going to Paris, what should I see?"
}
],
"max_tokens": 2048,
"temperature": 0.8,
"top_p": 0.1,
"model": "qwen2.5-7b-instruct",
}'
VLLM 직접 API 호출 (변환 전)
curl -L -X POST 'https://my-vllm-server.com/chat/completions' \
-H 'Content-Type: application/json' \
-d '{
"messages": [
{
"role": "user",
"content": "I am going to Paris, what should I see?"
}
],
"max_tokens": 2048,
"temperature": 0.8,
"top_p": 0.1,
"model": "qwen2.5-7b-instruct",
}'
고급: 가상 키(Virtual Keys)와 함께 사용하기
가상 키는 LiteLLM 프록시에 데이터베이스가 설정된 경우에 사용할 수 있어요. 가상 키 설정 문서를 참고해 주세요. 개발자에게 VLLM 서버 키를 직접 주지 않으면서도 VLLM 엔드포인트를 쓰게 하려면 이 방식을 사용해요.
사용법 (Usage)
환경 변수를 설정해요.
export DATABASE_URL=""
export LITELLM_MASTER_KEY=""
export HOSTED_VLLM_API_BASE=""
프록시를 실행해요.
litellm
# RUNNING on http://0.0.0.0:4000
가상 키를 생성해요.
curl -X POST 'http://0.0.0.0:4000/key/generate' \
-H "Authorization: Bearer ***" \
-H 'Content-Type: application/json' \
-d '{}'
응답에서 키를 받아요.
{
...
"key": "sk-<virtual-key>"
}
이제 chat completions 엔드포인트를 가상 키로 호출해요.
curl -L -X POST 'http://0.0.0.0:4000/vllm/chat/completions' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer ***" \
--data '{
"messages": [
{
"role": "user",
"content": "I am going to Paris, what should I see?"
}
],
"max_tokens": 2048,
"temperature": 0.8,
"top_p": 0.1,
"model": "qwen2.5-7b-instruct",
}'