OpenAI

1. Overview

OpenAI's text embeddings measure the relevance between text strings and are commonly used in the following scenarios:

  • Search: Rank search results based on relevance to a query.

  • Clustering: Group similar text strings together.

  • Recommendations: Suggest items with related text content.

  • Anomaly Detection: Identify outlier text with low correlation to other data.

  • Diversity Measurement: Analyze the distribution of text similarity.

  • Classification: Categorize text based on the most similar labels.

Available model list:

  • text-embedding-3-small

  • text-embedding-3-large

  • text-embedding-ada-002

2. Request Description

  • Request method: POST

  • Request address: https://gateway.theturbo.ai/v1/audio/speech

3. Input Parameters

3.1 Header Parameters

Parameter Name
Type
Required
Description
Example Value

Content-Type

string

Yes

Set the request header type, which must be application/json

application/json

Accept

string

Yes

Set the response type, which is recommended to be unified as application/json

application/json

Authorization

string

Yes

API_KEY required for authentication. Format: Bearer $YOUR_API_KEY

Bearer $YOUR_API_KEY

3.2 Body Parameters (application/json)

Parameter Name
Type
Required
Description
Example (Default Value)

model

string

Yes

Model ID to use. See available models listed in the Overview for details, such as text-embedding-ada-002.

text-embedding-ada-002

input

string/array

Yes

Input content. The array dimension must not exceed 2048, and the input token count must not exceed 8192.

Hello, please tell me a joke.

encoding_format

string

No

Return vector format: supports float and base64.

float

4. Request Example

POST /v1/embeddings
Content-Type: application/json
Accept: application/json
Authorization: Bearer $YOUR_API_KEY

{
	"model": "text-embedding-ada-002",
	"input": "How is the whether today?"
}

5. Response Example

{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "embedding": [
        0.0023064255,
        -0.009327292,
        .... (1536 floats total for ada-002)
        -0.0028842222,
      ],
      "index": 0
    }
  ],
  "model": "text-embedding-ada-002",
  "usage": {
    "prompt_tokens": 8,
    "total_tokens": 8
  }
}

Last updated