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.
IB-Context
A single API Key can be associated with both an AI Hub community account and an AI Hub organization account. The IB-Context value (“IB” stands for Instabase) specifies which account performs an action—and incurs the consumption unit charge—triggered by an SDK request.
john.doe
) or your company name (acme-anvils
).This value is critical to get right, and there’s no default value that works for everyone. 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.