Quick prototyping with Gemini

Google's Generative Language API enables seamless prototyping using the Gemini models. It lets you test and explore the capabilities of Gemini models without needing to set up complex infrastructure or manage model deployment. Google's browser based prototyping tool Google AI Studio uses the Generative Language API to enable browser-based prototyping with generative models.

With Vertex AI SDK for ABAP, you can use the Generative Language API—Gemini API to start your prototyping journey, directly from within your ABAP environment. You need an API key generated from Google AI Studio to access the Gemini models. You need to generate this API key only once.

Generate an API key

The API key that you generate from Google AI Studio provides a convenient way to authenticate to the Gemini API.

  1. In Google AI Studio, create an API key:

    1. Open the API keys page.

      Get an API key

    2. Click Create API key.

    3. If populated, then read and acknowledge the legal notice, and then click Continue.

    4. If populated, then read and acknowledge the safety setting reminder.

    5. In the Create API key dialog, select one of the following options, as appropriate:

      • Create API key in new project
      • Create API key in existing project
    6. Copy your key string and keep it secure. You need this API key to configure authentication to the Gemini API.

    7. Copy the project number of the Google Cloud project where the API key is stored.

  2. In your SAP system, create a Z class by implementing the interface /GOOG/IF_AUTH that is shipped with the ABAP SDK for Google Cloud:

    1. In SAP GUI, execute the transaction code SE24.
    2. In the Object type field, type a name such as Z_TEST_GEMINI_API, and then click Create.
    3. Make sure that the Object type is Class, and then click OK.
    4. In the Description field, provide a description of the class such as Class for authentication to Google AI Studio, and then save the class as a Local Object or in a Transport Request.
    5. Open the Interfaces tab, add the interface /GOOG/IF_AUTH, and then press enter.
    6. Open the Methods tab. Methods of the interface /GOOG/IF_AUTH are automatically implemented into the Z class.
    7. Double-click the method /GOOG/IF_AUTH~GET_ACCESS_TOKEN.
    8. In the method /GOOG/IF_AUTH~GET_ACCESS_TOKEN, add the following code:

      ev_auth_type = /goog/if_auth=>c_auth_type_apik_ssf.
      cv_token = 'API_KEY'.
      GET TIME STAMP FIELD ev_logtime.
      

      Replace API_KEY with the API key that you generated in Google AI Studio.

    9. Activate your Z class.

  3. In the SAP system, create a client key configuration:

    1. In SAP GUI, execute the transaction code /GOOG/SDK_IMG.

      Alternatively, execute the transaction code SPRO, and then click SAP Reference IMG.

    2. Click ABAP SDK for Google Cloud > Basic Settings > Configure Client Key.

    3. Click New Entries.

    4. Enter values for the following fields:

      Field Description
      Google Cloud Key Name Specify a name of the client key configuration, such as TEST_GEMINI_API.
      Google Cloud Service Account Name Leave this field blank.
      Google Cloud Scope Leave this field blank.
      Google Cloud Project Identifier Specify the project number of the Google Cloud project where the API key is stored.
      Command name Leave this field blank.
      Authorization Class Specify the Z class that you created in the preceding step, such as Z_TEST_GEMINI_API.
      Token Caching

      Leave this field blank.

      Token Refresh Seconds Leave this field blank.
      Authorization Parameter 1 Leave this field blank.
      Authorization Parameter 2 Leave this field blank.
    5. Save the new entry.

  4. Make a note of the client key. You use this client key for authentication.

Run the AI Studio demo

You can explore the Gemini API capabilities by using the AI studio demo shipped with the Vertex AI SDK for ABAP.

To run the AI Studio demo, perform the following steps:

  1. In SAP GUI, execute the transaction code /GOOG/SDK_IMG.

    Alternatively, execute the transaction code SPRO, and then click SAP Reference IMG.

  2. Go to ABAP SDK for Google Cloud > Demos.

  3. Open Vertex AI SDK: Demo: Prototyping with Generative Language API.

  4. In the Client key field, enter the client key that you've created in the Generate an API key section.

  5. In the Model ID field, enter the ID of the LLM model that you want to use, such as gemini-1.5-flash. For information about the available models, see Model variants.

  6. Optionally, provide the following generation parameters as appropriate:

    • Max output tokens
    • Response Mime type
    • Temperature
    • TopK
    • TopP

    For information about these model generation parameters, see Experiment with parameter values.

  7. In the Enter system instructions field, provide a system instruction.

  8. In the Enter prompt field, provide your input prompt.

  9. Run the program. The Response from LLM area shows the generated output.

Prototype AI use cases using ABAP

You can build prototype SAP applications using the /GOOG/CL_GENERATIVELANGUAGE_V1 and /GOOG/CL_GENERATIVELANG_V1BETA classes shipped with the SDK. You can invoke these classes from your ABAP environment using the client Key that you've created in the Generate an API key section.

What's next