嵌入向量
嵌入向量是指一种向量表示法,可以对给定的输入进行向量化处理,以便机器学习模型和算法更容易地使用。 相关指南:Embeddings
创建嵌入向量
POST https://api.openai.com/v1/embeddings请求体
请求示例
curl https://api.openai.com/v1/embeddings \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "The food was delicious and the waiter...",
"model": "text-embedding-ada-002"
}import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Embedding.create(
model="text-embedding-ada-002",
input="The food was delicious and the waiter..."
)const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createEmbedding({
model: "text-embedding-ada-002",
input: "The food was delicious and the waiter...",
});
{
"model": "text-embedding-ada-002",
"input": "The food was delicious and the waiter..."
}
最后更新于