Developers
Documentation
A technical guide to integrating leading AI models through Oblion's unified API.
Embeddings Guide
Embeddings turn text into a vector of numbers that capture its meaning — useful for semantic search, clustering, recommendations, and RAG (retrieval-augmented generation). Available models: text-embedding-3-large, text-embedding-3-small, text-embedding-ada-002.
POST https://api.oblion.io/v1/embeddings
Basic request
curl https://api.oblion.io/v1/embeddings \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
"model": "text-embedding-3-small",
"input": "The food was delicious and the service was excellent."
}'
from openai import OpenAI
client = OpenAI(base_url="https://api.oblion.io/v1", api_key="YOUR_API_KEY")
response = client.embeddings.create(
model="text-embedding-3-small",
input="The food was delicious and the service was excellent.",
)
vector = response.data[0].embedding
print(len(vector), vector[:5])
import OpenAI from "openai";
const openai = new OpenAI({ baseURL: "https://api.oblion.io/v1", apiKey: "YOUR_API_KEY" });
const response = await openai.embeddings.create({
model: "text-embedding-3-small",
input: "The food was delicious and the service was excellent.",
});
console.log(response.data[0].embedding.length);
Embedding multiple texts at once
Pass an array to input to batch multiple strings in a single request — the response data array preserves the same order via each item's index:
response = client.embeddings.create(
model="text-embedding-3-small",
input=["cat", "dog", "airplane"],
)
for item in response.data:
print(item.index, item.embedding[:3])
Comparing similarity
Use cosine similarity to measure how close two embeddings are — closer to 1 means more similar:
import numpy as np
def cosine_similarity(a, b):
a, b = np.array(a), np.array(b)
return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))
response = client.embeddings.create(
model="text-embedding-3-small",
input=["The cat sat on the mat.", "A feline rested on the rug.", "Quarterly revenue exceeded expectations."],
)
vectors = [d.embedding for d in response.data]
print(cosine_similarity(vectors[0], vectors[1])) # similar sentences -> higher score
print(cosine_similarity(vectors[0], vectors[2])) # unrelated sentence -> lower score
Choosing a model
| Model | Notes |
|---|---|
text-embedding-3-small | Cheapest, fastest — good default for most search/RAG use cases |
text-embedding-3-large | Higher accuracy, larger vector size, higher cost |
text-embedding-ada-002 | Legacy model, kept for backward compatibility |