Embeddings(Youdao)
POST
/v1/embeddingsText 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:0.02 PTC / 1M tokens
请求参数
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": "bce-embedding-base_v1",
"input": "The food was delicious and the waiter..."
}
示例代码
Responses
Create embeddings(200)
HTTP 状态码: 200
内容格式: JSONapplication/json
Data Schema
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
ExampleCreate embeddings
{
"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 modified: 2 个月前