Clarifai's comprehensive suite of AI-powered APIs empowers developers and businesses to extract meaningful insights from images, videos, and text data. Leveraging cutting-edge computer vision and natural language processing (NLP) models, Clarifai automates tasks like object detection, image classification, and content moderation, streamlining workflows and enriching your data analysis.
Authentication:
Clarifai utilizes API keys for authentication. You can obtain your free API key by creating an account on the Clarifai platform.
Here's a breakdown of some key Clarifai API endpoints along with JavaScript example code snippets for each:
1. Image Classification (Classify)
- About: This endpoint analyzes an image and returns a list of predicted concepts and their likelihood scores.
- Type: POST
- JavaScript Example:
const apiKey = 'YOUR_API_KEY';
const url =
'https://api.clarifai.com/v2/models/aaa03c0a-1a06-4ffa-b9a2-a9e3e3be641f/outputs';
const data = {
inputs: [
{
data: {
url: 'https://www.example.com/image.jpg', // Replace with your image URL
},
},
],
};
const headers = {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
};
fetch(url, { method: 'POST', headers, body: JSON.stringify(data) })
.then((response) => response.json())
.then((data) => {
console.log('Predicted Concepts:', data.outputs[0].data.concepts);
})
.catch((error) => console.error(error));
2. Object Detection (Detect)
- About: This endpoint identifies and locates objects within an image, returning bounding boxes and confidence scores.
- Type: POST
- JavaScript Example:
const apiKey = 'YOUR_API_KEY';
const url =
'https://api.clarifai.com/v2/models/aaa7a2c7-33ba-4a1f-b62d-89e09e8e45c6/outputs';
const data = {
inputs: [
{
data: {
url: 'https://www.example.com/image.jpg', // Replace with your image URL
},
},
],
};
const headers = {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
};
fetch(url, { method: 'POST', headers, body: JSON.stringify(data) })
.then((response) => response.json())
.then((data) => {
console.log('Detected Objects:', data.outputs[0].data.regions);
})
.catch((error) => console.error(error));
3. Image and Video Moderation (Moderate) (Paid Plans)
- About: This endpoint analyzes images and videos for inappropriate content, aiding in content moderation tasks.
- Type: POST
- JavaScript Example: (Note: Not possible with free API key)
4. Text Analysis (Embed & Analyze) (Paid Plans)
- About: This endpoint analyzes text data, generating embeddings for various NLP tasks and insights like sentiment analysis.
- Type: POST
- JavaScript Example: (Note: Not possible with free API key)
5. Custom Models (Paid Plans)
- About: This feature allows you to train your own custom machine learning models for specific use cases.
- Type: Various (refer to documentation)
- JavaScript Example: (Note: Not possible with free API key)
Explore More with Clarifai
Clarifai offers a free tier along with paid plans that unlock additional features and capabilities. Explore their comprehensive documentation to delve deeper into each API endpoint, advanced functionalities