Mistral API Integration for Python

Use Mistral’s native chat integration from Python, with a separately metered OCR step for PDF input on supported models.

All providers

Installation

Use Python 3.10–3.14 and run this command in your virtual environment.

python -m pip install llm-api-adapter==0.11.0 llm-api-adapter-mistral==0.1.7

Authentication

Open Mistral Studio API key guide. Create a key in the Mistral Studio workspace where you want to run requests. Set the following in the terminal where you will run the example.

export MISTRAL_API_KEY="your-api-key"

Quickstart

Send a message

Save the example as chat.py and run python chat.py.

import os

from llm_api_adapter.models.messages.chat_message import UserMessage
from llm_api_adapter.universal_adapter import UniversalLLMAPIAdapter

adapter = UniversalLLMAPIAdapter(
    organization="mistral",
    model="mistral-large-4",
    api_key=os.environ["MISTRAL_API_KEY"],
)

response = adapter.chat(
    messages=[UserMessage("Explain what an API is in one sentence.")],
    max_tokens=1024,
    timeout_s=60,
)
print(response.content)

Supported models

Registry snapshot

Prices are first-tier base rates from the adapter registry. Open a model for all tiers, cache rates, pricing schedules, and capability notes. Unknown means the registry has no value.

  • mistral-large-4

    Context tokens
    1,048,576
    Base input per million tokens
    1.36 USD
    Maximum output tokens
    1,048,576
    Base output per million tokens
    4.18 USD
    Reasoning
    Supported
    Image URLs
    Unknown
    PDF URLs
    Supported
    PDF bytes
    Supported
    JSON Schema output
    Unknown
    Pydantic output
    Unknown
  • mistral-small-2603

    Context tokens
    256,000
    Base input per million tokens
    0.15 USD
    Maximum output tokens
    256,000
    Base output per million tokens
    0.6 USD
    Reasoning
    Supported
    Image URLs
    Unknown
    PDF URLs
    Supported
    PDF bytes
    Supported
    JSON Schema output
    Unknown
    Pydantic output
    Unknown
  • mistral-medium-3-5

    Context tokens
    256,000
    Base input per million tokens
    1.5 USD
    Maximum output tokens
    256,000
    Base output per million tokens
    7.5 USD
    Reasoning
    Supported
    Image URLs
    Unknown
    PDF URLs
    Supported
    PDF bytes
    Supported
    JSON Schema output
    Unknown
    Pydantic output
    Unknown
  • mistral-large-2512

    Context tokens
    256,000
    Base input per million tokens
    0.5 USD
    Maximum output tokens
    256,000
    Base output per million tokens
    1.5 USD
    Reasoning
    Unknown
    Image URLs
    Unknown
    PDF URLs
    Supported
    PDF bytes
    Supported
    JSON Schema output
    Unknown
    Pydantic output
    Unknown
  • glm-5.3-flash

    Context tokens
    1,048,576
    Base input per million tokens
    0.15 USD
    Maximum output tokens
    128,000
    Base output per million tokens
    0.5 USD
    Reasoning
    Supported
    Image URLs
    Unknown
    PDF URLs
    Supported
    PDF bytes
    Supported
    JSON Schema output
    Unknown
    Pydantic output
    Unknown
  • deepseek-flash

    Context tokens
    1,048,576
    Base input per million tokens
    0.3 USD
    Maximum output tokens
    128,000
    Base output per million tokens
    1.2 USD
    Reasoning
    Supported
    Image URLs
    Unknown
    PDF URLs
    Supported
    PDF bytes
    Supported
    JSON Schema output
    Unknown
    Pydantic output
    Unknown

Provider-specific features and limitations

  • Send the full message history on each turn. For supported PDFs, the adapter calls Mistral OCR and reports page charges separately from the model’s token costs.
  • Use organization="mistral" for native Mistral models. For a model from another developer hosted by Mistral, keep the developer’s organization and set service_provider="mistral".

Metered operations

  • OCR · mistral-ocr-4-1 · 0.004 USD per page

Resources