Embeddings API.
- create - Embeddings
Embeddings
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)| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
model |
str | ✔️ | ID of the model to use. | mistral-embed |
inputs |
models.EmbeddingRequestInputs | ✔️ | Text to embed. | [ "Embed this sentence.", "As well as this one." ] |
metadata |
Dict[str, Any] | ➖ | N/A | |
output_dimension |
OptionalNullable[int] | ➖ | The dimension of the output embeddings when feature available. If not provided, a default output dimension will be used. | |
output_dtype |
Optional[models.EmbeddingDtype] | ➖ | N/A | |
encoding_format |
Optional[models.EncodingFormat] | ➖ | N/A | |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |