New
WEBINAR | AI Prototype to Production: Operationalizing and Orchestrating AI
September 14, 2023

Developer Preview: Clarifai Python SDK

Table of Contents:

We’re excited to announce our new Python SDK - https://github.com/Clarifai/clarifai-python for Clarifai, launching in developer preview.

While you can interact with Clarifai with our powerful gRPC API, we also recognize that Python is the most common programming language used by developers, data scientists, and the machine learning community at large, and prefer to use in an object-oriented way. We aim to provide the functionality of the platform, accessible with one or fewer lines of code.

With the new Python SDK, you can now:

  • Simplify your data import. Import datasets along with annotations.
  • Interact with the API in an object-oriented way
  • Create apps, inputs, and datasets, and consume model predictions.
  • Consume models and workflows from the Clarifai community with ease.

We’d love for you to participate in the open beta and provide feedback. Sign up and setup your PAT token, you can access the Python SDK directly today via pip.

pip install -U clarifai

You can also learn more about the Python SDK and API Reference our docs.

Signup and get your PAT Token

The SDK uses PAT token for authentication.  To create a new PAT, log in to the portal, navigate to the upper right-hand section of the navigation bar, and click your user’s profile icon.

Select the Security settings option on the drop-down list.

 

On the ensuing Security page, click the Create Personal Access Token button.


On the command line on your computer, export your PAT as an environment variable

export CLARIFAI_PAT={your personal access token}

Building an AI App with Clarifai-python SDK

Initializing the client

Get Started by uploading your data

Creating an app in Clarifai

Dataset Upload

For more examples, see https://github.com/Clarifai/examples/tree/main/datasets/upload

Customizing Model Inference Output

Exploring Community Models

Explore and choose state-of-art Vision, Language, and Generative AI models here.

Copy the URL of the selected model as above and start predicting from the models within the Clarifai Community.

Model Predict

Additionally, you can list the models from the community with the below snippet:

Users of clarifai-python-utils, take notice that the repository is deprecated, and clarifai-python-grpc will still be available with granular API access. For more information on gRPC / HTTP clients, refer to the docs here.

What's Next

Try it out inside the Clarifai platform!

If you haven't already signed up for Clarifai, you're missing out on a lot of cool AI features.

More features are in progress, and we are working on adding Workflow creation with YAML, MLOps processes, and more exciting utilities. If you want to see any feature within the SDK, please reach out to us on Clarifai Discord!