AI Platform

AxilJS Embeddings for Vector Search and AI Applications

Generate vector embeddings with AxilJS for semantic search, RAG pipelines, similarity matching, and other TypeScript and Node.js AI applications.

2 min readDocumentationEdit this page

Vector Embeddings

AxilJS provides an embedding API for converting text into vector embeddings that can be used by TypeScript and Node.js AI applications.

Vector embeddings represent text as numerical vectors, making them useful for semantic search, similarity matching, retrieval-augmented generation (RAG), and other AI workflows.

Generate an Embedding

Use ai.embed() to generate an embedding for a single text input.

typescript
const result = await ai.embed({
  input: 'What is JavaScript?'
})
 
result.embeddings[0] // number[]

The returned embeddings array contains the generated vector representation. For a single input, the first embedding can be accessed with result.embeddings[0].

Each embedding is represented as a number[].

Generate Multiple Embeddings

AxilJS also supports multiple text inputs in a single embedding request.

typescript
const result = await ai.embed({
  input: [
    'text one',
    'text two'
  ]
})

When multiple inputs are provided, AxilJS generates an embedding for each text input.

This is useful when processing documents, batches of text, or multiple records that need to be converted into vectors.

Embeddings in AI Applications

Embeddings are commonly used as a building block for applications that need to compare the semantic meaning of text.

Typical use cases include:

  • Semantic search
  • Retrieval-augmented generation (RAG)
  • Document retrieval
  • Similarity matching
  • Knowledge-base search
  • Recommendation systems
  • Text clustering
  • Duplicate or related-content detection

A typical RAG workflow can use embeddings to convert document chunks into vectors and later retrieve the most semantically relevant chunks for an AI model.

text
Text
  │
  ▼
AxilJS Embedding API
  │
  ▼
Vector Embedding
  │
  ▼
Vector Storage
  │
  ▼
Similarity Search
  │
  ▼
Relevant Context

Single vs Multiple Inputs

Use a single string when you need to generate one embedding:

typescript
const result = await ai.embed({
  input: 'What is JavaScript?'
})

Use an array when you need embeddings for multiple pieces of text:

typescript
const result = await ai.embed({
  input: [
    'text one',
    'text two'
  ]
})

The multiple-input form is particularly useful for batch-oriented document processing and RAG ingestion pipelines.

Help improve the documentation

AxilJS is open source and documentation improvements are welcome.

AxilJS DocumentationMIT License · Built by SyntaxilitY