Skip to main content

Eggplant DAI Model Execution Endpoints

The Eggplant DAI Execution API lets you run your models and interact with execution controls via REST APIs. These services allow you to integrate this behaviour into your devOps toolchains.

New Feature

Eggplant DAI API uses open standards authorization (OAuth 2.0 - Client Credentials Grant) to protect its APIs.

Getting Started

The API is ready and available to use as soon as you finish installing Eggplant DAI. To gain access to the API, you need to:

As soon as you acquire an access token, you can start to test models with all the options that are available in the Eggplant DAI web app. After a run starts, you can leave it to process. An ID is returned which you can use to check the progress of a run. In addition, you can abort a run.

Retrieve Your Credentials

You'll need the credentials for the System Administrator account that you set up during installation. This is different from the DAI Administrator account that you use for day-to-day user management.

  1. On the machine where Eggplant DAI is installed, open a terminal with elevated permissions and navigate to the /python/tools folder of the installation directory. The default path, unless changed during install, is: "C:\Program Files\Digital Automation Intelligence\python\tools".

    cd "C:\Program Files\Digital Automation Intelligence\python\tools"
  2. (Optional) Set the following environment variables or you will be prompted.

    IAM_ADMIN_USER={your-admin-username}
    IAM_ADMIN_PASSWORD={your-admin-password}
  3. Run the following command to generate your credentials.

    Important

    Do not omit any of the arguments from the command as this can reset the credentials for all services.

    python.exe -m eggplant.iam.realm_mgmt --quiet --init-file "C:\ProgramData\Eggplant\Digital Automation Intelligence\logs\keycloak\.keycloak_migration_config" run --realm eggplant --procedure dai_rotate_secrets --vars generated=True --vars client=integration

    Your credentials - a client_id and client_secret pair, and token url are printed out to stdout (standard out/console).

    Example output:

    $ cd "C:\Program Files\Digital Automation Intelligence\python\tools"
    $ set IAM_ADMIN_USER=admin
    $ set IAM_ADMIN_PASSWORD=adminpassword
    $ python.exe -m eggplant.iam.realm_mgmt --quiet --init-file "C:\ProgramData\Eggplant\Digital Automation Intelligence\logs\keycloak\.keycloak_migration_config" run --realm eggplant --procedure dai_rotate_secrets --vars generated=True --vars client=integration

    clients:

Acquire an Access Token and Authenticate

Use the credentials from the previous steps to obtain an access token from the API, and to authenticate.

  1. Send a request to the token_url.

    POST > http://localhost:8000/auth/realms/{realm}/protocol/openid-connect/token
    Content-Type:application/x-www-form-urlencoded

    Request body:

    {
    "grant_type": "client_credentials",
    "client_id":"{your client identifier}",
    "client_secret":"{your client secret}",
    }

    Example successful response:

    {
    "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia...",
    "expires_in": 300,
    "refresh_expires_in": 0,
    "token_type": "Bearer",
    "not-before-policy": 0,
    "session_state": "4fcb07e1-eb73-42e7-b369-26c8db036f90",
    "scope": "email template:dai:agents profile"
    }

    The access token lasts for 5 minutes. To maintain access to the API, you need to check when the access token expires, resend your credentials to get a new token before the original one expires, or when a 401 response is returned.

Available Methods

Use the following HTTP methods to send requests to the Eggplant DAI API endpoints:

  • GET for requesting data
  • POST for creating new records
  • PUT for updating records
  • DELETE for deleting records

This table includes links to descriptions of the individual API methods for starting, monitoring, and stopping a model run.

TitleURLHTTP MethodDescription
NEW Auth Methodhttp://localhost:8000/auth/realms/{realm}/protocol/openid-connect/tokenPOSTReturns an access token for the API.
NEW Start Model Executionhttp://localhost:8000/execution_service/api/v1/executionsPOSTExecutes a model run.
List Run Detailshttp://localhost:8000/ai/runsGETReturns details of the model run in progress.
Get a List of all Agentshttp://localhost:8000/ai/agentsPOSTReturns details of all hosted agents.
NEW Abort Model Executionhttp://localhost:8000/execution_service/api/v1/executions/{execution_status_id}DELETEStops the model run.

For more detailed analysis of model runs, such as viewing run reports, viewing coverage reports, analyzing test cases, and so on see our Swagger docs.