Skip to content

Embeddings (OpenAI Format)

Official Documentation

OpenAI Embeddings

📝 Introduction

Get a vector representation of a given input that can be easily consumed by machine learning models — for semantic search, clustering, recommendations, classification and RAG.

📮 Endpoint

POST /v1/embeddings

Authentication

Authorization: Bearer $WS_API_KEY

💡 Request Examples

Single Text ✅

curl http://baseurl/v1/embeddings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $WS_API_KEY" \
  -d '{
    "model": "text-embedding-3-small",
    "input": "The food was delicious and the waiter was very friendly."
  }'

Response Example:

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

Batch Input ✅

curl http://baseurl/v1/embeddings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $WS_API_KEY" \
  -d '{
    "model": "text-embedding-3-large",
    "input": [
      "First document text",
      "Second document text",
      "Third document text"
    ],
    "dimensions": 1024
  }'

📋 Request Body Parameters

Parameter Type Required Description
model string Yes text-embedding-3-large, text-embedding-3-small or text-embedding-ada-002
input string / array Yes Text (or array of texts) to embed. Max 8192 tokens per input
dimensions integer No Number of output dimensions (only text-embedding-3-* models). Allows shortening vectors
encoding_format string No float (default) or base64
user string No End-user identifier

📥 Response Fields

Field Type Description
object string Always list
data array One embedding object per input, each with index and embedding (vector of floats)
model string Model used
usage object prompt_tokens, total_tokens

Available Models

Model ID Max Dimensions
text-embedding-3-large 3072
text-embedding-3-small 1536
text-embedding-ada-002 1536 (fixed)