Mistral Python Client
Migrating from v1
If you are upgrading from v1 to v2, check the migration guide for details on breaking changes and how to update your code.
API Key Setup
Before you begin, you will need a Mistral AI API key.
- Get your own Mistral API Key: https://docs.mistral.ai/#api-access
- Set your Mistral API Key as an environment variable. You only need to do this once.
# set Mistral API Key (using zsh for example)
$ echo 'export MISTRAL_API_KEY=[your_key_here]' >> ~/.zshenv
# reload the environment (or just quit and open a new terminal)
$ source ~/.zshenv
Summary
Mistral AI API: Our Chat Completion and Embeddings APIs specification. Create your account on La Plateforme to get access and read the docs to learn how to use it.
Table of Contents
SDK Installation
[!NOTE] Python version upgrade policy
Once a Python version reaches its official end of life date, a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
The SDK can be installed with uv, pip, or poetry package managers.
uv
uv is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
uv add mistralai
PIP
PIP is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
pip install mistralai
Poetry
Poetry is a modern tool that simplifies dependency management and package publishing by using a single pyproject.toml file to handle project metadata and dependencies.
poetry add mistralai
Shell and script usage with uv
You can use this SDK in a Python shell with uv and the uvx command that comes with it like so:
uvx --from mistralai python
It's also possible to write a standalone Python script without needing to set up a whole project like so:
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "mistralai",
# ]
# ///
from mistralai.client import Mistral
sdk = Mistral(
# SDK arguments
)
# Rest of script here...
Once that is saved to a file, you can run it with uv run script.py where
script.py can be replaced with the actual file name.
Agents extra dependencies
When using the agents related feature it is required to add the agents extra dependencies. This can be added when
installing the package:
pip install "mistralai[agents]"
Note: These features require Python 3.10+ (the SDK minimum).
Additional packages
Additional mistralai-* packages (e.g. mistralai-workflows) can be installed separately and are available under the mistralai namespace:
pip install mistralai-workflows
SDK Example Usage
Create Chat Completions
This example shows how to create chat completions.
# Synchronous Example
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.chat.complete(model="mistral-large-latest", messages=[
{
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence.",
},
], stream=False, response_format={
"type": "text",
})
# Handle response
print(res)
The same SDK client can also be used to make asynchronous requests by importing asyncio.
# Asynchronous Example
import asyncio
from mistralai.client import Mistral
import os
async def main():
async with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = await mistral.chat.complete_async(model="mistral-large-latest", messages=[
{
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence.",
},
], stream=False, response_format={
"type": "text",
})
# Handle response
print(res)
asyncio.run(main())
Upload a file
This example shows how to upload a file.
# Synchronous Example
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.files.upload(file={
"file_name": "example.file",
"content": open("example.file", "rb"),
}, visibility="workspace")
# Handle response
print(res)
The same SDK client can also be used to make asynchronous requests by importing asyncio.
# Asynchronous Example
import asyncio
from mistralai.client import Mistral
import os
async def main():
async with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = await mistral.files.upload_async(file={
"file_name": "example.file",
"content": open("example.file", "rb"),
}, visibility="workspace")
# Handle response
print(res)
asyncio.run(main())
Create Agents Completions
This example shows how to create agents completions.
# Synchronous Example
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.agents.complete(messages=[
{
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence.",
},
], agent_id="<id>", stream=False, response_format={
"type": "text",
})
# Handle response
print(res)
The same SDK client can also be used to make asynchronous requests by importing asyncio.
# Asynchronous Example
import asyncio
from mistralai.client import Mistral
import os
async def main():
async with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = await mistral.agents.complete_async(messages=[
{
"role": "user",
"content": "Who is the best French painter? Answer in one short sentence.",
},
], agent_id="<id>", stream=False, response_format={
"type": "text",
})
# Handle response
print(res)
asyncio.run(main())
Create Embedding Request
This example shows how to create embedding request.
# Synchronous Example
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.embeddings.create(model="mistral-embed", inputs=[
"Embed this sentence.",
"As well as this one.",
])
# Handle response
print(res)
The same SDK client can also be used to make asynchronous requests by importing asyncio.
# Asynchronous Example
import asyncio
from mistralai.client import Mistral
import os
async def main():
async with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = await mistral.embeddings.create_async(model="mistral-embed", inputs=[
"Embed this sentence.",
"As well as this one.",
])
# Handle response
print(res)
asyncio.run(main())
More examples
You can run the examples in the examples/ directory using uv run.
Providers' SDKs Example Usage
Azure AI
Prerequisites
Before you begin, ensure you have AZURE_ENDPOINT and an AZURE_API_KEY. To obtain these, you will need to deploy Mistral on Azure AI.
See instructions for deploying Mistral on Azure AI here.
Step 1: Install
pip install mistralai
Step 2: Example Usage
Here's a basic example to get you started. You can also run the example in the examples directory.
import os
from mistralai.azure.client import MistralAzure
# The SDK automatically injects api-version as a query parameter
client = MistralAzure(
api_key=os.environ["AZURE_API_KEY"],
server_url=os.environ["AZURE_ENDPOINT"],
api_version="2024-05-01-preview", # Optional, this is the default
)
res = client.chat.complete(
model=os.environ["AZURE_MODEL"],
messages=[
{
"role": "user",
"content": "Hello there!",
}
],
)
print(res.choices[0].message.content)
Google Cloud
Prerequisites
Before you begin, you will need to create a Google Cloud project and enable the Mistral API. To do this, follow the instructions here.
To run this locally you will also need to ensure you are authenticated with Google Cloud. You can do this by running
gcloud auth application-default login
Step 1: Install
pip install mistralai
# For GCP authentication support (required):
pip install "mistralai[gcp]"
Step 2: Example Usage
Here's a basic example to get you started. You can also run the example in the examples directory.
The SDK automatically:
- Detects credentials via
google.auth.default() - Auto-refreshes tokens when they expire
- Builds the Vertex AI URL from
project_idandregion
import os
from mistralai.gcp.client import MistralGCP
# The SDK auto-detects credentials and builds the Vertex AI URL
client = MistralGCP(
project_id=os.environ.get("GCP_PROJECT_ID"), # Optional: auto-detected from credentials
region="us-central1", # Default: europe-west4
)
res = client.chat.complete(
model="mistral-small-2503",
messages=[
{
"role": "user",
"content": "Hello there!",
}
],
)
print(res.choices[0].message.content)
Available Resources and Operations
Available methods
Agents
Audio.Speech
- complete - Speech
Audio.Transcriptions
Audio.Voices
- list - List all voices
- create - Create a new voice
- delete - Delete a custom voice
- update - Update voice metadata
- get - Get voice details
- get_sample_audio - Get voice sample audio
Batch.Jobs
- list - Get Batch Jobs
- create - Create Batch Job
- get - Get Batch Job
- delete - Delete Batch Job
- cancel - Cancel Batch Job
Beta.Agents
- create - Create a agent that can be used within a conversation.
- list - List agent entities.
- get - Retrieve an agent entity.
- update - Update an agent entity.
- delete - Delete an agent entity.
- update_version - Update an agent version.
- list_versions - List all versions of an agent.
- get_version - Retrieve a specific version of an agent.
- create_version_alias - Create or update an agent version alias.
- list_version_aliases - List all aliases for an agent.
- delete_version_alias - Delete an agent version alias.
Beta.Connectors
- create - Create a new connector.
- list - List all connectors.
- get_auth_url - Get the auth URL for a connector.
- call_tool - Call Connector Tool
- list_tools - List tools for a connector.
- get - Get a connector.
- update - Update a connector.
- delete - Delete a connector.
Beta.Conversations
- start - Create a conversation and append entries to it.
- list - List all created conversations.
- get - Retrieve a conversation information.
- delete - Delete a conversation.
- append - Append new entries to an existing conversation.
- get_history - Retrieve all entries in a conversation.
- get_messages - Retrieve all messages in a conversation.
- restart - Restart a conversation starting from a given entry.
- start_stream - Create a conversation and append entries to it.
- append_stream - Append new entries to an existing conversation.
- restart_stream - Restart a conversation starting from a given entry.
Beta.Libraries
- list - List all libraries you have access to.
- create - Create a new Library.
- get - Detailed information about a specific Library.
- delete - Delete a library and all of it's document.
- update - Update a library.
Beta.Libraries.Accesses
- list - List all of the access to this library.
- update_or_create - Create or update an access level.
- delete - Delete an access level.
Beta.Libraries.Documents
- list - List documents in a given library.
- upload - Upload a new document.
- get - Retrieve the metadata of a specific document.
- update - Update the metadata of a specific document.
- delete - Delete a document.
- text_content - Retrieve the text content of a specific document.
- status - Retrieve the processing status of a specific document.
- get_signed_url - Retrieve the signed URL of a specific document.
- extracted_text_signed_url - Retrieve the signed URL of text extracted from a given document.
- reprocess - Reprocess a document.
Beta.Observability.Campaigns
- create - Create and start a new campaign
- list - Get all campaigns
- fetch - Get campaign by id
- delete - Delete a campaign
- fetch_status - Get campaign status by campaign id
- list_events - Get event ids that were selected by the given campaign
Beta.Observability.ChatCompletionEvents
- search - Get Chat Completion Events
- search_ids - Alternative to /search that returns only the IDs and that can return many IDs at once
- fetch - Get Chat Completion Event
- fetch_similar_events - Get Similar Chat Completion Events
- judge - Run Judge on an event based on the given options
Beta.Observability.ChatCompletionEvents.Fields
- list - Get Chat Completion Fields
- fetch_options - Get Chat Completion Field Options
- fetch_option_counts - Get Chat Completion Field Options Counts
Beta.Observability.Datasets
- create - Create a new empty dataset
- list - List existing datasets
- fetch - Get dataset by id
- delete - Delete a dataset
- update - Patch dataset
- list_records - List existing records in the dataset
- create_record - Add a conversation to the dataset
- import_from_campaign - Populate the dataset with a campaign
- import_from_explorer - Populate the dataset with samples from the explorer
- import_from_file - Populate the dataset with samples from an uploaded file
- import_from_playground - Populate the dataset with samples from the playground
- import_from_dataset_records - Populate the dataset with samples from another dataset
- export_to_jsonl - Export to the Files API and retrieve presigned URL to download the resulting JSONL file
- fetch_task - Get status of a dataset import task
- list_tasks - List import tasks for the given dataset
Beta.Observability.Datasets.Records
- fetch - Get the content of a given conversation from a dataset
- delete - Delete a record from a dataset
- bulk_delete - Delete multiple records from datasets
- judge - Run Judge on a dataset record based on the given options
- update_payload - Update a dataset record conversation payload
- update_properties - Update conversation properties
Beta.Observability.Judges
- create - Create a new judge
- list - Get judges with optional filtering and search
- fetch - Get judge by id
- delete - Delete a judge
- update - Update a judge
- judge_conversation - Run a saved judge on a conversation
Chat
Classifiers
- moderate - Moderations
- moderate_chat - Chat Moderations
- classify - Classifications
- classify_chat - Chat Classifications
Embeddings
- create - Embeddings
Events
- get_stream_events - Get Stream Events
- get_workflow_events - Get Workflow Events
Files
- upload - Upload File
- list - List Files
- retrieve - Retrieve File
- delete - Delete File
- download - Download File
- get_signed_url - Get Signed Url
Fim
FineTuning.Jobs
- list - Get Fine Tuning Jobs
- create - Create Fine Tuning Job
- get - Get Fine Tuning Job
- cancel - Cancel Fine Tuning Job
- start - Start Fine Tuning Job
Models
- list - List Models
- retrieve - Retrieve Model
- delete - Delete Model
- update - Update Fine Tuned Model
- archive - Archive Fine Tuned Model
- unarchive - Unarchive Fine Tuned Model
Ocr
- process - OCR
Workflows
- get_workflows - Get Workflows
- get_workflow_registrations - Get Workflow Registrations
- execute_workflow - Execute Workflow
execute_workflow_registration- Execute Workflow Registration :warning: Deprecated- get_workflow - Get Workflow
- update_workflow - Update Workflow
- get_workflow_registration - Get Workflow Registration
- archive_workflow - Archive Workflow
- unarchive_workflow - Unarchive Workflow
Workflows.Deployments
- list_deployments - List Deployments
- get_deployment - Get Deployment
Workflows.Events
- get_stream_events - Get Stream Events
- get_workflow_events - Get Workflow Events
Workflows.Executions
- get_workflow_execution - Get Workflow Execution
- get_workflow_execution_history - Get Workflow Execution History
- signal_workflow_execution - Signal Workflow Execution
- query_workflow_execution - Query Workflow Execution
- terminate_workflow_execution - Terminate Workflow Execution
- batch_terminate_workflow_executions - Batch Terminate Workflow Executions
- cancel_workflow_execution - Cancel Workflow Execution
- batch_cancel_workflow_executions - Batch Cancel Workflow Executions
- reset_workflow - Reset Workflow
- update_workflow_execution - Update Workflow Execution
- get_workflow_execution_trace_otel - Get Workflow Execution Trace Otel
- get_workflow_execution_trace_summary - Get Workflow Execution Trace Summary
- get_workflow_execution_trace_events - Get Workflow Execution Trace Events
- stream - Stream
Workflows.Metrics
- get_workflow_metrics - Get Workflow Metrics
Workflows.Runs
- list_runs - List Runs
- get_run - Get Run
- get_run_history - Get Run History
Workflows.Schedules
- get_schedules - Get Schedules
- schedule_workflow - Schedule Workflow
- unschedule_workflow - Unschedule Workflow
Workflows.Workers
- whoami - Get Worker Info
Server-sent event streaming
Server-sent events are used to stream content from certain
operations. These operations will expose the stream as Generator that
can be consumed using a simple for loop. The loop will
terminate when the server no longer has any events to send and closes the
underlying connection.
The stream is also a Context Manager and can be used with the with statement and will close the
underlying connection when the context is exited.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.audio.speech.complete(input="<value>", stream=False, additional_properties={
})
with res as event_stream:
for event in event_stream:
# handle event
print(event, flush=True)
Pagination
Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the
returned response object will have a Next method that can be called to pull down the next group of results. If the
return value of Next is None, then there are no more pages to be fetched.
Here's an example of one such pagination call:
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.workflows.get_workflows(active_only=False, include_shared=True, limit=50)
while res is not None:
# Handle items
res = res.next()
File uploads
Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
[!TIP]
For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.audio.transcriptions.complete(model="Model X", diarize=False)
# Handle response
print(res)
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a RetryConfig object to the call:
from mistralai.client import Mistral
from mistralai.client.utils import BackoffStrategy, RetryConfig
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.audio.speech.complete(input="<value>", stream=False, additional_properties={
},
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
with res as event_stream:
for event in event_stream:
# handle event
print(event, flush=True)
If you'd like to override the default retry strategy for all operations that support retries, you can use the retry_config optional parameter when initializing the SDK:
from mistralai.client import Mistral
from mistralai.client.utils import BackoffStrategy, RetryConfig
import os
with Mistral(
retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.audio.speech.complete(input="<value>", stream=False, additional_properties={
})
with res as event_stream:
for event in event_stream:
# handle event
print(event, flush=True)
Error Handling
MistralError is the base class for all HTTP error responses. It has the following properties:
| Property | Type | Description |
|---|---|---|
err.message |
str |
Error message |
err.status_code |
int |
HTTP response status code eg 404 |
err.headers |
httpx.Headers |
HTTP response headers |
err.body |
str |
HTTP body. Can be empty string if no body is returned. |
err.raw_response |
httpx.Response |
Raw HTTP response |
err.data |
Optional. Some errors may contain structured data. See Error Classes. |
Example
from mistralai.client import Mistral, errors
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = None
try:
res = mistral.audio.speech.complete(input="<value>", stream=False, additional_properties={
})
with res as event_stream:
for event in event_stream:
# handle event
print(event, flush=True)
except errors.MistralError as e:
# The base class for HTTP error responses
print(e.message)
print(e.status_code)
print(e.body)
print(e.headers)
print(e.raw_response)
# Depending on the method different errors may be thrown
if isinstance(e, errors.HTTPValidationError):
print(e.data.detail) # Optional[List[models.ValidationError]]
Error Classes
Primary error:
MistralError: The base class for HTTP error responses.
Less common errors (7)
Network errors:
httpx.RequestError: Base class for request errors.httpx.ConnectError: HTTP client was unable to make a request to a server.httpx.TimeoutException: HTTP request timed out.
Inherit from MistralError:
HTTPValidationError: Validation Error. Status code422. Applicable to 103 of 169 methods.*ObservabilityError: Bad Request - Invalid request parameters or data. Applicable to 41 of 169 methods.*ResponseValidationError: Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via thecauseattribute.
* Check the method documentation to see if the error is applicable.
Server Selection
Select Server by Name
You can override the default server globally by passing a server name to the server: str optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
| Name | Server | Description |
|---|---|---|
eu |
https://api.mistral.ai |
EU Production server |
Example
from mistralai.client import Mistral
import os
with Mistral(
server="eu",
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.audio.speech.complete(input="<value>", stream=False, additional_properties={
})
with res as event_stream:
for event in event_stream:
# handle event
print(event, flush=True)
Override Server URL Per-Client
The default server can also be overridden globally by passing a URL to the server_url: str optional parameter when initializing the SDK client instance. For example:
from mistralai.client import Mistral
import os
with Mistral(
server_url="https://api.mistral.ai",
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.audio.speech.complete(input="<value>", stream=False, additional_properties={
})
with res as event_stream:
for event in event_stream:
# handle event
print(event, flush=True)
Custom HTTP Client
The Python SDK makes API calls using the httpx HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
Depending on whether you are using the sync or async version of the SDK, you can pass an instance of HttpClient or AsyncHttpClient respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of httpx.Client or httpx.AsyncClient directly.
For example, you could specify a header for every request that this sdk makes as follows:
from mistralai.client import Mistral
import httpx
http_client = httpx.Client(headers={"x-custom-header": "someValue"})
s = Mistral(client=http_client)
or you could wrap the client with your own custom logic:
from mistralai.client import Mistral
from mistralai.client.httpclient import AsyncHttpClient
import httpx
class CustomClient(AsyncHttpClient):
client: AsyncHttpClient
def __init__(self, client: AsyncHttpClient):
self.client = client
async def send(
self,
request: httpx.Request,
*,
stream: bool = False,
auth: Union[
httpx._types.AuthTypes, httpx._client.UseClientDefault, None
] = httpx.USE_CLIENT_DEFAULT,
follow_redirects: Union[
bool, httpx._client.UseClientDefault
] = httpx.USE_CLIENT_DEFAULT,
) -> httpx.Response:
request.headers["Client-Level-Header"] = "added by client"
return await self.client.send(
request, stream=stream, auth=auth, follow_redirects=follow_redirects
)
def build_request(
self,
method: str,
url: httpx._types.URLTypes,
*,
content: Optional[httpx._types.RequestContent] = None,
data: Optional[httpx._types.RequestData] = None,
files: Optional[httpx._types.RequestFiles] = None,
json: Optional[Any] = None,
params: Optional[httpx._types.QueryParamTypes] = None,
headers: Optional[httpx._types.HeaderTypes] = None,
cookies: Optional[httpx._types.CookieTypes] = None,
timeout: Union[
httpx._types.TimeoutTypes, httpx._client.UseClientDefault
] = httpx.USE_CLIENT_DEFAULT,
extensions: Optional[httpx._types.RequestExtensions] = None,
) -> httpx.Request:
return self.client.build_request(
method,
url,
content=content,
data=data,
files=files,
json=json,
params=params,
headers=headers,
cookies=cookies,
timeout=timeout,
extensions=extensions,
)
s = Mistral(async_client=CustomClient(httpx.AsyncClient()))
Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
| Name | Type | Scheme | Environment Variable |
|---|---|---|---|
api_key |
http | HTTP Bearer | MISTRAL_API_KEY |
To authenticate with the API the api_key parameter must be set when initializing the SDK client instance. For example:
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.audio.speech.complete(input="<value>", stream=False, additional_properties={
})
with res as event_stream:
for event in event_stream:
# handle event
print(event, flush=True)
Resource Management
The Mistral class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a context manager and reuse it across the application.
from mistralai.client import Mistral
import os
def main():
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
# Rest of application here...
# Or when using async:
async def amain():
async with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
# Rest of application here...
Debugging
You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass your own logger class directly into your SDK.
from mistralai.client import Mistral
import logging
logging.basicConfig(level=logging.DEBUG)
s = Mistral(debug_logger=logging.getLogger("mistralai.client"))
You can also enable a default debug logger by setting an environment variable MISTRAL_DEBUG to true.
IDE Support
PyCharm
Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
Development
Contributions
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.