Registry / ai-ml / clarifai-web-grpc

clarifai-web-grpc

JSON →
library12.4.5jsnpmunverified

The official gRPC-web client for the Clarifai API, designed for browser applications. Version 12.4.5 is the latest stable release. It does not support direct browser-to-API calls due to CORS restrictions; a proxy server is required. The package ships TypeScript types and relies on protobuf-generated classes. Releases are tied to the underlying Clarifai gRPC spec version. Use ClarifaiStub.promise() to get a client instance and protobuf message classes for API interactions.

npm install clarifai-web-grpc
INSTALL
IMPORT
SIG · CLARIFAI-WEB-GRPC
C
clarifai-web-grpc
ai-mljavascriptv12.4.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ClarifaiStub
import { ClarifaiStub } from 'clarifai-web-grpc'
const ClarifaiStub = require('clarifai-web-grpc')
Named import; CommonJS require is not supported.
App
import { App } from 'clarifai-web-grpc/proto/clarifai/api/resources_pb'
import { App } from 'clarifai-web-grpc'
Resource classes live under proto paths, not the main entry.
PostAppsRequest
import { PostAppsRequest } from 'clarifai-web-grpc/proto/clarifai/api/service_pb'
import { PostAppsRequest } from 'clarifai-web-grpc'
Service request classes also under proto paths.

Creates a Clarifai app using the gRPC client; demonstrates stub instantiation, protobuf message setup, and authenticated request.

import { ClarifaiStub } from 'clarifai-web-grpc'; import { App } from 'clarifai-web-grpc/proto/clarifai/api/resources_pb'; import { PostAppsRequest } from 'clarifai-web-grpc/proto/clarifai/api/service_pb'; const client = ClarifaiStub.promise(); const app = new App(); app.setId('my-app'); app.setDefaultWorkflowId('General-Detection'); app.setDescription('Example app'); const req = new PostAppsRequest(); req.setAppsList([app]); const auth = { authorization: `Key ${process.env.CLARIFAI_TOKEN ?? ''}` }; const resp = await client.postApps(req, auth); console.log(resp.getAppsList()[0].getId());
Debug
Known issues
gotchaCannot call Clarifai API directly from browser due to CORS restrictions.
fix
Set up a backend proxy server to forward requests from frontend to Clarifai.
affects: all
breakingVersion 10+ changed stub initialization; ClarifaiStub.promise() replaced older patterns.
fix
Use ClarifaiStub.promise() instead of deprecated constructors.
affects: >=10.0.0
deprecatedOlder callback-based stubs are deprecated; use promise-based stubs.
fix
Switch to ClarifaiStub.promise() and async/await.
affects: >=8.0.0
gotchaProto import paths are case-sensitive and must match exactly.
fix
Use lowercased paths like 'clarifai-web-grpc/proto/clarifai/api/service_pb'.
affects: all
gotchaAuth object must have key 'authorization' (lowercase).
fix
Use { authorization: 'Key ...' } not { Authorization: 'Key ...' }.
affects: all
Errors
Common errors & fixes
Module not found: Can't resolve 'clarifai-web-grpc'
Missing dependency or wrong import path for subpath.
fix
Ensure clarifai-web-grpc is installed: yarn add clarifai-web-grpc
TypeError: clarifai_web_grpc_1.ClarifaiStub is not a constructor
Using CommonJS require instead of ESM import.
fix
Use import { ClarifaiStub } from 'clarifai-web-grpc'
Uncaught (in promise) Error: Failed to fetch
Browser CORS blocking direct requests to Clarifai API.
fix
Use a backend proxy server.
TypeError: req.setAppsList is not a function
Missing or incorrect import of PostAppsRequest.
fix
Import PostAppsRequest from 'clarifai-web-grpc/proto/clarifai/api/service_pb'
Upgrade
Version history
12.4.5latest on npm
Audit
Dependencies
google-protobufrequiredRequired for protobuf message classes used throughout the API
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources
clarifai-web-grpc — npm install clarifai-web-grpc · libregistry