Embeddings with /v1/embeddings
This page explains how to use the OpenAI-compatible /v1/embeddings route exposed by the Clovis gateway to generate vector representations (embeddings) from textual content.
Embeddings are used for use cases such as semantic search, similarity, clustering, and vector indexing for a RAG pipeline (retrieval).
Endpoint
Embeddings
POST
/v1/embeddingsFull URL (Clovis Gateway)
Clovis Gateway
{
POST https://llm-gateway.clovis-ai.fr/v1/embeddings
Authorization: Bearer <CLOVIS_API_KEY>
Content-Type: application/json
}
Structure
Each request must include a JSON similar to:
Request body
{
"model": "ClovisEmbedding",
"input": "Explain what an embedding is.",
"encoding_format": "float"
}
Multiple input (batch)
{
"model": "ClovisEmbeddings",
"input": [
"Document 1: text to vectorize",
"Document 2: text to vectorize",
"Document 3: text to vectorize"
],
"encoding_format": "float"
}
Field description
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | ✔️ | Embedding model name |
| input | stringarray | ✔️ | Text (or list of texts) to convert into embeddings |
| encoding_format | string | ✔️ | Embedding output format (e.g. float, base64) |
| user | string | User identifier (useful for traceability / logs) |
API Response
Main response object
Response example
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0123, -0.9821, 0.4421, 0.1182]
}
],
"model": "ClovisEmbeddings",
"usage": {
"prompt_tokens": 12,
"total_tokens": 12
}
}
Details of the data field
| Field | Type | Description |
|---|---|---|
| object | string | Returned object type ("embedding") |
| index | int | Index corresponding to the input provided in input |
| embedding | array | Numerical vector (dimension depends on the model) |
Info
If input contains multiple texts, data will contain multiple embedding objects, each with a corresponding index.
Details of the usage field
| Field | Type | Description |
|---|---|---|
| prompt_tokens | int | Number of tokens used for the input |
| total_tokens | int | Total billed (no generation, so no completion_tokens) |
Usage examples
- cURL
- Javascript
Request
curl https://llm-gateway.clovis-ai.fr/v1/embeddings -H "Content-Type: application/json" -H "Authorization: Bearer sk-xxxxxxxx" -d '{
"model": "ClovisEmbeddings",
"input": "RAG combines vector search and text generation.",
"encoding_format": "float"
}'
Request
curl https://llm-gateway.clovis-ai.fr/v1/embeddings -H "Content-Type: application/json" -H "Authorization: Bearer sk-xxxxxxxx" -d '{
"model": "ClovisEmbeddings",
"input": [
"Chunk 1: introduction...",
"Chunk 2: details...",
"Chunk 3: conclusion..."
],
"encoding_format": "float"
}'
require('dotenv').config();
const axios = require('axios');
async function testEmbeddings() {
try {
const payload = {
model: ClovisEmbeddings,
input: 'Basile',
encoding_format: 'float'
};
const res = await axios.post('https://llm-gateway.clovis-ai.fr/v1/embeddings', payload, {
headers: {
Authorization: 'Bearer sk-xxxxxxxx',
'Content-Type': 'application/json',
},
});
return true;
} catch (err) {
console.error('/embeddings failed:', err.response?.status, err.message);
return false;
}
}
module.exports = testEmbeddings;