Skip to main content

Request

curl --location 'https://api.znapai.com/v1/embeddings' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $ZnapAI_API_KEY' \
--data '{
    "input": "The food was delicious and the waiter...",
    "model": "text-embedding-ada-002",
    "encoding_format": "float"
  }'

Response

{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "embedding": [
        0.0023064255,
        -0.009327292,
        0.001287413,
        -0.0028842222
      ],
      "index": 0
    }
  ],
  "model": "text-embedding-ada-002",
  "usage": {
    "prompt_tokens": 8,
    "total_tokens": 8
  }
}

Parameters

input
string | array
required
Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays.The input must not exceed the max input tokens for the model (8192 tokens for all embedding models), cannot be an empty string, and any array must be 2048 dimensions or less. In addition to the per-input token limit, all embedding models enforce a maximum of 300,000 tokens summed across all inputs in a single request.Supported formats:
  • string: The string that will be turned into an embedding.
  • array of strings: The array of strings that will be turned into an embedding.
  • array of numbers: The array of integers (tokens) that will be turned into an embedding.
  • array of arrays of numbers: The array of arrays containing integers (tokens) that will be turned into an embedding.
model
string
required
ID of the model to use.Supported models:
  • text-embedding-ada-002
  • text-embedding-3-small
  • text-embedding-3-large
dimensions
integer
The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3 and later models.
encoding_format
string
default:"float"
The format to return the embeddings in.Options:
  • float
  • base64
user
string
A unique identifier representing your end-user, which can help monitor and detect abuse.

Returns

The response is a CreateEmbeddingResponse object containing the generated embeddings and usage statistics.
object
string
The object type, which is always "list".
data
array
The list of embeddings generated by the model.
model
string
The name of the model used to generate the embedding.
usage
object
The usage information for the request.