Tutorial
Video Processing
8 min reading

How to Detect Labels (Objects) in Videos Using JavaScript

Summarize this article with:

summary
  • Label detection automatically identifies and categorizes objects, people, and scenes in videos or images.
  • Developers can Detect Labels (Objects) in Videos Using JavaScript using Eden AI's unified REST API with a single API key across all supported providers.
  • Eden AI lets you experiment with various AI models before integration, making it easy to compare and choose the provider that best fits your needs.
  • Label detection in videos now goes through a multimodal LLM: you send the video URL and get the labels back as JSON in the same response.
  • Using Eden AI with JavaScript gives you fast, flexible access to powerful label detection tools.

Label detection, or Object Detection plays a crucial role in video and image analysis by identifying and classifying elements within each frame like objects, people, animals, or landmarks.

This process enhances content tagging, indexing, and searchability. In this tutorial, we’ll guide you through implementing label detection using JavaScript and the Eden AI API.

With just a few lines of code, you’ll be able to analyze visual content and extract valuable insights effortlessly.

‍

What is Label Detection?

__wf_reserved_inherit

Label detection automatically identifies and categorizes objects, people, and scenes in videos or images. It assigns labels like animals, buildings, or landmarks to visual elements, making content easier to search, organize, and analyze.

‍

How to Detect Labels in Videos

‍

Get Access to Eden AI API

1. Sign up: Visit Eden AI and create an account for free to get started. Once registered, go to the API section to find your personal API key which gives you access to AI services, including Label Detection.

__wf_reserved_inherit

2. Navigate to Video Technologies – Log in and head to the Video Technologies section.

3. Select Label Detection– From there, select the Label Detection option.

‍

Live Test Models on Eden AI

Eden AI lets you experiment with various AI models before integration, making it easy to compare and choose the provider that best fits your needs.

‍

Implementing Label Detection in JavaScript

‍

Step 1: Install JavaScript's Requests Module

To get started, you'll need to install Axios. Axios is a promise-based HTTP client for the browser and Node.js, which makes it easy to send asynchronous HTTP requests.



npm install axios

‍

Code Breakdown

Label detection in videos now goes through a multimodal LLM that accepts video as input, called with Eden AI’s OpenAI-compatible chat completions endpoint. It works in two steps:

  1. Sending the request: you send the video URL, your instruction and the JSON format you expect for the answer.
  2. Reading the results: the labels come back in the same response, as JSON, so there is no job to poll.

A 10-second clip is processed in a few seconds. For long videos, set a generous timeout on your HTTP client.

‍

Sending the Label Detection Request

This POST part of the code sends the video and the instruction to Eden AI.



const API_TOKEN = 'your_api_token_here';
const videoUrl = '🔗 URL of your video'; // Replace with the actual video URL

const headers = {
"Authorization": `Bearer ${API_TOKEN}`,
"Content-Type": "application/json"
};

// The JSON format expected for the answer: each label with the time range where it appears
const schema = {
type: "object",
properties: {
labels: {
type: "array",
items: {
type: "object",
properties: {
label: { type: "string" },
start_time: { type: "number" },
end_time: { type: "number" }
},
required: ["label", "start_time", "end_time"]
}
}
},
required: ["labels"]
};

const body = JSON.stringify({
model: "google/gemini-2.5-flash", // Any model that accepts video input
messages: [{
role: "user",
content: [
{ type: "text", text: "List the objects, people and scenes in this video, with start and end times in seconds." },
{ type: "image_url", image_url: { url: videoUrl } }
]
}],
response_format: { type: "json_schema", json_schema: { name: "labels", schema: schema } }
});

fetch("https://api.edenai.run/v3/chat/completions", {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(result => {
showLabels(result); // See the next step
})
.catch(error => {
console.error('Error:', error);
});

What This Does:

  • model: The multimodal LLM to use, in the provider/model format. It must accept video: check for video in input_modalities at https://api.edenai.run/v3/models (for example google/gemini-2.5-flash or amazon/amazon.nova-2-lite-v1:0).
  • messages: Your instruction in a text block, and the public URL of your video in an image_url block.
  • response_format: The JSON schema the answer must follow, here a list of labels with start and end times.
  • fetch(): Sends the request to Eden AI, at https://api.edenai.run/v3/chat/completions.

‍

Reading the Results

The labels are in the same response: the showLabels function called in the previous step reads them.



function showLabels(result) {
// The labels are in the model's answer, as a JSON string
const { labels } = JSON.parse(result.choices[0].message.content);
labels.forEach(item => {
console.log(`${item.label}: ${item.start_time}s to ${item.end_time}s`);
});
console.log("Cost:", result.cost, "USD");
}

Code Explanation

  • JSON.parse turns the answer, a JSON string that follows your schema, into an object.
  • The loop prints each label with the time range where it appears.
  • result.cost gives the cost of the request, in USD.
  • A single request, authenticated by the Authorization header, covers both steps.

‍

Example Output & Interpreting Results

Here’s an example of the model’s answer, read from choices[0].message.content:



{
"labels": [
{"label": "Snowy mountain landscape", "start_time": 0.0, "end_time": 9.0},
{"label": "Red-haired character", "start_time": 0.0, "end_time": 9.0},
{"label": "Large muscular character", "start_time": 1.0, "end_time": 9.0},
{"label": "Man with a knife", "start_time": 6.0, "end_time": 7.0}
]
}

What the Fields Mean:

  • label: The detected object, person or scene.
  • ‍start_time / end_time: When the label appears in the video, in seconds.

The timestamps are estimated by the model: check them on a few of your own videos before relying on them in production.

‍

Managing Your Video Files

To analyze a video stored on your machine, upload it first with POST https://api.edenai.run/v3/upload, then send a file block with the returned file_id instead of the image_url block. Eden AI provides additional optional endpoints to manage these files:

Video Files - List Files

GET Request:
https://api.edenai.run/v3/upload
This lists the files you uploaded, with their file_id and expiration date.

Video Files - Delete Files

POST Request:
https://api.edenai.run/v3/upload/delete
Send the list of file_ids you no longer need in the file_ids field to delete them.

‍

Why Eden AI is the Best Tool for Label Detection

Eden AI offers a robust Label Detection solution with several advantages.

__wf_reserved_inherit

‍

Multiple Provider Options

Eden AI lets you compare multimodal models from providers like Google and Amazon by changing a single parameter, model.

Ease of Integration

Eden AI simplifies the integration of label detection into your applications with clear and straightforward JavaScript code examples.

Security and Trust

‍The Eden AI platform prioritizes data security and privacy, ensuring that your image data is handled securely.

‍

Conclusion

Using Eden AI with JavaScript gives you fast, flexible access to powerful label detection tools. With an easy-to-use OpenAI-compatible API and support for top AI providers, you can quickly integrate object recognition into your applications.

By combining video understanding from multimodal LLMs with simple file management, Eden AI is a reliable and scalable choice for developers and businesses alike.

‍

Frequently Asked Questions (FAQ)

‍

What do I need to Detect Labels (Objects) in Videos Using JavaScript?

You'll need an Eden AI account and API key. The platform provides a unified endpoint so you can get started quickly without setting up individual provider accounts.

‍

How long does it take to implement this?

With Eden AI's standardized API and ready-to-use code examples, most developers can integrate the feature in under an hour.

‍

Do I need to manage multiple API keys for different providers?

No. Eden AI consolidates access to dozens of AI providers under a single API key, simplifying authentication and billing.

‍

What programming languages are supported?

Eden AI's REST API works with any language. Official code examples are available for Python, JavaScript, PHP, and more.

‍

Is my data safe when using Eden AI?

Yes. Eden AI does not store or reuse your data, and you can filter to use only GDPR-compliant providers for full data protection compliance.

Similar articles

A letter marked ZDR passes through a chain of sorting stations, where a hidden figure copies it at one station while a canary on the wire sounds an alert.
Tutorial
Generative AI
OpenRouter's ZDR Incident: What Failed and How to Check
11/23/2026
·
Written byClément Moreau
An operator steers a thread of prompt blocks toward the GPU tower whose cache blocks are still lit, away from a tower where they have faded.
Tutorial
Generative AI
Should You Switch to SageMaker KV Cache-Aware Routing?
11/17/2026
·
Written byClément Moreau
Fireworks AI and Notion logos connected by a simple data path, representing third-party AI data exposure.
Tutorial
Generative AI
Fireworks AI Breach: How to Limit Third-Party AI Data Exposure
11/12/2026
·
Written byClément Moreau
let’s start

Start building with Eden AI

A single interface to integrate the best AI technologies into your products.