> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.instabase.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.instabase.com/_mcp/server.

# Test SDK installation and authorization

> Tutorial -- Testing the SDK.

Before you start coding, test that the SDK is installed and configured correctly.

## Making an *SDK-Tutorial* workspace

All the code in this tutorial performs its work in a shared workspace called *SDK-Tutorial*. The code fails if it can't find that workspace, so [make a shared workspace](/admin/workspace-management#creating-shared-workspaces) with that name now.

> **Tip**
>
> If you don't have permission to make a workspace, ask an administrator of your AI Hub organization to do it for you.

> **Info**
>
> Workspace names can't contain spaces, which is why the name is *SDK-Tutorial* instead of *SDK Tutorial*.

## Testing the SDK installation and authorization

A *batch* is a collection of files that AI Hub can process. To see if the SDK is set up correctly, this test does the simplest thing possible: create a batch that contains no files. If this test runs with no error messages, the SDK is behaving as expected and is ready for more complicated operations.

Here's the code for making an empty batch.

The *Technical details* boxes in some steps contain optional information for experienced programmers.

#### Make a file to hold your Python program

With a text editor, create and save an empty file called `test_sdk.py`. Put it anywhere on your computer. As each snippet of test code is introduced, paste it at the bottom of this file.

#### Import the SDK

Make your program aware of the AI Hub SDK by importing it.

```python
from aihub import AIHub
```

> **Technical details**
>
> \
> This imports the `AIHub` class from the `aihub` module, so you can refer to it later as `AIHub` instead of `aihub.AIHub`.

#### Convert authorization details into code

Remember the authorization details mentioned earlier? You need to let your program know about those API Key, IB-Context, and API Root values.

This code instantiates the `AIHub` class and initializes it with the three authorization values. Add it below the line you already entered.

> **Warning**
>
> Spacing matters in Python! Copy and paste can scramble indents, so make sure all the spacing in your code matches the spacing in the tutorial exactly or your program might not run.

```python
client = AIHub(api_root="PASTE YOUR API ROOT HERE",
               api_key="PASTE YOUR API KEY HERE",
               ib_context="PASTE YOUR IB-CONTEXT HERE")
```

#### Make the batch

Here's where you use the SDK to make an empty batch. You're requesting that a new batch named *test batch* be created in the *SDK-Tutorial* workspace.

```python
client.batches.create(name="test batch",
                      workspace="SDK-Tutorial")
```

> **Technical details**
>
> \
> You're calling the `create` method from the `batches` object that's stored as a field of the `client` object. Calling `client.OBJECT-TYPE.ACTION()` is a common pattern in AI Hub SDK usage.

> **Info**
>
> The *Cleanup* use case later in the tutorial shows you how to clean up batches after you're done with them.

#### Print the status

Let the user know if the batch creation worked. If something goes wrong, Python prints an error message and quits the program--you don't need to add code to do that explicitly.

```python
print("Successfully created a batch.")
print("The AI Hub SDK is installed, authorized, and ready to use.")
```

> **Tip**
>
> If this code was deployed to production, you would want to handle exceptions in a more graceful and possibly recoverable way.
>
> If you don't know what that means or how to do it, don't worry--an exception handling discussion comes later.

Here's the whole program as a single piece of code, with comments to remind you what each line does. If you haven't been copying and pasting from the previous steps, copy and paste this version.

**`Test SDK installation and authorization (complete program)`**

```python Test SDK installation and authorization (complete program)
# make the AI Hub SDK available for use
from aihub import AIHub

# initialize the "client" variable as an instance of the AIHub class,
# configured with authorization details for our AI Hub account
client = AIHub(api_root="PASTE YOUR API ROOT HERE",
               api_key="PASTE YOUR API KEY HERE",
               ib_context="PASTE YOUR IB-CONTEXT HERE")

# create a new batch called "test batch" in the
# "SDK-Tutorial" workspace
create_batch_resp = client.batches.create(name="test batch",
                                          workspace="SDK-Tutorial")

# If the batch was created successfully, the program prints the
# messages below and quits normally. If it wasn't created successfully, 
# Python automatically prints an error message and quits the program.
print("Successfully created a batch.")
print("The AI Hub SDK is installed, authorized, and ready to use.")
```

### Running the test

After you've typed in the whole program, save it somewhere on your computer as `test_sdk.py`.

Now run it using the instructions for your operating system. It takes a few seconds.

#### Linux

1. Open a terminal.

2. Type `cd PATH/TO/DIRECTORY/WITH/test_sdk.py`, replacing the placeholders with the actual path to wherever you stored `test_sdk.py`.

3. Type `python3 test_sdk.py`.

#### macOS

1. Open the Terminal app.

2. Type `cd PATH/TO/DIRECTORY/WITH/test_sdk.py`, replacing the placeholders with the actual path to wherever you stored `test_sdk.py`.

3. Type `python3 test_sdk.py`.

#### Windows

1. Run `cmd` to open a command window.

2. Type `cd PATH\TO\DIRECTORY\WITH\test_sdk.py`, replacing the placeholders with the actual path to wherever you stored `test_sdk.py`.

3. Type `python3 test_sdk.py`.

If the SDK works as expected, the program displays this message.

```text
Successfully created a batch.
The AI Hub SDK is installed, authorized, and ready to use.
```

### Troubleshooting

If the test program fails, it displays a complicated error message. Exactly what the error message says depends on what went wrong, but you can usually get the gist of the problem by looking at the end of the message.

Here are some common error messages. Click on each to see solutions.

#### Repo (instabase-enablement-enterprise/SDK-Tutorial) not found. Non-retriable error

Your account doesn't have an *SDK-Tutorial* workspace. See the [instructions](#making-an-sdk-tutorial-workspace) on how to create it.

#### ModuleNotFoundError: No module named 'aihub'

The `instabase-aihub` module isn't installed correctly on your computer. Review the [installation instructions](/api-sdk/sdk-for-beginners/2-prepare#installing-the-sdk).

#### Access Denied

Your API Key is wrong. Review the instructions on how to [find](/api-sdk/sdk-for-beginners/2-prepare#api-key) and [set](/api-sdk/sdk-for-beginners/3-test#convert-authorization-details-into-code) it.

#### Message: Org (YOUR CONTEXT-ID) not found. Non-retriable error

Your IB-Context is wrong. Review the instructions on how to [find](/api-sdk/sdk-for-beginners/2-prepare#ib-context) and [set](/api-sdk/sdk-for-beginners/3-test#convert-authorization-details-into-code) it.

#### 404 Not Found: The requested URL was not found on the server. If you entered the URL manually, please check your spelling and try again.

Your API Root is wrong. Review the instructions on how to [find](/api-sdk/sdk-for-beginners/2-prepare#api-root) and [set](/api-sdk/sdk-for-beginners/3-test#convert-authorization-details-into-code) it.

## Next steps

Now that the SDK is installed, authorized, and tested, go on to the next page to learn how to use the SDK for an actual document processing use case.