@effect-uai/mistral
v0.11.0
Published
Mistral provider for @effect-uai/core: chat-completions plus Voxtral speech-to-text and text-to-speech.
Maintainers
Readme
@effect-uai/mistral
Mistral provider for @effect-uai/core.
One package, the whole Mistral surface:
Mistral— theLanguageModelcontract against Mistral's chat-completions API, with SSE streaming, function calling, andjson_schemastructured output.MistralTranscriber— batch speech-to-text (Voxtral) via/v1/audio/transcriptions.MistralRealtimeTranscriber— live speech-to-text over the Voxtral Realtime WebSocket (registers theSttStreamingcapability).MistralSynthesizer— Voxtral text-to-speech, including streaming output and zero-shot voice cloning via a reference clip.
Install
pnpm add @effect-uai/mistral @effect-uai/core effectESM-only. Requires [email protected] and @effect-uai/core as peers. The
realtime transcriber additionally needs the optional ws peer (Node /
Bun only).
Usage
Chat completions (LanguageModel)
import { Config, Effect, Layer } from "effect"
import { FetchHttpClient } from "effect/unstable/http"
import { layer as mistralLayer } from "@effect-uai/mistral/Mistral"
const provider = Layer.unwrap(
Effect.gen(function* () {
const apiKey = yield* Config.redacted("MISTRAL_API_KEY")
return mistralLayer({ apiKey })
}),
)
const layer = Layer.provide(provider, FetchHttpClient.layer)The layer registers both the provider-typed Mistral tag and the
generic LanguageModel tag.
Voxtral speech (STT + TTS)
import { layer as transcriber } from "@effect-uai/mistral/MistralRealtimeTranscriber"
import { layer as synthesizer } from "@effect-uai/mistral/MistralSynthesizer"
// transcriber({ apiKey }) registers Transcriber + SttStreaming
// synthesizer({ apiKey }) registers SpeechSynthesizer + TtsIncrementalTextFor batch (non-streaming) transcription, import
@effect-uai/mistral/MistralTranscriber instead — it omits the ws
dependency.
Notes
tool_choicemaps"required"to Mistral's"any".- Voxtral TTS
pcmoutput is float32 LE;wavis s16le. - The realtime STT wire frames are reconstructed from the SDK; verify against the live API before production use.
Docs
https://effect-uai.betalyra.com/providers/mistral/
License
MIT
