Embeddings Integration
Embeddings are used for vector retrieval, RAG, similarity calculation, clustering, and recommendations. Chat models and Embeddings models are typically not the same; select Model IDs explicitly marked as supporting Embeddings in the console.
Interface Information
| Configuration | Value |
|---|---|
| Endpoint | https://api.corerouter.cloud/v1/embeddings |
| Header | Authorization: Bearer sk-... |
| Required Fields | model, input |
| Input Format | String or string array |
curl Example
bash
export COREROUTER_API_KEY="sk-xxxxxxxxxxxxxxxx"
curl https://api.corerouter.cloud/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $COREROUTER_API_KEY" \
-d '{
"model": "embedding-model-id",
"input": [
"CoreRouter is a unified AI API integration service.",
"Embeddings can be used for search and RAG."
]
}'Python Example
python
from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ["COREROUTER_API_KEY"],
base_url="https://api.corerouter.cloud/v1",
)
result = client.embeddings.create(
model="embedding-model-id",
input=[
"CoreRouter is a unified AI API integration service.",
"Embeddings can be used for search and RAG.",
],
)
print(len(result.data[0].embedding))Node.js Example
typescript
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.COREROUTER_API_KEY,
baseURL: "https://api.corerouter.cloud/v1",
});
const result = await client.embeddings.create({
model: "embedding-model-id",
input: [
"CoreRouter is a unified AI API integration service.",
"Embeddings can be used for search and RAG.",
],
});
console.log(result.data[0].embedding.length);RAG Usage Recommendations
- Use the same Embeddings model for document indexing and querying.
- Save vector dimensions to avoid dimension mismatch after switching models.
- Split long documents first then vectorize; adjust split size based on business semantics.
- Model status, context, and billing information in console takes priority over model IDs in examples.
Common Issues
- Inconsistent returned dimensions: Check if different Embeddings models were mixed.
- Poor query results: Check chunking strategy, recall count, reranking logic, and original text quality.
- Returns
model not found: Use Model IDs from console that support Embeddings.
