Authorization and context identification
The AI Hub API uses a system of authorization and context identification for all API calls. Your API token authorizes the call and your user or organization ID, passed in the IB-Context
header, identifies the request as coming from your community or organization account. You can manage tokens and locate your user ID and organization ID in your user settings.
OAuth tokens
All API requests made to an AI Hub API require an OAuth access token. You can add and manage OAuth tokens yourself from the APIs settings page.
Add a token
You can add as many tokens as needed. While you can use a single token for all AI Hub API requests, creating multiple tokens can be helpful for organizing third-party access. For example, you might use one token per third-party application, so you can selectively manage and revoke third-party access.
-
In the header, click the initials icon and select Settings.
-
Select the APIs tab.
-
Click New token.
-
In the Label field, name your token.
-
In the Description field, describe the token’s purpose or intended usage.
-
Use the Token expiry field to select or define a custom expiration date for the token. The default is No expiry.
-
Click Add.
-
Copy the token. After closing the create token dialog, the token’s value is encrypted and can’t be copied again.
Refresh a token
You can refresh a token as needed. Refreshing a token updates its value.
-
In the header, click the initials icon and select Settings.
-
Select the APIs tab.
-
In the tokens list, locate the token to refresh.
-
On the token’s details card, click the Refresh icon.
-
(Optional) Select or define a custom expiration date for the refreshed token. The default is No expiry.
-
Click Refresh token.
-
Copy the token. After closing the refresh token dialog, the token’s value is encrypted and can’t be copied again.
Delete tokens
If a token is no longer needed or you wish to revoke the access it grants, you can delete it.
-
In the header, click the initials icon and select Settings.
-
Select the APIs tab.
-
In the tokens list, locate the token to delete.
-
On the token’s details card, click the Delete (trash can) icon.
-
In the confirmation dialog, enter the specified confirmation text.
-
Click Delete token.
To delete all tokens:
-
In the header, click the initials icon and select Settings.
-
Select the APIs tab.
-
Click the overflow icon next to New token.
-
Select Delete all tokens.
-
In the confirmation dialog, enter the specified confirmation text.
-
Click Delete all tokens.
IB-Context header
Because AI Hub supports having both a community and an organization account tied to the same user ID and API token, the IB-Context
header is used in API requests to identify the context of the call. For example, commercial and enterprise users have two contexts: an organization account and a personal community account. The IB-Context
header specifies which context (account) to use to complete the API request.
Some notes on using the IB-Context
header:
-
To make a request with your community account’s context, use your user ID as the
IB-Context
header value. -
To make a request with your organization account’s context, use your organization ID as the
IB-Context
header value. -
For requests that require consumption units to complete, the context dictates which account’s consumption units to use. For organization members, this means your community account is used as the cost center if the header is undefined.
-
The context dictates where to find input files and where to save output files. If your request specifies inputs or outputs that don’t exist in the defined or default context, the request fails.
-
The
IB-Context
header is optional but it’s a best practice to include it in all requests, even for users without an organization account. If the header is undefined, the default behavior is to use the community context.
User ID
Your user ID is a unique, non-editable identifier tied to your account. It’s created using the email address tied to your account.
To copy your user ID:
-
In the header, click the initials icon and select Settings.
-
Select the APIs tab.
-
Under User ID, click the Copy icon.
Organization ID
An organization ID is a unique, non-editable identifier tied to your organization.
To copy your organization ID:
-
In the header, click the initials icon and select Settings.
-
Select the APIs tab.
-
Under Organization ID, click the Copy icon.