Embeddings
March 2, 2026 ยท View on GitHub
Overview
Embeddings API.
Available Operations
- create - Embeddings
create
Embeddings
Example Usage
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.embeddings.create(model="mistral-embed", inputs=[
"Embed this sentence.",
"As well as this one.",
])
# Handle response
print(res)
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
model | str | :heavy_check_mark: | ID of the model to use. | mistral-embed |
inputs | models.EmbeddingRequestInputs | :heavy_check_mark: | Text to embed. | [ "Embed this sentence.", "As well as this one." ] |
metadata | Dict[str, Any] | :heavy_minus_sign: | N/A | |
output_dimension | OptionalNullable[int] | :heavy_minus_sign: | The dimension of the output embeddings when feature available. If not provided, a default output dimension will be used. | |
output_dtype | Optional[models.EmbeddingDtype] | :heavy_minus_sign: | N/A | |
encoding_format | Optional[models.EncodingFormat] | :heavy_minus_sign: | N/A | |
retries | Optional[utils.RetryConfig] | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
Response
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |