Developer quickstart
With the AI Hub API, you can integrate AI Hub functionality into your own workflows and tooling. The AI Hub API is a RESTful API that can be used with any language. AI Hub also offers a Python software development kit (SDK) and Postman collection to help interface with the API.
Account setup
To get started using the AI Hub API:
-
You must have an AI Hub account. See the getting started page to learn how to sign up for a community account or join an organization by invitation.
-
You must have an API token. After creating an account, you can generate an API token yourself.
-
You need your user ID or organization ID, to use in the
IB-Context
header. Read the context identification documentation to understand how theIB-Context
header is used, its default behavior, and where to find your user ID and organization ID.If you belong to an organization, passing your organization ID in theIB-Context
header is the only way to identify a request as coming from your organization account. Your API token is tied to both your community account and your organization account. If the header is undefined, the default behavior is to use your community account. This means if the header is undefined, your community account is the cost center for any requests that require consumption units to complete.
Using the Python SDK
The AI Hub SDK is published to the Python Package Index (PyPI). To install the AI Hub SDK, run the following command:
Initializing the API client
When using the AI Hub SDK, you must initialize the API client with your own api_key
, api_root
, and ib_context
values. The client can then handle authorization and context identification when interacting with the AI Hub API through the SDK.
To initialize the API client, run the following command:
Fill in your details as follows:
-
Replace
<API-ROOT>
with your root API URL.-
To use the default AI Hub root API URL, enter
https://aihub.instabase.com/api
or omitapi_root
. -
Commercial & Enterprise If your organization has a custom AI Hub domain, enter your organization’s root API URL, such as
https://my-organization.instabase.com/api
.
-
-
Replace
<API-TOKEN>
with your API token. -
Replace
<IB-CONTEXT>
with the value to use for theIB-Context
header.-
To use your community account, enter your user ID or omit
ib_context
. -
To use your organization account, enter your organization ID.
-
With the SDK installed and client initialized, you can follow any Python example provided in the AI Hub API reference.
Using Postman
An AI Hub API collection is available in Postman, an API platform for building and using APIs. The AI Hub collection includes automation so that responses from one API call are automatically populated in subsequent calls. To get started, click Run in Postman and fork or import the collection. If given the option, enable notifications for any changes to the collection.
After making a copy of the collection, you can set up your authorization and context identification variables on the Variables tab.
Update the Current value column for the following commonly used variables, then click Save.
Using curl
curl is a common but minimalist command line tool that can be used to make HTTP requests. While you can interact with the AI Hub API in any language, all endpoint references include a curl example. Some notes when using curl examples:
-
All curl examples reference the API root, API token, and
IB-Context
header values as variables. For example: -
If you don’t set up these variables, define them as follows:
-
Replace
${API_ROOT}
with your root API URL.-
To use the default AI Hub root API URL, enter
https://aihub.instabase.com/api
. -
Commercial & Enterprise If your organization has a custom AI Hub domain, enter your organization’s root API URL, such as
https://my-organization.instabase.com/api
.
-
-
Replace
${API_TOKEN}
with your API token. -
Replace
${IB_CONTEXT}
with the value to use for theIB-Context
header.-
To use your community account, enter your user ID or omit the
IB-Context
header. -
To use your organization account, enter your organization ID.
-
-
Testing
To test your setup, you can make a simple request that requires no consumption units to complete, such as calling the Create batch endpoint. This endpoint creates an empty resource called a batch.
-
Python SDK: Run the following command:
-
Postman: Navigate to the Batches > Create batch endpoint and click Run.
-
curl: Run the following command:
A successful response returns a 201
status code and a batch ID in a JSON object, such as {"id":231}
.
Next steps
With your setup complete and tested, you can start interacting with the AI Hub API. Your next steps might include:
-
Running an AI Hub app using the AI Hub SDK.
-
Creating a Converse conversation using the AI Hub SDK.
-
Learning about all AI Hub API endpoints with our AI Hub API reference. All endpoint references include a curl example and a Python example that works with the SDK.
-
Learning about tracking billing and usage, as well as how unit consumption is calculated for AI Hub operations that use consumption units.