# langchain-mistralai
This package contains the LangChain integrations for [MistralAI](https://docs.mistral.ai) through their [mistralai](https://pypi.org/project/mistralai/) SDK.
## Installation
```bash
pip install -U langchain-mistralai
```
## Chat Models
This package contains the `ChatMistralAI` class, which is the recommended way to interface with MistralAI models.
To use, install the requirements, and configure your environment.
```bash
export MISTRAL_API_KEY=your-api-key
```
Then initialize
```python
from langchain_core.messages import HumanMessage
from langchain_mistralai.chat_models import ChatMistralAI
chat = ChatMistralAI(model="mistral-small")
messages = [HumanMessage(content="say a brief hello")]
chat.invoke(messages)
```
`ChatMistralAI` also supports async and streaming functionality:
```python
# For async...
await chat.ainvoke(messages)
# For streaming...
for chunk in chat.stream(messages):
print(chunk.content, end="", flush=True)
```
## Embeddings
With `MistralAIEmbeddings`, you can directly use the default model 'mistral-embed', or set a different one if available.
### Choose model
`embedding.model = 'mistral-embed'`
### Simple query
`res_query = embedding.embed_query("The test information")`
### Documents
`res_document = embedding.embed_documents(["test1", "another test"])`
Raw data
{
"_id": null,
"home_page": "https://github.com/langchain-ai/langchain",
"name": "langchain-mistralai",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/8f/b8/6b3fa2ad08872ea5cce3bfd8aa40670b1b02ced2b32d0bb31ff915f7bd29/langchain_mistralai-0.2.5.tar.gz",
"platform": null,
"description": "# langchain-mistralai\n\nThis package contains the LangChain integrations for [MistralAI](https://docs.mistral.ai) through their [mistralai](https://pypi.org/project/mistralai/) SDK.\n\n## Installation\n\n```bash\npip install -U langchain-mistralai\n```\n\n## Chat Models\n\nThis package contains the `ChatMistralAI` class, which is the recommended way to interface with MistralAI models.\n\nTo use, install the requirements, and configure your environment.\n\n```bash\nexport MISTRAL_API_KEY=your-api-key\n```\n\nThen initialize\n\n```python\nfrom langchain_core.messages import HumanMessage\nfrom langchain_mistralai.chat_models import ChatMistralAI\n\nchat = ChatMistralAI(model=\"mistral-small\")\nmessages = [HumanMessage(content=\"say a brief hello\")]\nchat.invoke(messages)\n```\n\n`ChatMistralAI` also supports async and streaming functionality:\n\n```python\n# For async...\nawait chat.ainvoke(messages)\n\n# For streaming...\nfor chunk in chat.stream(messages):\n print(chunk.content, end=\"\", flush=True)\n```\n\n## Embeddings\n\nWith `MistralAIEmbeddings`, you can directly use the default model 'mistral-embed', or set a different one if available.\n\n### Choose model\n\n`embedding.model = 'mistral-embed'`\n\n### Simple query\n\n`res_query = embedding.embed_query(\"The test information\")`\n\n### Documents\n\n`res_document = embedding.embed_documents([\"test1\", \"another test\"])`\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An integration package connecting Mistral and LangChain",
"version": "0.2.5",
"project_urls": {
"Homepage": "https://github.com/langchain-ai/langchain",
"Release Notes": "https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-mistralai%3D%3D0%22&expanded=true",
"Repository": "https://github.com/langchain-ai/langchain",
"Source Code": "https://github.com/langchain-ai/langchain/tree/master/libs/partners/mistralai"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "9cc105c4d6dedc9afd3f6b8773a363d357bbda4b8f7f5af8409e17d730eba9fd",
"md5": "55eb1cf833fceb15b3c2940e033b8eca",
"sha256": "0b413257845a0abdf31fca1ddf622f9ade8a63a37ec470dba0362f4d9e1a1769"
},
"downloads": -1,
"filename": "langchain_mistralai-0.2.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "55eb1cf833fceb15b3c2940e033b8eca",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 15680,
"upload_time": "2025-01-28T23:34:16",
"upload_time_iso_8601": "2025-01-28T23:34:16.334171Z",
"url": "https://files.pythonhosted.org/packages/9c/c1/05c4d6dedc9afd3f6b8773a363d357bbda4b8f7f5af8409e17d730eba9fd/langchain_mistralai-0.2.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8fb86b3fa2ad08872ea5cce3bfd8aa40670b1b02ced2b32d0bb31ff915f7bd29",
"md5": "8f399f7e318583a904abc8fccb200920",
"sha256": "3c68c4bdf6ab213ef435edc3a9a3dc0f21a57436d18336209ec10a9ac3e9ff48"
},
"downloads": -1,
"filename": "langchain_mistralai-0.2.5.tar.gz",
"has_sig": false,
"md5_digest": "8f399f7e318583a904abc8fccb200920",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 14917,
"upload_time": "2025-01-28T23:34:17",
"upload_time_iso_8601": "2025-01-28T23:34:17.994273Z",
"url": "https://files.pythonhosted.org/packages/8f/b8/6b3fa2ad08872ea5cce3bfd8aa40670b1b02ced2b32d0bb31ff915f7bd29/langchain_mistralai-0.2.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-28 23:34:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "langchain-ai",
"github_project": "langchain",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "langchain-mistralai"
}