Azure AI Search - Vector Store
Azure AI Search - Vector Store (통합 API)
LiteLLM의 통합 /chat/completions API로 Azure AI Search Vector Store를 검색해요.
출처: 문서
본문
빠른 시작 (Quick Start)
세 가지가 필요해요:
- Azure AI Search 서비스
- 임베딩 모델 (쿼리를 벡터로 변환)
- 벡터 필드가 있는 검색 인덱스
사용법 (Usage)
기본 검색 (LiteLLM SDK)
from litellm import vector_stores
import os
# Set your credentials
os.environ["AZURE_SEARCH_API_KEY"] = "your-search-api-key"
os.environ["AZURE_AI_SEARCH_EMBEDDING_API_BASE"] = "your-embedding-endpoint"
os.environ["AZURE_AI_SEARCH_EMBEDDING_API_KEY"] = "your-embedding-api-key"
# Search the vector store
response = vector_stores.search(
vector_store_id="my-vector-index", # Your Azure AI Search index name
query="What is the capital of France?",
custom_llm_provider="azure_ai",
azure_search_service_name="your-search-service",
litellm_embedding_model="azure/text-embedding-3-large",
litellm_embedding_config={
"api_base": os.getenv("AZURE_AI_SEARCH_EMBEDDING_API_BASE"),
"api_key": os.getenv("AZURE_AI_SEARCH_EMBEDDING_API_KEY"),
},
api_key=os.getenv("AZURE_SEARCH_API_KEY"),
)
print(response)
비동기 검색 (Async Search)
from litellm import vector_stores
response = await vector_stores.asearch(
vector_store_id="my-vector-index",
query="What is the capital of France?",
custom_llm_provider="azure_ai",
azure_search_service_name="your-search-service",
litellm_embedding_model="azure/text-embedding-3-large",
litellm_embedding_config={
"api_base": os.getenv("AZURE_AI_SEARCH_EMBEDDING_API_BASE"),
"api_key": os.getenv("AZURE_AI_SEARCH_EMBEDDING_API_KEY"),
},
api_key=os.getenv("AZURE_SEARCH_API_KEY"),
)
print(response)
고급 옵션
from litellm import vector_stores
response = vector_stores.search(
vector_store_id="my-vector-index",
query="What is the capital of France?",
custom_llm_provider="azure_ai",
azure_search_service_name="your-search-service",
litellm_embedding_model="azure/text-embedding-3-large",
litellm_embedding_config={
"api_base": os.getenv("AZURE_AI_SEARCH_EMBEDDING_API_BASE"),
"api_key": os.getenv("AZURE_AI_SEARCH_EMBEDDING_API_KEY"),
},
api_key=os.getenv("AZURE_SEARCH_API_KEY"),
top_k=10, # Number of results to return
azure_search_vector_field="contentVector", # Custom vector field name
)
print(response)
Proxy 설정 (config.yaml)
vector_store_registry:
- vector_store_name: "azure-ai-search-litellm-website-knowledgebase"
litellm_params:
vector_store_id: "test-litellm-app_1761094730750"
custom_llm_provider: "azure_ai"
api_key: os.environ/AZURE_SEARCH_API_KEY
litellm_embedding_model: "azure/text-embedding-3-large"
litellm_embedding_config:
api_base: https://krris-mh44uf7y-eastus2.cognitiveservices.azure.com/
api_key: os.environ/AZURE_API_KEY
api_version: "2025-09-01"
Proxy 시작 후 API로 검색:
curl -X POST 'http://0.0.0.0:4000/v1/vector_stores/my-vector-index/search' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer ***" \
-d '{
"query": "What is the capital of France?",
}'
필수 파라미터 (Required Parameters)
| 파라미터 | 타입 | 설명 |
|---|---|---|
| vector_store_id | string | Azure AI Search 인덱스 이름 |
| custom_llm_provider | string | "azure_ai"로 설정 |
| azure_search_service_name | string | Azure AI Search 서비스 이름 |
| litellm_embedding_model | string | 쿼리 임베딩 생성 모델 (예: "azure/text-embedding-3-large") |
| litellm_embedding_config | dict | 임베딩 모델용 설정 (api_base, api_key, api_version) |
| api_key | string | Azure AI Search API 키 |
지원 기능 (Supported Features)
| 기능 | 상태 | 비고 |
|---|---|---|
| 로깅 (Logging) | ✅ 지원 | 전체 로깅 지원 |
| 가드레일 (Guardrails) | ❌ 미지원 | 벡터 스토어에는 현재 가드레일 미지원 |
| 비용 추적 | ✅ 지원 | Azure 기준 비용 $0 |
| 통합 API | ✅ 지원 | OpenAI 호환 /v1/vector_stores/search 엔드포인트로 호출 |
| 패스스루 (Passthrough) | ❌ 미지원 |
응답 형식 (Response Format)
응답은 표준 LiteLLM 벡터 스토어 형식을 따르며, 유사도 점수와 함께 반환돼요.
{
"object": "vector_store.search_results.page",
"search_query": "What is the capital of France?",
"data": [
{
"score": 0.95,
"content": [
{
"text": "Paris is the capital of France...",
"type": "text"
}
],
"file_id": "doc_123",
"filename": "Document doc_123",
"attributes": {
"document_id": "doc_123"
}
}
]
}
동작 방식 (How It Works)
검색할 때:
- LiteLLM이 지정한 임베딩 모델로 쿼리를 벡터로 변환해요
- 벡터를 Azure AI Search로 보내요
- Azure AI Search가 인덱스에서 가장 유사한 문서를 찾아요
- 유사도 점수와 함께 결과가 반환돼요
임베딩 모델은 LiteLLM이 지원하는 어떤 모델이든 사용할 수 있어요 (Azure OpenAI, OpenAI, Bedrock 등).
Azure AI Search 인덱스 설정
인덱스에 벡터 필드가 필요해요:
{
"name": "my-vector-index",
"fields": [
{ "name": "id", "type": "Edm.String", "key": true },
{ "name": "content", "type": "Edm.String" },
{
"name": "contentVector",
"type": "Collection(Edm.Single)",
"searchable": true,
"dimensions": 1536,
"vectorSearchProfile": "myVectorProfile"
}
]
}
벡터 차원은 임베딩 모델과 일치해야 해요:
text-embedding-3-large: 1536 차원text-embedding-3-small: 1536 차원text-embedding-ada-002: 1536 차원