Example
Batch embeddings
Pass an array asinput to embed multiple texts in a single request:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Generate embedding vectors from text using the OpenAI-compatible embeddings API.
POST https://api.deepinfra.com/v1/openai/embeddings
import os
from openai import OpenAI
openai = OpenAI(
api_key=os.environ["DEEPINFRA_API_KEY"],
base_url="https://api.deepinfra.com/v1/openai",
)
input_text = "The food was delicious and the waiter..."
# Or a list: ["hello", "world"]
embeddings = openai.embeddings.create(
model="Qwen/Qwen3-Embedding-8B",
input=input_text,
encoding_format="float"
)
print(embeddings.data[0].embedding)
print(embeddings.usage.prompt_tokens)
import OpenAI from "openai";
const openai = new OpenAI({
baseURL: "https://api.deepinfra.com/v1/openai",
apiKey: process.env.DEEPINFRA_API_KEY,
});
const input = "The quick brown fox jumped over the lazy dog";
// Or an array: ["hello", "world"]
const embedding = await openai.embeddings.create({
model: "Qwen/Qwen3-Embedding-8B",
input: input,
encoding_format: "float",
});
console.log(embedding.data[0].embedding);
console.log(embedding.usage.prompt_tokens);
curl "https://api.deepinfra.com/v1/openai/embeddings" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DEEPINFRA_API_KEY" \
-d '{
"input": "The food was delicious and the waiter...",
"model": "Qwen/Qwen3-Embedding-8B",
"encoding_format": "float"
}'
input to embed multiple texts in a single request:
embeddings = openai.embeddings.create(
model="Qwen/Qwen3-Embedding-8B",
input=["Hello", "World", "How are you?"],
encoding_format="float"
)
for i, item in enumerate(embeddings.data):
print(f"Text {i}: {item.embedding[:5]}...") # First 5 dims
| Parameter | Notes |
|---|---|
model | Embedding model name |
input | String or array of strings |
encoding_format | float only |