Skip to content

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,

fromclarifai.client.datasetimportDatasetdataset=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

FunctionLinkDescriptionLink to Docs
BasicsBasicsBasic Functionalities (create, list, patch, delete) of SDK App, Dataset, Input & Model ClassesOpen in Colab
Compute OrchestrationCRUD OperationsBasic Functionalities (create, list, get, delete) of Compute Orchestration Classes - ComputeCluster, Nodepool, DeploymentOpen in Colab
Model PredictPredictCall predict of any model in a Python native way with our SDK. See many more examples hereDocs for Python/Javascript
Using OpenAI ClientUse the openAI client to call openAI-compatible models in Clarifai. See many more examples here.Docs for Pyhon/Typescript
Using OpenAI Client on Node.jsUse the OpenAI node client to call OpenAI-compatible models in Clarifai. See many more examples hereDocs for Typescript
Using Vercel AI SDK on Node.jsUse the Vercel AI SDK with OpenAI provider to call OpenAI-compatible models in Clarifai. See many more examples hereDocs for Typescript
Using LiteLLMUse Litellm to call openAI-compatible models in Clarifai. See many more examples here
Legacy ModelsCall predict of any model not uploaded to compute orchestration with our SDKDocs
Model UploadModel UploadUpload custom models, MCP tools, or any python function you want. See our new runner examples repo for compute orchestration with many examples covered!
MCP ToolsMCP Tool ExamplesUpload custom MCP tools and have them fully hosted in Clarifai to use with any MCP client.
Agent ToolkitsCrewAI ExamplesBuild agents with CrewAI toolkits on top of Clarifai LLMs and MCP tools.Video
Google ADKCreate agetns with Google ADK leveraging LLMs and tools powered by Clarifai
LLM + MCP ExamplesSimple python native examples of building agents covering function calls, JSON parsing and more

SDK Notebooks

FunctionNotebookDescriptionOpen in Colab
BasicsBasicsBasic Functionalities (create, list, patch, delete) of SDK App, Dataset, Input & Model ClassesOpen in Colab
Compute OrchestrationCRUD OperationsBasic Functionalities (create, list, get, delete) of Compute Orchestration Classes - ComputeCluster, Nodepool, DeploymentOpen in Colab
ConceptsConcept ManagementBasic Functionalities (add, search, delete) of Concept RelationsOpen in Colab
DatasetsBasicsBasic Functionalities of Dataset & Input Class in SDKOpen in Colab
Input UploadUpload Functionalities of SDK with different kinds of data (image, text, audio, video ) and annotations (classes, bbox, etc) using Input ClassOpen in Colab
Dataset UploadUpload Functionalities of SDK with different of dataset annotation formats (Clarifai, Cifar10, VOC, etc.) using Dataset ClassOpen in Colab
Dataset ExportExport Functionalities of SDK to different of dataset annotation formats (Clarifai, Cifar10, VOC, etc.) using Dataset ClassOpen in Colab
Model PredictModel PredictPrediction Functionalities of SDK Model Class for different type of input dataOpen in Colab
WorkflowsCreate WorkflowDifferent kinds of Workflow Creation examples using SDKOpen in Colab
Patch WorkflowModifying a workflow with patch operations using SDK Workflow ClassOpen in Colab
Export WorkflowExporting Workflow config and create a modified workflow using SDK Workflow ClassOpen in Colab
Model TrainingImage Classification TrainingModel Train demo for Visual-Classifier model type with MMClassification_EfficientNet TemplateOpen in Colab
Text Classification TrainingModel Train demo for Text-Classifier model type with HF_GPTNeo_125m_lora templateOpen in Colab
Image Detection TrainingModel Train demo for Visual-Detector model type with MMDetection templateOpen in Colab
Image Segmentation TrainingModel Train demo for Visual-Segmenter model type with MMDetection templateOpen in Colab
Transfer Learn TrainingModel Train demo for Embedded-Classifier model type using Transfer-LearningOpen in Colab
Model EvaluationEmbedding ClassifierModel Eval demo for Embedded-Classifier model type using SDKOpen in Colab
Text ClassifierModel Eval demo for Text-Classifier model type using SDKOpen in Colab
Visual ClassifierModel Eval demo for Visual-Classifier model type using SDKOpen in Colab
Visual DetectorModel Eval demo for Visual-Detector model type using SDKOpen in Colab
SearchVector SearchIntroductory guide to setting up a Cross-Modal Search system using SDKOpen in Colab
RAGRAGRAG setup and chat with the RAG interface.Open in Colab

CLI Notebooks

FunctionNotebookDescriptionOpen in Colab
Compute OrchestrationCompute OrchestrationBasic functionalities of Compute Orchestration using CLIOpen in Colab
ModelModel PredictModel Prediction using CLIOpen in Colab

Integrations Notebooks

IntegrationFunctionNotebookOpen in Colab
LangchainChainsPrompt Templates and ChainsOpen in Colab
Retrieval QA ChainOpen in Colab
Router ChainOpen in Colab
PostgreSQL LLMOpen in Colab
AgentsConversational AgentOpen in Colab
ReAct Docstore AgentOpen in Colab
DeepEvalLLM EvaluationLLM EvaluationOpen in Colab
Unstructured.ioGithub Data IngestionOpen in Colab
S3 Data IngestionOpen in Colab
DropBox Data IngestionOpen in Colab

Data Utils Notebooks

Data UtilFunctionNotebookOpen in Colab
ImageImage Annotation annotation loaderOpen in Colab
MultimodalData Ingestion Ready to Use PipelinesOpen in Colab
Data Ingestion Multimodal IngestionOpen in Colab
Data Ingestion Advanced Multimodal Ingestion with summarizerOpen 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.

Releases

Packages

Used by

Contributors

Languages