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 Azure ChatCompletionStreamRequest

From Leeroopedia
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 Azure Mistral SDK.

Description

The ChatCompletionStreamRequest class is the streaming counterpart of ChatCompletionRequest for Azure-hosted Mistral models. It shares the same parameter set (messages, temperature, tools, etc.) but defaults stream to True. The Messages type alias defines the discriminated union of message types (UserMessage, SystemMessage, AssistantMessage, ToolMessage) used in the messages field. Like its non-streaming sibling, the model defaults to "azureai" and includes the safe_prompt parameter specific to the Azure SDK.

Usage

Import this model when constructing streaming chat completion requests for Azure-deployed Mistral models. The Chat.stream() method constructs this internally.

Code Reference

Source Location

Signature

class ChatCompletionStreamRequest(BaseModel):
    messages: List[Messages]
    model: Optional[str] = "azureai"
    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
    safe_prompt: Optional[bool] = None

Import

from mistralai_azure.models import ChatCompletionStreamRequest

I/O Contract

Inputs

Name Type Required Description
messages List[Messages] Yes Conversation messages (System, User, Assistant, Tool)
model Optional[str] No Model ID (defaults to "azureai")
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
safe_prompt Optional[bool] No Whether to inject safety prompt

Outputs

Name Type Description
Serialized dict Dict[str, Any] JSON-serializable streaming request body

Usage Examples

Building a Streaming Request

from mistralai_azure.models import (
    ChatCompletionStreamRequest,
    UserMessage,
)

request = ChatCompletionStreamRequest(
    messages=[
        UserMessage(content="Explain quantum computing in simple terms."),
    ],
    temperature=0.5,
    max_tokens=500,
)

# stream defaults to True
assert request.stream is True

Related Pages

Page Connections

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