SAP Generative AI Hub
SAP Generative AI Hub
LiteLLM에서 SAP Generative AI Hub의 Orchestration Service를 사용하는 방법을 알아봐요.
출처: 문서
본문
LiteLLM은 SAP Generative AI Hub의 Orchestration Service를 지원해요.
| 속성 | 내용 |
|---|---|
| 설명 | SAP의 Generative AI Hub는 AI Core 오케스트레이션 서비스를 통해 OpenAI, Anthropic, Gemini, Mistral, NVIDIA, Amazon, SAP LLM에 접근을 제공해요 |
| LiteLLM 라우트 | sap/ |
| 지원 엔드포인트 | /chat/completions, /embeddings |
| API 레퍼런스 | SAP AI Core Documentation |
사전 요구사항
시작 전에 다음이 있는지 확인하세요:
- SAP AI Core에 접근할 수 있는 SAP BTP 계정
- 서브어카운트에 프로비저닝된 AI Core Service 인스턴스
- AI Core 인스턴스에 만들어진 Service Key (자격 증명이 들어 있음)
- AI 모델이 배포된 Resource Group (SAP 관리자에게 확인)
자격 증명 찾기: 자격 증명은 SAP BTP Cockpit에서 만드는 Service Key에서 옵니다. Subaccount → Instances and Subscriptions → AI Core 인스턴스 → Service Keys → 만들기. JSON에 필요한 모든 값이 있어요.
서비스 키 JSON 모양:
{
"clientid": "sb-abc123...",
"clientsecret": "xyz789...",
"url": "https://myinstance.authentication.eu10.hana.ondemand.com",
"serviceurls": {
"AI_API_URL": "https://api.ai.prod.eu-central-1.aws.ml.hana.ondemand.com"
}
}
Resource Group: 리소스 그룹은 보통 service key가 아니라 AI Core 배포에 별도로 구성돼요. AICORE_RESOURCE_GROUP 환경 변수로 설정할 수 있어요(기본값 "default").
빠른 시작
1단계: LiteLLM 설치
uv add litellm
2단계: 자격 증명 설정
인증 방법 중 하나를 선택해요.
Breaking change: 자격 증명 해석은 "first-source-wins"예요. 해석 순서:
kwargs→service key→env (AICORE_*)→config→VCAP service. LiteLLM이 어떤 소스에서 자격 증명 값을 찾으면 그 소스의 모든 자격 증명만 사용해요(resource_group은 별도로 해석될 수 있어요).
서비스 키 JSON (권장): 전체 서비스 키를 단일 환경 변수로 붙여넣어요. (service key는 더 이상 "credentials" 키로 감쌀 필요가 없어요.)
export AICORE_SERVICE_KEY='{
"clientid": "your-client-id",
"clientsecret": "your-client-secret",
"url": "https://.authentication.sap.hana.ondemand.com",
"serviceurls": {
"AI_API_URL": "https://api.ai..aws.ml.hana.ondemand.com"
}
}'
export AICORE_RESOURCE_GROUP="default"
개별 변수 (대안):
export AICORE_AUTH_URL="https://.authentication.sap.hana.ondemand.com/oauth/token"
export AICORE_CLIENT_ID="your-client-id"
export AICORE_CLIENT_SECRET="your-client-secret"
export AICORE_RESOURCE_GROUP="default"
export AICORE_BASE_URL="https://api.ai..aws.ml.hana.ondemand.com/v2"
3단계: 첫 요청 보내기
from litellm import completion
response = completion(
model="sap/gpt-5.6-terra",
messages=[{"role": "user", "content": "Hello from LiteLLM!"}]
)
print(response.choices[0].message.content)
예상 출력:
Hello! How can I assist you today?
인증
SAP Generative AI Hub는 인증에 OAuth2 서비스 키를 사용해요. 빠른 시작의 설정 지침을 참고해요.
환경 변수 레퍼런스
| 변수 | 필수 | 설명 |
|---|---|---|
AICORE_SERVICE_KEY |
예* | 전체 서비스 키 JSON (권장 방법) |
AICORE_RESOURCE_GROUP |
예 | AI Core 리소스 그룹 이름 |
AICORE_AUTH_URL |
예* | OAuth 토큰 URL (서비스 키 대안) |
AICORE_CLIENT_ID |
예* | OAuth client ID (서비스 키 대안) |
AICORE_CLIENT_SECRET |
예* | OAuth client secret (서비스 키 대안) |
AICORE_BASE_URL |
예* | AI Core API base URL (서비스 키 대안) |
*AICORE_SERVICE_KEY 원 또는 개별 변수(AICORE_AUTH_URL, AICORE_CLIENT_ID, AICORE_CLIENT_SECRET, AICORE_BASE_URL) 중 하나를 선택해요.
모델 명명 규칙
모델 명명을 이해하는 것이 SAP Gen AI Hub를 올바르게 쓰는 데 중요해요. 명명 패턴은 SDK를 직접 쓰는지 proxy를 통하는지에 따라 달라요.
직접 SDK 사용
LiteLLM SDK를 직접 호출할 때는 모델 이름에 sap/ 접두사를 포함해야 해요:
# Correct - includes sap/ prefix
model="sap/gpt-5.6-terra"
model="sap/anthropic--claude-4.5-sonnet"
model="sap/gemini-3.1-pro-preview"
# Incorrect - missing prefix
model="gpt-5.6-terra" # ❌ Won't work
Proxy 사용
LiteLLM Proxy에서는 구성에 정의한 친숙한 model_name을 사용해요. proxy가 sap/ 접두사 라우팅을 자동 처리해요.
# In config.yaml, define the mapping
model_list:
- model_name: gpt-5.6-terra # ← Use this name in client requests
litellm_params:
model: sap/gpt-5.6-terra # ← Proxy handles the sap/ prefix
Anthropic 모델 특수 구문
Anthropic 모델은 더블 대시(--) 접두사 규칙을 사용해요:
| 제공사 | 모델 예시 | LiteLLM 형식 |
|---|---|---|
| OpenAI | GPT-4o | sap/gpt-4o |
| Anthropic | Claude 4.5 Sonnet | sap/anthropic--claude-4.5-sonnet |
| Gemini 2.5 Pro | sap/gemini-2.5-pro |
|
| Mistral | Mistral Large | sap/mistral-large |
빠른 참조
| 사용 유형 | 모델 형식 | 예시 |
|---|---|---|
| 직접 SDK | sap/ |
sap/gpt-4o |
| 직접 SDK (Anthropic) | sap/anthropic-- |
sap/anthropic--claude-4.5-sonnet |
| Proxy 클라이언트 | `` | gpt-4o 또는 claude-sonnet |
Python SDK 사용
LiteLLM Python SDK가 인증 방법을 자동으로 감지해요. 환경 변수를 설정하고 요청하기만 하면 돼요.
from litellm import completion
# Assumes AICORE_AUTH_URL, AICORE_CLIENT_ID, etc. are set
response = completion(
model="sap/anthropic--claude-4.5-sonnet",
messages=[{"role": "user", "content": "Explain quantum computing"}]
)
print(response.choices[0].message.content)
두 인증 방법(개별 변수 또는 서비스 키 JSON) 모두 코드 변경 없이 자동 동작해요.
Proxy 서버 사용
LiteLLM Proxy는 SAP 모델용 통합 OpenAI 호환 API를 제공해요.
구성
config.yaml:
model_list:
# OpenAI models
- model_name: gpt-5.6-terra
litellm_params:
model: sap/gpt-5.6-terra
# Anthropic models (note the double-dash)
- model_name: claude-sonnet
litellm_params:
model: sap/anthropic--claude-4.5-sonnet
- model_name: claude-opus
litellm_params:
model: sap/anthropic--claude-4.5-opus
# Embeddings
- model_name: text-embedding-3-small
litellm_params:
model: sap/text-embedding-3-small
litellm_settings:
drop_params: true
set_verbose: false
request_timeout: 600
num_retries: 2
forward_client_headers_to_llm_api: ["anthropic-version"]
general_settings:
master_key: "sk-"
# Authentication
environment_variables:
AICORE_SERVICE_KEY: '{"credentials": {"clientid": "...", "clientsecret": "...", "url": "...", "serviceurls": {"AI_API_URL": "..."}}}'
AICORE_RESOURCE_GROUP: "default"
Proxy 시작
litellm --config config.yaml
proxy는 기본적으로 http://localhost:4000에서 시작돼요.
요청하기
curl http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ***" \
-d '{
"model": "gpt-5.6-terra",
"messages": [{"role": "user", "content": "Hello"}]
}'
OpenAI SDK:
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:4000",
api_key="sk-"
)
response = client.chat.completions.create(
model="gpt-5.6-terra",
messages=[{"role": "user", "content": "Hello"}]
)
print(response.choices[0].message.content)
기능
스트리밍 응답
from litellm import completion
response = completion(
model="sap/gpt-5.6-terra",
messages=[{"role": "user", "content": "Count from 1 to 10"}],
stream=True
)
for chunk in response:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
구조화 출력
JSON Schema (권장):
from litellm import completion
response = completion(
model="sap/gpt-5.6-terra",
messages=[{
"role": "user",
"content": "Generate info about Tokyo"
}],
response_format={
"type": "json_schema",
"json_schema": {
"name": "city_info",
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"population": {"type": "number"},
"country": {"type": "string"}
},
"required": ["name", "population", "country"],
"additionalProperties": False
},
"strict": True
}
}
)
print(response.choices[0].message.content)
# Output: {"name":"Tokyo","population":37000000,"country":"Japan"}
JSON Object 형식:
json_object 타입을 쓸 때 SAP의 orchestrasiom 서비스는 프롬프트에 "json" 단어가 나타나야 해요. 스키마 검증 출력에는 json_schema(권장)를 사용해요.
다중 턴 대화
from litellm import completion
response = completion(
model="sap/gpt-5.6-terra",
messages=[
{"role": "user", "content": "My name is Alice"},
{"role": "assistant", "content": "Hello Alice! Nice to meet you."},
{"role": "user", "content": "What is my name?"}
]
)
print(response.choices[0].message.content)
# Output: Your name is Alice.
임베딩
from litellm import embedding
response = embedding(
model="sap/text-embedding-3-small",
input=["Hello world", "Machine learning is fascinating"]
)
print(response.data[0]["embedding"]) # Vector representation
추가 모듈
SAP Gen AI Hub는 고급 사용 사례를 위한 추가 모듈을 포함해요:
- Grounding
- Translation
- Data Masking
- Content Filtering
Grounding
Grounding은 벡터 데이터베이스를 사용해 데이터 관련 작업(grounding, 검색)을 처리하는 서비스예요. 실시간·정밀 데이터로 의사결정을 개선해요. 오케스트레이션 파이프라인에서 Grounding 모듈을 쓰려면 지식 베이스를 미리 준비해야 해요.
from litellm import completion
grounding_config = {
'type': 'document_grounding_service',
'config': {
'filters': [
{'id': 's3-docs',
'data_repository_type': 'vector',
'search_config': {'max_chunk_count': 2},
'data_repositories': ['012345-6789-0123-4567-890123456789']
}
],
'placeholders': {'input': ['user_query'], 'output': 'grounding_response'},
'metadata_params': ['source', 'webUrl', 'title', 'mimeType', 'fileSuffix']
}
}
response = completion(model="sap/gpt-5.6-terra",
messages=[
{"content":"""...""", "role": "system"},
{"content":"""...""", "role": "user"}
],
placeholder_values={"user_query": "Is there a complaint?"},
grounding=grounding_config
)
print(response.choices[0].message.content)
사용 가능한 모든 grounding 설정은 문서를 참고해요.
Translation
번역 모듈은 LLM 텍스트 프롬프트를 선택한 대상 언어로 번역해요.
from litellm import completion
translation_config = {
'input':
{'type': 'sap_document_translation',
'config':
{'source_language': 'en-US',
'target_language': 'de-DE'}
},
'output':
{'type': 'sap_document_translation',
'config':
{'source_language': 'de-DE',
'target_language': 'fr-FR'}
}
}
response = completion(model="sap/gpt-5.6-terra",
messages=[{"role": "user", "content": "Hello world!"}],
translation=translation_config)
print(response.choices[0].message.content)
Data Masking
데이터 마스킹 모듈은 선택한 엔터티에 대해 입력에서 개인 식별 정보를 익명화·기명화해요.
from litellm import completion, embedding
masking_config = {
'providers':
[
{
'type': 'sap_data_privacy_integration',
'method': 'anonymization',
'entities': [
{'type': 'profile-address'},
{'type': 'profile-email'},
{'type': 'profile-phone'},
{'type': 'profile-person'},
{'type': 'profile-location'}
]
}
]
}
mock_cv = "some text with personal information"
response = completion(model="sap/gpt-5.6-terra",
messages=[{"role": "user", "content": "Give a one sentence summary of the CV. CV: {{?cv}}?"}],
placeholder_values={"cv": mock_cv},
masking=masking_config)
print(response.choices[0].message.content)
# Data masking module also available for embedding
response = embedding(model="sap/text-embedding-3-small",
input=mock_cv,
masking=masking_config)
print(response.data[0])
Content Filtering
콘텐츠 필터링 모듈은 콘텐츠 안전 기준에 따라 입력·출력을 필터링해요. Azure Content Safety와 Llama Guard 3 두 서비스를 지원해요.
from litellm import completion
filtering_config_azure = {
'input':
{
'filters':
[
{'type': 'azure_content_safety',
'config':
{'hate': 0,
'sexual': 0,
'violence': 0,
'self_harm': 0
}
}
]
},
'output':
{
'filters':
[
{'type': 'azure_content_safety',
'config': {'hate': 0,
'sexual': 0,
'violence': 0,
'self_harm': 0
}
}
]
}
}
response = completion(model="sap/gpt-5.6-terra",
messages=[{"role": "user", "content": "Hello world!"}],
filtering=filtering_config_azure)
print(response.choices[0].message.content)
try:
response = completion(model="sap/gpt-5.6-terra",
messages=[{"role": "user", "content": "I hate you"}],
filtering=filtering_config_azure)
except Exception as e:
print(e)
폴백용 모듈 설정 목록
SAP Gen AI Hub는 오류 처리를 위한 폴백 메커니즘을 지원해요. 오류 시 사용할 폴백 모듈 목록을 지정할 수 있어요.
from litellm import completion
translation_config = {
'input':
{'type': 'sap_document_translation',
'config':
{'source_language': 'en-US',
'target_language': 'de-DE'}
},
'output':
{'type': 'sap_document_translation',
'config':
{'source_language': 'de-DE',
'target_language': 'fr-FR'}
}
}
response = completion(model="sap/gpt-5.6-terra",
messages=[{"role": "user", "content": "Hello world!"}],
translation=translation_config,
fallback_sap_modules=[{
"model":"sap/gemini-3.8-flash",
"messages":[{"role": "user", "content": "Hello world!"}],
"translation":translation_config
}])
# In case of error with the first configuration, the fallback module is used.
print(response.choices[0].message.content)
레퍼런스
지원 파라미터
| 파라미터 | 타입 | 설명 |
|---|---|---|
model |
string | 모델 식별자 (SDK는 sap/ 접두사 포함) |
messages |
array | 대화 메시지 |
temperature |
float | 무작위성 제어 (0-2) |
max_tokens |
integer | 응답의 최대 토큰 |
top_p |
float | Nucleus sampling 임계값 |
stream |
boolean | 스트리밍 응답 활성화 |
response_format |
object | 출력 형식 (json_object, json_schema) |
tools |
array | 함수 호출 도구 정의 |
tool_choice |
string/object | 도구 선택 동작 |
지원 모델
완전하고 최신의 사용 가능 모델 목록은 SAP AI Core Generative AI Hub 문서를 참고해요. 모델 가용성은 SAP 배포 리전과 구독에 따라 달라요. 환경에서 사용 가능한 모델은 SAP 관리자에게 확인하세요.
문제 해결
인증 오류: 필요한 모든 환경 변수가 올바르게 설정됐는지, 서비스 키가 만료되지 않았는지, 리소스 그룹이 원하는 모델에 접근하는지, AICORE_AUTH_URL·AICORE_BASE_URL이 SAP 리전과 일치하는지 확인해요.
모델 없음: SAP 배포에서 모델이 사용 가능한지, 올바른 모델 이름 형식(sap/ 접두사)인지, 리소스 그룹이 그 모델에 접근하는지, Anthropic 모델은 anthropic-- 더블 대시 접두사를 쓰는지 확인해요.
레이트 리밋: 구독 기반 제한에 걸리면 지수 백오프 재시도, proxy 내장 레이트 리밋 기능, 또는 SAP 관리자에게 할당량 검토를 요청해요.
더 알아보기 (Learn more)
- SAP AI Core Generative AI Hub 문서
- LiteLLM 컴플리션 API