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 GCP BaseSDK

From Leeroopedia
Knowledge Sources
Domains SDK_Infrastructure, Cloud_Integration
Last Updated 2026-02-15 14:00 GMT

Overview

Concrete tool for building and executing HTTP requests in the GCP variant of the Mistral Python SDK.

Description

The BaseSDK class is the foundational request-handling layer for the mistralai_gcp package. Auto-generated by Speakeasy, it encapsulates all HTTP communication logic including URL construction, header management, security credential injection, request body serialization, and response processing. It provides both synchronous (do_request) and asynchronous (do_request_async) execution paths with integrated hook lifecycle support (before_request, after_success, after_error) and configurable retry logic via RetryConfig. This is structurally identical to the Azure BaseSDK but imports from the mistralai_gcp namespace.

Usage

This class is not imported directly by end users. It serves as the base class for MistralGoogleCloud (the top-level GCP SDK client), the Chat resource class, and the FIM resource class. Understanding its internals is relevant when debugging request failures, implementing custom hooks, or tracing the SDK request lifecycle.

Code Reference

Source Location

Signature

class BaseSDK:
    sdk_configuration: SDKConfiguration
    parent_ref: Optional[object] = None

    def __init__(
        self,
        sdk_config: SDKConfiguration,
        parent_ref: Optional[object] = None,
    ) -> None: ...

    def do_request(
        self,
        hook_ctx,
        request,
        error_status_codes,
        stream=False,
        retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
    ) -> httpx.Response: ...

    async def do_request_async(
        self,
        hook_ctx,
        request,
        error_status_codes,
        stream=False,
        retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
    ) -> httpx.Response: ...

Import

from mistralai_gcp.basesdk import BaseSDK

I/O Contract

Inputs

Name Type Required Description
sdk_config SDKConfiguration Yes SDK configuration with client, hooks, and server details
parent_ref Optional[object] No Reference to root SDK instance to prevent garbage collection during streaming
hook_ctx HookContext Yes Context passed through the hook lifecycle
request httpx.Request Yes The built HTTP request to execute
error_status_codes List[str] Yes Status code patterns that indicate errors
stream bool No Whether to stream the response (default False)
retry_config Optional[Tuple[RetryConfig, List[str]]] No Retry configuration and retryable status codes

Outputs

Name Type Description
httpx.Response httpx.Response The HTTP response from the Mistral API via GCP

Usage Examples

Internal Usage (how Chat and FIM resources use BaseSDK)

# BaseSDK is used internally by the Chat and FIM resource classes.
# End users interact with MistralGoogleCloud, which inherits from BaseSDK.
from mistralai_gcp import MistralGoogleCloud

client = MistralGoogleCloud(
    region="us-central1",
    project_id="my-gcp-project"
)

# The chat.complete() method internally calls BaseSDK.do_request()
response = client.chat.complete(
    model="mistral-large-latest",
    messages=[{"role": "user", "content": "Hello"}]
)

Related Pages

Page Connections

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