This project facilitates the technical integration between Eerly AI Studio and SAP BTP, specifically focusing on leveraging unused Generative AI tokens (Capacity Units) from an existing SAP subscription.
Many organizations have SAP BTP subscriptions that include Generative AI token allocations (Capacity Units). Often, these tokens go unused because they are not fully consumed by the existing SAP-native workflows.
Eerly AI Studio acts as an external AI platform that can tap into this "remaining capacity." By connecting Eerly AI to SAP AI Core and BTP Usage APIs, we can:
- Run Inferences: Use the client's already-paid-for LLMs via SAP AI Core.
- Monitor Consumption: Fetch real-time and monthly usage data to compute "Unused Tokens."
- Optimize Spend: Ensure no BTP credits go to waste by prioritizing consumption of existing SAP capacity.
We have successfully implemented and validated the OAuth 2.0 Client Credentials authentication pattern required for SAP BTP services and successfully passed all API connectivity checks on a Pay-As-You-Go (PAYG) account.
- ✅ SAP AI Core (Base): Successfully authenticated and retrieved resource groups.
- ✅ Generative AI Hub: Successfully retrieved Foundation Model scenarios (
foundation-models,orchestration, etc.) proving LLM API access. - ✅ SAP Service Manager: Successfully authenticated and retrieved service offerings (Trial/PAYG).
- ✅ SAP Usage Data Management: Successfully authenticated to the Billing API.
To enable the full integration with Generative AI Hub, you must use a Pay-As-You-Go (PAYG) or enterprise account. Trial accounts do not support the required extended plan.
(Note: If you have previously created failed instances, it is highly recommended to create a fresh Subaccount to avoid SAP BTP's Service Broker cache bugs).
- Enable the Pay-As-You-Go (PAYG) or CPEA model for your Global Account.
- Create a new Subaccount (e.g.,
Eerly-AI-SAP-AI-Core) in an AWS region that supports GenAI Hub (e.g.,us10oreu10).
Go to Global Account → Entitlements → Subaccount Assignments and assign the following to your new subaccount:
- SAP AI Core: Give it the
extendedplan (mandatory for Generative AI Hub). - SAP AI Launchpad: Give it the
standardplan.
Inside your new Subaccount, go to Services → Instances and Subscriptions:
- Click Create and subscribe to SAP AI Launchpad (
standardplan). - Click Create and instantiate SAP AI Core (must be the
extendedplan!).
- Click on the name of your new
extendedAI Core instance. - Go to the Service Keys tab.
- Click Create to generate a key (e.g.,
eerly-payg-key). - Click View Credentials and copy the entire JSON object.
To use the SAP AI Launchpad web interface, assign these Role Collections to your user in the Subaccount (Security → Users):
AI Core AdministratorAI Core DeveloperGenerative AI Hub User
Follow these steps to replicate the successful ping tests locally to prove API connectivity.
- Python 3.x
- Dependencies:
pip install requests python-dotenv
Create a .env file in the project root containing your Service Keys.
# ── SAP AI Core (PAYG) Credentials ──────────────────────────────────────────
AI_CORE_CLIENT_ID=your_aicore_clientid
AI_CORE_CLIENT_SECRET=your_aicore_clientsecret
AI_CORE_AUTH_URL=https://<tenant>.authentication.<region>.hana.ondemand.com/oauth/token
AI_CORE_API_URL=https://api.ai.prod.us-east-1.aws.ml.hana.ondemand.com
AI_CORE_RESOURCE_GROUP=default
# ── Service Manager Credentials (Optional) ──────────────────────────────────
BTP_CLIENT_ID=your_sm_clientid
BTP_CLIENT_SECRET=your_sm_clientsecret
BTP_AUTH_URL=https://<tenant>.authentication.../oauth/token
BTP_API_BASE_URL=https://service-manager.cfapps...
# ── Usage Data Management Credentials (Optional) ────────────────────────────
USAGE_CLIENT_ID=your_uas_clientid
USAGE_CLIENT_SECRET=your_uas_clientsecret
USAGE_AUTH_URL=https://<tenant>-ga.authentication.../oauth/token
USAGE_API_BASE_URL=https://uas-reporting.cfapps...Primary Test: SAP AI Core & Generative AI Hub This checks if the AI models are truly accessible.
# Run with UTF-8 flag to support emojis in Windows Terminal
python -X utf8 ping_test_payg.pySecondary Test: Service Manager & Usage Billing
python ping_test.pyWith API connectivity 100% proven, the actual product engineering inside Eerly AI Studio can begin:
- Usage Math Execution: Implement the API logic to calculate
Purchased CUs - Consumed CUs = Remaining Tokens. - LLM Router Integration: Send LLM inference requests from Eerly AI directly to the SAP AI Core
foundation-modelsscenario via the/v2/inference/deploymentsendpoint.