<!-- LLM_VERSION_INFO
FORMAT: text/markdown
CONTENT_TYPE: article
ORIGINAL_URL: https://www.clarifai.com/blog/developer-preview-clarifai-python-sdk
ALTERNATE_VERSION: blog/developer-preview-clarifai-python-sdk/index.html (text/html)
EXTRACTION_DATE: 2026-04-17T04:01:32.421Z

This is the markdown version with text-only content (images converted to alt-text).
For rich formatting with images, request the HTML version at: blog/developer-preview-clarifai-python-sdk/index.html
-->

# Developer Preview: Clarifai Python SDK

By [Sanjay Chelliah](/content/blog/author/sanjay-chelliah/index.html)

We’re excited to announce our **new Python SDK** - [GitHub Repository](https://github.com/Clarifai/clarifai-python) for Clarifai, launching in developer preview.

While you can interact with [Clarifai](/content/site-root.html) 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](/content/explore/index.html) 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.

```bash
pip install -U clarifai
```

You can also learn more about the [Python SDK](https://docs.clarifai.com/python-sdk/sdk-overview/) and [API Reference](https://api.clarifai.com/api-doc/?url=https://api.clarifai.com/v2/swagger.json&).

## **Signup and get your PAT Token**

The SDK uses PAT token for authentication. To create a new PAT, [log in](/content/login/index.html) 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:

```bash
export CLARIFAI_PAT={your personal access token}
```

## **Building an AI App with Clarifai-python SDK**

### **Initializing the client**

```python
# Note: CLARIFAI_PAT must be set as env variable.
from clarifai.client import User
client = User(user_id="user_id")
```

### **Get Started by uploading your data**

### **Creating an app in Clarifai**

```python
# Create app
app = client.create_app(app_id="demo_app", base_workflow="Universal")
```

### **Dataset Upload**

```python
# upload text from csv
dataset = app.create_dataset(dataset_id="demo_dataset")
dataset.upload_from_csv(csv_path='csv_path', input_type='text', csv_type='raw', labels=True)
```

### **Customizing Model Inference Output**

```python
# Customizing Model Inference Output
from clarifai.client import Model
model = Model(user_id="user_id", app_id="app_id", model_id="model_id", output_config={"min_value": 0.98})  # Return predictions having prediction confidence > 0.98
model_prediction = model.predict_by_filepath(filepath="local_filepath", input_type="text")
```

## **Exploring Community Models**

Explore and choose state-of-the-art Vision, Language, and Generative AI models [here](/content/explore/index.html).

### **Model Predict**

```python
# Model Predict
from clarifai.client import Model
model_prediction = Model("https://clarifai.com/meta/Llama-2/models/llama2-13b-chat").predict_by_bytes(b"Write a tweet on future of AI", "text")
print(model_prediction)
```

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

```python
# List all models in community filtered by model_type, description
from clarifai.client import App
all_llm_community_models = App().list_models(filter_by={"query": "LLM", "model_type_id": "text-to-text"}, only_in_app=False)
print(all_llm_community_models)
```

Users of [clarifai-python-utils](https://github.com/Clarifai/clarifai-python-utils), take notice that the repository is deprecated, and [clarifai-python-grpc](https://github.com/Clarifai/clarifai-python-grpc) will still be available with granular API access. For more information on gRPC / HTTP clients, refer to the docs [here](https://docs.clarifai.com/python-sdk/sdk-overview/).

### **What's Next**

**Try it out inside the [Clarifai platform](/content/signup/index.html)!**

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](https://discord.gg/WgUvPK4pVD)!
