Implementation:Mistralai Client python GCP Models Init
| Knowledge Sources | |
|---|---|
| Domains | SDK_Infrastructure, Cloud_Integration |
| Last Updated | 2026-02-15 14:00 GMT |
Overview
Concrete tool for lazy-loading all model types in the GCP variant of the Mistral Python SDK.
Description
The models/__init__.py module serves as the public namespace for all data models in the mistralai_gcp package. Auto-generated by Speakeasy, it uses Python's __getattr__ protocol to implement lazy dynamic imports, loading model classes only when first accessed. It exports symbols covering message types (UserMessage, AssistantMessage, SystemMessage, ToolMessage), request/response models (ChatCompletionRequest, ChatCompletionResponse, FIMCompletionRequest, FIMCompletionResponse), error classes (MistralGcpError, SDKError), and type aliases. Compared to the Azure variant, this module additionally exports FIM (Fill-in-the-Middle) completion models.
Usage
Import individual model classes from mistralai_gcp.models when constructing requests, processing responses, or handling errors in GCP-specific Mistral API interactions.
Code Reference
Source Location
- Repository: Mistralai_Client_python
- File: packages/mistralai_gcp/src/mistralai_gcp/models/__init__.py
- Lines: 1-438
Signature
# Module-level lazy loading via __getattr__
def __getattr__(attr_name: str) -> object: ...
def __dir__() -> list: ...
# Key exported symbols include:
# ChatCompletionRequest, ChatCompletionResponse, ChatCompletionStreamRequest
# FIMCompletionRequest, FIMCompletionResponse, FIMCompletionStreamRequest
# AssistantMessage, UserMessage, SystemMessage, ToolMessage
# MistralGcpError, SDKError
# Tool, ToolCall, ToolChoice, FunctionCall, etc.
Import
from mistralai_gcp.models import ChatCompletionRequest, FIMCompletionRequest
from mistralai_gcp.models import UserMessage, AssistantMessage
from mistralai_gcp.models import MistralGcpError, SDKError
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| attr_name | str | Yes | The name of the model class to import (via __getattr__) |
Outputs
| Name | Type | Description |
|---|---|---|
| Model class | type | The requested Pydantic model class, enum, or type alias |
Usage Examples
Importing GCP Models
from mistralai_gcp.models import (
ChatCompletionRequest,
FIMCompletionRequest,
UserMessage,
SystemMessage,
)
# Chat completion request
chat_request = ChatCompletionRequest(
model="mistral-large-latest",
messages=[
UserMessage(content="What is the capital of France?")
],
)
# FIM completion request (GCP-specific)
fim_request = FIMCompletionRequest(
model="codestral-latest",
prompt="def fibonacci(n):",
suffix=" return result",
)