APIs

The AI Hub API helps you integrate AI Hub functionality into your own workflows and tooling.

Authorization

All AI Hub API calls require a token to authorize the request. Some AI Hub API endpoints require that you pass additional organization context in the request header to identify the user’s organization context. You can manage tokens and locate your user ID and organization context (for Commercial accounts) in your user settings. See the authorization documentation for further information.

Postman collection

To run the AI Hub API in Postman, clone the collection and add your API token. This collection includes automation so that responses from one API call are automatically populated in subsequent calls.

API errors

AI Hub has both v1 and v2 APIs. Version is indicated in the endpoint itself, such as the Filesystem API (/api/v2/files) or the Job status API (/api/v1/jobs/status). v1 and v2 APIs communicate errors differently.

v1 APIs

v1 API endpoints return a 200 status code and rely on the response message body to communicate errors. If an API execution error occurs, the response is in the form of:

HTTP STATUS CODE 200

# body
{
  "status": "ERROR",
  "msg": <string>
}

v2 APIs

v2 API endpoints use HTTP status codes to communicate errors. Responses are grouped in the following classes:

  • Client errors (400–499)

    • A 401 code indicates an authorization error. This can be caused by an invalid API token, an invalid IB-Context header, or by calling an API that requires permissions you don’t have.

    • A 403 code indicates insufficient consumption units to complete the call. For commercial organizations on a free trial of AI Hub Commercial, a 403 code can indicate that your trial has ended.

  • Server errors (500–599)

Info

v2 APIs use the following classes for non-error responses:

  • Informational responses (100–199)

  • Successful responses (200–299)

  • Redirects (300–399)