@sap-ai-sdk/ai-api 1.11.1-20250414013204.0 → 1.11.1-20250415013200.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -159
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,16 +14,7 @@ We maintain a list of [currently available and tested AI Core APIs](https://gith
|
|
|
14
14
|
### Table of Contents
|
|
15
15
|
|
|
16
16
|
- [Installation](#installation)
|
|
17
|
-
- [
|
|
18
|
-
- [Prerequisites](#prerequisites)
|
|
19
|
-
- [Usage](#usage)
|
|
20
|
-
- [Create an Artifact](#create-an-artifact)
|
|
21
|
-
- [Create a Configuration](#create-a-configuration)
|
|
22
|
-
- [Create a Deployment](#create-a-deployment)
|
|
23
|
-
- [Delete a Deployment](#delete-a-deployment)
|
|
24
|
-
- [Custom Destination](#custom-destination)
|
|
25
|
-
- [Error Handling](#error-handling)
|
|
26
|
-
- [Local Testing](#local-testing)
|
|
17
|
+
- [Documentation](#documentation)
|
|
27
18
|
- [Support, Feedback, Contribution](#support-feedback-contribution)
|
|
28
19
|
- [License](#license)
|
|
29
20
|
|
|
@@ -33,156 +24,9 @@ We maintain a list of [currently available and tested AI Core APIs](https://gith
|
|
|
33
24
|
$ npm install @sap-ai-sdk/ai-api
|
|
34
25
|
```
|
|
35
26
|
|
|
36
|
-
##
|
|
27
|
+
## Documentation
|
|
37
28
|
|
|
38
|
-
|
|
39
|
-
Updates to this package may include breaking changes.
|
|
40
|
-
|
|
41
|
-
To ensure compatibility and manage updates effectively, we strongly recommend using the tilde (`~`) version range in your project instead of the caret (`^`). This approach will allow patch-level updates while preventing potentially breaking minor version changes.
|
|
42
|
-
|
|
43
|
-
```JSON
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"@sap-ai-sdk/ai-api": "~1.0.0"
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Prerequisites
|
|
50
|
-
|
|
51
|
-
- [Enable the AI Core service in SAP BTP](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/initial-setup).
|
|
52
|
-
- Configure the project with **Node.js v20 or higher** and **native ESM** support.
|
|
53
|
-
|
|
54
|
-
> **Accessing the AI Core Service via the SDK**
|
|
55
|
-
>
|
|
56
|
-
> The SDK automatically retrieves the `AI Core` service credentials and resolves the access token needed for authentication.
|
|
57
|
-
>
|
|
58
|
-
> - In Cloud Foundry, it's accessed from the `VCAP_SERVICES` environment variable.
|
|
59
|
-
> - In Kubernetes / Kyma environments, you have to mount the service binding as a secret instead, for more information refer to [this documentation](https://www.npmjs.com/package/@sap/xsenv#usage-in-kubernetes).
|
|
60
|
-
|
|
61
|
-
## Usage
|
|
62
|
-
|
|
63
|
-
The examples below demonstrate the usage of the most commonly used APIs in SAP AI Core.
|
|
64
|
-
In addition to the examples below, you can find more **sample code** [here](https://github.com/SAP/ai-sdk-js/blob/main/sample-code/src/ai-api).
|
|
65
|
-
|
|
66
|
-
### Create an Artifact
|
|
67
|
-
|
|
68
|
-
```ts
|
|
69
|
-
async function createArtifact() {
|
|
70
|
-
const requestBody: ArtifactPostData = {
|
|
71
|
-
name: 'training-test-dataset',
|
|
72
|
-
kind: 'dataset',
|
|
73
|
-
url: 'https://ai.example.com',
|
|
74
|
-
scenarioId: 'foundation-models'
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const responseData: ArtifactCreationResponse =
|
|
78
|
-
await ArtifactApi.artifactCreate(requestBody, {
|
|
79
|
-
'AI-Resource-Group': 'default'
|
|
80
|
-
}).execute();
|
|
81
|
-
return responseData;
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Create a Configuration
|
|
86
|
-
|
|
87
|
-
```ts
|
|
88
|
-
async function createConfiguration() {
|
|
89
|
-
const requestBody: ConfigurationBaseData = {
|
|
90
|
-
name: 'gpt-4o',
|
|
91
|
-
executableId: 'azure-openai',
|
|
92
|
-
scenarioId: 'foundation-models',
|
|
93
|
-
parameterBindings: [
|
|
94
|
-
{
|
|
95
|
-
key: 'modelName',
|
|
96
|
-
value: 'gpt-4o'
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
key: 'modelVersion',
|
|
100
|
-
value: 'latest'
|
|
101
|
-
}
|
|
102
|
-
],
|
|
103
|
-
inputArtifactBindings: []
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const responseData: ConfigurationCreationResponse =
|
|
107
|
-
await ConfigurationApi.configurationCreate(requestBody, {
|
|
108
|
-
'AI-Resource-Group': 'default'
|
|
109
|
-
}).execute();
|
|
110
|
-
return responseData;
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Create a Deployment
|
|
115
|
-
|
|
116
|
-
```ts
|
|
117
|
-
async function createDeployment() {
|
|
118
|
-
const requestBody: DeploymentCreationRequest = {
|
|
119
|
-
configurationId: '0a1b2c3d-4e5f6g7h'
|
|
120
|
-
};
|
|
121
|
-
const responseData: DeploymentCreationResponse =
|
|
122
|
-
await DeploymentApi.deploymentCreate(requestBody, {
|
|
123
|
-
'AI-Resource-Group': 'default'
|
|
124
|
-
}).execute();
|
|
125
|
-
return responseData;
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Delete a Deployment
|
|
130
|
-
|
|
131
|
-
Only deployments with `targetStatus: STOPPED` can be deleted.
|
|
132
|
-
Thus, a modification request must be sent before deletion can occur.
|
|
133
|
-
|
|
134
|
-
```ts
|
|
135
|
-
async function modifyDeployment() {
|
|
136
|
-
let deploymentId: string = '0a1b2c3d4e5f';
|
|
137
|
-
|
|
138
|
-
const deployment: DeploymentResponseWithDetails =
|
|
139
|
-
await DeploymentApi.deploymentGet(
|
|
140
|
-
deploymentId,
|
|
141
|
-
{},
|
|
142
|
-
{ 'AI-Resource-Group': 'default' }
|
|
143
|
-
).execute();
|
|
144
|
-
|
|
145
|
-
if (deployment.targetStatus === 'RUNNING') {
|
|
146
|
-
// Only RUNNING deployments can be STOPPED.
|
|
147
|
-
const requestBody: DeploymentModificationRequest = {
|
|
148
|
-
targetStatus: 'STOPPED'
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
await DeploymentApi.deploymentModify(deploymentId, requestBody, {
|
|
152
|
-
'AI-Resource-Group': 'default'
|
|
153
|
-
}).execute();
|
|
154
|
-
}
|
|
155
|
-
// Wait a few seconds for the deployment to stop
|
|
156
|
-
return DeploymentApi.deploymentDelete(deploymentId, {
|
|
157
|
-
'AI-Resource-Group': 'default'
|
|
158
|
-
}).execute();
|
|
159
|
-
}
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
### Custom Destination
|
|
163
|
-
|
|
164
|
-
When calling the `execute()` method, it is possible to provide a custom destination.
|
|
165
|
-
For example, when querying deployments targeting a destination with the name `my-destination`, the following code can be used:
|
|
166
|
-
|
|
167
|
-
```ts
|
|
168
|
-
const queryParams = status ? { status } : {};
|
|
169
|
-
return DeploymentApi.deploymentQuery(queryParams, {
|
|
170
|
-
'AI-Resource-Group': resourceGroup
|
|
171
|
-
}).execute({
|
|
172
|
-
destinationName: 'my-destination'
|
|
173
|
-
});
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
By default, the fetched destination is cached.
|
|
177
|
-
To disable caching, set the `useCache` parameter to `false` together with the `destinationName` parameter.
|
|
178
|
-
|
|
179
|
-
## Error Handling
|
|
180
|
-
|
|
181
|
-
For error handling instructions, refer to this [section](https://github.com/SAP/ai-sdk-js/blob/main/README.md#error-handling).
|
|
182
|
-
|
|
183
|
-
## Local Testing
|
|
184
|
-
|
|
185
|
-
For local testing instructions, refer to this [section](https://github.com/SAP/ai-sdk-js/blob/main/README.md#local-testing).
|
|
29
|
+
Visit the [SAP Cloud SDK for AI (JavaScript)](https://sap.github.io/ai-sdk/docs/js/overview-cloud-sdk-for-ai-js) documentation portal to learn more about its capabilities and detailed usage.
|
|
186
30
|
|
|
187
31
|
## Support, Feedback, Contribution
|
|
188
32
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ai-sdk/ai-api",
|
|
3
|
-
"version": "1.11.1-
|
|
3
|
+
"version": "1.11.1-20250415013200.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@sap-cloud-sdk/connectivity": "^4.0.2",
|
|
23
23
|
"@sap-cloud-sdk/util": "^4.0.2",
|
|
24
|
-
"@sap-ai-sdk/core": "^1.11.1-
|
|
24
|
+
"@sap-ai-sdk/core": "^1.11.1-20250415013200.0"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"compile": "tsc",
|