Embeddings convert text into dense numeric vectors. You can use them to build semantic search, clustering, classification, and retrieval-augmented generation (RAG) pipelines — all billed in DA like every other resource on OpenDunes.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://opendunes.com/api/v1",
api_key=os.environ["OPENDUNES_API_KEY"],
)
resp = client.embeddings.create(
model="openai/text-embedding-3-large",
input="مرحبا — the OpenDunes API is OpenAI-compatible.",
)
vector = resp.data[0].embedding
print(f"Dimensions: {len(vector)}")
Pass a list of strings to embed multiple inputs in one call:
resp = client.embeddings.create(
model="openai/text-embedding-3-large",
input=[
"What are the best models for Arabic text?",
"How do I top up my DA balance?",
"Show me vision-capable models.",
],
)
for i, item in enumerate(resp.data):
print(f"[{i}] {len(item.embedding)}-dim vector")
- The
encoding_format parameter accepts float (default) or base64.
- Embeddings are billed per input token at the model's DA rate — no output tokens.
- Browse embedding models in the catalog by filtering for
modality=text and checking the embedding capability flag.