OpenAI Guide OpenAI API ReferenceOpenAI's text embeddings are used to measure the relevance between text strings. Embeddings are typically used for:
Search (where results are ranked based on relevance to the query string)
Clustering (where text strings are grouped by similarity)
Recommendations (suggesting items related to relevant text strings)
Anomaly Detection(identifying outliers that are different or less relevant)
Diversity Measurement (analyzing the distribution of similarities)
Classification (categorizing text strings by the most similar label)
An embedding is a list of floating-point numbers (a vector). The distance between two vectors measures their relevance. A small distance indicates high relevance, while a large distance indicates low relevance.Price List:https://302.ai/pricing_api/
Request
Authorization
Provide your bearer token in the
Authorization
header when making requests to protected resources.
Example:
Authorization: Bearer ********************
Header Params
Authorization
string
optional
API Key from 302.AI backend
Example:
Bearer {{YOUR_API_KEY}}
Body Params application/json
model
string
required
ID of the model to be used. You can use the List models API to view all available models, or refer to our model overview to understand their descriptions.
input
string
required
Enter text to get the embedding, which can be encoded as a string or an array of tokens. To get embeddings for multiple inputs in a single request, pass an array of strings or tokens. Each input must not exceed 8192 tokens.
Example
{"model":"text-embedding-ada-002","input":"The food was delicious and the waiter..."}
Request samples
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl--location--request POST 'https://api.302.ai/v1/embeddings' \
--header'Authorization: Bearer sk-jls4AaVBGoe1GwZD64qZA1qyKTN1MPHa4NmvH1cT68z7K1Zz' \
--header'Content-Type: application/json' \
--data-raw'{
"model": "text-embedding-ada-002",
"input": "The food was delicious and the waiter..."
}'
Responses
🟢200Create embeddings
application/json
Body
object
string
required
data
array [object {3}]
required
object
string
optional
embedding
array[number]
optional
index
integer
optional
model
string
required
usage
object
required
prompt_tokens
integer
required
total_tokens
integer
required
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}}