Embeddings
Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
POST https://openapi.linkwo.ai/v1/embeddingsRequest Body
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | — | Embedding model ID |
input | string/array | Yes | — | Text(s) to embed |
encoding_format | string | No | float | float or base64 |
dimensions | integer | No | model default | Output dimensions (if supported) |
Example Request
curl https://openapi.linkwo.ai/v1/embeddings \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-v3",
"input": "The food was delicious and the waiter was friendly."
}'Response
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0023064255, -0.009327292, ...]
}
],
"model": "text-embedding-v3",
"usage": {
"prompt_tokens": 12,
"total_tokens": 12
}
}
```bash
## Batch Embedding
Pass an array to embed multiple inputs in a single request:
```python
from openai import OpenAI
client = OpenAI(
base_url="https://openapi.linkwo.ai/v1",
api_key="YOUR_API_KEY"
)
response = client.embeddings.create(
model="text-embedding-v3",
input=[
"The food was delicious.",
"The service was excellent.",
"I would visit again."
]
)
for item in response.data:
print(f"Input {item.index}: {len(item.embedding)} dimensions")Use Cases
| Use Case | Description |
|---|---|
| Semantic Search | Find documents similar to a query by comparing embedding distances |
| Clustering | Group similar texts together using vector similarity |
| Classification | Train classifiers on embedding vectors |
| Recommendations | Suggest items with similar embeddings |
Choosing Dimensions
Some embedding models support adjustable output dimensions via the dimensions parameter. Lower dimensions reduce storage and computation costs at the expense of some representational fidelity.
response = client.embeddings.create(
model="text-embedding-v3",
input="Hello world",
dimensions=256
)
```bash
## Best Practices
- **Pre-process text** — Remove unnecessary whitespace and normalize encoding before embedding
- **Batch requests** — Embed multiple texts in one call for better throughput
- **Cache results** — Store embeddings to avoid recomputing for the same input
- **Truncate long inputs** — Text exceeding the model's context limit will be truncated
## Related
- [Model Overview](/docs/models/model-overview) — Available embedding models
- [Chat Completions](/docs/api-reference/chat-completions) — Text generation API