Clarifai Python gRPC Client
This is the official Clarifai gRPC Python client for interacting with our powerful recognition API. Clarifai provides a platform for data scientists, developers, researchers and enterprises to master the entire artificial intelligence lifecycle. Gather valuable business insights from images, video and text using computer vision and natural language processing.
- Try the Clarifai demo at: https://clarifai.com/demo
- Sign up for a free account at: https://portal.clarifai.com/signup
- Read the documentation at: https://docs.clarifai.com/
Installation
python -m pip install clarifai-grpc
Versioning
This library doesn't use semantic versioning. The first two version numbers (X.Y out of X.Y.Z) follow the API (backend) versioning, and
whenever the API gets updated, this library follows it.
The third version number (Z out of X.Y.Z) is used by this library for any independent releases of library-specific improvements and bug fixes.
Getting started
Construct the V2Stub object using which you'll access all the Clarifai API functionality:
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import service_pb2_grpc
stub = service_pb2_grpc.V2Stub(ClarifaiChannel.get_grpc_channel())
Alternatives to the encrypted gRPC channel (
ClarifaiChannel.get_grpc_channel()) are:
- the HTTPS+JSON channel (
ClarifaiChannel.get_json_channel()), and- the unencrypted gRPC channel (
ClarifaiChannel.get_insecure_grpc_channel()).We only recommend them in special cases.
Predict concepts in an image:
from clarifai_grpc.grpc.api import service_pb2, resources_pb2
from clarifai_grpc.grpc.api.status import status_code_pb2
YOUR_CLARIFAI_API_KEY = "???"
YOUR_APPLICATION_ID = "???"
SAMPLE_URL = "https://samples.clarifai.com/metro-north.jpg"
# This is how you authenticate.
metadata = (("authorization", f"Key {YOUR_CLARIFAI_API_KEY}"),)
request = service_pb2.PostModelOutputsRequest(
# This is the model ID of a publicly available General model. You may use any other public or custom model ID.
model_id="general-image-recognition",
user_app_id=resources_pb2.UserAppIDSet(app_id=YOUR_APPLICATION_ID),
inputs=[
resources_pb2.Input(
data=resources_pb2.Data(image=resources_pb2.Image(url=SAMPLE_URL))
)
],
)
response = stub.PostModelOutputs(request, metadata=metadata)
if response.status.code != status_code_pb2.SUCCESS:
print(response)
raise Exception(f"Request failed, status code: {response.status}")
for concept in response.outputs[0].data.concepts:
print("%12s: %.2f" % (concept.name, concept.value))
See the Clarifai API documentation for all available functionality.
Troubleshooting
I get the following error when installing the library: Failed building wheel for grpcio
Try upgrading setuptools to a version 40.7.1 or higher.
pip install --upgrade setuptools
Metadata
Release files for clarifai-grpc 12.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| clarifai_grpc-12.6.0.tar.gz | 291.5 kB | Without provenance | Details for clarifai_grpc-12.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clarifai_grpc-12.6.0-py3-none-any.whl | Python 3 | none | any | Details for clarifai_grpc-12.6.0-py3-none-any.whl |
Total release size: 599.6 kB
Release files / clarifai_grpc-12.6.0.tar.gz
| Download URL | clarifai_grpc-12.6.0.tar.gz |
|---|---|
| Size | 291.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5228c4effe0b6cbe19b4ab6adce6d13191a21fcc02eeea2e8472558df7515d2f
|
|
BLAKE2b-256 checksum How to use checksums |
541c47bf7b17c24d40c643ef1aad20c7e085cec6d9134fdd34aaf2cfed51cd26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / clarifai_grpc-12.6.0-py3-none-any.whl
| Download URL | clarifai_grpc-12.6.0-py3-none-any.whl |
|---|---|
| Size | 308.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
29d6429ad5e1bc2b605b55c4f706fe7a74a05ff64081cb233a9eb14b39285e40
|
|
BLAKE2b-256 checksum How to use checksums |
c5325fe0ce14d039d7f23c3e18d143b11d49dfab3f9a6efedfef14d8d7e2e944
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Security for clarifai-grpc 12.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.