Class PromptTemplatesApi

java.lang.Object
com.sap.cloud.sdk.services.openapi.apache.apiclient.BaseApi
com.sap.ai.sdk.prompt.registry.client.PromptTemplatesApi

public class PromptTemplatesApi extends com.sap.cloud.sdk.services.openapi.apache.apiclient.BaseApi
Prompt Registry in version 0.14.4.

The Prompt Registry simplifies the lifecycle management of prompt templates across design and runtime environments. It comes with an imperative and declarative interface. This API specification describes the imperative API for managing prompt templates and also allows the retrieval of declarative managed prompt templates. A prompt template consists of chat messages where placeholders can be defined together with default values. Additional information such as metadata tags can be added to the resource as well.

  • Constructor Details

    • PromptTemplatesApi

      public PromptTemplatesApi(@Nonnull com.sap.cloud.sdk.cloudplatform.connectivity.Destination httpDestination)
      Instantiates this API class to invoke operations on the Prompt Registry.
      Parameters:
      httpDestination - The destination that API should be used with
    • PromptTemplatesApi

      public PromptTemplatesApi(@Nonnull com.sap.cloud.sdk.services.openapi.apache.apiclient.ApiClient apiClient)
      Instantiates this API class to invoke operations on the Prompt Registry based on a given ApiClient.
      Parameters:
      apiClient - ApiClient to invoke the API on
  • Method Details

    • withDefaultHeaders

      public PromptTemplatesApi withDefaultHeaders(@Nonnull Map<String,String> defaultHeaders)
      Creates a new API instance with additional default headers.
      Parameters:
      defaultHeaders - Additional headers to include in all requests
      Returns:
      A new API instance with the combined headers
    • createUpdatePromptTemplate

      @Nonnull public PromptTemplatePostResponse createUpdatePromptTemplate(@Nonnull PromptTemplatePostRequest promptTemplatePostRequest, @Nullable String aiResourceGroup, @Nullable String aiResourceGroupScope) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template create

      Create or update a prompt template

      200 - Successful response

      400 - Bad Request

      403 - Forbidden Error

      0 - Common Error

      Parameters:
      promptTemplatePostRequest - (required) The value for the parameter promptTemplatePostRequest
      aiResourceGroup - (optional) Specify a resource group id to use
      aiResourceGroupScope - (optional) Specify whether the resource group scope is to be used
      Returns:
      PromptTemplatePostResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • createUpdatePromptTemplate

      @Nonnull public PromptTemplatePostResponse createUpdatePromptTemplate(@Nonnull PromptTemplatePostRequest promptTemplatePostRequest) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template create

      Create or update a prompt template

      200 - Successful response

      400 - Bad Request

      403 - Forbidden Error

      0 - Common Error

      Parameters:
      promptTemplatePostRequest - The value for the parameter promptTemplatePostRequest
      Returns:
      PromptTemplatePostResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • deletePromptTemplate

      @Nonnull public PromptTemplateDeleteResponse deletePromptTemplate(@Nonnull UUID promptTemplateId, @Nullable String aiResourceGroup, @Nullable String aiResourceGroupScope) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template delete

      Delete an imperatively managed prompt template

      200 - Successful response

      403 - Forbidden Error

      404 - Bad Request

      0 - Common Error

      Parameters:
      promptTemplateId - (required) UUID of the prompt template.
      aiResourceGroup - (optional) Specify a resource group id to use
      aiResourceGroupScope - (optional) Specify whether the resource group scope is to be used
      Returns:
      PromptTemplateDeleteResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • deletePromptTemplate

      @Nonnull public PromptTemplateDeleteResponse deletePromptTemplate(@Nonnull UUID promptTemplateId) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template delete

      Delete an imperatively managed prompt template

      200 - Successful response

      403 - Forbidden Error

      404 - Bad Request

      0 - Common Error

      Parameters:
      promptTemplateId - UUID of the prompt template.
      Returns:
      PromptTemplateDeleteResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • deletePromptTemplateHistory

      @Nonnull public PromptTemplateHistoryDeleteResponse deletePromptTemplateHistory(@Nonnull String scenario, @Nonnull String version, @Nonnull String name, @Nullable String aiResourceGroup, @Nullable String aiResourceGroupScope) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template history delete

      Delete the version history of an imperatively managed prompt template

      200 - Successful response

      403 - Forbidden Error

      404 - Bad Request

      0 - Common Error

      Parameters:
      scenario - (required) Scenario field of the resource.
      version - (required) Version field of the resource.
      name - (required) Name field of the resource.
      aiResourceGroup - (optional) Specify a resource group id to use
      aiResourceGroupScope - (optional) Specify whether the resource group scope is to be used
      Returns:
      PromptTemplateHistoryDeleteResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • deletePromptTemplateHistory

      @Nonnull public PromptTemplateHistoryDeleteResponse deletePromptTemplateHistory(@Nonnull String scenario, @Nonnull String version, @Nonnull String name) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template history delete

      Delete the version history of an imperatively managed prompt template

      200 - Successful response

      403 - Forbidden Error

      404 - Bad Request

      0 - Common Error

      Parameters:
      scenario - Scenario field of the resource.
      version - Version field of the resource.
      name - Name field of the resource.
      Returns:
      PromptTemplateHistoryDeleteResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • deletePromptTemplatesByScenario

      @Nonnull public PromptTemplateScenarioDeleteResponse deletePromptTemplatesByScenario(@Nonnull String scenario, @Nullable String aiResourceGroup, @Nullable String aiResourceGroupScope) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template scenario delete

      Delete all imperatively managed prompt templates in a scenario

      200 - Successful response

      403 - Forbidden Error

      404 - Bad Request

      0 - Common Error

      Parameters:
      scenario - (required) Scenario field of the resource.
      aiResourceGroup - (optional) Specify a resource group id to use
      aiResourceGroupScope - (optional) Specify whether the resource group scope is to be used
      Returns:
      PromptTemplateScenarioDeleteResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • deletePromptTemplatesByScenario

      @Nonnull public PromptTemplateScenarioDeleteResponse deletePromptTemplatesByScenario(@Nonnull String scenario) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template scenario delete

      Delete all imperatively managed prompt templates in a scenario

      200 - Successful response

      403 - Forbidden Error

      404 - Bad Request

      0 - Common Error

      Parameters:
      scenario - Scenario field of the resource.
      Returns:
      PromptTemplateScenarioDeleteResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • exportPromptTemplate

      @Nonnull public byte[] exportPromptTemplate(@Nonnull UUID promptTemplateId, @Nullable String aiResourceGroup, @Nullable String aiResourceGroupScope) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template export

      Download a prompt template as a file

      200 - Successful response

      400 - Bad Request

      0 - Common Error

      Parameters:
      promptTemplateId - (required) UUID of the prompt template.
      aiResourceGroup - (optional) Specify a resource group id to use
      aiResourceGroupScope - (optional) Specify whether the resource group scope is to be used
      Returns:
      byte[]
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • exportPromptTemplate

      @Nonnull public byte[] exportPromptTemplate(@Nonnull UUID promptTemplateId) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template export

      Download a prompt template as a file

      200 - Successful response

      400 - Bad Request

      0 - Common Error

      Parameters:
      promptTemplateId - UUID of the prompt template.
      Returns:
      byte[]
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • getPromptTemplateByUuid

      @Nonnull public PromptTemplateGetResponse getPromptTemplateByUuid(@Nonnull UUID promptTemplateId, @Nullable String aiResourceGroup, @Nullable String aiResourceGroupScope) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template get

      Get prompt template by UUID

      200 - Successful response

      400 - Bad Request

      403 - Forbidden Error

      0 - Common Error

      Parameters:
      promptTemplateId - (required) UUID of the prompt template.
      aiResourceGroup - (optional) Specify a resource group id to use
      aiResourceGroupScope - (optional) Specify whether the resource group scope is to be used
      Returns:
      PromptTemplateGetResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • getPromptTemplateByUuid

      @Nonnull public PromptTemplateGetResponse getPromptTemplateByUuid(@Nonnull UUID promptTemplateId) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template get

      Get prompt template by UUID

      200 - Successful response

      400 - Bad Request

      403 - Forbidden Error

      0 - Common Error

      Parameters:
      promptTemplateId - UUID of the prompt template.
      Returns:
      PromptTemplateGetResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • importPromptTemplate

      @Nonnull public PromptTemplatePostResponse importPromptTemplate(@Nullable String aiResourceGroup, @Nullable String aiResourceGroupScope, @Nullable File _file) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template create

      Create an imperatively managed prompt template from a file

      200 - Successful response

      400 - Bad Request

      0 - Common Error

      Parameters:
      aiResourceGroup - (optional) Specify a resource group id to use
      aiResourceGroupScope - (optional) Specify whether the resource group scope is to be used
      _file - (optional) The value for the parameter _file
      Returns:
      PromptTemplatePostResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • importPromptTemplate

      @Nonnull public PromptTemplatePostResponse importPromptTemplate() throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template create

      Create an imperatively managed prompt template from a file

      200 - Successful response

      400 - Bad Request

      0 - Common Error

      Returns:
      PromptTemplatePostResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • listPromptTemplateHistory

      @Nonnull public PromptTemplateListResponse listPromptTemplateHistory(@Nonnull String scenario, @Nonnull String version, @Nonnull String name, @Nullable String aiResourceGroup, @Nullable String aiResourceGroupScope, @Nullable Integer $top, @Nullable Integer $skip) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template history

      List prompt template history

      200 - Successful response

      400 - Bad Request

      403 - Forbidden Error

      413 - Payload Too Large — result set exceeds maximum allowed rows; use $top and $skip to paginate

      0 - Common Error

      Parameters:
      scenario - (required) Scenario field of the resource.
      version - (required) Version field of the resource.
      name - (required) Name field of the resource.
      aiResourceGroup - (optional) Specify a resource group id to use
      aiResourceGroupScope - (optional) Specify whether the resource group scope is to be used
      $top - (optional) Number of results to return (1–500). When omitted the full result set is returned (up to the server limit).
      $skip - (optional, default to 0) Number of results to skip before returning the page.
      Returns:
      PromptTemplateListResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • listPromptTemplateHistory

      @Nonnull public PromptTemplateListResponse listPromptTemplateHistory(@Nonnull String scenario, @Nonnull String version, @Nonnull String name) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template history

      List prompt template history

      200 - Successful response

      400 - Bad Request

      403 - Forbidden Error

      413 - Payload Too Large — result set exceeds maximum allowed rows; use $top and $skip to paginate

      0 - Common Error

      Parameters:
      scenario - Scenario field of the resource.
      version - Version field of the resource.
      name - Name field of the resource.
      Returns:
      PromptTemplateListResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • listPromptTemplates

      @Nonnull public PromptTemplateListResponse listPromptTemplates(@Nullable String aiResourceGroup, @Nullable String aiResourceGroupScope, @Nullable String scenario, @Nullable String name, @Nullable String version, @Nullable String retrieve, @Nullable Boolean includeSpec, @Nullable Integer $top, @Nullable Integer $skip) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template list

      List prompt templates

      200 - Successful response

      400 - Bad Request

      403 - Forbidden Error

      413 - Payload Too Large — result set exceeds maximum allowed rows; use $top and $skip to paginate

      0 - Common Error

      Parameters:
      aiResourceGroup - (optional) Specify a resource group id to use
      aiResourceGroupScope - (optional) Specify whether the resource group scope is to be used
      scenario - (optional) Scenario field of the resource.
      name - (optional) Name field of the resource.
      version - (optional) Version field of the resource.
      retrieve - (optional, default to both) Whether to retrieve 'imperative', 'declarative', or 'both'.
      includeSpec - (optional, default to false) Whether include the spec section or not.
      $top - (optional) Number of results to return (1–500). When omitted the full result set is returned (up to the server limit).
      $skip - (optional, default to 0) Number of results to skip before returning the page.
      Returns:
      PromptTemplateListResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • listPromptTemplates

      @Nonnull public PromptTemplateListResponse listPromptTemplates() throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template list

      List prompt templates

      200 - Successful response

      400 - Bad Request

      403 - Forbidden Error

      413 - Payload Too Large — result set exceeds maximum allowed rows; use $top and $skip to paginate

      0 - Common Error

      Returns:
      PromptTemplateListResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • parsePromptTemplateById

      @Nonnull public PromptTemplateSubstitutionResponse parsePromptTemplateById(@Nonnull UUID promptTemplateId, @Nullable String aiResourceGroup, @Nullable String aiResourceGroupScope, @Nullable Boolean metadata, @Nullable PromptTemplateSubstitutionRequest promptTemplateSubstitutionRequest) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template fill

      Fill the placeholders of a prompt template that is identified by its UUID

      200 - Successful response

      400 - Bad Request

      403 - Forbidden Error

      0 - Common Error

      Parameters:
      promptTemplateId - (required) UUID of the prompt template.
      aiResourceGroup - (optional) Specify a resource group id to use
      aiResourceGroupScope - (optional) Specify whether the resource group scope is to be used
      metadata - (optional, default to false) Whether to not include metadata in the response.
      promptTemplateSubstitutionRequest - (optional) The value for the parameter promptTemplateSubstitutionRequest
      Returns:
      PromptTemplateSubstitutionResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • parsePromptTemplateById

      @Nonnull public PromptTemplateSubstitutionResponse parsePromptTemplateById(@Nonnull UUID promptTemplateId) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template fill

      Fill the placeholders of a prompt template that is identified by its UUID

      200 - Successful response

      400 - Bad Request

      403 - Forbidden Error

      0 - Common Error

      Parameters:
      promptTemplateId - UUID of the prompt template.
      Returns:
      PromptTemplateSubstitutionResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • parsePromptTemplateByNameVersion

      @Nonnull public PromptTemplateSubstitutionResponse parsePromptTemplateByNameVersion(@Nonnull String scenario, @Nonnull String version, @Nonnull String name, @Nullable String aiResourceGroup, @Nullable String aiResourceGroupScope, @Nullable Boolean metadata, @Nullable PromptTemplateSubstitutionRequest promptTemplateSubstitutionRequest) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template fill

      Fill the placeholders of a prompt template that is identified by its scenario, name and version

      200 - Successful response

      400 - Bad Request

      403 - Forbidden Error

      0 - Common Error

      Parameters:
      scenario - (required) Scenario field of the resource.
      version - (required) Version field of the resource.
      name - (required) Name field of the resource.
      aiResourceGroup - (optional) Specify a resource group id to use
      aiResourceGroupScope - (optional) Specify whether the resource group scope is to be used
      metadata - (optional, default to false) Whether to not include metadata in the response.
      promptTemplateSubstitutionRequest - (optional) The value for the parameter promptTemplateSubstitutionRequest
      Returns:
      PromptTemplateSubstitutionResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API
    • parsePromptTemplateByNameVersion

      @Nonnull public PromptTemplateSubstitutionResponse parsePromptTemplateByNameVersion(@Nonnull String scenario, @Nonnull String version, @Nonnull String name) throws com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException
      Prompt template fill

      Fill the placeholders of a prompt template that is identified by its scenario, name and version

      200 - Successful response

      400 - Bad Request

      403 - Forbidden Error

      0 - Common Error

      Parameters:
      scenario - Scenario field of the resource.
      version - Version field of the resource.
      name - Name field of the resource.
      Returns:
      PromptTemplateSubstitutionResponse
      Throws:
      com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException - if an error occurs while attempting to invoke the API