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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .genignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pyproject.toml
examples/*
/utils/*
src/mistral/extra/*
src/mistralai/extra/*
pylintrc
scripts/prepare_readme.py
26 changes: 13 additions & 13 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ speakeasyVersion: 1.685.0
sources:
mistral-azure-source:
sourceNamespace: mistral-openapi-azure
sourceRevisionDigest: sha256:d303e640ad565cc8a9801519b20dc7eab226efdfdab951c11256962d9e479f74
sourceBlobDigest: sha256:6e4c789de61b2c9c604bf581e0abbadae90e360491d95ec4247678f4f70cee87
sourceRevisionDigest: sha256:a57165e46202d35d2e53880f219fb19b35358b1bd61bfd2023606e7cdb445ed4
sourceBlobDigest: sha256:b836ce324de54e4cf0c66293d21c08a4544c6493138f4500a36ce4e071337836
tags:
- latest
mistral-google-cloud-source:
sourceNamespace: mistral-openapi-google-cloud
sourceRevisionDigest: sha256:351c4d392b8b2220c337a207e98ed5665ed27fd85de854871a70c4bc2b9c0784
sourceBlobDigest: sha256:d79b21f70efb93b0cd261d2044939a288beaf8707a7caae86aca5c4d5de3821b
sourceRevisionDigest: sha256:0f53d01014da9f064fc87a4a25c6566c268f037f9dd3a92f83b3a65d4042f945
sourceBlobDigest: sha256:26d64def9e3b1922237f7336f37e234315d402293cc78de23fafd887232b8091
tags:
- latest
mistral-openapi:
Expand All @@ -22,24 +22,24 @@ targets:
mistralai-azure-sdk:
source: mistral-azure-source
sourceNamespace: mistral-openapi-azure
sourceRevisionDigest: sha256:d303e640ad565cc8a9801519b20dc7eab226efdfdab951c11256962d9e479f74
sourceBlobDigest: sha256:6e4c789de61b2c9c604bf581e0abbadae90e360491d95ec4247678f4f70cee87
sourceRevisionDigest: sha256:a57165e46202d35d2e53880f219fb19b35358b1bd61bfd2023606e7cdb445ed4
sourceBlobDigest: sha256:b836ce324de54e4cf0c66293d21c08a4544c6493138f4500a36ce4e071337836
codeSamplesNamespace: mistral-openapi-azure-code-samples
codeSamplesRevisionDigest: sha256:0109302b87fa17b0103ef1e372fae76356811b3c552103e659bd5373d537d759
codeSamplesRevisionDigest: sha256:e7fbdb25b0273637fc1bb5bcf7f9376f009ef1564334ad0a12cc77f778fb85df
mistralai-gcp-sdk:
source: mistral-google-cloud-source
sourceNamespace: mistral-openapi-google-cloud
sourceRevisionDigest: sha256:351c4d392b8b2220c337a207e98ed5665ed27fd85de854871a70c4bc2b9c0784
sourceBlobDigest: sha256:d79b21f70efb93b0cd261d2044939a288beaf8707a7caae86aca5c4d5de3821b
sourceRevisionDigest: sha256:0f53d01014da9f064fc87a4a25c6566c268f037f9dd3a92f83b3a65d4042f945
sourceBlobDigest: sha256:26d64def9e3b1922237f7336f37e234315d402293cc78de23fafd887232b8091
codeSamplesNamespace: mistral-openapi-google-cloud-code-samples
codeSamplesRevisionDigest: sha256:09bb7cbf291076170d228116db05d1c9606af541b301b6564609c4d76633258a
codeSamplesRevisionDigest: sha256:661da477dc87ca20dbb39b16a3f4de2481b5f8c9502a49d04abb363424b51d47
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 All @@ -57,7 +57,7 @@ workflow:
mistralai-azure-sdk:
target: python
source: mistral-azure-source
output: ./packages/mistralai_azure
output: ./packages/azure
publish:
pypi:
token: $pypi_token
Expand All @@ -68,7 +68,7 @@ workflow:
mistralai-gcp-sdk:
target: python
source: mistral-google-cloud-source
output: ./packages/mistralai_gcp
output: ./packages/gcp
publish:
pypi:
token: $pypi_token
Expand Down
4 changes: 2 additions & 2 deletions .speakeasy/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ targets:
mistralai-azure-sdk:
target: python
source: mistral-azure-source
output: ./packages/mistralai_azure
output: ./packages/azure
publish:
pypi:
token: $pypi_token
Expand All @@ -25,7 +25,7 @@ targets:
mistralai-gcp-sdk:
target: python
source: mistral-google-cloud-source
output: ./packages/mistralai_gcp
output: ./packages/gcp
publish:
pypi:
token: $pypi_token
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.

6 changes: 6 additions & 0 deletions packages/azure/.genignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pyproject.toml
src/mistralai/azure/client/sdk.py
src/mistralai/azure/client/_hooks/registration.py
README.md
USAGE.md
docs/sdks/**/README.md
File renamed without changes.
File renamed without changes.
Loading
Loading