Skip to main content

SAP Generative AI Hub

LiteLLM supports SAP Generative AI Hub's Orchestration Service.

PropertyDetails
DescriptionSAP's Generative AI Hub provides access to foundation models through the AI Core orchestration service.
Provider Route on LiteLLMsap/
Supported Endpoints/chat/completions
API ReferenceSAP AI Core Documentation

Authentication​

SAP Generative AI Hub uses service key authentication. You can provide credentials via:

  1. Environment variable - Set AICORE_SERVICE_KEY with your service key JSON
  2. Direct parameter - Pass api_key with the service key JSON string
Environment Variable
import os
os.environ["AICORE_SERVICE_KEY"] = '{"clientid": "...", "clientsecret": "...", ...}'

Usage - LiteLLM Python SDK​

SAP Chat Completion
from litellm import completion
import os

os.environ["AICORE_SERVICE_KEY"] = '{"clientid": "...", "clientsecret": "...", ...}'

response = completion(
model="sap/gpt-4",
messages=[{"role": "user", "content": "Hello from LiteLLM"}]
)
print(response)
SAP Chat Completion - Streaming
from litellm import completion
import os

os.environ["AICORE_SERVICE_KEY"] = '{"clientid": "...", "clientsecret": "...", ...}'

response = completion(
model="sap/gpt-4",
messages=[{"role": "user", "content": "Hello from LiteLLM"}],
stream=True
)

for chunk in response:
print(chunk.choices[0].delta.content or "", end="")

Usage - LiteLLM Proxy​

Add to your LiteLLM Proxy config:

config.yaml
model_list:
- model_name: sap-gpt4
litellm_params:
model: sap/gpt-4
api_key: os.environ/AICORE_SERVICE_KEY

Start the proxy:

Start Proxy
litellm --config config.yaml
Test Request
curl http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-proxy-api-key" \
-d '{
"model": "sap-gpt4",
"messages": [{"role": "user", "content": "Hello"}]
}'

Supported Parameters​

ParameterDescription
temperatureControls randomness
max_tokensMaximum tokens in response
top_pNucleus sampling
toolsFunction calling tools
tool_choiceTool selection behavior
response_formatOutput format (json_object, json_schema)
streamEnable streaming