Embeddings
Generate vector embeddings for text search, clustering, and similarity.
Endpoint
POST /v1/embeddingsRequest
{
"model": "model-id",
"input": "The quick brown fox jumps over the lazy dog.",
"encoding_format": "float"
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Embedding model ID |
input | string/array | Yes | Text(s) to embed |
encoding_format | string | No | float (default) or base64 |
dimensions | integer | No | Output dimensions (if model supports) |
Response
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0023, -0.0091, 0.0152, ...]
}
],
"model": "model-id",
"usage": {
"prompt_tokens": 10,
"total_tokens": 10
}
}Batch Embeddings
Embed multiple texts in a single request:
response = client.embeddings.create(
model="model-id",
input=[
"First document text",
"Second document text",
"Third document text"
]
)
for item in response.data:
print(f"Index {item.index}: {len(item.embedding)} dimensions")Available Models
Use the Models API to query available embedding models:
curl https://api.yuhuanstudio.com/v1/models?type=embedding \
-H "Authorization: Bearer YOUR_API_KEY"Embedding models and dimensions vary by provider. Check the dashboard for current availability.
Use Cases
- Semantic search — Find documents similar to a query
- Clustering — Group similar texts together
- Classification — Categorize text by comparing embeddings
- RAG — Retrieval-Augmented Generation pipelines
How is this guide?