Mistral
MistralLLMService streams chat completions from Mistral through its OpenAI-compatible API.
Overview
Mistral AI's chat models.
MistralLLMService: anOpenAILLMServicesubclass with Mistral's base URL and default model. It usesMistralLLMAdapter, which rewrites the history to Mistral's rules: an assistant message after every tool message, system messages only at the start, andprefix: trueon a trailing assistant message.
Upstream page
Pipecat's documentation for the same service.
Source
packages/mistral/src/llm.ts and mistral_adapter.ts.
Mistral docs
The API reference.
Installation
bun add @pipedog/mistralIt depends on @pipedog/openai, which is installed with it.
import { MistralLLMService } from "@pipedog/mistral/llm";
import { MistralLLMAdapter } from "@pipedog/mistral/mistral_adapter";Prerequisites
- A Mistral account and an API key from Mistral.
- Pass the key as
apiKey. It is required, and the service never falls back toOPENAI_API_KEY. The examples read it fromMISTRAL_API_KEY.
MistralLLMService
Configuration
Prop
Type
The other options (organization, project, defaultHeaders, serviceTier,
retryOnTimeout, retryTimeoutSecs, function calling) are OpenAILLMService's. See
OpenAI.
| Base URL | https://api.mistral.ai/v1 |
| Default model | mistral-small-latest |
| Models to try | mistral-small-latest, mistral-large-latest. See the provider's catalog for the rest. |
Settings
Runtime-updatable settings, passed as settings: new MistralLLMService.Settings({...})
(MistralLLMSettings). They are OpenAI's settings, with these
defaults:
| Setting | Type | Default | Description |
|---|---|---|---|
model | string | "mistral-small-latest" | Model name. |
Every other setting keeps OpenAI's default. Unset sampling settings are left out of the request, so
the provider's own defaults apply. extra carries provider-specific request fields.
Usage
import { LLMUpdateSettingsFrame } from "@pipedog/core/frames/frames";
import { MistralLLMService } from "@pipedog/mistral/llm";
const llm = new MistralLLMService({
apiKey: process.env.MISTRAL_API_KEY ?? "",
settings: new MistralLLMService.Settings({
model: "mistral-small-latest",
systemInstruction: "You are a helpful assistant in a voice conversation.",
temperature: 0.7,
}),
});Change settings mid-call with an LLMUpdateSettingsFrame. The next completion uses them:
// Queue it on the worker, or push it from a processor upstream of the service.
const update = new LLMUpdateSettingsFrame({
delta: new MistralLLMService.Settings({ temperature: 0.2, maxTokens: 300 }),
});Notes
- Runs a completion for each
LLMContextFrame, between anLLMFullResponseStartFrameand anLLMFullResponseEndFrame, and streams the reply asLLMTextFrames, asOpenAILLMServicedoes. Function calls, token usage metrics andrunInferencework the same way. - "developer" messages are sent as "user" messages, since the API doesn't support that role (
supportsDeveloperRoleisfalse). - Messages go through
MistralLLMAdapter, which rewrites the history to Mistral's rules: an assistant message after every tool message, system messages only at the start, andprefix: trueon a trailing assistant message. seedis sent as Mistral'srandom_seed.stream_options,max_completion_tokensandservice_tierare not sent.- Mistral detects function calls from the whole history, so calls that already have a tool result in the context are skipped instead of run twice.
on_function_calls_startedmay still fire twice. - The same package has Mistral's speech-to-text and text-to-speech services.
Runtime notes
| Runtime | Works | What it needs |
|---|---|---|
| Bun | ✅ yes | Nothing. |
| Node.js | ✅ yes | Nothing. |
| Deno | ✅ yes | Nothing. |
| Cloudflare Workers | ✅ yes | Nothing. |
Generated from pipecat.runtimes and pipecat.compat in packages/mistral/package.json: ✅ means the compat smoke test passes on that runtime.
- The client is the official
openaiJS SDK (through@pipedog/openai), which talks throughfetch. It works on Bun, Node, Deno and Cloudflare Workers. - The deprecated
modelconstructor option is not ported. Usesettings. - Tested against a local OpenAI-compatible mock server, not against Mistral itself.
pipedog is an unofficial community TypeScript port of Pipecat. It is not affiliated with or endorsed by Daily or the Pipecat project.
Portions adapted from the Pipecat documentation, Copyright (c) 2024–2025 Daily, BSD-2-Clause (see apps/docs/LICENSE-pipecat-docs).