Skip to content

Commit 3afa7a2

Browse files
committed
feat: add SAP AI Core as a provider
1 parent d45c7ec commit 3afa7a2

File tree

30 files changed

+4332
-89
lines changed

30 files changed

+4332
-89
lines changed

.changeset/better-comics-pay.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"kilo-code": minor
3+
"kilocode-docs": patch
4+
"@roo-code/types": patch
5+
---
6+
7+
Added SAP AI Core provider
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
sidebar_label: SAP AI Core
3+
---
4+
5+
# Using SAP AI Core With Kilo Code
6+
7+
Kilo Code supports accessing models through SAP AI Core, a service in the SAP Business Technology Platform that lets you efficiently run AI scenarios in a standardized, scalable, and hyperscaler-agnostic manner.
8+
9+
**Website:** [https://help.sap.com/docs/sap-ai-core](https://help.sap.com/docs/sap-ai-core)
10+
11+
## Prerequisites
12+
13+
- **SAP BTP Account:** You need an active SAP Business Technology Platform account.
14+
- **SAP AI Core Service:** You must have access to the SAP AI Core service in your BTP subaccount.
15+
- **Service Instance:** Create a service instance of SAP AI Core with appropriate service plan.
16+
- **Service Key:** Generate a service key for your SAP AI Core service instance to obtain the required credentials.
17+
18+
## Getting Credentials
19+
20+
To use SAP AI Core with Kilo Code, you'll need to create a service key for your SAP AI Core service instance:
21+
22+
1. **In SAP BTP Cockpit:**
23+
24+
- Navigate to your subaccount
25+
- Go to "Services" → "Instances and Subscriptions"
26+
- Find your SAP AI Core service instance
27+
- Create a new service key
28+
29+
2. **Service Key Information:**
30+
The service key will contain the following information you'll need:
31+
- **Client ID:** OAuth2 client identifier
32+
- **Client Secret:** OAuth2 client secret
33+
- **Auth URL:** OAuth2 authentication endpoint
34+
- **Base URL:** SAP AI Core API base URL
35+
- **Resource Group:** (Optional) Specify a resource group, defaults to "default"
36+
37+
## Operating Modes
38+
39+
SAP AI Core provider supports two operating modes:
40+
41+
### Foundation Models Mode (Default)
42+
43+
- Uses foundation models that require active deployments
44+
- Currently, supports **OpenAI models only** due to SAP AI Core SDK limitations
45+
- Requires you to have running deployments for the models you want to use
46+
- Models must have deployments in "RUNNING" status to be selectable
47+
48+
### Orchestration Mode
49+
50+
- Uses SAP AI Core's orchestration capabilities
51+
- Supports models from multiple providers: **Amazon, Anthropic, Google, OpenAI, and Mistral AI**
52+
- Does not require separate deployments
53+
- Provides access to a broader range of models
54+
55+
## Model Requirements
56+
57+
Kilo Code applies the following filters when fetching models:
58+
59+
- **Streaming:** Models must support streaming
60+
- **Capabilities:** Models must support text generation
61+
- **Context Window:** Models must have a context window of at least 32,000 tokens
62+
63+
## Supported Providers
64+
65+
### Foundation Models Mode
66+
67+
- **OpenAI:** All OpenAI models with active deployments
68+
69+
### Orchestration Mode
70+
71+
- **Amazon:** Amazon foundation models
72+
- **Anthropic:** Claude models
73+
- **Google:** Gemini models
74+
- **OpenAI:** ChatGPT and GPT models
75+
- **Mistral AI:** Mistral AI models
76+
77+
The exact list of available models depends on your SAP AI Core configuration and active model offerings.
78+
79+
## Configuration in Kilo Code
80+
81+
1. **Open Kilo Code Settings:** Click the gear icon (<Codicon name="gear" />) in the Kilo Code panel.
82+
2. **Select Provider:** Choose "SAP AI Core" from the "API Provider" dropdown.
83+
3. **Enter Credentials:**
84+
- **Client ID:** Enter your SAP AI Core OAuth2 client ID
85+
- **Client Secret:** Enter your SAP AI Core OAuth2 client secret
86+
- **Base URL:** Enter your SAP AI Core API base URL (e.g., `https://api.ai.ml.hana.ondemand.com`)
87+
- **Auth URL:** Enter your SAP AI Core OAuth2 auth URL (e.g., `https://your-subdomain.authentication.sap.hana.ondemand.com`)
88+
- **Resource Group:** (Optional) Enter your resource group name, defaults to "default"
89+
4. **Choose Operating Mode:**
90+
- **Orchestration Mode:** Check the "Use Orchestration" checkbox for broader model access
91+
- **Foundation Models Mode:** Leave unchecked to use foundation models with deployments
92+
5. **Select Model:** Choose your desired model from the dropdown
93+
6. **Select Deployment:** (Foundation Models Mode only) Choose an active deployment for your selected model
94+
95+
## Deployments (Foundation Models Mode)
96+
97+
When using Foundation Models mode:
98+
99+
- You must have active deployments for the models you want to use
100+
- Only deployments with "RUNNING" status are available for selection
101+
- Deployments in other states (PENDING, STOPPED, etc.) are shown but disabled
102+
- The interface displays the number of available deployments for each model
103+
104+
## Tips and Notes
105+
106+
- **Authentication:** SAP AI Core uses OAuth2 client credentials flow for authentication
107+
- **Caching:** Model and deployment information is cached for 15 and 5 minutes respectively to improve performance
108+
- **Resource Groups:** If you use multiple resource groups, specify the appropriate one in the configuration
109+
- **Permissions:** Ensure your service key has the necessary permissions to access models and deployments
110+
- **Orchestration Benefits:** Use Orchestration mode for access to a wider variety of models without managing deployments
111+
- **Foundation Models Benefits:** Use Foundation Models mode when you need more control over specific model deployments
112+
113+
## Troubleshooting
114+
115+
### Common Issues
116+
117+
1. **Authentication Failures:**
118+
119+
- Verify your Client ID and Client Secret are correct
120+
- Check that your Auth URL is properly formatted
121+
- Ensure your service key hasn't expired
122+
123+
2. **No Models Available:**
124+
125+
- Check that you have the necessary permissions in your resource group
126+
- Verify your Base URL is correct
127+
- In Foundation Models mode, ensure you have running deployments
128+
129+
3. **Deployment Issues:**
130+
131+
- Check that your deployments are in "RUNNING" status
132+
- Verify you're using the correct resource group
133+
- Review your SAP AI Core service configuration
134+
135+
4. **Model Access:**
136+
- In Foundation Models mode, **only OpenAI models** are currently supported
137+
- Switch to Orchestration mode for access to other providers
138+
- Ensure models meet the minimum requirements (32k context window, streaming support)
139+
140+
## Getting Started
141+
142+
To get started with SAP AI Core:
143+
144+
1. Set up your SAP BTP account and access SAP AI Core service
145+
2. Create a service instance and generate a service key
146+
3. Configure Kilo Code with your credentials
147+
4. Choose between Foundation Models or Orchestration mode based on your needs
148+
5. Select an appropriate model and start coding
149+
150+
For detailed setup instructions and service configuration, visit the [SAP AI Core documentation](https://help.sap.com/docs/sap-ai-core).

packages/types/src/global-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ export const SECRET_STATE_KEYS = [
233233
"ioIntelligenceApiKey",
234234
"vercelAiGatewayApiKey",
235235
"ovhCloudAiEndpointsApiKey", // kilocode_change
236+
"sapAiCoreServiceKey",
236237
] as const
237238

238239
// Global secrets that are part of GlobalSettings (not ProviderSettings)

packages/types/src/provider-settings.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const dynamicProviders = [
5555
"requesty",
5656
"unbound",
5757
"glama",
58+
"sap-ai-core",
5859
] as const
5960

6061
export type DynamicProvider = (typeof dynamicProviders)[number]
@@ -146,6 +147,7 @@ export const providerNames = [
146147
"virtual-quota-fallback",
147148
"synthetic",
148149
// kilocode_change end
150+
"sap-ai-core",
149151
"sambanova",
150152
"vertex",
151153
"xai",
@@ -480,6 +482,15 @@ const vercelAiGatewaySchema = baseProviderSettingsSchema.extend({
480482
vercelAiGatewayModelId: z.string().optional(),
481483
})
482484

485+
const sapAiCoreSchema = baseProviderSettingsSchema.extend({
486+
sapAiCoreServiceKey: z.string().optional(),
487+
sapAiCoreResourceGroup: z.string().optional(),
488+
sapAiCoreUseOrchestration: z.boolean().optional(),
489+
sapAiCoreModelId: z.string().optional(),
490+
sapAiCoreDeploymentId: z.string().optional(),
491+
sapAiCoreCustomModelInfo: modelInfoSchema.nullish(),
492+
})
493+
483494
const defaultSchema = z.object({
484495
apiProvider: z.undefined(),
485496
})
@@ -527,6 +538,7 @@ export const providerSettingsSchemaDiscriminated = z.discriminatedUnion("apiProv
527538
qwenCodeSchema.merge(z.object({ apiProvider: z.literal("qwen-code") })),
528539
rooSchema.merge(z.object({ apiProvider: z.literal("roo") })),
529540
vercelAiGatewaySchema.merge(z.object({ apiProvider: z.literal("vercel-ai-gateway") })),
541+
sapAiCoreSchema.merge(z.object({ apiProvider: z.literal("sap-ai-core") })),
530542
defaultSchema,
531543
])
532544

@@ -573,6 +585,7 @@ export const providerSettingsSchema = z.object({
573585
...qwenCodeSchema.shape,
574586
...rooSchema.shape,
575587
...vercelAiGatewaySchema.shape,
588+
...sapAiCoreSchema.shape,
576589
...codebaseIndexProviderSchema.shape,
577590
...ovhcloudSchema.shape, // kilocode_change
578591
})
@@ -610,6 +623,7 @@ export const modelIdKeys = [
610623
"deepInfraModelId",
611624
"kilocodeModel",
612625
"ovhCloudAiEndpointsModelId", // kilocode_change
626+
"sapAiCoreModelId",
613627
] as const satisfies readonly (keyof ProviderSettings)[]
614628

615629
export type ModelIdKey = (typeof modelIdKeys)[number]
@@ -666,6 +680,7 @@ export const modelIdKeysByProvider: Record<TypicalProvider, ModelIdKey> = {
666680
kilocode: "kilocodeModel",
667681
"virtual-quota-fallback": "apiModelId",
668682
ovhcloud: "ovhCloudAiEndpointsModelId", // kilocode_change
683+
"sap-ai-core": "sapAiCoreModelId",
669684
}
670685

671686
/**
@@ -798,6 +813,7 @@ export const MODELS_BY_PROVIDER: Record<
798813
requesty: { id: "requesty", label: "Requesty", models: [] },
799814
unbound: { id: "unbound", label: "Unbound", models: [] },
800815
ovhcloud: { id: "ovhcloud", label: "OVHcloud AI Endpoints", models: [] }, // kilocode_change
816+
"sap-ai-core": { id: "sap-ai-core", label: "SAP AI Core", models: [] },
801817

802818
// kilocode_change start
803819
kilocode: { id: "kilocode", label: "Kilocode", models: [] },

0 commit comments

Comments
 (0)