Skip to main content
POST
/
v1
/
embeddings
Embeddings
curl --request POST \
  --url https://modelswitch.io/v1/embeddings \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "input": {},
  "encoding_format": "<string>"
}
'
{
  "object": "<string>",
  "data": [
    {
      "object": "<string>",
      "index": 123,
      "embedding": [
        {}
      ]
    }
  ],
  "model": "<string>",
  "usage": {
    "prompt_tokens": 123,
    "total_tokens": 123
  }
}
Convert text into a vector representation (embedding). Embeddings are used for semantic search, clustering, similarity comparisons, and retrieval-augmented generation (RAG). Authentication: Authorization: Bearer ms-YOUR_KEY

Parameters

model
string
required
Embedding model ID. See available models below. Example: text-embedding-3-small.
input
string or array
required
Text to embed. Pass a single string for one embedding, or an array of strings to generate multiple embeddings in a single request.
encoding_format
string
default:"float"
Format for the returned embedding vector. Either "float" (array of numbers) or "base64" (base64-encoded string).

Examples

Single input

curl https://modelswitch.io/v1/embeddings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ms-YOUR_KEY" \
  -d '{
    "model": "text-embedding-3-small",
    "input": "The quick brown fox",
    "encoding_format": "float"
  }'
Request body:
{
  "model": "text-embedding-3-small",
  "input": "The quick brown fox",
  "encoding_format": "float"
}
Response:
{
  "object": "list",
  "data": [{
    "object": "embedding",
    "index": 0,
    "embedding": [0.0023, -0.0091, 0.0156, "... 1536 dimensions"]
  }],
  "model": "text-embedding-3-small",
  "usage": {
    "prompt_tokens": 5,
    "total_tokens": 5
  }
}

Batch input

Pass an array of strings to embed multiple texts in one request. The response data array preserves the input order via the index field.
{
  "model": "text-embedding-3-small",
  "input": ["First sentence", "Second sentence", "Third sentence"]
}
Batching multiple texts in a single request is more efficient than making separate calls. Each string in the array is embedded independently; they do not affect each other.

Response

object
string
Always "list".
data
array
Array of embedding objects, one per input string.
model
string
The model used to generate the embeddings.
usage
object
Token counts for billing purposes.

Available models

ModelDimensionsNotes
text-embedding-3-small1536Cost-effective, recommended for most use cases
text-embedding-3-large3072Higher quality, better for precision-sensitive tasks
text-embedding-ada-0021536Legacy model
Use GET /v1/models for the full, up-to-date list of available embedding models.