DocsAPI reference
Embeddings
POST /v1/embeddings — multilingual text embeddings from Qwen3-Embedding-8B on your own GPU, for search, RAG and clustering.
HTTP
POST https://osarai.xyz/v1/embeddingsTurns text into vectors for semantic search, retrieval-augmented generation and clustering. Deploy Qwen3-Embedding-8B (qwen3-embedding-8b, 4096 dimensions, 32K tokens per input) to use it.
Request
Terminal
curl "https://osarai.xyz/v1/embeddings" \
-H "Authorization: Bearer $OSARAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-embedding-8b",
"input": ["A cat sleeps on the sofa.", "A kitten naps on the couch."]
}'Python
from openai import OpenAI
import os
client = OpenAI(base_url="https://osarai.xyz/v1", api_key=os.environ["OSARAI_API_KEY"])
result = client.embeddings.create(
model="qwen3-embedding-8b",
input=["A cat sleeps on the sofa.", "A kitten naps on the couch."],
)
vectors = [d.embedding for d in result.data]
print(len(vectors), len(vectors[0])) # 2 4096TypeScript
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://osarai.xyz/v1", apiKey: process.env.OSARAI_API_KEY });
const result = await client.embeddings.create({
model: "qwen3-embedding-8b",
input: ["A cat sleeps on the sofa.", "A kitten naps on the couch."],
});
console.log(result.data.length, result.data[0].embedding.length);| Field | Notes |
|---|---|
model | qwen3-embedding-8b |
input | A string or a list of strings |
encoding_format | float (default) or base64 |
Request bodies can be up to 8 MiB; send large corpora in batches.
Response
JSON
{
"object": "list",
"model": "qwen3-embedding-8b",
"data": [
{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456, 0.0789] },
{ "object": "embedding", "index": 1, "embedding": [0.0119, -0.0441, 0.0802] }
],
"usage": { "prompt_tokens": 18, "total_tokens": 18 }
}Vectors are shortened here; each has 4096 numbers. Compare them with cosine similarity.
Tips
- For search, Qwen3-Embedding works best when the query carries a one-line task, for example
Instruct: Given a question, find passages that answer it\nQuery: how do I reset my password?. Embed the documents as they are. - Run the embedding model next to a chat model: with two instances, each request goes to the one that serves its
model. - To order search hits by relevance, add a reranker (Rerank and score).