Embedding
Request Body
python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="http://server.opendatasky.com/v1/api/open-ai/ds"
)
client.embeddings.create(
model="text-embedding-v3",
input="The food was delicious and the waiter...",
encoding_format="float"
)
curl
curl http://server.opendatasky.com/v1/api/open-ai/ds/embeddings \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "The food was delicious and the waiter...",
"model": "text-embedding-v3",
"encoding_format": "float"
}'
node.js
import OpenAI from "openai";
const openai = new OpenAI(
api_key="YOUR_API_KEY",
base_url="http://server.opendatasky.com/v1/api/open-ai/ds"
);
async function main() {
const embedding = await openai.embeddings.create({
model: "text-embedding-v3",
input: "The quick brown fox jumped over the lazy dog",
encoding_format: "float",
});
console.log(embedding);
}
main();
Response
{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [
0.0023064255,
-0.009327292,
....
-0.0028842222,
],
"index": 0
}
],
"model": "text-embedding-v3",
"usage": {
"prompt_tokens": 8,
"total_tokens": 8
}
}