Generate vector embeddings for text using the OpenDunes embeddings endpoint.
The embeddings endpoint converts text into dense vector representations you can use for semantic search, clustering, classification, and retrieval-augmented generation (RAG). It is OpenAI-compatible, so the openai SDK's embeddings.create call works without modification.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://opendunes.com/v1",
apiKey: process.env.OPENDUNES_API_KEY,
});
const resp = await client.embeddings.create({
model: "openai/text-embedding-3-large",
input: "خوارزمي pioneered algebra in the 9th century.",
});
const vector = resp.data[0].embedding; // float32[], e.g. 3072-dimensionalThe response follows the OpenAI embeddings schema:
{
"object": "list",
"data": [
{ "object": "embedding", "index": 0, "embedding": [0.002, -0.018, ...] }
],
"model": "openai/text-embedding-3-large",
"usage": { "prompt_tokens": 12, "total_tokens": 12 }
}