Embedding
Embedding & Reranker Quickstart
This quickstart walks you through generating your first embedding with Infron.
Embedding quickstart
Basic Request
To generate embeddings, send a POST request to /embeddings with your text input and chosen model:
import requests
response = requests.post(
"https://llm.onerouter.pro/v1/embeddings",
headers={
"Authorization": "Bearer <API_KEY>",
"Content-Type": "application/json",
},
json={
"model": "qwen/qwen3-embedding-0.6b",
"input": "The quick brown fox jumps over the lazy dog"
}
)
data = response.json()
embedding = data["data"][0]["embedding"]
print(f"Embedding dimension: {len(embedding)}")
print(f"Embedding: {embedding}")const response = await fetch('https://llm.onerouter.pro/v1/embeddings', {
method: 'POST',
headers: {
'Authorization': 'Bearer <API_KEY>',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'qwen/qwen3-embedding-0.6b',
input: 'The quick brown fox jumps over the lazy dog'
}),
});
const data = await response.json();
const embedding = data.data[0].embedding;
console.log(`Embedding dimension: ${embedding.length}`);Batch Processing
You can generate embeddings for multiple texts in a single request by passing an array of strings:
Semantic Search
Here's a complete example of building a semantic search system using embeddings:
Expected output:
Reranker quickstart
In the example below, we use the Rerank API endpoint to index the list of documents from most to least relevant to the query "What is the capital of the United States?".
Example with Texts
Request
In this example, the documents being passed in are a list of strings:
Response
Next steps
Embeddings APIRerank APILast updated