Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Mistralai Client python MistralGoogleCloud Init

From Leeroopedia
Knowledge Sources
Domains Cloud_Deployment, GCP, API_Client
Last Updated 2026-02-15 14:00 GMT

Overview

Concrete tool for creating a GCP Vertex AI-specific Mistral client with automatic URL rewriting and Google credential authentication.

Description

The MistralGoogleCloud class creates a client for Mistral models on GCP Vertex AI. It accepts project_id, region (default "europe-west4"), and optionally an access_token. If no token is provided, it uses Google Application Default Credentials. The constructor registers a GoogleCloudBeforeRequestHook that rewrites all API request URLs to the Vertex AI rawPredict format. The client exposes .chat and .fim sub-SDKs.

Usage

Install mistralai_gcp (or mistralai[gcp]) and authenticate with gcloud auth application-default login. Then instantiate with your GCP project ID and desired region.

Code Reference

Source Location

  • Repository: client-python
  • File: packages/mistralai_gcp/src/mistralai_gcp/sdk.py
  • Lines: L47-164

Signature

class MistralGoogleCloud:
    def __init__(
        self,
        region: str = "europe-west4",
        project_id: Optional[str] = None,
        access_token: Optional[str] = None,
        retry_config: OptionalNullable[RetryConfig] = UNSET,
        timeout_ms: Optional[int] = None,
        http_client: Optional[HttpClient] = None,
        async_http_client: Optional[AsyncHttpClient] = None,
        debug_logger: Optional[Logger] = None,
    ):
        """
        Args:
            region: GCP region (default: "europe-west4").
            project_id: GCP project ID (auto-detected from ADC if not set).
            access_token: Manual OAuth2 token (bypasses ADC).
            retry_config: Retry configuration.
            timeout_ms: Timeout in milliseconds.
        """

Import

from mistralai_gcp import MistralGoogleCloud

I/O Contract

Inputs

Name Type Required Description
region str No GCP region (default: "europe-west4")
project_id Optional[str] No GCP project ID; auto-detected from ADC if omitted
access_token Optional[str] No Manual OAuth2 token; bypasses ADC
retry_config OptionalNullable[RetryConfig] No Retry configuration

Outputs

Name Type Description
MistralGoogleCloud instance MistralGoogleCloud Client with .chat and .fim sub-SDKs, URLs auto-rewritten to Vertex AI format

Usage Examples

Basic GCP Client

from mistralai_gcp import MistralGoogleCloud

# Using Application Default Credentials
client = MistralGoogleCloud(
    region="europe-west4",
    project_id="my-gcp-project",
)

response = client.chat.complete(
    model="mistral-large-latest",
    messages=[{"role": "user", "content": "Hello from GCP!"}],
)
print(response.choices[0].message.content)

With Explicit Token

from mistralai_gcp import MistralGoogleCloud

client = MistralGoogleCloud(
    region="us-central1",
    project_id="my-project",
    access_token="ya29.xxx...",  # Manual OAuth2 token
)

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment