Clarifai Rust gRPC Client
This is the official Clarifai gRPC Rust 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
Add these dependencies to Cargo.toml
: clarifai_grpc
, protobuf
and grpcio
.
[dependencies]
clarifai_grpc = "*"
grpcio = "0.6.0"
protobuf = "2.0"
Getting started
Construct the V2Client
object using which you'll access all the Clarifai API functionality,
and a CallOption
object that will be used for authentication.
use ;
use ;
use clarifai_channel;
use ;
use PostModelOutputsRequest;
use V2Client;
use StatusCode;
let client = new;
// Setup authentication.
let auth = "Key YOUR_CLARIFAI_API_KEY_OR_PAT".to_string;
let mut builder = with_capacity;
builder.add_str.unwrap;
let metadata = builder.build;
let call_opt = default.headers;
Predict concepts in an image:
// This is a publicly available model.
const GENERAL_MODEL_ID: &str = "aaa03c23b3724a16a56b629203edc62c";
let request = PostModelOutputsRequest ;
let response = client
.post_model_outputs_opt
.expect;
let status = response.get_status;
if status.get_code != SUCCESS
println!;
for concept in response.get_outputs.get_data.get_concepts