Implementation:Mistralai Client python GCP ChatCompletionStreamRequest
| Knowledge Sources | |
|---|---|
| Domains | Chat_Completion, Streaming, Cloud_Integration |
| Last Updated | 2026-02-15 14:00 GMT |
Overview
Concrete tool for defining the request body of streaming chat completions in the GCP Mistral SDK.
Description
The ChatCompletionStreamRequest class is the streaming counterpart of ChatCompletionRequest for GCP-hosted Mistral models. It requires model as a mandatory string field (no default, unlike Azure's "azureai" default) and defaults stream to True. It shares the same message and parameter types as the non-streaming variant. Compared to the Azure version, the GCP streaming request does not include the safe_prompt parameter.
Usage
Import this model when constructing streaming chat completion requests for GCP-deployed Mistral models. The Chat.stream() method constructs this internally.
Code Reference
Source Location
- Repository: Mistralai_Client_python
- File: packages/mistralai_gcp/src/mistralai_gcp/models/chatcompletionstreamrequest.py
- Lines: 1-213
Signature
class ChatCompletionStreamRequest(BaseModel):
model: str
messages: List[Messages]
temperature: OptionalNullable[float] = UNSET
top_p: Optional[float] = None
max_tokens: OptionalNullable[int] = UNSET
stream: Optional[bool] = True
stop: Optional[Stop] = None
random_seed: OptionalNullable[int] = UNSET
metadata: OptionalNullable[Dict[str, Any]] = UNSET
response_format: Optional[ResponseFormat] = None
tools: OptionalNullable[List[Tool]] = UNSET
tool_choice: Optional[ChatCompletionStreamRequestToolChoice] = None
presence_penalty: Optional[float] = None
frequency_penalty: Optional[float] = None
n: OptionalNullable[int] = UNSET
prediction: Optional[Prediction] = None
parallel_tool_calls: Optional[bool] = None
prompt_mode: OptionalNullable[MistralPromptMode] = UNSET
Import
from mistralai_gcp.models import ChatCompletionStreamRequest
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| model | str | Yes | Model ID (required, no default) |
| messages | List[Messages] | Yes | Conversation messages (System, User, Assistant, Tool) |
| temperature | OptionalNullable[float] | No | Sampling temperature |
| max_tokens | OptionalNullable[int] | No | Maximum tokens to generate |
| stream | Optional[bool] | No | Streaming flag (defaults to True) |
| tools | OptionalNullable[List[Tool]] | No | Available tools for function calling |
| tool_choice | Optional[Union[ToolChoice, ToolChoiceEnum]] | No | Tool selection strategy |
Outputs
| Name | Type | Description |
|---|---|---|
| Serialized dict | Dict[str, Any] | JSON-serializable streaming request body |
Usage Examples
Building a GCP Streaming Request
from mistralai_gcp.models import (
ChatCompletionStreamRequest,
UserMessage,
)
request = ChatCompletionStreamRequest(
model="mistral-large-latest", # Required for GCP
messages=[
UserMessage(content="Explain quantum computing in simple terms."),
],
temperature=0.5,
max_tokens=500,
)
# stream defaults to True
assert request.stream is True