Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Environment:Mistralai Client python Realtime Transcription Environment

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Audio
Last Updated 2026-02-15 14:00 GMT

Overview

Extension environment requiring `websockets` >= 13.0 for Mistral real-time audio transcription via WebSockets.

Description

This environment extends the core Python SDK environment with WebSocket support for real-time audio transcription. The `websockets` library is an optional dependency that is only required when using the `mistralai.extra.realtime` module. The SDK uses the `websockets.asyncio.client` API which requires version 13.0 or higher.

Usage

Use this environment when working with real-time audio transcription features of the Mistral API. It is required for streaming audio input and receiving live transcription results.

System Requirements

Category Requirement Notes
OS Linux, macOS, Windows Same as core SDK
Python >= 3.10 Same as core SDK
Network WebSocket connectivity Must be able to establish WSS connections to `wss://api.mistral.ai`

Dependencies

Python Packages

Credentials

  • `MISTRAL_API_KEY`: Required (same as core SDK).
  • `MISTRAL_BASE_URL`: Optional override; default WebSocket URL is `wss://api.mistral.ai`.

Quick Install

# Install with realtime extra
pip install "mistralai[realtime]"

Code Evidence

Import guard in `src/mistralai/extra/realtime/connection.py:11-17`:

try:
    from websockets.asyncio.client import ClientConnection  # websockets >= 13.0
except ImportError as exc:
    raise ImportError(
        "The `websockets` package (>=13.0) is required for real-time transcription. "
        "Install with: pip install 'mistralai[realtime]'"
    ) from exc

Same import guard in `src/mistralai/extra/realtime/transcription.py:9-18`:

try:
    from websockets.asyncio.client import (
        ClientConnection,
        connect,
    )  # websockets >= 13.0
except ImportError as exc:
    raise ImportError(
        "The `websockets` package (>=13.0) is required for real-time transcription. "
        "Install with: pip install 'mistralai[realtime]'"
    ) from exc

Optional dependency declaration in `pyproject.toml:32-34`:

realtime = [
    "websockets >=13.0",
]

Common Errors

Error Message Cause Solution
`ImportError: The websockets package (>=13.0) is required for real-time transcription` `websockets` not installed or version < 13.0 `pip install "mistralai[realtime]"`
`RuntimeError: Connection is closed` Attempting to send audio on a closed WebSocket connection Check connection lifecycle; ensure `send_audio` is called within an active connection context
`RuntimeError: ffmpeg conversion failed` ffmpeg not installed or audio format unsupported Install ffmpeg and ensure audio input is in a supported format

Compatibility Notes

  • websockets < 13.0: Not supported. The SDK specifically requires the `websockets.asyncio.client` API introduced in version 13.0.
  • Sync usage: Real-time transcription is async-only. There is no synchronous API for WebSocket connections.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment