yera.models.interfaces.llms.mistral

Interface to Mistral llms.

This module provides the MistralLLM class for interacting with Mistral's language models. It supports both standard streaming chat completions and structured output generation via Mistral's native json_schema response format, which is available across Mistral's current chat completion models (unlike OpenAI, there is no per-model date cutoff to detect).

Symbols

class MistralLLM — Interface to Mistral llms.

MistralLLM

Interface to Mistral llms.

Provides a wrapper around the Mistral API client. Structured output uses Mistral's native json_schema response format directly, since Mistral does not require the model-version-based fallback that OpenAI/Anthropic need for their older models.

The client is lazily initialised on start() and must be explicitly shut down via stop().

Attributes

model_id
type: str

The identifier of the Mistral model to use.

connection
type: MistralConnection

Connection configuration including API key.

client
type: Mistral

Lazy-initialised Mistral API client instance.

Methods

start — Initialise the Mistral API client.
stop — Shut down and clear the Mistral API client.
chat — Stream a chat completion response from Mistral.
make_struct — Stream a structured output response conforming to a schema.

MistralLLM.start

start() → None

Initialise the Mistral API client.

Creates and stores a Mistral client instance using the configured connection settings (API key). This method must be called before making any API requests via the client property.

MistralLLM.stop

stop() → None

Shut down and clear the Mistral API client.

Releases the Mistral client instance by setting it to None. After calling this method, start() must be called again before further API requests can be made.

MistralLLM.chat

chat(
    messages: list[Message],
    reasoning_level: ReasoningLevel | None = None,
    **overrides,
) → Iterator[LLMToken]

Stream a chat completion response from Mistral.

Thinking is only produced when reasoning_effort is set to "high" on a model that supports it.

Parameters

messages
type: list[Message]

The workspace conversation history.

reasoning_level
type: ReasoningLevel | None = None

Set the reasoning effort level overriding the default (medium)

**overrides
type: str | float | int | bool

Per-call inference parameters.

MistralLLM.make_struct

make_struct(
    messages: list[Message],
    reasoning_level: ReasoningLevel | None = None,
    **overrides,
) → Iterator[LLMToken]

Stream a structured output response conforming to a schema.

Parameters

messages
type: list[Message]

The workspace conversation history.

cls
type: type[TStruct]

A pydantic model class defining the output structure.

reasoning_level
type: ReasoningLevel | None = None

Set the reasoning effort level overriding the default (off)

**overrides
type: str | float | int | bool

Per-call inference parameters.