---
title: Mistral Embedder
sidebarTitle: Mistral
---
`MistralEmbedder` 类用于通过 Mistral API 将文本数据嵌入到向量中。在此处获取您的密钥:[https://console.mistral.ai/api-keys/](https://console.mistral.ai/api-keys/)。
## 用法
```python cookbook/embedders/mistral_embedder.py
from agno.agent import AgentKnowledge
from agno.vectordb.pgvector import PgVector
from agno.embedder.mistral import MistralEmbedder
# 将句子嵌入数据库
embeddings = MistralEmbedder().get_embedding("The quick brown fox jumps over the lazy dog.")
# 打印嵌入向量及其维度
print(f"Embeddings: {embeddings[:5]}")
print(f"Dimensions: {len(embeddings)}")
# 在知识库中使用 embedder
knowledge_base = AgentKnowledge(
vector_db=PgVector(
db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
table_name="mistral_embeddings",
embedder=MistralEmbedder(),
),
num_documents=2,
)