Configuration

Calling OSAIS APIs and getting called back on specific end points

A Client Token is required to call OSAIS via APIs, as opposed to just using the User Interface for interacting with AIs.

As a subscribed user, you can create multiple client tokens, one per domain on which you would like to get called back.

1/ Create a Client Token

Go to your Profile, and then select the tab Settings.

If you have the right authorization, then a button [Add a Client Token] will appear. Click the button to go to the settings page of the Token. A dialog will appear.

Client Token creation dialog

Enter the domain, and then the uriNotify and the uriUpload. Make sure you DO NOT add the domain name again in the uris, otherwise the callbacks will not work!

When all in entered correctly, press [Create]. You will be redirected to the settings page, and will see the details of your Client Token.

A client token just registered, but not yet validated

Copy your token and your secret, and use them in your application.

The [Not Yet Validated] signal will turn to [validated] as soon as you make a first call to an AI, and that your notification is properly received and acknowledged.

2/ Call the PING AI

We have provided a full sample app to show the integration of OSAIS into a NodeJS backend. Use this sample app as a backbone sample for your own implementation.

Sample App

Make a call to the PING AI, via the specific API call, in particular a call to https://opensourceais.com/api/v1/private/client/ai/ping

ai_ping

If all is configured correctly, your notification endpoint (in our example above myapp.com/public/notify) will get called with some parameters.

Your upload endpoint will also get called with the file which was generated by the AI.

The generic parameters received in a notification are as follows:

{
    "cost": 0,
    "cycle": 0,
    "descr": "AI started",
    "engine": "ping",
    "filename": "default",
    "engine": "ping",
    "qty": 0,
    "stage": 2,
    "uid": "123456789",
    "username": "google_123456",
    "token": "23422f....21313d"
}

3/ Further consideration during testing

It is likely that during testing, you may have to change many times the Domain configuration, for example if you are using an nGROK. To facilitate the update, there is an API for an authenticated Client to update its own parameters (i.e. here in our case, the domain).

Change a domain settings for an authenticated Client

PATCH https://opensourceAIs.com/v1/private/client

Request Body

Name
Type
Description

domain

String

the new domain, e.g. "mydomain.com"

uriNotify

String

The new notify URI, e.g. "public/notify"

uriUpload

String

The new upload URI, e.g. "public/upload"

Last updated