Skip to content
Merged
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
  •  
  •  
  •  
4,824 changes: 2,637 additions & 2,187 deletions .speakeasy/gen.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ generation:
requestBodyFieldName: ""
versioningStrategy: automatic
persistentEdits:
enabled: "true"
enabled: "false"
tests:
generateTests: true
generateNewTests: false
skipResponseBodyAssertions: false
python:
version: 2.10.1
version: 3.0.0
additionalDependencies:
dev:
pytest: ^8.2.2
Expand Down Expand Up @@ -70,7 +70,7 @@ python:
flatteningOrder: parameters-first
forwardCompatibleEnumsByDefault: true
forwardCompatibleUnionsByDefault: tagged-only
httpClientLibrary: httpx
httpClientLibrary: httpx2
imports:
option: openapi
paths:
Expand Down
14 changes: 7 additions & 7 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ sources:
- speakeasy-mistralai-gcp-sdk-26292830187-1
mistral-openapi:
sourceNamespace: mistral-openapi
sourceRevisionDigest: sha256:ad1adbc7f2f353506f09eca50c0b4e8b7fb67e957c5a10255fdc13d39326a8b7
sourceBlobDigest: sha256:48bb84a33d45aae9398fe68d784075714aee477a0db99cd13b064bab7957dd44
sourceRevisionDigest: sha256:5c136a8e459fca0edf36b519df7d0656c349368e5d8d7783bf0fa9fed34f38b3
sourceBlobDigest: sha256:cd1f89be90a7f5c6d27326308ce3d905f47830c99abe7f1fea69dc6647e1a320
tags:
- latest
- 1.0.0
Expand All @@ -39,10 +39,10 @@ targets:
mistralai-sdk:
source: mistral-openapi
sourceNamespace: mistral-openapi
sourceRevisionDigest: sha256:ad1adbc7f2f353506f09eca50c0b4e8b7fb67e957c5a10255fdc13d39326a8b7
sourceBlobDigest: sha256:48bb84a33d45aae9398fe68d784075714aee477a0db99cd13b064bab7957dd44
codeSamplesNamespace: mistral-openapi-code-samples
codeSamplesRevisionDigest: sha256:16a44c72d8d7bbecf2b558d34615ffb4a639ab0cd29ecfe94500fc7786d69438
sourceRevisionDigest: sha256:5c136a8e459fca0edf36b519df7d0656c349368e5d8d7783bf0fa9fed34f38b3
sourceBlobDigest: sha256:cd1f89be90a7f5c6d27326308ce3d905f47830c99abe7f1fea69dc6647e1a320
codeSamplesNamespace: mistral-openapi-python-code-samples
codeSamplesRevisionDigest: sha256:3c3e420f5d5c47961f3273528d7f7d733d5a994f148e7f7fe4536fa712be4232
workflow:
workflowVersion: 1.0.0
speakeasyVersion: 1.796.4
Expand Down Expand Up @@ -89,5 +89,5 @@ workflow:
token: $pypi_token
codeSamples:
registry:
location: registry.speakeasyapi.dev/mistral-dev/mistral-dev/mistral-openapi-code-samples
location: registry.speakeasyapi.dev/mistral-dev/mistral-dev/mistral-openapi-python-code-samples
blocking: false
97 changes: 97 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,100 @@
# Migration Guide: v2.x to v3.x

Imports, core method names (`chat.complete`, `embeddings.create`, `files.upload`, ...) and the Python minimum (`>=3.10`) are unchanged. The breaking changes are the HTTP transport and a handful of beta and workflow APIs.

## HTTPX2 and MCP 2.2

The SDK depends on `httpx2` instead of `httpx`, and the `agents` extra on `mcp>=2.2,<3`. This also applies to `MistralAzure` and `MistralGCP`.

- A custom HTTP client must be the HTTPX2 equivalent:

```python
import httpx2
from mistralai.client import Mistral

client = Mistral(
api_key="...",
client=httpx2.Client(timeout=60),
async_client=httpx2.AsyncClient(timeout=60),
)
```

- Raw requests and responses exposed on results and errors are `httpx2` types; catch `httpx2` exceptions instead of `httpx` ones.
- `mistral.beta.connectors.http_client()` returns an `httpx2.AsyncClient`.
- MCP results use MCP 2.2 field names, e.g. `structured_content` instead of `structuredContent`.

## Service-Account Authentication

`Mistral()` reads a service-account token from the file at `MISTRAL_SA_TOKEN_PATH` when one is configured. Credentials resolve in this order:

1. An `Authorization` header you set yourself, through `http_headers` or per request
2. An explicit `api_key` or `security` passed to the client
3. The token file at `MISTRAL_SA_TOKEN_PATH`
4. `MISTRAL_API_KEY`

Set both `MISTRAL_SA_TOKEN_PATH` and `MISTRAL_API_KEY` and the token file wins, so an environment carrying both authenticates as the service account where v2 used the API key.

The file is re-read on every request so rotation is picked up without a restart. If `MISTRAL_SA_TOKEN_PATH` is set but the file is missing, unreadable or empty, every request that would otherwise use the token file or `MISTRAL_API_KEY` raises `ServiceAccountTokenError`, with no fallback; unset the variable rather than leaving it pointing at a path that does not exist. An explicit `api_key` or `security` short-circuits the lookup, so it is unaffected.

The token is sent to whatever `server_url` the client is configured with. `MistralAzure` and `MistralGCP` do not read it.

## Chat and Agents Completions

`chat.complete`, `chat.stream`, `agents.complete` and `agents.stream` no longer accept the `web_search`, `web_search_premium` and `code_interpreter` tools. Use them through the Conversations API (`beta.conversations`) or an agent created with `beta.agents.create`, where `WebSearchTool`, `WebSearchPremiumTool` and `CodeInterpreterTool` remain available.

## Connectors (beta)

The three credential deletions are one method with a scope:

| v2 | v3 |
|---|---|
| `beta.connectors.delete_user_credentials(...)` | `beta.connectors.delete_credentials(..., consumer_scope="user")` |
| `beta.connectors.delete_workspace_credentials(...)` | `beta.connectors.delete_credentials(..., consumer_scope="workspace")` |
| `beta.connectors.delete_organization_credentials(...)` | `beta.connectors.delete_credentials(..., consumer_scope="organization")` |

The `ConnectorDelete{User,Workspace,Organization}CredentialsV1Request` models are replaced by `ConnectorDeleteCredentialsRequest`.

- `beta.connectors.get()`: `fetch_customer_data` removed.
- `beta.connectors.list_tools()`: `page` removed; all tools are returned in one response.
- `beta.connectors.list()`: `query_filters.active` removed.

## Observability Pipeline Configs (beta)

A pipeline config holds a single definition:

| v2 | v3 |
|---|---|
| `create_pipeline_config(..., definitions=[d])` | `create_pipeline_config(..., definition=d)` |
| `update_pipeline_config(..., definitions=[d])` | `update_pipeline_config(..., definition=d)` |
| `config.definitions[0]` | `config.definition` |

`PipelineConfig.definitions` is still returned, as `[definition]`, but is now optional.

## Workflow Deployments

- The `koyeb` backend is now Mistral Cloud: `DeploymentKoyebBackendSpec` is replaced by `DeploymentMistralCloudBackendSpec` (`type="mistral_cloud"`). Requests accept only this backend; the Kubernetes backend can no longer be set.
- `DeploymentResourceConfig` and `DeploymentResourceConfigUpdate` keep only `replicas`; `cpu_request`, `cpu_limit`, `memory_request` and `memory_limit` are removed.
- `entrypoint` and `working_dir` are removed from `DeploymentWorkerSpecInput` and `WorkflowsWorkerSpecUpdate`, and together with `commit_sha` from `DeploymentWorkerSpecResponse`.
- `UnknownDeploymentWorkerSpecResponseBackendSpec` is renamed `UnknownBackendSpec`.

## Users (beta)

`beta.users.get_identity()`, `list_organizations()` and `list_workspaces()` accept either an API key or a bearer token, so both fields of their security models are optional. Set one of them; passing neither is rejected with a 401:

```python
import os
from mistralai.client import Mistral, models

with Mistral() as mistral:
res = mistral.beta.users.get_identity(
security=models.UsersAPIGetIdentitySecurity(
dashboard_user_context_auth=os.environ["MISTRAL_API_KEY"],
)
)
```

---

# Migration Guide: v1.x to v2.x

## Import Changes
Expand Down
Loading
Loading