Python SDK

Python SDK installation & setup

Installation Guide

The SDK currently supports Python versions 3.8.1 and upwards. It is strongly recommended that you use a virtual environment such as Conda or venv to manage Python packages for your development environment. This helps prevent incompatible dependencies with packages installed irrelevant to your current project or that conflict with system dependencies.

You can view our full release history on PyPi for the latest version of the Python SDK.

For Mac and Linux, use pip to install the octoai sdk Python package. We strongly recommend that you install OctoAI in a virtualenv, to avoid conflicting with your system packages.

$python3 -m pip install octoai

Please refer to CLI & SDK Installation for how to install the SDK in conjunction with the CLI for the authoring tool.

Setting API token as an environment variable

In order to access endpoints, create an OctoAI API token. Set OCTOAI_TOKEN to the token value wherever you set your environment variables, such as your .bashrc or .env file.


Then when you instantiate the client, it will detect the OCTOAI_TOKEN as an envvar and set it for you.

1from octoai.client import OctoAI
3client = OctoAI()

Alternatively, on creation of the OctoAI class, you can set your token, or the Client also accepts a path to where you’ve stored your API token from the config_path variable. Please see the OctoAI docs for more information.

1from octoai.client import OctoAI
3client = OctoAI(api_key="YOUR_OCTOAI_API_TOKEN_HERE")