Skip to main content

Crate agent_framework_mistral

Crate agent_framework_mistral 

Source
Expand description

§agent-framework-mistral

A Mistral AI ChatClient for agent-framework-rs.

Talks to the Mistral Chat Completions API (POST /v1/chat/completions), whose wire format is OpenAI-Chat-compatible: message shape, function-tool shape, tool-call/response shape, and usage shape all match agent-framework-openai’s Chat Completions client, so this crate reuses that conversion code directly (the same approach agent-framework-azure takes for Azure OpenAI) rather than duplicating it. Only the parts that genuinely differ — the base URL, bearer-token auth, the supported request-option set (see convert::apply_options), and error classification — are implemented here; see convert for the details.

Upstream (the Python/.NET agent-framework) ships no dedicated Mistral chat connector at all — Mistral only appears there as an embeddings/text-embedding provider. This crate instead provides a full Mistral chat client, since Mistral’s hosted models are chat models first and foremost and the framework’s ChatClient trait is the natural fit. It can gain an embeddings client of its own once agent-framework-core grows a shared embeddings trait to implement against; until then, chat is the complete scope of this crate.

use agent_framework_mistral::MistralChatClient;
use agent_framework_core::prelude::*;

let client = MistralChatClient::new("...", "mistral-large-latest");
let agent = Agent::builder(client)
    .instructions("You are concise.")
    .build();
let reply = agent.run_once("Say hi").await?;
println!("{}", reply.text());

Re-exports§

pub use embeddings::MistralEmbeddingClient;
pub use embeddings::DEFAULT_EMBEDDING_MODEL;

Modules§

convert
Conversion between framework types and the Mistral chat-completions wire format.
embeddings
Mistral embeddings client.

Structs§

MistralChatClient
A Mistral AI chat client (POST {base_url}/chat/completions).