Preparing to use the SDK
Letβs cover some technical requirements and then dive into installing and authorizing the SDK.
Operating systems
You can use Linux, macOS, or Windows to write and run programs that use the SDK.
Python automatically handles all the main differences between these operating systems, so code from this tutorialβand any SDK-enabled programs you writeβworks on any OS.
Virtual environments
Many people do development work using a virtual environment manager such as venv, virtualenv, or miniconda. These tools install separate copies of Python that are isolated from your computerβs main Python instance. This ensures that any third-party libraries you installβsuch as AI Hub SDKβdonβt affect your systemβs main Python environment.
Setting up a virtual environment with any of these tools is beyond the scope of this tutorial, but is a recommended practice for safety.
Installing the SDK
First, make sure you have Python 3.7 or later installed on your computer. Run this command in a terminal.
If you need a later version, refer to Pythonβs official installation instructions for your operating system.
The AI Hub SDK is distributed as a Python module called instabase-aihub that Instabase publishes to the PyPI software repository.
The easiest way to download and install the module is with Pythonβs built-in pip tool.
Itβs worth checking the AI Hub release notes occasionally to see if a new version of the SDK has been released.
To check the version of the installed SDK, run this command in a terminal.
To upgrade to the latest version, run this command in a terminal.
instabase-aihub module uses semantic versioning. This means upgrading to the latest version shouldnβt break your SDK-enabled programs unless the first digit of the version changes (such as upgrading from 0.11.0 to 1.0.2).Troubleshooting installation
ERROR: pip's dependency resolver does not currently have a solution
The version of instabase-aihub that youβre trying to install has conflicts with another Python module thatβs already installed. Solution: install the instabase-aihub module in a new virtual environment.
Any other problem
Re-run the pip command with maximum verbosity by adding the -v -v -v option to provide more information.
pip install -v -v -v instabase-aihub
or
pip install --upgrade -v -v -v instabase-aihub
Authorization
Whenever you use the SDK to control AI Hub, you must prove that youβre authorized to do so. Do this by providing three pieces of data: an API Key, an IB-Context, and an API Root.
API Key
Each AI Hub user has their own unique API key. In addition to proving that youβre authorized to use AI Hub, this also lets AI Hub keep track of which users perform specific operations.
Learn more about creating an API keyβalso called an OAuth tokenβand return to this tutorial after creating your own token and saving it somewhere for safekeeping. If you donβt see an option to create a token, contact your organization admin for next steps.
IB-Context
Specifies which account triggered the request, typically your organization ID. Learn more about finding your IB-Context value and then return to this tutorial.
API Root
The SDK needs to know which instance of AI Hub to submit your requests to. Specify the instance in the API Root value.
-
If you typically use the AI Hub instance at
https://aihub.instabase.com, your API Root value ishttps://aihub.instabase.com/api. -
If you use a dedicated, single-tenant instance of AI Hub such as
https://my-organization.instabase.com, your API Root value is the AI Hub URL plus/api. For example,https://my-organization.instabase.com/api.
Next steps
Now that you understand how to install the SDK and collect the information for authorizing SDK operations, learn how to test if the SDK is installed and authorized correctly.
