Vertex AI Search Datastores
Vertex AI Search Datastores (패스스루)
LiteLLM을 통해 Vertex AI Discovery Engine Search API를 Google 네이티브 요청·응답 형식 그대로 호출하는 기능을 소개할게요.
출처: 문서
본문
프로바이더 문서: Discovery Engine Search API
통합(Unified) API를 원하시나요?
이 페이지는 프록시를 통해 원본 Google API를 그대로 쓰는 방법이에요. 대신 OpenAI 호환 POST /v1/vector_stores/{id}/search 엔드포인트로 데이터스토어를 쿼리하거나, /chat/completions에서 RAG로 사용하고 싶다면, 이를 관리형 벡터 스토어(프로바이더 vertex_ai/search_api)로 등록하면 돼요.
무엇을 얻을 수 있나요? (What you get)
- Discovery Engine API의 전체 표면을 그대로 사용할 수 있어요.
- 자격 증명을 한 번만 설정하면 어디서든 사용할 수 있어요.
- URL의 데이터스토어 id가 관리형 벡터 스토어로 등록되어 있다면, LiteLLM이 등록 정보에서 프로젝트와 자격 증명을 자동으로 가져와요.
빠른 시작 (Quick Start)
1단계: 자격 증명 설정
export DEFAULT_VERTEXAI_PROJECT="your-project-id"
export DEFAULT_VERTEXAI_LOCATION="us-central1"
export DEFAULT_GOOGLE_APPLICATION_CREDENTIALS="/path/to/credentials.json"
2단계: 프록시 실행
litellm
3단계: 데이터스토어 검색
curl -X POST \
"http://localhost:4000/vertex_ai/discovery/v1/projects/my-project/locations/global/collections/default_collection/dataStores/my-datastore/servingConfigs/default_config:search" \
-H "Content-Type: application/json" \
-H "x-litellm-api-key: *** $LITELLM_API_KEY" \
-d '{
"query": "How do I authenticate?",
"pageSize": 10
}'
엔드포인트 (Endpoint)
{PROXY_BASE_URL}/vertex_ai/discovery/{endpoint:path}
이 주소는 https://discoveryengine.googleapis.com으로 라우팅돼요.
예시 (Examples)
필터와 함께 검색 (Search with Filters)
curl -X POST \
"http://localhost:4000/vertex_ai/discovery/v1/projects/my-project/locations/global/collections/default_collection/dataStores/my-datastore/servingConfigs/default_config:search" \
-H "Content-Type: application/json" \
-H "x-litellm-api-key: *** $LITELLM_API_KEY" \
-d '{
"query": "tutorials",
"pageSize": 20,
"filter": "category = \"beginner\"",
"spellCorrectionSpec": {"mode": "AUTO"}
}'
Python
import requests
url = "http://localhost:4000/vertex_ai/discovery/v1/projects/my-project/locations/global/collections/default_collection/dataStores/my-datastore/servingConfigs/default_config:search"
response = requests.post(url,
headers={
"Content-Type": "application/json",
"x-litellm-api-key": "Bearer sk-<your-litellm-api-key>"
},
json={"query": "pricing", "pageSize": 10})
for result in response.json().get("results", []):
data = result["document"]["derivedStructData"]
print(f"{data['title']}: {data['link']}")