While you can interact with Clarifai 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.
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.
The SDK uses PAT token for authentication. To create a new PAT,log into the portal, navigate to the upper right-hand section of the navigation bar, and click your user’s profile icon.
Select theSecuritysettings option on the drop-down list.
On the ensuingSecuritypage, click theCreate Personal Access Tokenbutton.
On the command line on your computer, export your PAT as an environment variable
export CLARIFAI_PAT={your personal access token}
Building an AI App with Clarifai-python SDK
Initializing the client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Explore and choose state-of-art Vision, Language, and Generative AI models here.
Copy the URL of the selected model as above and start predicting from the models within the Clarifai Community.
Model Predict
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Additionally, you can list the models from the community with the below snippet:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Users of clarifai-python-utils, take notice that the repository is deprecated, and clarifai-python-grpc will still be available with granular API access. For more information on gRPC / HTTP clients, refer to the docs here.
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!