Skip to content

Clarifai/examples

Repository files navigation

image

Clarifai Python SDK and Integrations Examples

This is a collection of examples for the clarifai-python SDK and Integrations done with Clarifai SDK. Use these examples to learn Clarifai and build your own robust and scalable AI applications.

Experience the power of Clarifai in building Computer Vision , Natual Language processsing , Generative AI applications.

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

Setup

  • Sign up for a free account at clarifai and set your PAT key.

  • You can generate PAT key in the Personal settings -> Security section

  • Install the Clarifai python sdk.

  • Export your PAT as an environment variable.

    export CLARIFAI_PAT={your personal access token}
  • Explore and run the examples in this repo.

Usage

The examples are organized into several folders based on their category. A quick example below,

from clarifai.client.dataset import Dataset
dataset = Dataset(user_id="user_id", app_id="app_id", dataset_id="dataset_id")
dataset.upload_dataset(task="text_clf", split="train", module_dir="path_to_imdb_reviews_module")

Compute Orchestration and Agentic Examples

Function Link Description Link to Docs
Basics Basics Basic Functionalities (create, list, patch, delete) of SDK App, Dataset, Input & Model Classes Open in Colab
Compute Orchestration CRUD Operations Basic Functionalities (create, list, get, delete) of Compute Orchestration Classes - ComputeCluster, Nodepool, Deployment Open in Colab
Model Predict Predict Call predict of any model in a Python native way with our SDK. See many more examples here Docs for Python/Javascript
Using OpenAI Client Use the openAI client to call openAI-compatible models in Clarifai. See many more examples here. Docs for Pyhon/Typescript
Using OpenAI Client on Node.js Use the OpenAI node client to call OpenAI-compatible models in Clarifai. See many more examples here Docs for Typescript
Using Vercel AI SDK on Node.js Use the Vercel AI SDK with OpenAI provider to call OpenAI-compatible models in Clarifai. See many more examples here Docs for Typescript
Using LiteLLM Use Litellm to call openAI-compatible models in Clarifai. See many more examples here
Legacy Models Call predict of any model not uploaded to compute orchestration with our SDK Docs
Model Upload Model Upload Upload custom models, MCP tools, or any python function you want. See our new runner examples repo for compute orchestration with many examples covered!
MCP Tools MCP Tool Examples Upload custom MCP tools and have them fully hosted in Clarifai to use with any MCP client.
Agent Toolkits CrewAI Examples Build agents with CrewAI toolkits on top of Clarifai LLMs and MCP tools. Video
Google ADK Create agetns with Google ADK leveraging LLMs and tools powered by Clarifai
LLM + MCP Examples Simple python native examples of building agents covering function calls, JSON parsing and more

SDK Notebooks

Function Notebook Description Open in Colab
Basics Basics Basic Functionalities (create, list, patch, delete) of SDK App, Dataset, Input & Model Classes Open in Colab
Compute Orchestration CRUD Operations Basic Functionalities (create, list, get, delete) of Compute Orchestration Classes - ComputeCluster, Nodepool, Deployment Open in Colab
Concepts Concept Management Basic Functionalities (add, search, delete) of Concept Relations Open in Colab
Datasets Basics Basic Functionalities of Dataset & Input Class in SDK Open in Colab
Input Upload Upload Functionalities of SDK with different kinds of data (image, text, audio, video ) and annotations (classes, bbox, etc) using Input Class Open in Colab
Dataset Upload Upload Functionalities of SDK with different of dataset annotation formats (Clarifai, Cifar10, VOC, etc.) using Dataset Class Open in Colab
Dataset Export Export Functionalities of SDK to different of dataset annotation formats (Clarifai, Cifar10, VOC, etc.) using Dataset Class Open in Colab
Model Predict Model Predict Prediction Functionalities of SDK Model Class for different type of input data Open in Colab
Workflows Create Workflow Different kinds of Workflow Creation examples using SDK Open in Colab
Patch Workflow Modifying a workflow with patch operations using SDK Workflow Class Open in Colab
Export Workflow Exporting Workflow config and create a modified workflow using SDK Workflow Class Open in Colab
Model Training Image Classification Training Model Train demo for Visual-Classifier model type with MMClassification_EfficientNet Template Open in Colab
Text Classification Training Model Train demo for Text-Classifier model type with HF_GPTNeo_125m_lora template Open in Colab
Image Detection Training Model Train demo for Visual-Detector model type with MMDetection template Open in Colab
Image Segmentation Training Model Train demo for Visual-Segmenter model type with MMDetection template Open in Colab
Transfer Learn Training Model Train demo for Embedded-Classifier model type using Transfer-Learning Open in Colab
Model Evaluation Embedding Classifier Model Eval demo for Embedded-Classifier model type using SDK Open in Colab
Text Classifier Model Eval demo for Text-Classifier model type using SDK Open in Colab
Visual Classifier Model Eval demo for Visual-Classifier model type using SDK Open in Colab
Visual Detector Model Eval demo for Visual-Detector model type using SDK Open in Colab
Search Vector Search Introductory guide to setting up a Cross-Modal Search system using SDK Open in Colab
RAG RAG RAG setup and chat with the RAG interface. Open in Colab

CLI Notebooks

Function Notebook Description Open in Colab
Compute Orchestration Compute Orchestration Basic functionalities of Compute Orchestration using CLI Open in Colab
Model Model Predict Model Prediction using CLI Open in Colab

Integrations Notebooks

Integration Function Notebook Open in Colab
Langchain Chains Prompt Templates and Chains Open in Colab
Retrieval QA Chain Open in Colab
Router Chain Open in Colab
PostgreSQL LLM Open in Colab
Agents Conversational Agent Open in Colab
ReAct Docstore Agent Open in Colab
DeepEval LLM Evaluation LLM Evaluation Open in Colab
Unstructured.io Github Data Ingestion Open in Colab
S3 Data Ingestion Open in Colab
DropBox Data Ingestion Open in Colab

Data Utils Notebooks

Data Util Function Notebook Open in Colab
Image Image Annotation annotation loader Open in Colab
Multimodal Data Ingestion Ready to Use Pipelines Open in Colab
Data Ingestion Multimodal Ingestion Open in Colab
Data Ingestion Advanced Multimodal Ingestion with summarizer Open in Colab

Note

Although these scripts are run on your local machine, they'll communicate with Clarifai and run in our cloud on demand.

Examples provide a guided tour through Clarifai's concepts and capabilities. contains uncategorized, miscellaneous examples.