Skip to main content
POST
/
embeddings
Create Embeddings
curl --request POST \
  --url https://api.electronhub.ai/v1/embeddings \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "text-embedding-ada-002",
  "input": "<string>",
  "encoding_format": "float",
  "dimensions": 123
}
'
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "embedding": [
        123
      ],
      "index": 123
    }
  ],
  "model": "<string>",
  "usage": {
    "prompt_tokens": 123,
    "total_tokens": 123
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.electronhub.ai/llms.txt

Use this file to discover all available pages before exploring further.

The Embeddings API enables you to generate numerical representations of text that can be used for semantic search, clustering, and other machine learning tasks.

Create Embeddings

POST /embeddings Generate embeddings for input text.

Request Body

input
string | array
required
Input text to embed, encoded as a string or array of strings
model
string
required
The model to use for generating embeddings (e.g., “text-embedding-ada-002”, “text-embedding-3-small”, “text-embedding-3-large”)
encoding_format
string
The format to return the embeddings in (“float” or “base64”)
dimensions
integer
The number of dimensions the resulting output embeddings should have (only supported in text-embedding-3 models)
user
string
A unique identifier representing your end-user

Response

Returns an embedding object containing the vector embeddings.

Example

const response = await fetch('https://api.electronhub.ai/v1/embeddings', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    input: 'The quick brown fox jumps over the lazy dog',
    model: 'text-embedding-3-small'
  })
});

const data = await response.json();
console.log(data);

Multiple Inputs

You can embed multiple text inputs in a single request:
{
  "input": [
    "Text to embed 1",
    "Text to embed 2",
    "Text to embed 3"
  ],
  "model": "text-embedding-3-small"
}

Use Cases

  • Semantic Search: Find documents similar to a query
  • Clustering: Group similar texts together
  • Classification: Train classifiers on embedding features
  • Recommendation: Recommend items based on similarity
  • Anomaly Detection: Identify outliers in text data

Best Practices

  • Use text-embedding-3-small for most use cases (good balance of performance and cost)
  • Use text-embedding-3-large for maximum performance
  • Batch multiple inputs in a single request for efficiency
  • Store embeddings for reuse rather than regenerating them

Authorizations

Authorization
string
header
required

Enter your API key (starts with 'ek-')

Body

application/json
model
string
required
Example:

"text-embedding-ada-002"

input
required

Input text to embed

encoding_format
enum<string>
default:float
Available options:
float,
base64
dimensions
integer

Number of dimensions for the embedding

Response

200 - application/json

Success

object
string
required
Example:

"list"

data
object[]
required
model
string
required
usage
object
required