Implementation:Mistralai Client python EmbeddingResponse
Appearance
| Knowledge Sources | |
|---|---|
| Domains | NLP, Embeddings |
| Last Updated | 2026-02-15 14:00 GMT |
Overview
Concrete tool for extracting embedding vectors and usage metadata from API responses provided by the EmbeddingResponse model.
Description
The EmbeddingResponse Pydantic model encapsulates the embedding API response. It contains data (a list of EmbeddingResponseData objects, each with an embedding vector and index), model name, and usage statistics. Access individual vectors via response.data[i].embedding.
Usage
Access the EmbeddingResponse returned by client.embeddings.create(). Iterate over response.data to get each embedding vector.
Code Reference
Source Location
- Repository: client-python
- File: src/mistralai/client/models/embeddingresponse.py (L1-30), embeddingresponsedata.py (L1-25)
Signature
class EmbeddingResponseData(BaseModel):
embedding: List[float]
index: int
object: str
class EmbeddingResponse(BaseModel):
id: str
object: str
data: List[EmbeddingResponseData]
model: str
usage: UsageInfo
Import
from mistralai.models import EmbeddingResponse
# Typically received as return value from client.embeddings.create()
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| response | EmbeddingResponse | Yes | Return value from embeddings.create() |
Outputs
| Name | Type | Description |
|---|---|---|
| embeddings | List[List[float]] | Vector representations, one per input text |
| usage | UsageInfo | Token consumption (prompt_tokens, total_tokens) |
Usage Examples
Extract Vectors
response = client.embeddings.create(
model="mistral-embed",
inputs=["Hello world", "Goodbye world"],
)
# Get all vectors
vectors = [item.embedding for item in response.data]
print(f"Number of vectors: {len(vectors)}")
print(f"Vector dimension: {len(vectors[0])}")
# Usage statistics
print(f"Tokens used: {response.usage.total_tokens}")
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment