Skip to main content

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)​

FieldTypeDefaultDescription
modelstr | NoneNoneModel identifier.
messageslist[Message]requiredConversation history.
streamboolFalseWhether to stream the response as SSE.
temperaturefloat | NoneNoneSampling temperature (0.0–2.0).
top_pfloat | NoneNoneNucleus sampling (0.0–1.0).
nint | NoneNoneNumber of choices to generate (1–128).
stopstr | list[str] | NoneNoneStop sequences (up to 4 strings).
max_tokensint | NoneNoneMaximum tokens to generate (positive integer).
presence_penaltyfloat | NoneNonePresence penalty (-2.0–2.0).
frequency_penaltyfloat | NoneNoneFrequency penalty (-2.0–2.0).
logit_biasdict[int, float] | NoneNoneToken logit biases.
userstr | NoneNoneEnd-user identifier.
seedint | NoneNoneRandom seed for deterministic generation.
logprobsbool | NoneNoneWhether to return log probabilities.
top_logprobsint | NoneNoneNumber of top log probabilities to return.
response_formatResponseFormat | NoneNoneResponse format constraint. See Response formats.
functionslist[Function] | NoneNoneFunction definitions (legacy).
function_callstr | FunctionChoice | NoneNoneFunction call control: "auto", "none", or a specific function.
toolslist[Tool | StaticTool] | NoneNoneTool definitions. See Tools.
tool_choicestr | ToolChoice | NoneNoneTool call control: "auto", "none", "required", or a specific tool.

DIAL extension fields​

FieldTypeDefaultDescription
addonslist[Addon] | NoneNoneLegacy addon references.
max_prompt_tokensint | NoneNoneMaximum tokens for the prompt. When set, DIAL Core may call truncate_prompt to discard messages that exceed this limit.
custom_fieldsChatCompletionRequestCustomFields | NoneNoneDIAL-specific custom fields (see below).

ChatCompletionRequestCustomFields​

FieldTypeDefaultDescription
configurationdict[str, Any] | NoneNoneApplication-specific configuration passed from DIAL Chat or API callers.
application_propertiesdict[str, Any] | NoneNoneProperties from the application definition in DIAL Core.

Request properties​

PropertyTypeDescription
deployment_idstrThe deployment name from the URL path.
api_key_secretstrThe API key from the api-key header.
jwtstr | NoneThe JWT from the Authorization header, if present.
headersdict[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
FieldTypeDefaultDescription
roleRolerequiredThe message role.
contentstr | list[MessageContentPart] | NoneNoneText content or a list of content parts (for multimodal messages).
custom_contentCustomContent | NoneNoneDIAL-specific content (stages, attachments, state, form values).
namestr | NoneNoneAuthor name for display.
tool_callslist[ToolCall] | NoneNoneTool calls made by the assistant.
tool_call_idstr | NoneNoneID of the tool call this message responds to (for role=tool).
function_callFunctionCall | NoneNoneFunction 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
ValueDescription
Role.SYSTEMSystem instruction.
Role.USERUser message.
Role.ASSISTANTAssistant response.
Role.FUNCTIONFunction result (legacy).
Role.TOOLTool result.

Content parts​

For multimodal messages, content can be a list of parts:

MessageContentTextPart​

FieldTypeDescription
type"text"Discriminator.
textstrText content.

MessageContentImagePart​

FieldTypeDescription
type"image_url"Discriminator.
image_urlImageURLImage reference.

ImageURL​

FieldTypeDefaultDescription
urlstrrequiredImage URL or base64 data URI.
detail"auto" | "low" | "high" | NoneNoneImage detail level.

CustomContent​

DIAL extension for rich content beyond plain text.

FieldTypeDefaultDescription
stageslist[Stage] | NoneNoneProcessing stages (request-side representation).
attachmentslist[Attachment] | NoneNoneFile attachments.
stateAny | NoneNoneOpaque application state, round-tripped between turns.
form_valueAny | NoneNoneUser input from a form schema.
form_schemaAny | NoneNoneJSON Schema for form rendering.

Attachment​

FieldTypeDefaultDescription
typestr | None"text/markdown"MIME type.
titlestr | NoneNoneDisplay title.
datastr | NoneNoneInline data (base64 or text).
urlstr | NoneNoneURL to the attachment content.
reference_typestr | NoneNoneType of the reference.
reference_urlstr | NoneNoneURL to the original source.

Tools​

Tool​

FieldTypeDescription
type"function"Discriminator.
functionFunctionFunction definition.

StaticTool​

FieldTypeDescription
type"static_function"Discriminator.
static_functionStaticFunctionStatic function definition.

Function​

FieldTypeDefaultDescription
namestrrequiredFunction name.
descriptionstr | NoneNoneHuman-readable description.
parametersdict | NoneNoneJSON Schema for the function parameters.

StaticFunction​

FieldTypeDefaultDescription
namestrrequiredFunction name.
descriptionstr | NoneNoneHuman-readable description.
configurationdict[str, Any] | NoneNoneStatic configuration for the function.

ToolCall​

FieldTypeDefaultDescription
indexint | NoneNonePosition in the tool call list.
idstrrequiredUnique tool call ID.
type"function"requiredDiscriminator.
functionFunctionCallrequiredThe function call details.

FunctionCall (request model)​

FieldTypeDescription
namestrFunction name.
argumentsstrJSON-encoded arguments.

ToolChoice​

FieldTypeDescription
type"function"Discriminator.
functionFunctionChoiceSpecifies the function to call.

FunctionChoice​

FieldTypeDescription
namestrName of the function to call.

Response formats​

ResponseFormatText​

FieldTypeDescription
type"text"Free-form text output.

ResponseFormatJsonObject​

FieldTypeDescription
type"json_object"Constrain output to valid JSON.

ResponseFormatJsonSchema​

FieldTypeDescription
type"json_schema"Constrain output to a specific JSON Schema.
json_schemaResponseFormatJsonSchemaObjectSchema definition.

ResponseFormatJsonSchemaObject​

FieldTypeDefaultDescription
namestrrequiredSchema name.
descriptionstr | NoneNoneSchema description.
schemadict[str, Any]requiredJSON Schema object.
strictbool | NoneFalseWhether 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