How to connect to AI gateway microservice

How to connect to AI gateway microservice

AI Gateway client

This is a library developed especially for allowing easy integration of the AI Gateway features into any other microservice.

What the AI Gateway Client does

  • provides functionalities of calling the AI gateway endpoints in both sync and async ways

  • generates the bearer tokens which are used on the gateway side to authorize the received requests

Setup

1. Clone the repository

PublicisSapient/knowhow-ai-gateway-client

2. Add the repository as a Maven project and run a maven clean and maven install on it

2. Add the ai-gateway-client dependency in your pom.xml or build.gradle files

Example with build.gradle on knowhow-retro-core-api:

implementation 'com.knowhow.retro:ai-gateway-client:1.0.0'

The version of the client should be the one which resulted after running the maven install. At the date when this documentation was written the version was 1.0.0

Example with pom.xml on custom-api (KnowHOW api):

<dependency> <groupId>com.knowhow.retro</groupId> <artifactId>ai-gateway-client</artifactId> <version>1.0.0</version> </dependency>

The version of the client should be the one which resulted after running the maven install. At the date when this documentation was written the version was 1.0.0

3. Set the related configurations in the application.yml or application.properties

The below configurations are mandatory

m2mauth
  • the properties set under m2mauth are related to “microservice-to-microservice” authentication and authorization

  • the AI gateway microservice has a list of “trusted issuers” which is a list of microservice names which are allowed to call this service (check the authorization mechanism explained in detail in the AI-gateway microservice technical documentation)

Currently there are only two microservices set as trusted issuers in the ai-gateway microservice: custom-api (KnowHOW api) and knowhow-retro-core-api. If you want to add AI gateway connectivity to another microservice other than these two then please contact a colleague to establish the naming conventions and approaches. Regarding the proposed naming conventions for a new microservice please follow the guidelines displayed on the AI-Gateway microservice technical documentation.

m2mauth config for custom-api

application.properties

m2mauth.secret=${auth.secret} m2mauth.duration=7200 //2 hours m2mauth.issuer-service-id=knowhow.custom.api
m2mauth config for knowhow-retro-core-api

application.yml

m2mauth: secret: {AUTH_SECRET} duration: 7200 //2 hours issuer-service-id: knowhow.retrospective.api
ai-gateway-config
  • represents the API connectivity properties that the client will use to call the ai-gateway endpoints

ai-gateway-config config for custom-api
ai-gateway-config.base-url=<environment_based_url> //check the urls below ai-gateway-config.default-ai-provider=openai //or any other available provider as present in the technical documentation of the AI gateway service ai-gateway-config.audience=knowhow.ai-gateway.api
ai-gateway-config config for knowhow-retro-core-api
ai-gateway-config: base-url: <environment_based_url> ai-gateway-config: default-ai-provider: openai //or any other available provider as present in the technical documentation of the AI gateway service ai-gateway-config: audience: knowhow.ai-gateway.api

 

© 2022 Publicis Sapient. All rights reserved.