Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ management:
docVersion: 1.0.0
speakeasyVersion: 1.685.0
generationVersion: 2.794.1
releaseVersion: 2.0.0a3
configChecksum: 7fc1ba01c21def8447b979e71593af4a
releaseVersion: 2.0.0a4
configChecksum: ba32c03a012ed288fd25d0468115c501
repoURL: https://github.com/mistralai/client-python.git
installationURL: https://github.com/mistralai/client-python.git
published: true
persistentEdits:
generation_id: 3aa9018f-cb6c-4c1b-96d0-b832fd5f6513
pristine_commit_hash: 5c4e3b65b7572c91338d50dc3ca91ea6a46eedf7
pristine_tree_hash: aaea604044e12872107c3b550ea7be094fb66a99
generation_id: 9a42b13b-8fe7-416e-b97e-9a713b61df12
pristine_commit_hash: fe97508889702d0b0a1bb4615bc6ff682ded6104
pristine_tree_hash: 38fd75708b2c808e2a9d1e51b4129f9dd94676f1
features:
python:
additionalDependencies: 1.0.0
Expand Down Expand Up @@ -1686,8 +1686,8 @@ trackedFiles:
pristine_git_object: 036d44b8cfc51599873bd5c401a6aed30450536c
src/mistralai/client/_version.py:
id: cc807b30de19
last_write_checksum: sha1:dd6d1521f7ecfc56be58eafc1709873a04d27fb0
pristine_git_object: 814d9ec74a37ae50f106ea07b3c174e65685521b
last_write_checksum: sha1:67bfbc4ca7bff931843370465ed647cd885b8668
pristine_git_object: 78591b3e820d9368eeedac50bb5a11242bc8e9cc
src/mistralai/client/accesses.py:
id: 76fc53bfcf59
last_write_checksum: sha1:16574ca54176ec30b236ab1a4694f57a6314db43
Expand Down
2 changes: 1 addition & 1 deletion .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ generation:
generateNewTests: false
skipResponseBodyAssertions: false
python:
version: 2.0.0a3
version: 2.0.0a4
additionalDependencies:
dev:
pytest: ^8.2.2
Expand Down
6 changes: 3 additions & 3 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ targets:
sourceRevisionDigest: sha256:d303e640ad565cc8a9801519b20dc7eab226efdfdab951c11256962d9e479f74
sourceBlobDigest: sha256:6e4c789de61b2c9c604bf581e0abbadae90e360491d95ec4247678f4f70cee87
codeSamplesNamespace: mistral-openapi-azure-code-samples
codeSamplesRevisionDigest: sha256:0109302b87fa17b0103ef1e372fae76356811b3c552103e659bd5373d537d759
codeSamplesRevisionDigest: sha256:8711f9530be8d85c07ddd45d57cb9f66471faa6c890b63c86bb26c602a552a3c
mistralai-gcp-sdk:
source: mistral-google-cloud-source
sourceNamespace: mistral-openapi-google-cloud
sourceRevisionDigest: sha256:351c4d392b8b2220c337a207e98ed5665ed27fd85de854871a70c4bc2b9c0784
sourceBlobDigest: sha256:d79b21f70efb93b0cd261d2044939a288beaf8707a7caae86aca5c4d5de3821b
codeSamplesNamespace: mistral-openapi-google-cloud-code-samples
codeSamplesRevisionDigest: sha256:09bb7cbf291076170d228116db05d1c9606af541b301b6564609c4d76633258a
codeSamplesRevisionDigest: sha256:be70721be1bcbef628ebca0ae3b3321c869d7e5abca8beb5451ba0abb7f2f425
mistralai-sdk:
source: mistral-openapi
sourceNamespace: mistral-openapi
sourceRevisionDigest: sha256:74d0de7750f6a1878b68c9da683eba7a447d7c367131d0cb8f5c3b1e05829624
sourceBlobDigest: sha256:41e8354c48993fc29be68959d835ea4f8e0cc1d4b4fbd527afcd970bc02c62a2
codeSamplesNamespace: mistral-openapi-code-samples
codeSamplesRevisionDigest: sha256:f37fb6188ad25957bef4cadaa03f454a4f9ab0c045db633a46d9cc89af145ba2
codeSamplesRevisionDigest: sha256:99fcae1bc81801e3825648a44f5ffa62a8f124e3186e5570be40414de164e7f2
workflow:
workflowVersion: 1.0.0
speakeasyVersion: 1.685.0
Expand Down
20 changes: 20 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ from mistralai.client.types import BaseModel
| `from mistralai.types import ...` | `from mistralai.client.types import ...` |
| `from mistralai.utils import ...` | `from mistralai.client.utils import ...` |

### Azure & GCP Import Changes

Azure and GCP SDKs now live under the `mistralai` namespace as separate distributions:

| v1 | v2 |
|---|---|
| `from mistralai_azure import MistralAzure` | `from mistralai.azure.client import MistralAzure` |
| `from mistralai_azure.models import ...` | `from mistralai.azure.client.models import ...` |
| `from mistralai_gcp import MistralGoogleCloud` | `from mistralai.gcp.client import MistralGCP` |
| `from mistralai_gcp.models import ...` | `from mistralai.gcp.client.models import ...` |

#### Installation Changes

| v1 | v2 |
|---|---|
| `pip install mistralai` | `pip install mistralai` (includes Azure and GCP) |
| `pip install mistralai[gcp]` (for GCP auth) | `pip install "mistralai[gcp]"` (for GCP auth dependencies) |

Azure and GCP are now standalone distributions that can be installed independently of the core SDK. The `mistralai[azure]` and `mistralai[gcp]` extras are syntactic sugar that pull in the respective distributions.

### What Stays the Same

- The `Mistral` client API is unchanged
Expand Down
78 changes: 36 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,35 +372,35 @@ You can run the examples in the `examples/` directory using `uv run`.
Before you begin, ensure you have `AZUREAI_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](https://docs.mistral.ai/deployment/cloud/azure/).

**Step 1: Install**

```bash
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](/examples/azure).

```python
import asyncio
import os

from mistralai_azure import MistralAzure
from mistralai.azure.client import MistralAzure

client = MistralAzure(
azure_api_key=os.getenv("AZURE_API_KEY", ""),
azure_endpoint=os.getenv("AZURE_ENDPOINT", "")
api_key=os.getenv("AZURE_API_KEY", ""),
server_url=os.getenv("AZURE_ENDPOINT", "")
)

async def main() -> None:
res = await client.chat.complete_async(
max_tokens= 100,
temperature= 0.5,
messages= [
{
"content": "Hello there!",
"role": "user"
}
]
)
print(res)

asyncio.run(main())
res = client.chat.complete(
messages=[
{
"content": "Hello there!",
"role": "user"
}
]
)
print(res.choices[0].message.content)
```
The documentation for the Azure SDK is available [here](packages/mistralai_azure/README.md).

### Google Cloud

Expand All @@ -417,40 +417,34 @@ gcloud auth application-default login

**Step 1: Install**

Install the extras dependencies specific to Google Cloud:

```bash
pip install mistralai
# For GCP authentication support:
pip install "mistralai[gcp]"
```

**Step 2: Example Usage**

Here's a basic example to get you started.
Here's a basic example to get you started. You can also run [the example in the `examples` directory](/examples/gcp).

```python
import asyncio
from mistralai_gcp import MistralGoogleCloud

client = MistralGoogleCloud()

import os
from mistralai.gcp.client import MistralGCP

async def main() -> None:
res = await client.chat.complete_async(
model= "mistral-small-2402",
messages= [
{
"content": "Hello there!",
"role": "user"
}
]
)
print(res)
client = MistralGCP(api_key=os.getenv("GCP_API_KEY", ""))

asyncio.run(main())
res = client.chat.complete(
model="mistral-large-2407",
messages=[
{
"content": "Hello there!",
"role": "user"
}
]
)
print(res.choices[0].message.content)
```

The documentation for the GCP SDK is available [here](packages/mistralai_gcp/README.md).


<!-- Start Available Resources and Operations [operations] -->
## Available Resources and Operations
Expand Down
43 changes: 43 additions & 0 deletions docs/gen-yaml-diff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# gen.yaml Diff: Main vs Azure vs GCP

## `generation` section

| Setting | Main | Azure | GCP |
|---------|------|-------|-----|
| `sdkClassName` | `Mistral` | `MistralAzure` | `MistralGCP` |
| `nameResolutionDec2023` | `true` | `true` | `true` |
| `nameResolutionFeb2025` | `true` | `true` | `true` |
| `parameterOrderingFeb2024` | `true` | `true` | `true` |
| `requestResponseComponentNamesFeb2024` | `true` | `true` | `true` |
| `securityFeb2025` | `true` | `true` | `true` |
| `sharedErrorComponentsApr2025` | `true` | `true` | `true` |
| `methodSignaturesApr2024` | `true` | `true` | `true` |
| `sharedNestedComponentsJan2026` | `true` | `true` | `true` |

## `python` section

| Setting | Main | Azure | GCP |
|---------|------|-------|-----|
| `version` | `2.0.0a4` | `2.0.0a4` | `2.0.0a4` |
| `additionalDependencies.main` | *none* | *none* | *none* |
| `baseErrorName` | `MistralError` | `MistralAzureError` | `MistralGcpError` |
| `description` | `...Mistral AI API.` | `...in Azure.` | `...in GCP.` |
| `enableCustomCodeRegions` | `true` | `false` | `false` |
| `envVarPrefix` | `MISTRAL` | *missing* | *missing* |
| `responseRequiredSep2024` | `true` | `true` | `true` |
| `flatAdditionalProperties` | `true` | `true` | `true` |
| `forwardCompatibleEnumsByDefault` | `true` | `true` | `true` |
| `forwardCompatibleUnionsByDefault` | `tagged-only` | `tagged-only` | `tagged-only` |
| `preApplyUnionDiscriminators` | `true` | `true` | `true` |
| `moduleName` | `mistralai.client` | `mistralai.azure.client` | `mistralai.gcp.client` |
| `packageName` | `mistralai` | `mistralai-azure` | `mistralai-gcp` |

## Remaining intentional differences

All fix flags and feature flags are now aligned. The only remaining differences are expected per-target values:

- **`version`** -- all at 2.0.0a4 (versions may diverge independently)
- **`baseErrorName`** / `description` -- per-target identity
- **`enableCustomCodeRegions`** -- `false` in Azure/GCP (they have no custom code regions)
- **`envVarPrefix`** -- absent in Azure/GCP (only the main SDK reads `MISTRAL_*` env vars)
- **`moduleName`** / `packageName` -- per-target namespace
15 changes: 0 additions & 15 deletions examples/azure/az_chat_no_streaming.py

This file was deleted.

10 changes: 5 additions & 5 deletions examples/azure/chat_no_streaming.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import os

from mistralai_azure import MistralAzure
from mistralai_azure.models import ChatCompletionRequestMessages, UserMessage
from mistralai.azure.client import MistralAzure
from mistralai.azure.client.models import ChatCompletionRequestMessage, UserMessage

client = MistralAzure(
azure_api_key=os.environ["AZURE_API_KEY"],
azure_endpoint=os.environ["AZURE_ENDPOINT"],
api_key=os.environ["AZURE_API_KEY"],
server_url=os.environ["AZURE_ENDPOINT"],
)

messages: list[ChatCompletionRequestMessages] = [
messages: list[ChatCompletionRequestMessage] = [
UserMessage(content="What is the capital of France?"),
]
res = client.chat.complete(messages=messages)
Expand Down
6 changes: 3 additions & 3 deletions examples/gcp/async_chat_no_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import asyncio
import os

from mistralai_gcp import MistralGoogleCloud
from mistralai_gcp.models.usermessage import UserMessage
from mistralai.gcp.client import MistralGCP
from mistralai.gcp.client.models.usermessage import UserMessage


async def main():
model = "mistral-large-2407"

client = MistralGoogleCloud(project_id=os.environ["GCP_PROJECT_ID"])
client = MistralGCP(api_key=os.environ["GCP_API_KEY"])

chat_response = await client.chat.complete_async(
model=model,
Expand Down
24 changes: 0 additions & 24 deletions examples/gcp/gcp_async_chat_no_streaming.py

This file was deleted.

Loading