Request
The Request class represents an incoming chat completion request. It extends the Azure OpenAI chat completion format with DIAL-specific fields.
from aidial_sdk.chat_completion import Request
Request fields
Standard fields (Azure OpenAI compatible)
| Field | Type | Default | Description |
|---|---|---|---|
model | str | None | None | Model identifier. |
messages | list[Message] | required | Conversation history. |
stream | bool | False | Whether to stream the response as SSE. |
temperature | float | None | None | Sampling temperature (0.0–2.0). |
top_p | float | None | None | Nucleus sampling (0.0–1.0). |
n | int | None | None | Number of choices to generate (1–128). |
stop | str | list[str] | None | None | Stop sequences (up to 4 strings). |
max_tokens | int | None | None | Maximum tokens to generate (positive integer). |
presence_penalty | float | None | None | Presence penalty (-2.0–2.0). |
frequency_penalty | float | None | None | Frequency penalty (-2.0–2.0). |
logit_bias | dict[int, float] | None | None | Token logit biases. |
user | str | None | None | End-user identifier. |
seed | int | None | None | Random seed for deterministic generation. |
logprobs | bool | None | None | Whether to return log probabilities. |
top_logprobs | int | None | None | Number of top log probabilities to return. |
response_format | ResponseFormat | None | None | Response format constraint. See Response formats. |
functions | list[Function] | None | None | Function definitions (legacy). |
function_call | str | FunctionChoice | None | None | Function call control: "auto", "none", or a specific function. |
tools | list[Tool | StaticTool] | None | None | Tool definitions. See Tools. |
tool_choice | str | ToolChoice | None | None | Tool call control: "auto", "none", "required", or a specific tool. |
DIAL extension fields
| Field | Type | Default | Description |
|---|---|---|---|
addons | list[Addon] | None | None | Legacy addon references. |
max_prompt_tokens | int | None | None | Maximum tokens for the prompt. When set, DIAL Core may call truncate_prompt to discard messages that exceed this limit. |
custom_fields | ChatCompletionRequestCustomFields | None | None | DIAL-specific custom fields (see below). |
ChatCompletionRequestCustomFields
| Field | Type | Default | Description |
|---|---|---|---|
configuration | dict[str, Any] | None | None | Application-specific configuration passed from DIAL Chat or API callers. |
application_properties | dict[str, Any] | None | None | Properties from the application definition in DIAL Core. |
Request properties
| Property | Type | Description |
|---|---|---|
deployment_id | str | The deployment name from the URL path. |
api_key_secret | str | The API key from the api-key header. |
jwt | str | None | The JWT from the Authorization header, if present. |
headers | dict[str, str] | All HTTP headers from the original request. |
Message
Represents a single message in the conversation.
from aidial_sdk.chat_completion.request import Message
| Field | Type | Default | Description |
|---|---|---|---|
role | Role | required | The message role. |
content | str | list[MessageContentPart] | None | None | Text content or a list of content parts (for multimodal messages). |
custom_content | CustomContent | None | None | DIAL-specific content (stages, attachments, state, form values). |
name | str | None | None | Author name for display. |
tool_calls | list[ToolCall] | None | None | Tool calls made by the assistant. |
tool_call_id | str | None | None | ID of the tool call this message responds to (for role=tool). |
function_call | FunctionCall | None | None | Function call (legacy). |
Message.text()
def text(self) -> str
Returns the message content as a string. Raises InvalidRequestError if content is None or a list of content parts.
Role
from aidial_sdk.chat_completion.request import Role
| Value | Description |
|---|---|
Role.SYSTEM | System instruction. |
Role.USER | User message. |
Role.ASSISTANT | Assistant response. |
Role.FUNCTION | Function result (legacy). |
Role.TOOL | Tool result. |
Content parts
For multimodal messages, content can be a list of parts:
MessageContentTextPart
| Field | Type | Description |
|---|---|---|
type | "text" | Discriminator. |
text | str | Text content. |
MessageContentImagePart
| Field | Type | Description |
|---|---|---|
type | "image_url" | Discriminator. |
image_url | ImageURL | Image reference. |
ImageURL
| Field | Type | Default | Description |
|---|---|---|---|
url | str | required | Image URL or base64 data URI. |
detail | "auto" | "low" | "high" | None | None | Image detail level. |
CustomContent
DIAL extension for rich content beyond plain text.
| Field | Type | Default | Description |
|---|---|---|---|
stages | list[Stage] | None | None | Processing stages (request-side representation). |
attachments | list[Attachment] | None | None | File attachments. |
state | Any | None | None | Opaque application state, round-tripped between turns. |
form_value | Any | None | None | User input from a form schema. |
form_schema | Any | None | None | JSON Schema for form rendering. |
Attachment
| Field | Type | Default | Description |
|---|---|---|---|
type | str | None | "text/markdown" | MIME type. |
title | str | None | None | Display title. |
data | str | None | None | Inline data (base64 or text). |
url | str | None | None | URL to the attachment content. |
reference_type | str | None | None | Type of the reference. |
reference_url | str | None | None | URL to the original source. |
Tools
Tool
| Field | Type | Description |
|---|---|---|
type | "function" | Discriminator. |
function | Function | Function definition. |
StaticTool
| Field | Type | Description |
|---|---|---|
type | "static_function" | Discriminator. |
static_function | StaticFunction | Static function definition. |
Function
| Field | Type | Default | Description |
|---|---|---|---|
name | str | required | Function name. |
description | str | None | None | Human-readable description. |
parameters | dict | None | None | JSON Schema for the function parameters. |
StaticFunction
| Field | Type | Default | Description |
|---|---|---|---|
name | str | required | Function name. |
description | str | None | None | Human-readable description. |
configuration | dict[str, Any] | None | None | Static configuration for the function. |
ToolCall
| Field | Type | Default | Description |
|---|---|---|---|
index | int | None | None | Position in the tool call list. |
id | str | required | Unique tool call ID. |
type | "function" | required | Discriminator. |
function | FunctionCall | required | The function call details. |
FunctionCall (request model)
| Field | Type | Description |
|---|---|---|
name | str | Function name. |
arguments | str | JSON-encoded arguments. |
ToolChoice
| Field | Type | Description |
|---|---|---|
type | "function" | Discriminator. |
function | FunctionChoice | Specifies the function to call. |
FunctionChoice
| Field | Type | Description |
|---|---|---|
name | str | Name of the function to call. |
Response formats
ResponseFormatText
| Field | Type | Description |
|---|---|---|
type | "text" | Free-form text output. |
ResponseFormatJsonObject
| Field | Type | Description |
|---|---|---|
type | "json_object" | Constrain output to valid JSON. |
ResponseFormatJsonSchema
| Field | Type | Description |
|---|---|---|
type | "json_schema" | Constrain output to a specific JSON Schema. |
json_schema | ResponseFormatJsonSchemaObject | Schema definition. |
ResponseFormatJsonSchemaObject
| Field | Type | Default | Description |
|---|---|---|---|
name | str | required | Schema name. |
description | str | None | None | Schema description. |
schema | dict[str, Any] | required | JSON Schema object. |
strict | bool | None | False | Whether the model must strictly follow the schema. |
Further reading
- Response — construct the response to a parsed request
- Per-request keys — understand request-scoped access to Core resources
- Build a RAG app — process messages and file attachments in an application
- Unified API — find the wire-format schemas corresponding to SDK models