Skip to main content

Personal Access Tokens

Authenticate access to your own resources and those outside the scope of your apps


A Personal Access Token (usually shortened as PAT) is a kind of key that authenticates your connection to the Clarifai platform. It's not linked to a specific application.

A PAT represents you when accessing the Clarifai API. It's a powerful way of accessing your resources within the Clarifai platform.

You can use PATs to accomplish various tasks, including:

  • Access multiple apps with a single key. This lets you access your own apps as well as any other apps you have permission to use, such as public apps, apps where you're added as a collaborator, or apps belonging to your organization's team.
  • Create apps and app-specific keys programmatically through the API. This is crucial for programs that segregate the data of each of their end-users into different apps.

Note: PAT is the primary authentication mechanism we use. For example, when using a PAT to access a resource, you need to specify the user ID alongside the application ID of the owner of the resource you want to access — be it your own or for another user. If accessing your own resources, you specify your own user_id and app_id; if you don't own them, specify the owner's user_id and app_id.

PAT Versus API Key

A PAT allows you to make inferences on resources that are outside the scope of your apps. An API Key only allows you to access resources scoped to the app defined by that key. So, you can use an API Key to access your own resources, but not Clarifai's or other public resources.

How to Create a PAT on the Platform

A default PAT is automatically generated for you when you create an account on the Clarifai platform. Nonetheless, you can also create a new PAT explicitly on the platform.

To create it, log in to the platform, go to the top-right corner of the navigation bar, and open the drop-down menu.

Then, select the Security settings option in the drop-down list.

Create new PAT on Community

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

Account security settings

On the form that pops up, provide a short token description, set the scopes you want to apply, and click the Create Personal Access Token button.

create pat

You can find the new PAT listed in the Personal Access Token section, where you can copy, view, edit, or delete it.

listed pat

note
  • PATs do not expire. In case your PAT gets compromised, you should delete it, and create a new one with the same scopes.
  • We recommend that you do not share your PAT with other users.

Set PAT as an Environment Variable

It's recommended to load your PAT from an environment variable. Keeping your PAT in a secrets manager, and not in the source code, improves its security and management.

Here is how you can set it as an environment variable.

 export CLARIFAI_PAT=YOUR_PERSONAL_ACCESS_TOKEN_HERE 

Example

Here is an example of how to use a PAT to make a prediction request.

import os
from clarifai.client import Model

# Or, you can set the PAT as an environment variable instead of hardcoding it
os.environ["CLARIFAI_PAT"] = "YOUR_PAT_HERE"

# Initialize with model URL
model = Model(url="https://clarifai.com/qwen/qwenLM/models/Qwen3-30B-A3B-GGUF")

response = model.predict(prompt="What is the future of AI?")

print(response)