Introduction to the SDK

Learn to use the AI Hub SDK from the ground up, work through real examples, and build enough knowledge to continue exploring the SDK on your own.

Audience and prerequisites

  • You don’t need to know anything about the AI Hub SDK—you don’t even have to know what “SDK” stands for.

  • You need an AI Hub account at any license tier.

  • You need any text editor—even a basic one like TextEdit on macOS or Notepad on Windows.

  • Some familiarity with AI Hub concepts and terminology.

  • It helps to have basic familiarity with the Python programming language. If you know how to print things, create loops, and use if statements, you’re in good shape. Otherwise, any of these resources can help you learn the basics.

Goals

This tutorial teaches you how to do these tasks.

  • Decide whether to use the SDK or GUI to interact with AI Hub.
  • Install the AI Hub SDK.

  • Authorize the SDK to perform AI Hub operations.

  • Test the SDK to make sure it’s installed and authorized correctly.

  • Use the SDK to process documents with an AI Hub app.

  • Use the SDK to analyze a document with AI Hub.

  • Use the SDK to delete files left over from the two previous use cases.

What is an SDK?

“SDK” stands for “software development kit.” It’s a code library that you use to interact with software such as AI Hub.

If you’re already familiar with APIs, think of an SDK as a wrapper around an API. It lets you interact with the API by calling Python methods instead of making raw HTTP calls to REST endpoints.

Of course, you could just point a browser to aihub.instabase.com and work through its graphical user interface (GUI). But the API and SDK give you more options. They let you use AI Hub programmatically, or via another computer program. The API and the SDK are more complicated than using the GUI, but also more flexible and powerful.

This tutorial covers only the SDK, not the API or the GUI.
Analogy
  • Using the API is like driving a car with a manual transmission.

  • Using the SDK is like driving a car with an automatic transmission.

  • Using the GUI is like calling a taxi.

You arrive at the same place in each case, but some approaches take care of more details for you.

Why use the AI Hub SDK?

You know that the SDK is a tool for using AI Hub while bypassing the GUI. Why would you want to do that?

By allowing you to control AI hub through code instead of clicks, the SDK lets you build automated and repeatable workflows.

Imagine that your company collects hundreds of documents from its sales department every night. In the morning you process those documents with AI Hub and store the results in a CSV file for further processing by other systems.

Here’s one workflow you could use every morning:

  1. Use your browser to log in to AI Hub.

  2. Run the appropriate AI Hub app.

  3. Upload files for the app to process.

  4. Wait for the AI Hub app to finish.

  5. View the results within AI Hub.

  6. Export the results to a CSV file for further processing.

That’s a lot of steps and a lot of chances for human error.

By writing a program that uses the SDK to control AI Hub, you could run this one-step workflow every morning to get the same results without any human errors.

  1. Run your SDK-enabled program.

This one command is an ideal example of an automated and repeatable workflow.

You could also run a deployment in the AI Hub GUI, automating certain steps like uploading input documents or sending the results to a CSV. So when you consider using the SDK, it’s worth thinking about whether a deployment would be a reasonable alternative.
You can make automated workflows using the AI Hub API instead of the SDK, but SDK-based programs are usually easier to understand and maintain than API-based programs. If you don’t need API-specific features, stick to the SDK.

The AI Hub SDK works only with the Python programming language. If you’re new to Python, you might wonder why Python was chosen instead of another popular language like Java or Go.

It’s because Python is:

  • Similar in structure and syntax to English and how many people think.

  • Easier to learn than most other languages.

  • Straightforward to understand and maintain.

  • Concise, so you can do a lot with just a few lines of code.

Consider these code snippets, which all display Hello, SDK user.

Go
1package main
2
3import "fmt"
4
5func main() {
6 fmt.Println("Hello, SDK user")
7}
Java
1public class HelloSdkUser {
2 public static void main(String[] args) {
3 System.out.println("Hello, SDK user");
4 }
5}
Python
1print("Hello, SDK user")

Which language is easiest to understand? Which would you prefer to deal with if you were in charge of debugging code that someone else wrote?

Python’s main drawback is slow performance. But that doesn’t matter for most AI Hub SDK use. Programs that use the SDK spend most of their time waiting for responses from AI Hub. This means that the speed of the programming language makes essentially no difference to how fast the program runs.

Next steps

You now understand what an SDK is and why you might want to use an SDK instead of a GUI. The next page of this tutorial shows how to install and authorize the SDK on your computer.