Skip to main content

Documentation Index

Fetch the complete documentation index at: https://doc.hitopen.com/llms.txt

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

The embeddings endpoint converts text into a numerical vector that captures its semantic meaning. You can use these vectors for tasks such as semantic search, document clustering, similarity comparison, and classification.

Endpoint

POST https://YOUR_NEWAPI_BASE_URL/v1/embeddings

Request parameters

model
string
required
The embedding model ID, for example text-embedding-3-small, text-embedding-3-large, or text-embedding-ada-002.
input
string | string[]
required
The text to embed. Pass a single string or an array of strings. Each input must not exceed the model’s token limit. To embed large documents, split them into chunks first.
encoding_format
string
default:"\"float\""
Format of the returned vectors. "float" returns an array of floating-point numbers. "base64" returns a base64-encoded binary string, which is more compact for network transfer.
dimensions
integer
The number of dimensions in the output embedding. Only supported by certain models (for example, text-embedding-3-small and text-embedding-3-large). Reduces the vector size while preserving most of the semantic information.

Response fields

object
string
Always "list".
data
object[]
model
string
The model used to generate the embeddings.
usage
object

Examples

curl -X POST "https://YOUR_NEWAPI_BASE_URL/v1/embeddings" \
  -H "Authorization: Bearer sk-your-token" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-small",
    "input": "The food was delicious and the service was excellent."
  }'

Batch embedding example

Pass an array to embed multiple texts in a single request:
Python (batch)
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-token",
    base_url="https://YOUR_NEWAPI_BASE_URL/v1",
)

texts = [
    "How do I reset my password?",
    "What payment methods do you accept?",
    "How long does shipping take?",
]

response = client.embeddings.create(
    model="text-embedding-3-small",
    input=texts,
)

for item in response.data:
    print(f"Text {item.index}: {len(item.embedding)}-dimensional vector")

Example response

{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.0023064255, -0.009327292, 0.015797141]
    }
  ],
  "model": "text-embedding-3-small",
  "usage": {
    "prompt_tokens": 10,
    "total_tokens": 10
  }
}