From 6c0ef976db10d7bba98a779d41aebb6863ec7b58 Mon Sep 17 00:00:00 2001 From: Guillaume Dumont Date: Fri, 9 Jan 2026 12:47:09 +0100 Subject: [PATCH 1/3] Fix Speakeasy targets in GitHub actions --- .github/workflows/sdk_generation_mistralai_azure_sdk.yaml | 2 +- .github/workflows/sdk_generation_mistralai_gcp_sdk.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sdk_generation_mistralai_azure_sdk.yaml b/.github/workflows/sdk_generation_mistralai_azure_sdk.yaml index ed4e94cf..167d8865 100644 --- a/.github/workflows/sdk_generation_mistralai_azure_sdk.yaml +++ b/.github/workflows/sdk_generation_mistralai_azure_sdk.yaml @@ -22,7 +22,7 @@ jobs: mode: pr set_version: ${{ github.event.inputs.set_version }} speakeasy_version: latest - target: mistral-python-sdk-azure + target: mistralai-azure-sdk secrets: github_access_token: ${{ secrets.GITHUB_TOKEN }} pypi_token: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/sdk_generation_mistralai_gcp_sdk.yaml b/.github/workflows/sdk_generation_mistralai_gcp_sdk.yaml index 4fefe244..aa753830 100644 --- a/.github/workflows/sdk_generation_mistralai_gcp_sdk.yaml +++ b/.github/workflows/sdk_generation_mistralai_gcp_sdk.yaml @@ -22,7 +22,7 @@ jobs: mode: pr set_version: ${{ github.event.inputs.set_version }} speakeasy_version: latest - target: mistral-python-sdk-google-cloud + target: mistralai-gcp-sdk secrets: github_access_token: ${{ secrets.GITHUB_TOKEN }} pypi_token: ${{ secrets.PYPI_TOKEN }} From fbc2661ec653f13c1cb289c537ff7cccdcc842b7 Mon Sep 17 00:00:00 2001 From: Guillaume Dumont Date: Fri, 9 Jan 2026 13:04:09 +0100 Subject: [PATCH 2/3] Fix the return type of GoogleCloudBeforeRequestHook#before_request --- packages/mistralai_gcp/src/mistralai_gcp/sdk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mistralai_gcp/src/mistralai_gcp/sdk.py b/packages/mistralai_gcp/src/mistralai_gcp/sdk.py index dd93cc7f..6476f851 100644 --- a/packages/mistralai_gcp/src/mistralai_gcp/sdk.py +++ b/packages/mistralai_gcp/src/mistralai_gcp/sdk.py @@ -2,7 +2,7 @@ import json import weakref -from typing import Any, Optional, cast +from typing import Any, Optional, Union, cast import google.auth import google.auth.credentials @@ -197,7 +197,7 @@ def __init__(self, region: str, project_id: str): def before_request( self, hook_ctx, request: httpx.Request - ) -> httpx.Request | Exception: + ) -> Union[httpx.Request, Exception]: # The goal of this function is to template in the region, project and model into the URL path # We do this here so that the API remains more user-friendly model_id = None From 154ad6a0be458bfe492cce1ea4bbaed3e361baec Mon Sep 17 00:00:00 2001 From: Guillaume Dumont Date: Fri, 9 Jan 2026 14:16:34 +0100 Subject: [PATCH 3/3] Stop using SDKError for non-HTTP errors during initialization The generated SDKError now requires a raw_response, which we don't have in the init or hook. --- .../mistralai_gcp/src/mistralai_gcp/sdk.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/mistralai_gcp/src/mistralai_gcp/sdk.py b/packages/mistralai_gcp/src/mistralai_gcp/sdk.py index 6476f851..de48fbbb 100644 --- a/packages/mistralai_gcp/src/mistralai_gcp/sdk.py +++ b/packages/mistralai_gcp/src/mistralai_gcp/sdk.py @@ -67,30 +67,32 @@ def __init__( :param timeout_ms: Optional request timeout applied to each operation in milliseconds """ + credentials = None if not access_token: credentials, loaded_project_id = google.auth.default( scopes=["https://www.googleapis.com/auth/cloud-platform"], ) - credentials.refresh(google.auth.transport.requests.Request()) - if not isinstance(credentials, google.auth.credentials.Credentials): - raise models.SDKError( - "credentials must be an instance of google.auth.credentials.Credentials" - ) + # default will already raise a google.auth.exceptions.DefaultCredentialsError if no credentials are found + assert isinstance( + credentials, google.auth.credentials.Credentials + ), "credentials must be an instance of google.auth.credentials.Credentials" + credentials.refresh(google.auth.transport.requests.Request()) project_id = project_id or loaded_project_id if project_id is None: - raise models.SDKError("project_id must be provided") + raise ValueError("project_id must be provided") def auth_token() -> str: if access_token: return access_token + assert credentials is not None, "credentials must be initialized" credentials.refresh(google.auth.transport.requests.Request()) token = credentials.token if not token: - raise models.SDKError("Failed to get token from credentials") + raise Exception("Failed to get token from credentials") return token client_supplied = True @@ -210,7 +212,7 @@ def before_request( new_content = json.dumps(parsed).encode("utf-8") if model_id == "": - raise models.SDKError("model must be provided") + raise ValueError("model must be provided") stream = "streamRawPredict" in request.url.path specifier = "streamRawPredict" if stream else "rawPredict"