Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@sap-ai-sdk/ai-api
Advanced tools
This package provides tools to manage your scenarios and workflows in SAP AI Core.
This package provides tools to manage your scenarios and workflows in SAP AI Core.
$ npm install @sap-ai-sdk/ai-api
.env
file in the sample-code directory.AICORE_SERVICE_KEY='<content-of-service-key>'
.We maintain a list of currently available and tested AI Core APIs
The examples below demonstrate the usage of the most commonly used APIs in SAP AI Core.
async function createArtifact() {
const requestBody: ArtifactPostData = {
name: 'training-test-dataset',
kind: 'dataset',
url: 'https://ai.example.com',
scenarioId: 'foundation-models'
}
try {
const responseData: ArtifactCreationResponse = await ArtifactApi
.artifactCreate(requestBody, {'AI-Resource-Group': 'default'})
.execute();
return responseData;
} catch (errorData) {
const apiError = errorData.response.data.error as ApiError;
console.error('Status code:', errorData.response.status);
throw new Error(`Artifact creation failed: ${apiError.message}`);
}
}
async function createConfiguration() {
const requestBody: ConfigurationBaseData = {
name: 'gpt-35-turbo',
executableId: 'azure-openai',
scenarioId: 'foundation-models',
parameterBindings: [
{
"key": "modelName",
"value": "gpt-35-turbo"
},
{
"key": "modelVersion",
"value": "latest"
}
],
inputArtifactBindings: []
}
try {
const responseData: ConfigurationCreationResponse = await ConfigurationApi
.configurationCreate(requestBody, {'AI-Resource-Group': 'default'})
.execute();
return responseData;
} catch (errorData) {
const apiError = errorData.response.data.error as ApiError;
console.error('Status code:', errorData.response.status);
throw new Error(`Configuration creation failed: ${apiError.message}`);
}
}
async function createDeployment() {
const requestBody: DeploymentCreationRequest = {
configurationId: '0a1b2c3d-4e5f6g7h'
};
try{
const responseData: DeploymentCreationResponse = await DeploymentApi
.deploymentCreate(requestBody, {'AI-Resource-Group': 'default'})
.execute();
return responseData;
} catch (errorData) {
const apiError = errorData.response.data.error as ApiError;
console.error('Status code:', errorData.response.status);
throw new Error(`Deployment creation failed: ${apiError.message}`);
}
}
Only deployments with targetStatus: STOPPED
can be deleted. So a modification request must be sent before deletion can occur.
async function modifyDeployment() {
let deploymentId: string = '0a1b2c3d4e5f';
const deployment: DeploymentResponseWithDetails = await DeploymentApi
.deploymentGet(deploymentId, {}, {'AI-Resource-Group': 'default'})
.execute();
if(deployment.targetStatus === 'RUNNING') {
// Only RUNNING deployments can be STOPPED.
const requestBody: DeploymentModificationRequest = {
targetStatus: 'STOPPED',
};
try {
await DeploymentApi
.deploymentModify(deploymentId, requestBody, {'AI-Resource-Group': 'default'})
.execute();
} catch (errorData) {
const apiError = errorData.response.data.error as ApiError;
console.error('Status code:', errorData.response.status);
throw new Error(`Deployment modification failed: ${apiError.message}`);
}
}
// Wait a few seconds for the deployment to stop
try {
return DeploymentApi.deploymentDelete(deploymentId, { 'AI-Resource-Group': 'default' }).execute();
} catch (errorData) {
const apiError = errorData.response.data.error as ApiError;
console.error('Status code:', errorData.response.status);
throw new Error(`Deployment deletion failed: ${apiError.message}`);
}
}
This project is open to feature requests/suggestions, bug reports etc. via GitHub issues.
Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our Contribution Guidelines.
The SAP Cloud SDK for AI is released under the Apache License Version 2.0.
FAQs
SAP Cloud SDK for AI is the official Software Development Kit (SDK) for **SAP AI Core**, **SAP Generative AI Hub**, and **Orchestration Service**.
The npm package @sap-ai-sdk/ai-api receives a total of 1,071 weekly downloads. As such, @sap-ai-sdk/ai-api popularity was classified as popular.
We found that @sap-ai-sdk/ai-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.