Skip to main content

Provider-specific Swarmauri import package for Mistral chat, tool-calling, streaming, async, and batch LLM workflows.

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_llm_mistral Discord

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 llms and tool_llms package boundaries.
  • Support sync, async, streaming, and batch generation workflows against the Mistral API.
  • Execute tools through MistralToolModel without 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

  • MistralModel for sync, async, streaming, and batch chat completion workflows.
  • Optional JSON response mode and safe prompt support on chat requests.
  • MistralToolModel for 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 MistralModel for standard chat completion workflows when you want a direct Mistral provider package import.
  • Use MistralToolModel when the application needs function calling and tool execution through a Swarmauri toolkit.
  • Use enable_json=True on MistralModel when downstream code expects structured JSON output.

Related Packages

Foundational Swarmauri Packages

More Documentation

Best Practices

  • Keep MISTRAL_API_KEY in environment variables or a secret manager.
  • Validate model availability against Mistral’s current catalog before hard-coding a specific family into production workflows.
  • Use MistralToolModel only when a toolkit-backed tool loop is actually needed; plain chat is simpler with MistralModel.
  • Tune temperature, top_p, max_tokens, and safe_prompt to match your product constraints.

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swarmauri_llm_mistral-0.11.0.dev1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swarmauri_llm_mistral-0.11.0.dev1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

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

Hashes for swarmauri_llm_mistral-0.11.0.dev1.tar.gz
Algorithm Hash digest
SHA256 fcf85c8a3a92f6c4d19429ee97779c7b620aa44fe4b2f53bf6efb912a2a17c52
MD5 14b0bfc9a096f5cea62960771f582ff2
BLAKE2b-256 ea5bdef2d5ca758c32413b05c96eee1af44e366fc03a5a7126bde111dd50859e

See more details on using hashes here.

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

Hashes for swarmauri_llm_mistral-0.11.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 021f84a8c32af8964db9333a332836860e00c9d62b9b16064f2d12f3236c076c
MD5 cb1b6712e1cc8ad21ebba5e834cfe515
BLAKE2b-256 bf6294b114dfefbd4a8b9790848173c50d530a3e3cbd85ca6a62a17e9fbe0f1e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page