API ResourcesEmbeddings

Embeddings

The Embeddings API creates a vector representation for given text input. This vector captures the deep semantic information of the text and can be easily consumed by machine learning models and algorithms, widely used in search, clustering, recommendation, anomaly detection and other tasks.


POST/beta/v1/embeddings

Create Embedding

Creates an embedding vector representing the input text.

Request Headers

  • Name
    Content-Type
    Type
    string
    Required
    Required
    Description

    The value must be application/json.

  • Name
    Authorization
    Type
    string
    Optional
    Optional
    Description

    Optional authentication method. The credential for API authentication, see Authentication for details.

  • Name
    x-api-key
    Type
    string
    Optional
    Optional
    Description

    Optional authentication method. Pass your API key directly. Note: Do not use Authorization and x-api-key at the same time.

Request Body

  • Name
    input
    Type
    string | array
    Required
    Required
    Description

    The input text to embed, encoded as a string or an array of tokens. To embed multiple inputs in a single request, pass an array of strings or an array of token arrays. The input must not exceed the model's maximum input tokens (8192 tokens for all embedding models), cannot be an empty string, and any array dimension must not exceed 2048. See example Python code for counting tokens. In addition to the per-input token limit, all embedding models enforce a total token limit of 300,000 tokens across all inputs in a single request.

  • Name
    model
    Type
    string
    Required
    Required
    Description

    The model ID used to generate the response. For example text-embedding-3-large, etc. See the Model List to choose the model that best suits your needs.

  • Name
    dimensions
    Type
    integer
    Optional
    Optional
    Description

    The number of dimensions the output embedding should have. Only supported in text-embedding-3 and later models.

    Reducing dimensions can lower vector storage costs, speed up similarity searches, and reduce memory footprint, but may slightly affect embedding accuracy. This is an important trade-off between performance and cost.

  • Name
    encoding_format
    Type
    string
    Optional
    Optional
    Description

    The format of the returned embedding vector. Can be float or base64. Defaults to float.

  • Name
    user
    Type
    string
    Optional
    Optional
    Description

    A unique identifier representing your end user.

Response Body

  • Name
    object
    Type
    string
    Required
    Required
    Description

    The type of the response object, always list for this endpoint.

  • Name
    data
    Type
    array
    Required
    Required
    Description

    An array containing embedding objects for each input text.

  • Name
    model
    Type
    string
    Required
    Required
    Description

    The model ID used to generate this embedding, for example text-embedding-3-small.

  • Name
    usage
    Type
    object
    Required
    Required
    Description

    An object containing token usage information for this API call.

Request

POST
/beta/v1/embeddings
curl https://api.easytransnote.com/beta/v1/embeddings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $YOUR_API_KEY" \
  -d '{
    "input": "你今天过得怎么样?",
    "model": "text-embedding-3-small"
  }'

Response

{
  "object": "list",
  "data": [
      {
          "object": "embedding",
          "embedding": [
              -0.0069292834,
              -0.005336422,
              ...
              -4.5471322e-05
          ],
          "index": 0
      }
  ],
  "model": "text-embedding-3-small",
  "usage": {
      "prompt_tokens": 5,
      "total_tokens": 5
  }
}

Was this page helpful?