Skip to main content

Creating your AI Apps

Learn how to interact with apps using Clarifai Python SDK


Unlock the power of artificial intelligence by seamlessly integrating Clarifai's Python SDK into your application development process. With the Clarifai Python SDK, creating intelligent and visually aware applications has never been more accessible. Empower your apps with cutting-edge AI capabilities, from image and video recognition to natural language processing. Our Python SDK provides a user-friendly interface, allowing developers to harness the full potential of Clarifai's state-of-the-art models effortlessly.

Create App

Leverage the Clarifai Python SDK to seamlessly generate a new application, complete with a distinct and unique app ID. The API empowers you to effortlessly create apps tailored to your specific requirements, unlocking the potential for innovative and personalized experiences. Dive into the simplicity of app creation with the Clarifai Python SDK

Visit this page for more information.

from clarifai.client.user import User

client = User(user_id="user_id", pat="YOUR_PAT")
# You can create an app by providing the app id
app = client.create_app(app_id="test_app", base_workflow="Empty")
Output
2024-01-15 16:11:26 INFO     clarifai.client.user:                                                      user.py:122

App created

code: SUCCESS

description: "Ok"

req_id: "1728082daee63fa593411dcb573e7e33"

Create an app with different base workflow

The API empowers you to establish an app with distinct base workflows, offering flexibility and adaptability. Choose from a range of available base workflows including Empty, Universal, Language Understanding, and General. This enables you to seamlessly integrate and customize the fundamental structure of your app, ensuring it aligns perfectly with your project requirements.

Visit this page for more information.

from clarifai.client.user import User

client = User(user_id="user_id", pat="YOUR_PAT")
# You can set the base workflow as ["Empty","Universal","Language-Understanding","General"]
app = client.create_app(app_id="test_app_2", base_workflow="Universal")
Output

2024-01-15 16:19:23 INFO clarifai.client.user: user.py:122

App created

code: SUCCESS

description: "Ok"

req_id: "7e7e9eaaebbd3c8f7ba6bf5e5cc7f2a3"

Listing Apps

The Clarifai Python SDK provides a convenient API to retrieve a list of all the apps available in your account. The list_apps function is a powerful tool that not only fetches the information but also supports essential features such as pagination for optimal data display.The use of parameters like page_no and per_page empowers you to customize the retrieval process based on your specific requirements.

Visit this page for more information.

from clarifai.client.user import User

# the list_apps method allows pagination
apps = list(User("user_id", pat="YOUR_PAT").list_apps(page_no=1,per_page=6))
for app in apps:
print("App id: ", app.id)
Output
App id:  test_app_3

App id: test_app_2

App id: test_app

App id: APP_ID

App id: demo_app

App id: test

Delete App

In the Clarifai Python SDK, the "Delete App" functionality empowers users to seamlessly remove an app from their account by specifying the unique App ID. This API-driven approach simplifies the app management process, allowing for efficient deletion of redundant or unused applications.

caution

Be certain that you want to delete a particular app as the operation cannot be undone.

from clarifai.client.user import User

# Provide the app id as parameter to delete_app function
user = User("user_id", pat="YOUR_PAT").delete_app("test_app_2")
Output
2024-01-15 16:28:09 INFO     clarifai.client.user:                                                      user.py:230

App Deleted

code: SUCCESS

description: "Ok"

details: "application \'test_app_2\' deleted"

req_id: "35bec06c2b871f335064ec2f197344b1"

Create Concept

With the Clarifai Python SDK, you have the capability to effortlessly create concepts by uploading input data to your app, accompanied by a specified label. This process automates the creation of concepts, streamlining the integration of new ideas or entities into your application.

Visit this page for more information.

from clarifai.client.input import Inputs

image_url = "https://2.img-dpreview.com/files/p/E~C1000x0S4000x4000T1200x1200~articles/3925134721/0266554465.jpeg"
# You can set the label parameter inorder to create a concept while uploading inputs
input_obj = Inputs(user_id="user_id", app_id="test_app", pat="YOUR_PAT")
input_obj.upload_from_url(
input_id="demo2",
image_url=image_url,
labels=["train"],
)
Output
2024-01-15 16:53:00 INFO     clarifai.client.input:                                                    input.py:669

Inputs Uploaded

code: SUCCESS

description: "Ok"

details: "All inputs successfully added"

req_id: "d54e6e6ef983e32cadbc7e6134a829a2"

List concept

The List Concepts feature in the Clarifai Python SDK empowers users to retrieve a comprehensive list of all available concepts within their application. With the list_concepts function, users can seamlessly navigate through large sets of concepts by leveraging built-in pagination functionalities. This enables efficient information display while providing flexibility through parameters such as page number (page_no) and items per page (per_page).

Visit this page for more information.

from clarifai.client.user import User

# the list_apps method allows pagination
apps = list(User("user_id", pat="YOUR_PAT").list_apps(page_no=1,per_page=6))
for app in apps:
print("App id: ", app.id)
Output
App id:  test_app_3

App id: test_app_2

App id: test_app

App id: APP_ID

App id: demo_app

App id: test