Skip to navigation

How to Authenticate to the API

View as Markdown

NVIDIA Run:ai APIs are accessed using bearer tokens. A token can be obtained using an access key, which serves as the authentication method for both users and service accounts.

An access key consists of a client ID and client secret, which are used to generate an access token for API authentication. Once a token is obtained, it can be included in the Authorization header of subsequent API requests.

Assign Access Rules

After you have created a new service account, you will need to assign it access rules. To assign access rules to the service account, see Access rules. Make sure you assign the correct rules to your service account. Use the Roles to assign the correct access rules.

Request an API Token

Use the client credentials created to get a temporary token to access NVIDIA Run:ai as follows.

Example Command to Get an API Token

Replace <COMPANY-URL> below with:

  • For self-hosted use the NVIDIA Run:ai user interface URL.

cURL

curl -X POST \
'https://<COMPANY-URL>/api/v2/token' \
--header 'Accept: */*' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=<CLIENT ID>' \
--data-urlencode 'client_secret=<CLIENT SECRET>'

Response

The API response will look as follows:

{
"access_token": "<TOKEN>",
"token_type": "Bearer",
"expires_in": 3600
}

To call NVIDIA Run:ai REST APIs, the application must pass the retrieved access_token as a Bearer token in the Authorization header of your HTTP request.