Skip to content

Mistral API

Mistral Minions create native remote agents and execute any client-side function tools to completion.

mistral


Assembly: minions Filename: mistral.py Author: Terry D. Eppler Created: 09-05-2026

Last Modified By: Terry D. Eppler Last Modified On: 09-06-2026


 mistral.py
 Copyright © 2026 Terry D. Eppler

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You can contact me at: terryeppler@gmail.com or eppler.terry@epa.gov

Mistral AI Minion implementations.

AggregatedChoice

Bases: TypedDict

Relevant choice data returned by the Mistral stream accumulator.

AggregatedResponse

Bases: TypedDict

Relevant response data returned by the Mistral stream accumulator.

Minion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Mistral workflow agent with complete local tool execution.

Initialize a Mistral Minion and its remote agent resource.

Parameters:

Name Type Description Default
model str

Mistral model identifier.

required
instructions str

System instructions for the agent.

required
tools Sequence[MistralTool] | None

Optional Mistral tool schemas.

None
functions Sequence[ToolFunction] | None

Optional matching local callables.

None
max_turns int

Maximum model turns per execution.

10
api_key str | None

Optional Mistral API key override.

None
name str | None

Optional name overriding the implementation default.

None

Returns:

Name Type Description
None None

Configuration, client, and remote agent are stored.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None

get_tool_name(tool: MistralTool) -> str | None

Read a local Mistral function-tool name when present.

Parameters:

Name Type Description Default
tool MistralTool

Native model or typed dictionary schema.

required

Returns:

Type Description
str | None

str | None: Declared function name, or None for provider-hosted tools.

Source code in mistral.py
def get_tool_name( self, tool: MistralTool ) -> str | None:
    """Read a local Mistral function-tool name when present.

    Args:
        tool (MistralTool): Native model or typed dictionary schema.

    Returns:
        str | None: Declared function name, or None for provider-hosted tools.
    """
    if isinstance( tool, dict ):
        if tool.get( 'type' ) != 'function':
            return None
        function = tool.get( 'function' )
        if not isinstance( function, dict ):
            raise TypeError( 'Mistral function tool requires a function object!' )
        name = function.get( 'name' )
    else:
        function = getattr( tool, 'function', None )
        if function is None:
            return None
        name = function.name
    throw_if( 'tool.function.name', name )
    return str( name )

validate_tools() -> None

Validate exact schema-to-callable pairing when tools are supplied.

Returns:

Name Type Description
None None

Valid pairs are retained on the Minion.

Source code in mistral.py
def validate_tools( self ) -> None:
    """Validate exact schema-to-callable pairing when tools are supplied.

    Returns:
        None: Valid pairs are retained on the Minion.
    """
    names = [ name for tool in self.tools
        if ( name := self.get_tool_name( tool ) ) is not None ]
    if len( names ) != len( set( names ) ):
        raise ValueError( 'Argument "tools" must contain unique function names!' )
    missing = sorted( set( names ).difference( self.functions ) )
    extra = sorted( set( self.functions ).difference( names ) )
    if missing or extra:
        raise ValueError(
            f'Mistral tools and functions must match exactly; missing={missing}, extra={extra}!'
        )

create() -> Agent

Create the provider-native remote Mistral agent.

Returns:

Name Type Description
Agent Agent

Mistral agent resource used for executions.

Source code in mistral.py
def create( self ) -> Agent:
    """Create the provider-native remote Mistral agent.

    Returns:
        Agent: Mistral agent resource used for executions.
    """
    return self.client.beta.agents.create(
        name=self.name,
        model=self.model,
        instructions=self.instructions,
        tools=self.tools or None,
    )

run(prompt: str) -> ChatCompletionResponse

Execute the complete Mistral workflow synchronously.

Parameters:

Name Type Description Default
prompt str

User input for the workflow.

required

Returns:

Name Type Description
ChatCompletionResponse ChatCompletionResponse

Final provider-native completion.

Source code in mistral.py
def run( self, prompt: str ) -> ChatCompletionResponse:
    """Execute the complete Mistral workflow synchronously.

    Args:
        prompt (str): User input for the workflow.

    Returns:
        ChatCompletionResponse: Final provider-native completion.
    """
    throw_if( 'prompt', prompt )
    messages: list[ MistralMessage ] = [ UserMessage( content=prompt ) ]
    for _ in range( self.max_turns ):
        result = self.client.agents.complete(
            agent_id=self.provider.id, messages=messages
        )
        self.result = result
        message = result.choices[ 0 ].message
        tool_calls = message.tool_calls or [ ]
        if not tool_calls:
            return result
        messages.append( message )
        messages.extend( self.execute_tools( tool_calls ) )
    raise RuntimeError( f'Mistral workflow exceeded {self.max_turns} model turns!' )

run_async(prompt: str) -> ChatCompletionResponse async

Execute the complete Mistral workflow asynchronously.

Parameters:

Name Type Description Default
prompt str

User input for the workflow.

required

Returns:

Name Type Description
ChatCompletionResponse ChatCompletionResponse

Final provider-native completion.

Source code in mistral.py
async def run_async( self, prompt: str ) -> ChatCompletionResponse:
    """Execute the complete Mistral workflow asynchronously.

    Args:
        prompt (str): User input for the workflow.

    Returns:
        ChatCompletionResponse: Final provider-native completion.
    """
    throw_if( 'prompt', prompt )
    messages: list[ MistralMessage ] = [ UserMessage( content=prompt ) ]
    for _ in range( self.max_turns ):
        result = await self.client.agents.complete_async(
            agent_id=self.provider.id, messages=messages
        )
        self.result = result
        message = result.choices[ 0 ].message
        tool_calls = message.tool_calls or [ ]
        if not tool_calls:
            return result
        messages.append( message )
        messages.extend( await self.execute_tools_async( tool_calls ) )
    raise RuntimeError( f'Mistral workflow exceeded {self.max_turns} model turns!' )

stream(prompt: str) -> Iterator[CompletionEvent]

Start a streamed workflow that continues across local tool calls.

Parameters:

Name Type Description Default
prompt str

User input for the workflow.

required

Returns:

Type Description
Iterator[CompletionEvent]

Iterator[CompletionEvent]: Provider events from every model turn.

Source code in mistral.py
def stream( self, prompt: str ) -> Iterator[ CompletionEvent ]:
    """Start a streamed workflow that continues across local tool calls.

    Args:
        prompt (str): User input for the workflow.

    Returns:
        Iterator[CompletionEvent]: Provider events from every model turn.
    """
    throw_if( 'prompt', prompt )
    return self.stream_events( prompt )

stream_events(prompt: str) -> Iterator[CompletionEvent]

Execute and stream the complete Mistral tool loop.

Parameters:

Name Type Description Default
prompt str

Validated user input.

required

Yields:

Name Type Description
CompletionEvent CompletionEvent

Native event from the active Mistral stream.

Source code in mistral.py
def stream_events( self, prompt: str ) -> Iterator[ CompletionEvent ]:
    """Execute and stream the complete Mistral tool loop.

    Args:
        prompt (str): Validated user input.

    Yields:
        CompletionEvent: Native event from the active Mistral stream.
    """
    messages: list[ MistralMessage ] = [ UserMessage( content=prompt ) ]
    for _ in range( self.max_turns ):
        chunks: list[ CompletionChunk ] = [ ]
        for event in self.client.agents.stream(
                agent_id=self.provider.id, messages=messages ):
            chunks.append( event.data )
            yield event
        if not chunks:
            raise RuntimeError( 'Mistral streaming returned no completion chunks!' )
        aggregate = cast(
            AggregatedResponse, accumulate_chunks_to_response_dict( chunks )
        )
        message = AssistantMessage.model_validate(
            aggregate[ 'choices' ][ 0 ][ 'message' ]
        )
        self.result = message
        tool_calls = message.tool_calls or [ ]
        if not tool_calls:
            return
        messages.append( message )
        messages.extend( self.execute_tools( tool_calls ) )
    raise RuntimeError( f'Mistral workflow exceeded {self.max_turns} model turns!' )

execute_tools(tool_calls: Sequence[ToolCall]) -> list[ToolMessage]

Execute synchronous Mistral tool calls.

Parameters:

Name Type Description Default
tool_calls Sequence[ToolCall]

Provider-requested function calls.

required

Returns:

Type Description
list[ToolMessage]

list[ToolMessage]: Correlated tool-result messages.

Source code in mistral.py
def execute_tools( self, tool_calls: Sequence[ ToolCall ] ) -> list[ ToolMessage ]:
    """Execute synchronous Mistral tool calls.

    Args:
        tool_calls (Sequence[ToolCall]): Provider-requested function calls.

    Returns:
        list[ToolMessage]: Correlated tool-result messages.
    """
    messages: list[ ToolMessage ] = [ ]
    for tool_call in tool_calls:
        function = self.functions.get( tool_call.function.name )
        if function is None:
            raise ValueError(
                f'Mistral requested an unregistered tool: "{tool_call.function.name}"!'
            )
        arguments = self.parse_arguments( tool_call.function.arguments )
        output = function( **arguments )
        if isawaitable( output ):
            raise TypeError( f'Tool "{tool_call.function.name}" requires async execution!' )
        messages.append( ToolMessage(
            name=tool_call.function.name,
            content=self.serialize_result( output ),
            tool_call_id=tool_call.id,
        ) )
    return messages

execute_tools_async(tool_calls: Sequence[ToolCall]) -> list[ToolMessage] async

Execute asynchronous Mistral tool calls.

Parameters:

Name Type Description Default
tool_calls Sequence[ToolCall]

Provider-requested function calls.

required

Returns:

Type Description
list[ToolMessage]

list[ToolMessage]: Correlated tool-result messages.

Source code in mistral.py
async def execute_tools_async( self,
        tool_calls: Sequence[ ToolCall ] ) -> list[ ToolMessage ]:
    """Execute asynchronous Mistral tool calls.

    Args:
        tool_calls (Sequence[ToolCall]): Provider-requested function calls.

    Returns:
        list[ToolMessage]: Correlated tool-result messages.
    """
    messages: list[ ToolMessage ] = [ ]
    for tool_call in tool_calls:
        function = self.functions.get( tool_call.function.name )
        if function is None:
            raise ValueError(
                f'Mistral requested an unregistered tool: "{tool_call.function.name}"!'
            )
        arguments = self.parse_arguments( tool_call.function.arguments )
        if iscoroutinefunction( function ):
            output = await function( **arguments )
        else:
            output = await asyncio.to_thread( function, **arguments )
            if isawaitable( output ):
                output = await output
        messages.append( ToolMessage(
            name=tool_call.function.name,
            content=self.serialize_result( output ),
            tool_call_id=tool_call.id,
        ) )
    return messages

parse_arguments(arguments: str | dict[str, object]) -> dict[str, object] staticmethod

Parse and validate model-supplied tool arguments.

Parameters:

Name Type Description Default
arguments str | dict[str, object]

JSON or decoded keyword arguments.

required

Returns:

Type Description
dict[str, object]

dict[str, object]: Validated keyword arguments.

Source code in mistral.py
@staticmethod
def parse_arguments( arguments: str | dict[ str, object ] ) -> dict[ str, object ]:
    """Parse and validate model-supplied tool arguments.

    Args:
        arguments (str | dict[str, object]): JSON or decoded keyword arguments.

    Returns:
        dict[str, object]: Validated keyword arguments.
    """
    values = json.loads( arguments ) if isinstance( arguments, str ) else arguments
    if not isinstance( values, dict ):
        raise TypeError( 'Tool arguments must be a JSON object!' )
    return values

serialize_result(result: object) -> str staticmethod

Serialize a local tool result.

Parameters:

Name Type Description Default
result object

Value returned by a tool.

required

Returns:

Name Type Description
str str

Provider-compatible result content.

Source code in mistral.py
@staticmethod
def serialize_result( result: object ) -> str:
    """Serialize a local tool result.

    Args:
        result (object): Value returned by a tool.

    Returns:
        str: Provider-compatible result content.
    """
    return result if isinstance( result, str ) else json.dumps( result, default=str )

DataMinion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Bases: Minion

Mistral Minion specialized for data workflows.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None

GovernanceMinion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Bases: Minion

Mistral Minion specialized for governance workflows.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None

ResearchMinion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Bases: Minion

Mistral Minion specialized for research workflows.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None

CodingMinion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Bases: Minion

Mistral Minion specialized for software workflows.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None

WritingMinion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Bases: Minion

Mistral Minion specialized for writing workflows.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None

PlanningMinion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Bases: Minion

Mistral Minion specialized for planning workflows.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None

ComplianceMinion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Bases: Minion

Mistral Minion specialized for compliance, legal, and budget workflows.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None

BusinessMinion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Bases: Minion

Mistral Minion specialized for business, finance, and marketing workflows.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None

ImageGenerationMinion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Bases: Minion

Mistral Minion specialized for image-generation workflows.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None

ImageAnalysisMinion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Bases: Minion

Mistral Minion specialized for image-analysis workflows.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None

ImageEditingMinion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Bases: Minion

Mistral Minion specialized for image-editing workflows.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None

TranslationMinion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Bases: Minion

Mistral Minion specialized for translation workflows.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None

TranscriptionMinion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Bases: Minion

Mistral Minion specialized for transcription workflows.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None

SpeechMinion(model: str, instructions: str, tools: Sequence[MistralTool] | None = None, functions: Sequence[ToolFunction] | None = None, max_turns: int = 10, api_key: str | None = None, name: str | None = None)

Bases: Minion

Mistral Minion specialized for speech workflows.

Source code in mistral.py
def __init__( self, model: str, instructions: str,
        tools: Sequence[ MistralTool ] | None=None,
        functions: Sequence[ ToolFunction ] | None=None, max_turns: int=10,
        api_key: str | None=None, name: str | None=None ) -> None:
    """Initialize a Mistral Minion and its remote agent resource.

    Args:
        model (str): Mistral model identifier.
        instructions (str): System instructions for the agent.
        tools (Sequence[MistralTool] | None): Optional Mistral tool schemas.
        functions (Sequence[ToolFunction] | None): Optional matching local callables.
        max_turns (int): Maximum model turns per execution.
        api_key (str | None): Optional Mistral API key override.
        name (str | None): Optional name overriding the implementation default.

    Returns:
        None: Configuration, client, and remote agent are stored.
    """
    throw_if( 'model', model )
    throw_if( 'instructions', instructions )
    if max_turns < 1:
        raise ValueError( 'Argument "max_turns" must be at least 1!' )
    self.name = name or self.minion_name
    throw_if( 'name', self.name )
    self.model = model
    self.instructions = instructions
    self.tools = list( tools or [ ] )
    function_list = list( functions or [ ] )
    self.functions = { function.__name__: function for function in function_list }
    if len( self.functions ) != len( function_list ):
        raise ValueError( 'Argument "functions" must contain unique names!' )
    self.validate_tools( )
    self.max_turns = max_turns
    self.api_key = api_key or os.getenv( 'MISTRAL_API_KEY' )
    throw_if( 'api_key', self.api_key )
    self.client = Mistral( api_key=self.api_key )
    self.provider = self.create( )
    self.result: ChatCompletionResponse | AssistantMessage | None = None