# Configuration

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

{% hint style="info" %}
As a subscribed user, you can create multiple client tokens, one per domain on which you would like to get called back.
{% endhint %}

### 1/ Create a Client Token

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

<figure><img src="/files/zUAxP4tT072g2o3gCIHr" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
You will only be able to create a Client Token if your have a valid subscription.
{% endhint %}

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.&#x20;

<figure><img src="/files/E6Tgudb10yLuxwfiyuP2" alt=""><figcaption><p>Client Token creation dialog</p></figcaption></figure>

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!&#x20;

{% hint style="danger" %}
If you are on a test environment with an nGROK for example, then make sure that you update your nGROK domain in the \[domain] filed each time you renew it. Otherwise, the call would end up calling another nGROK endpoint than yours.
{% endhint %}

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

<figure><img src="/files/aXGpyIczIIpDhTXJWDfe" alt=""><figcaption><p>A client token just registered, but not yet validated</p></figcaption></figure>

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.

{% content-ref url="/pages/LJnnpD4VV9d1fJeYpTK1" %}
[Sample App](/opensourceais/sample-app/nodejs-sample.md)
{% endcontent-ref %}

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>

{% content-ref url="/pages/tnoVHaYwEeFqyGPD5iBG" %}
[ai\_ping](/opensourceais/apis/ais/integration-test/ai_ping.md)
{% endcontent-ref %}

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

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

<mark style="color:purple;">`PATCH`</mark> `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" |

{% tabs %}
{% tab title="200: OK the updated Client data" %}

{% endtab %}

{% tab title="400: Bad Request At least domain, or uriNotify or uriUpload required" %}

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://incubiq.gitbook.io/opensourceais/client-tokens/configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
