RepoClarifaiClarifaipublished May 30, 2014seen 5d

Clarifai/clarifai-python

Python

Open original ↗

Captured source

source ↗
published May 30, 2014seen 5dcaptured 8hhttp 200method plain

Clarifai/clarifai-python

Description: Experience the power of Clarifai’s AI platform with the python SDK. 🌟 Star to support our work!

Language: Python

License: NOASSERTION

Stars: 44

Forks: 9

Open issues: 12

Created: 2014-05-30T15:10:36Z

Pushed: 2026-05-28T12:40:30Z

Default branch: master

Fork: no

Archived: no

README:

Clarifai Python SDK

This is the official Python client for interacting with our powerful API. The Clarifai Python SDK offers a comprehensive set of tools to integrate Clarifai's AI platform to leverage computer vision capabilities like classification , detection ,segementation and natural language capabilities like classification , summarisation , generation , Q&A ,etc into your applications. With just a few lines of code, you can leverage cutting-edge artificial intelligence to unlock valuable insights from visual and textual content.

Website | Schedule Demo | Signup for a Free Account | API Docs | Clarifai Community | Python SDK Docs | Examples | Colab Notebooks | Discord

Give the repo a star ⭐ ---

Table Of Contents

  • [Installation](#rocket-installation)
  • [Getting Started](#memo-getting-started)
  • [Compute Orchestration](#rocket-compute-orchestration)
  • [Cluster Operations](#cluster-operations)
  • [Nodepool Operations](#nodepool-operations)
  • [Depolyment Operations](#deployment-operations)
  • [Interacting with Datasets](#floppy_disk-interacting-with-datasets)
  • [Interacting with Inputs](#floppy_disk-interacting-with-inputs)
  • [Input Upload](#input-upload)
  • [Input Listing](#input-listing)
  • [Interacting with Models](#brain-interacting-with-models)
  • [Model Predict](#model-predict)
  • [Model Training](#model-training)
  • [Model Listing](#models-listing)
  • [Interacting with Workflows](#fire-interacting-with-workflows)
  • [Workflow Predict](#workflow-predict)
  • [Workflow Listing](#workflows-listing)
  • [Workflow Create](#workflow-create)
  • [Workflow Export](#workflow-export)
  • [Search](#mag-search)
  • [Smart Image Search](#smart-image-search)
  • [Smart Text Search](#smart-text-search)
  • [Filters](#filters)
  • [Pagination](#pagination)
  • [Retrieval Augmented Generation (RAG)](#retrieval-augmented-generation-rag)
  • [More Examples](#pushpin-more-examples)

:rocket: Installation

Install from PyPi:

pip install -U clarifai

Install from Source:

git clone https://github.com/Clarifai/clarifai-python.git
cd clarifai-python
python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Linting

For developers, use the precommit hook .pre-commit-config.yaml to automate linting.

pip install -r requirements-dev.txt
pre-commit install

Now every time you run git commit your code will be automatically linted and won't commit if it fails.

You can also manually trigger linting using:

pre-commit run --all-files

:memo: Getting started

Clarifai uses Personal Access Tokens(PATs) to validate requests. You can create and manage PATs under your Clarifai account security settings.

  • 🔗 Create PAT: *Log into Portal → Profile Icon → Security Settings → Create Personal Access Token → Set the scopes → Confirm*
  • 🔗 Get User ID: *Log into Portal → Profile Icon → Account → Profile → User-ID*

Export your PAT as an environment variable. Then, import and initialize the API Client.

Set PAT as environment variable through terminal:

export CLARIFAI_PAT={your personal access token}
# Note: CLARIFAI_PAT must be set as env variable.
from clarifai.client.user import User
client = User(user_id="user_id")

# Get all apps
apps_generator = client.list_apps()
apps = list(apps_generator)

OR

PAT can be passed as constructor argument

from clarifai.client.user import User
client = User(user_id="user_id", pat="your personal access token")

:rocket: Compute Orchestration

Clarifai’s Compute Orchestration offers a streamlined solution for managing the infrastructure required for training, deploying, and scaling machine learning models and workflows.

This flexible system supports any compute instance — across various hardware providers and deployment methods — and provides automatic scaling to match workload demands. More Details

Cluster Operations

from clarifai.client.user import User
client = User(user_id="user_id",base_url="https://api.clarifai.com")

# Create a new compute cluster
compute_cluster = client.create_compute_cluster(compute_cluster_id="demo-id",config_filepath="computer_cluster_config.yaml")

# List Clusters
all_compute_clusters = list(client.list_compute_clusters())
print(all_compute_clusters)

##### Example Cluster Config

Nodepool Operations

from clarifai.client.compute_cluster import ComputeCluster

# Initialize the ComputeCluster instance
compute_cluster = ComputeCluster(user_id="user_id",compute_cluster_id="demo-id")

# Create a new nodepool
nodepool = compute_cluster.create_nodepool(nodepool_id="demo-nodepool-id",config_filepath="nodepool_config.yaml")

#Get a nodepool
nodepool = compute_cluster.nodepool(nodepool_id="demo-nodepool-id")
print(nodepool)

# List nodepools
all_nodepools = list(compute_cluster.list_nodepools())
print(all_nodepools)

##### Example Nodepool config

Deployment Operations

from clarifai.client.nodepool import Nodepool

# Initialize the Nodepool instance
nodepool = Nodepool(user_id="user_id",nodepool_id="demo-nodepool-id")

# Create a new deployment
deployment = nodepool.create_deployment(deployment_id="demo-deployment-id",config_filepath="deployment_config.yaml")

#Get…

Excerpt shown — open the source for the full document.