Provider-specific Swarmauri import package for Mistral chat, tool-calling, streaming, async, and batch LLM workflows.
Project description
Swarmauri Mistral LLM
swarmauri_llm_mistral provides provider-specific Swarmauri imports for the Mistral API. The package exposes MistralModel for chat completion workflows and MistralToolModel for tool-calling workflows that execute toolkit functions and optionally follow up with a second model turn.
The runtime targets Mistral's hosted API at https://api.mistral.ai/v1/, supports the current allowlisted Mistral, Magistral, Codestral, Devstral, Pixtral, OCR, embedding, and moderation model families tracked in the repo, and preserves Swarmauri Conversation and toolkit semantics.
Why Use This Package?
- Keep Mistral-specific imports explicit in Swarmauri applications.
- Use a chat model adapter and a separate tool-calling adapter that match Swarmauri’s
llmsandtool_llmspackage boundaries. - Support sync, async, streaming, and batch generation workflows against the Mistral API.
- Execute tools through
MistralToolModelwithout hand-writing provider-specific function-calling payloads.
FAQ
What does swarmauri_llm_mistral install?
It installs MistralModel under swarmauri.llms and MistralToolModel under swarmauri.tool_llms.
Which Mistral capabilities are wrapped today?
MistralModel wraps chat completion workflows, including streaming and optional JSON response formatting. MistralToolModel wraps tool-calling workflows that serialize Swarmauri tools into Mistral-compatible schemas, execute tool calls, and optionally request a final assistant answer in a second turn.
Does it support usage metadata?
MistralModel can attach Swarmauri UsageData when usage information is returned and include_usage is enabled.
Does MistralToolModel support streaming?
Yes. The tool model performs the tool-call round first, appends tool results to the conversation, then streams the final assistant response when streaming is requested.
Which model families are covered?
The current allowlists include Mistral chat models plus related families such as Magistral, Codestral, Devstral, Pixtral, OCR, embed, and moderation surfaces tracked in the runtime code.
Where should I verify current model and pricing details?
Use the provider documentation links in docs/LLM_PROVIDER_MODEL_PRICING_LINKS.md, especially the Mistral models, function-calling, and pricing pages, before publishing model availability or pricing claims.
Features
MistralModelfor sync, async, streaming, and batch chat completion workflows.- Optional JSON response mode and safe prompt support on chat requests.
MistralToolModelfor tool-calling and multiturn tool execution workflows.- Current repo-tracked allowlists for Mistral, Magistral, Codestral, Devstral, Pixtral, OCR, embed, and moderation models.
- Compatibility with Python 3.10, 3.11, 3.12, 3.13, and 3.14.
Installation
uv add swarmauri_llm_mistral
pip install swarmauri_llm_mistral
Usage
Set MISTRAL_API_KEY in your environment before creating the model.
Chat Completion
import os
from swarmauri_llm_mistral import MistralModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage
conversation = Conversation()
conversation.add_message(HumanMessage(content="Summarize Swarmauri in two sentences."))
model = MistralModel(
api_key=os.environ["MISTRAL_API_KEY"],
name="mistral-medium-2508",
)
result = model.predict(conversation=conversation, max_tokens=200)
print(result.get_last().content)
Streaming
import os
from swarmauri_llm_mistral import MistralModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage
conversation = Conversation()
conversation.add_message(HumanMessage(content="Write a short haiku about AI tooling."))
model = MistralModel(api_key=os.environ["MISTRAL_API_KEY"])
for token in model.stream(conversation=conversation):
print(token, end="", flush=True)
Tool Calling
import os
from swarmauri_llm_mistral import MistralToolModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage
from swarmauri_standard.toolkits.Toolkit import Toolkit
from swarmauri_standard.tools.AdditionTool import AdditionTool
conversation = Conversation()
conversation.add_message(HumanMessage(content="What is 19 + 23? Use the tool."))
toolkit = Toolkit(tools={"add": AdditionTool()})
model = MistralToolModel(
api_key=os.environ["MISTRAL_API_KEY"],
name="mistral-medium-2508",
)
result = model.predict(
conversation=conversation,
toolkit=toolkit,
tool_choice="auto",
)
print(result.get_last().content)
Examples
- Use
MistralModelfor standard chat completion workflows when you want a direct Mistral provider package import. - Use
MistralToolModelwhen the application needs function calling and tool execution through a Swarmauri toolkit. - Use
enable_json=TrueonMistralModelwhen downstream code expects structured JSON output.
Related Packages
- swarmauri_llm_openai
- swarmauri_llm_groq
- swarmauri_llm_hyperbolic
- swarmauri_llm_deepinfra
- swarmauri_llm_perplexity
- swarmauri_llm_llamacpp
Foundational Swarmauri Packages
More Documentation
Best Practices
- Keep
MISTRAL_API_KEYin environment variables or a secret manager. - Validate model availability against Mistral’s current catalog before hard-coding a specific family into production workflows.
- Use
MistralToolModelonly when a toolkit-backed tool loop is actually needed; plain chat is simpler withMistralModel. - Tune
temperature,top_p,max_tokens, andsafe_promptto match your product constraints.
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmauri_llm_mistral-0.11.0.dev1.tar.gz.
File metadata
- Download URL: swarmauri_llm_mistral-0.11.0.dev1.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcf85c8a3a92f6c4d19429ee97779c7b620aa44fe4b2f53bf6efb912a2a17c52
|
|
| MD5 |
14b0bfc9a096f5cea62960771f582ff2
|
|
| BLAKE2b-256 |
ea5bdef2d5ca758c32413b05c96eee1af44e366fc03a5a7126bde111dd50859e
|
File details
Details for the file swarmauri_llm_mistral-0.11.0.dev1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_llm_mistral-0.11.0.dev1-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
021f84a8c32af8964db9333a332836860e00c9d62b9b16064f2d12f3236c076c
|
|
| MD5 |
cb1b6712e1cc8ad21ebba5e834cfe515
|
|
| BLAKE2b-256 |
bf6294b114dfefbd4a8b9790848173c50d530a3e3cbd85ca6a62a17e9fbe0f1e
|