Tutorial
Text Processing
8 min reading

How to Extract Custom Entities in Text Content with JavaScript?

Summarize this article with:

summary
  • Custom Named Entity Recognition (NER) API is a tool that enables users to build and deploy their own models for recognizing and extracting named entities from text such as names of people, organizations,...
  • A Custom NER API enables users to train models with their own labeled data, specifying the exact entities they want to extract.
  • After training, developers can easily integrate the custom NER capabilities into their applications through the API.
  • Developers can Extract Custom Entities in Text Content with JavaScript? using a REST API that accepts standard inputs and returns structured JSON responses.
  • The integration works with Python, JavaScript, PHP, and any HTTP-capable language with minimal setup.

In this tutorial, you’ll learn how to use the Custom Named Entity Recognition API with Javascript in just 5 minutes. Eden AI offers a simple, developer-friendly interface to extract specific entities from text effortlessly.

‍

What is Custom Named Entity Recognition API?

Custom Named Entity Recognition (NER) API is a tool that enables users to build and deploy their own models for recognizing and extracting named entities from text such as names of people, organizations, locations, dates, or any other custom-defined categories.

__wf_reserved_inherit

A Custom NER API enables users to train models with their own labeled data, specifying the exact entities they want to extract.

This approach offers more precise and domain-specific entity recognition tailored to specific industries or use cases.

After training, developers can easily integrate the custom NER capabilities into their applications through the API.

‍

How to Extract Custom Entities in Text Content?

Get Access to Eden AI API

1. Sign up: Create an account on Eden AI and obtain your API key. This key will give you access to a wide range of AI services including Custom Named Entity Recognition.

__wf_reserved_inherit

2. Access Text Processing: Once you're logged in, navigate to the Text section of the Eden AI platform to explore the available tools and features.

3. Choose Custom Named Entity Recognition: Click on the Custom Named Entity Recognition feature.

‍

Implementing the Feature in JavaScript

Install JavaScript Requests Module

For this tutorial, we’ll use axios, a promise-based HTTP client for Node.js. To install it, run:



npm install axios

Prepare the Code

Custom entity extraction now runs through an LLM on Eden AI’s OpenAI-compatible endpoint. Here’s a working example in JavaScript:



const axios = require("axios").default;

const text = "I was born in Lyon in February 1996";
const entities = ["person", "location", "date"]; // Define the custom entities you want to extract

const options = {
method: "POST",
url: "https://api.edenai.run/v3/chat/completions",
headers: {
authorization: "Bearer <your_api_key>", // Replace with your actual API key
},
data: {
model: "openai/gpt-4o-mini", // You can also test other models available on Eden AI
messages: [
{ role: "system", content: `Extract the entities of these categories from the text: ${entities.join(", ")}.` },
{ role: "user", content: text },
],
// The JSON schema only allows the categories you defined
response_format: {
type: "json_schema",
json_schema: {
name: "custom_ner",
strict: true,
schema: {
type: "object",
properties: {
entities: {
type: "array",
items: {
type: "object",
properties: {
entity: { type: "string" },
category: { type: "string", enum: entities },
},
required: ["entity", "category"],
additionalProperties: false,
},
},
},
required: ["entities"],
additionalProperties: false,
},
},
},
},
};

axios
.request(options)
.then((response) => {
console.log(JSON.parse(response.data.choices[0].message.content));
})
.catch((error) => {
console.error(error);
});

Code Explanation

  • url: Eden AI’s OpenAI-compatible chat endpoint, https://api.edenai.run/v3/chat/completions.
  • model: The provider and model that extract the entities, in the provider/model format (e.g., openai/gpt-4o-mini).
  • authorization: The Bearer token (your API key).
  • text: The input string to analyze.
  • entities: A list of custom entities you want the model to detect (e.g., person, location, date).
  • response_format: A JSON schema that makes the model return the entities in a fixed structure, using only your categories.

‍

Example Output

A sample response might look like this:



{
"entities": [
{ "entity": "Lyon", "category": "location" },
{ "entity": "February 1996", "category": "date" }
]
}

Explanation:

  • entities: An array of extracted items, each with:
    • entity: The detected string.
    • category: The category label you defined (e.g., "date").

The full API response also includes cost (the cost of the request, in USD) and provider.

‍

Why Eden AI is the Best Tool for Custom Named Entity Recognition

__wf_reserved_inherit

Multi-provider Access‍

Test and use top AI models (like OpenAI, Google, Amazon, etc.) from a single API.

Customizability‍

Easily define the entities that matter to your domain.

Cost-Efficient‍

Pay-as-you-go pricing and cost-optimization by comparing multiple provider results.

Developer-Friendly‍

Clean JSON responses and easy integration with most languages, including JavaScript.

‍

Conclusion

With just a few lines of JavaScript and Eden AI’s powerful API, you can implement a Custom NER system that fits your exact needs.

Whether you're working on content moderation, business automation, or intelligent search, this feature saves you time and boosts accuracy.

Eden AI simplifies complex AI integration, letting you focus on building great user experiences.

Try it today and unlock the full potential of your text data with custom entity extraction!

FAQ — Extract Custom Entities in Text

You need an API key from your chosen AI provider. Eden AI lets you access multiple providers with a single key, removing the need for separate vendor accounts.
Any language that supports HTTP requests works — Python, JavaScript, PHP, Ruby, Go, and more. Ready-to-use code snippets are available for the most common languages.
Most developers complete a basic integration in under an hour using standardized API endpoints and ready-to-use code examples.
Implement exponential backoff for rate limit errors and use try-catch blocks for network failures. Eden AI's built-in fallback routing automatically redirects requests if a provider is unavailable.
Eden AI supports GDPR-compliant provider filtering and does not store or reuse your data, ensuring compliance with European privacy regulations.

Similar articles

Tutorial
Generative AI
LLM API Security: How to Detect Abnormal Credential Usage
10/9/2026
·
Written byClément Moreau
Tutorial
Generative AI
How to Build an Open Source Software Factory
9/29/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.