EMBEDDINGS

Embeddings

Create embeddings

POST/v1/embeddings

Authorization

Authorizationstringheaderrequired

Bearer token — your API key. Example: Bearer sk-...

Request body

application/json
modelstringrequired

ID of the model to use.

inputstring | string[]required

Input text to embed. to embed multiple inputs in a single request, pass an array of strings. The input must not exceed the max input tokens for the model. The string that will be turned into an embedding.

Response

object"list"required
dataobject[]required
modelstringrequired
usageobjectrequired

Request

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "your-scx-api-key",
  baseURL: "https://api.scx.ai/v1",
});

const response = await client.embeddings.create({
  model: "E5-Mistral-7B-Instruct",
  input: "The quick brown fox jumps over the lazy dog",
});

console.log(response);

Response

{
  "model": "E5-Mistral-7B-Instruct",
  "object": "list",
  "data": [
    {
      "index": 0,
      "object": "embedding",
      "embedding": [
        0.2633975,
        0.13856208,
        "...",
        0.04331574
      ]
    },
    {
      "index": 1,
      "object": "embedding",
      "embedding": [
        -0.14496337,
        0.21044481,
        "...",
        -0.16187587
      ]
    }
  ]
}