Class AiCoreService

java.lang.Object
com.sap.ai.sdk.core.AiCoreService

public class AiCoreService extends Object
Connectivity convenience methods for AI Core, offering convenient access to destinations targeting the AI Core service. Loads base destinations from the environment or allows for setting a custom base destination.
  • Field Details

    • DEFAULT_RESOURCE_GROUP

      public static final String DEFAULT_RESOURCE_GROUP
      The default resource group.
      See Also:
  • Constructor Details

    • AiCoreService

      public AiCoreService()
      The default constructor.
  • Method Details

    • withBaseDestination

      @Nonnull public AiCoreService withBaseDestination(@Nonnull com.sap.cloud.sdk.cloudplatform.connectivity.HttpDestination destination)
      Set a specific base destination. This is useful when loading a destination from the BTP destination service or some other source.

      Note: For typical scenarios, the destination is expected to have the /v2/ base path set. But for special cases a different base path may be required (e.g. when consuming AI Core via some proxy that expects a different base path).

      Parameters:
      destination - The base destination to be used for AI Core service calls.
      Returns:
      A new AI Core Service object using the provided destination as basis.
    • getBaseDestination

      @Nonnull public com.sap.cloud.sdk.cloudplatform.connectivity.HttpDestination getBaseDestination() throws com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException, com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationNotFoundException
      Get the base destination for AI Core service calls. This destination won't have any resource group set.
      Returns:
      The base destination.
      Throws:
      com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException - If there was an issue creating the base destination, e.g. in case of invalid credentials.
      com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationNotFoundException - If there was an issue creating the base destination, e.g. in case of missing credentials.
      See Also:
    • getInferenceDestination

      @Nonnull public AiCoreService.InferenceDestinationBuilder getInferenceDestination() throws com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException, com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationNotFoundException
      Get a destination to perform inference calls against a deployment under the default resource group on AI Core.
      Returns:
      The destination pointing to the specific deployment ID.
      Throws:
      com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException - If there was an issue creating the base destination, e.g. in case of invalid credentials.
      com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationNotFoundException - If there was an issue creating the base destination, e.g. in case of missing credentials.
      See Also:
    • getInferenceDestination

      @Nonnull public AiCoreService.InferenceDestinationBuilder getInferenceDestination(@Nonnull String resourceGroup)
      Get a destination to perform inference calls against a deployment for the given resource group on AI Core.
      Parameters:
      resourceGroup - The resource group to be used for the new endpoint.
      Returns:
      The destination pointing to the specific deployment ID.
      See Also:
    • getApiClient

      @Nonnull public com.sap.cloud.sdk.services.openapi.apache.apiclient.ApiClient getApiClient()
      Get an ApiClient to execute requests based on clients generated from OpenAPI specifications.
      Returns:
      A new client object based on getBaseDestination().
    • buildDeploymentPath

      @Nonnull protected String buildDeploymentPath(@Nonnull String deploymentId)
      Helper method to build the relative URL path for the inference endpoint of a deployment. The result of this together with the base path defined on the destination will be used for inference calls towards this deployment.
      Parameters:
      deploymentId - The deployment ID to be used for the path.
      Returns:
      The path to the deployment.
    • reloadCachedDeployments

      @Beta public void reloadCachedDeployments(@Nonnull String resourceGroup)
      Remove all entries from the cache then load all deployments into the cache.

      Call this whenever a deployment is deleted.

      Parameters:
      resourceGroup - the resource group of the deleted deployment, usually "default".