azure.ai.inference.models package

class azure.ai.inference.models.AssistantMessage(*args: Any, **kwargs: Any)[source]

A request chat message representing response or action from the assistant.

Variables:
  • role (str or ASSISTANT) – The chat role associated with this message, which is always ‘assistant’ for assistant messages. Required. The role that provides responses to system-instructed, user-prompted input.

  • content (str) – The content of the message.

  • tool_calls (list[ChatCompletionsToolCall]) – The tool calls that must be resolved and have their outputs appended to subsequent input messages for the chat completions request to resolve as configured.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

content: str | None

The content of the message.

role: Literal[ChatRole.ASSISTANT]

The chat role associated with this message, which is always ‘assistant’ for assistant messages. Required. The role that provides responses to system-instructed, user-prompted input.

tool_calls: List[_models.ChatCompletionsToolCall] | None

The tool calls that must be resolved and have their outputs appended to subsequent input messages for the chat completions request to resolve as configured.

class azure.ai.inference.models.AsyncStreamingChatCompletions(response: AsyncHttpResponse)[source]

Represents an async interator over StreamingChatCompletionsUpdate objects. It can be used for either synchronous or asynchronous iterations. The class deserializes the Server Sent Events (SSE) response stream into chat completions updates, each one represented by a StreamingChatCompletionsUpdate object.

async aclose() None[source]
class azure.ai.inference.models.AudioContentFormat(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

A representation of the possible audio formats for audio.

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the front of the string and works to the end.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

MP3 = 'mp3'

Specifies audio in MP3 format.

WAV = 'wav'

Specifies audio in WAV format.

class azure.ai.inference.models.AudioContentItem(*args: Any, **kwargs: Any)[source]

A structured chat content item containing an audio content.

Variables:
  • type (str) – The discriminated object type: always ‘input_audio’ for this type. Required. Default value is “input_audio”.

  • input_audio (InputAudio) – The details of the input audio. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

input_audio: _models.InputAudio

The details of the input audio. Required.

type: Literal['input_audio']

always ‘input_audio’ for this type. Required. Default value is “input_audio”.

Type:

The discriminated object type

class azure.ai.inference.models.ChatChoice(*args: Any, **kwargs: Any)[source]

The representation of a single prompt completion as part of an overall chat completions request. Generally, n choices are generated per provided prompt with a default value of 1. Token limits and other settings may limit the number of choices generated.

Variables:
  • index (int) – The ordered index associated with this chat completions choice. Required.

  • finish_reason (str or CompletionsFinishReason) – The reason that this chat completions choice completed its generated. Required. Known values are: “stop”, “length”, “content_filter”, and “tool_calls”.

  • message (ChatResponseMessage) – The chat message for a given chat completions prompt. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

finish_reason: str | _models.CompletionsFinishReason

The reason that this chat completions choice completed its generated. Required. Known values are: “stop”, “length”, “content_filter”, and “tool_calls”.

index: int

The ordered index associated with this chat completions choice. Required.

message: _models.ChatResponseMessage

The chat message for a given chat completions prompt. Required.

class azure.ai.inference.models.ChatCompletions(*args: Any, **kwargs: Any)[source]

Representation of the response data from a chat completions request. Completions support a wide variety of tasks and generate text that continues from or “completes” provided prompt data.

Variables:
  • id (str) – A unique identifier associated with this chat completions response. Required.

  • created (datetime) – The first timestamp associated with generation activity for this completions response, represented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970. Required.

  • model (str) – The model used for the chat completion. Required.

  • usage (CompletionsUsage) – Usage information for tokens processed and generated as part of this completions operation. Required.

  • choices (list[ChatChoice]) – The collection of completions choices associated with this completions response. Generally, n choices are generated per provided prompt with a default value of 1. Token limits and other settings may limit the number of choices generated. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

choices: List['_models.ChatChoice']

The collection of completions choices associated with this completions response. Generally, n choices are generated per provided prompt with a default value of 1. Token limits and other settings may limit the number of choices generated. Required.

created: datetime.datetime

The first timestamp associated with generation activity for this completions response, represented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970. Required.

id: str

A unique identifier associated with this chat completions response. Required.

model: str

The model used for the chat completion. Required.

usage: _models.CompletionsUsage

Usage information for tokens processed and generated as part of this completions operation. Required.

class azure.ai.inference.models.ChatCompletionsNamedToolChoice(*args: Any, **kwargs: Any)[source]

A tool selection of a specific, named function tool that will limit chat completions to using the named function.

Variables:
  • type (str) – The type of the tool. Currently, only function is supported. Required. Default value is “function”.

  • function (ChatCompletionsNamedToolChoiceFunction) – The function that should be called. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

function: _models.ChatCompletionsNamedToolChoiceFunction

The function that should be called. Required.

type: Literal['function']

The type of the tool. Currently, only function is supported. Required. Default value is “function”.

class azure.ai.inference.models.ChatCompletionsNamedToolChoiceFunction(*args: Any, **kwargs: Any)[source]

A tool selection of a specific, named function tool that will limit chat completions to using the named function.

Variables:

name (str) – The name of the function that should be called. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

name: str

The name of the function that should be called. Required.

class azure.ai.inference.models.ChatCompletionsToolCall(*args: Any, **kwargs: Any)[source]

A function tool call requested by the AI model.

Variables:
  • id (str) – The ID of the tool call. Required.

  • type (str) – The type of tool call. Currently, only function is supported. Required. Default value is “function”.

  • function (FunctionCall) – The details of the function call requested by the AI model. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

function: _models.FunctionCall

The details of the function call requested by the AI model. Required.

id: str

The ID of the tool call. Required.

type: Literal['function']

The type of tool call. Currently, only function is supported. Required. Default value is “function”.

class azure.ai.inference.models.ChatCompletionsToolChoicePreset(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Represents a generic policy for how a chat completions tool may be selected.

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the front of the string and works to the end.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

AUTO = 'auto'

Specifies that the model may either use any of the tools provided in this chat completions request or instead return a standard chat completions response as if no tools were provided.

NONE = 'none'

Specifies that the model should not respond with a tool call and should instead provide a standard chat completions response. Response content may still be influenced by the provided tool definitions.

REQUIRED = 'required'

Specifies that the model should respond with a call to one or more tools.

class azure.ai.inference.models.ChatCompletionsToolDefinition(*args: Any, **kwargs: Any)[source]

The definition of a chat completions tool that can call a function.

Variables:
  • type (str) – The type of the tool. Currently, only function is supported. Required. Default value is “function”.

  • function (FunctionDefinition) – The function definition details for the function tool. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

function: _models.FunctionDefinition

The function definition details for the function tool. Required.

type: Literal['function']

The type of the tool. Currently, only function is supported. Required. Default value is “function”.

class azure.ai.inference.models.ChatRequestMessage(*args: Any, **kwargs: Any)[source]

An abstract representation of a chat message as provided in a request.

You probably want to use the sub-classes and not this class directly. Known sub-classes are: ChatRequestAssistantMessage, ChatRequestDeveloperMessage, ChatRequestSystemMessage, ChatRequestToolMessage, ChatRequestUserMessage

Variables:

role (str or ChatRole) – The chat role associated with this message. Required. Known values are: “system”, “user”, “assistant”, “tool”, and “developer”.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

role: str

“system”, “user”, “assistant”, “tool”, and “developer”.

Type:

The chat role associated with this message. Required. Known values are

class azure.ai.inference.models.ChatResponseMessage(*args: Any, **kwargs: Any)[source]

A representation of a chat message as received in a response.

Variables:
  • role (str or ChatRole) – The chat role associated with the message. Required. Known values are: “system”, “user”, “assistant”, “tool”, and “developer”.

  • content (str) – The content of the message. Required.

  • tool_calls (list[ChatCompletionsToolCall]) – The tool calls that must be resolved and have their outputs appended to subsequent input messages for the chat completions request to resolve as configured.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

content: str

The content of the message. Required.

role: str | _models.ChatRole

“system”, “user”, “assistant”, “tool”, and “developer”.

Type:

The chat role associated with the message. Required. Known values are

tool_calls: List[_models.ChatCompletionsToolCall] | None

The tool calls that must be resolved and have their outputs appended to subsequent input messages for the chat completions request to resolve as configured.

class azure.ai.inference.models.ChatRole(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

A description of the intended purpose of a message within a chat completions interaction.

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the front of the string and works to the end.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

ASSISTANT = 'assistant'

The role that provides responses to system-instructed, user-prompted input.

DEVELOPER = 'developer'

The role that instructs or sets the behavior of the assistant. Some AI models support this role instead of the ‘system’ role.

SYSTEM = 'system'

The role that instructs or sets the behavior of the assistant.

TOOL = 'tool'

The role that represents extension tool activity within a chat completions operation.

USER = 'user'

The role that provides input for chat completions.

class azure.ai.inference.models.CompletionsFinishReason(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Representation of the manner in which a completions response concluded.

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the front of the string and works to the end.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

CONTENT_FILTERED = 'content_filter'

Completions generated a response that was identified as potentially sensitive per content moderation policies.

STOPPED = 'stop'

Completions ended normally and reached its end of token generation.

TOKEN_LIMIT_REACHED = 'length'

Completions exhausted available token limits before generation could complete.

TOOL_CALLS = 'tool_calls'

Completion ended with the model calling a provided tool for output.

class azure.ai.inference.models.CompletionsUsage(*args: Any, **kwargs: Any)[source]

Representation of the token counts processed for a completions request. Counts consider all tokens across prompts, choices, choice alternates, best_of generations, and other consumers.

Variables:
  • completion_tokens (int) – The number of tokens generated across all completions emissions. Required.

  • prompt_tokens (int) – The number of tokens in the provided prompts for the completions request. Required.

  • total_tokens (int) – The total number of tokens processed for the completions request and response. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

completion_tokens: int

The number of tokens generated across all completions emissions. Required.

prompt_tokens: int

The number of tokens in the provided prompts for the completions request. Required.

total_tokens: int

The total number of tokens processed for the completions request and response. Required.

class azure.ai.inference.models.ContentItem(*args: Any, **kwargs: Any)[source]

An abstract representation of a structured content item within a chat message.

You probably want to use the sub-classes and not this class directly. Known sub-classes are: ImageContentItem, AudioContentItem, TextContentItem

Variables:

type (str) – The discriminated object type. Required. Default value is None.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

type: str

The discriminated object type. Required. Default value is None.

class azure.ai.inference.models.DeveloperMessage(*args: Any, **kwargs: Any)[source]

A request chat message containing developer instructions that influence how the model will generate a chat completions response. Some AI models support developer messages instead of system messages.

Variables:
  • role (str or DEVELOPER) – The chat role associated with this message, which is always ‘developer’ for developer messages. Required.

  • content (str) – The contents of the developer message. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

content: str

The contents of the developer message. Required.

role: Literal[ChatRole.DEVELOPER]

The chat role associated with this message, which is always ‘developer’ for developer messages. Required.

class azure.ai.inference.models.EmbeddingEncodingFormat(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

The format of the embeddings result. Returns a 422 error if the model doesn’t support the value or parameter.

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the front of the string and works to the end.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

BASE64 = 'base64'

Base64

BINARY = 'binary'

Binary

FLOAT = 'float'

Floating point

INT8 = 'int8'

Signed 8-bit integer

UBINARY = 'ubinary'

ubinary

UINT8 = 'uint8'

Unsigned 8-bit integer

class azure.ai.inference.models.EmbeddingInputType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Represents the input types used for embedding search.

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the front of the string and works to the end.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

DOCUMENT = 'document'

Indicates the input represents a document that is stored in a vector database.

QUERY = 'query'

Indicates the input represents a search query to find the most relevant documents in your vector database.

TEXT = 'text'

Indicates the input is a general text input.

class azure.ai.inference.models.EmbeddingItem(*args: Any, **kwargs: Any)[source]

Representation of a single embeddings relatedness comparison.

Variables:
  • embedding (str or list[float]) – List of embedding values for the input prompt. These represent a measurement of the vector-based relatedness of the provided input. Or a base64 encoded string of the embedding vector. Required. Is either a str type or a [float] type.

  • index (int) – Index of the prompt to which the EmbeddingItem corresponds. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

embedding: str | List[float]

List of embedding values for the input prompt. These represent a measurement of the vector-based relatedness of the provided input. Or a base64 encoded string of the embedding vector. Required. Is either a str type or a [float] type.

index: int

Index of the prompt to which the EmbeddingItem corresponds. Required.

class azure.ai.inference.models.EmbeddingsResult(*args: Any, **kwargs: Any)[source]

Representation of the response data from an embeddings request. Embeddings measure the relatedness of text strings and are commonly used for search, clustering, recommendations, and other similar scenarios.

Variables:
  • data (list[EmbeddingItem]) – Embedding values for the prompts submitted in the request. Required.

  • usage (EmbeddingsUsage) – Usage counts for tokens input using the embeddings API. Required.

  • model (str) – The model ID used to generate this result. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

data: List['_models.EmbeddingItem']

Embedding values for the prompts submitted in the request. Required.

id: str

Unique identifier for the embeddings result. Required.

model: str

The model ID used to generate this result. Required.

usage: _models.EmbeddingsUsage

Usage counts for tokens input using the embeddings API. Required.

class azure.ai.inference.models.EmbeddingsUsage(*args: Any, **kwargs: Any)[source]

Measurement of the amount of tokens used in this request and response.

Variables:
  • prompt_tokens (int) – Number of tokens in the request. Required.

  • total_tokens (int) – Total number of tokens transacted in this request/response. Should equal the number of tokens in the request. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

prompt_tokens: int

Number of tokens in the request. Required.

total_tokens: int

Total number of tokens transacted in this request/response. Should equal the number of tokens in the request. Required.

class azure.ai.inference.models.FunctionCall(*args: Any, **kwargs: Any)[source]

The name and arguments of a function that should be called, as generated by the model.

Variables:
  • name (str) – The name of the function to call. Required.

  • arguments (str) – The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

arguments: str

The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. Required.

name: str

The name of the function to call. Required.

class azure.ai.inference.models.FunctionDefinition(*args: Any, **kwargs: Any)[source]

The definition of a caller-specified function that chat completions may invoke in response to matching user input.

Variables:
  • name (str) – The name of the function to be called. Required.

  • description (str) – A description of what the function does. The model will use this description when selecting the function and interpreting its parameters.

  • parameters (any) – The parameters the function accepts, described as a JSON Schema object.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

description: str | None

A description of what the function does. The model will use this description when selecting the function and interpreting its parameters.

name: str

The name of the function to be called. Required.

parameters: Any | None

The parameters the function accepts, described as a JSON Schema object.

class azure.ai.inference.models.ImageContentItem(*args: Any, **kwargs: Any)[source]

A structured chat content item containing an image reference.

Variables:
  • type (str) – The discriminated object type: always ‘image_url’ for this type. Required. Default value is “image_url”.

  • image_url (ImageUrl) – An internet location, which must be accessible to the model,from which the image may be retrieved. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

image_url: _models.ImageUrl

An internet location, which must be accessible to the model,from which the image may be retrieved. Required.

type: Literal['image_url']

always ‘image_url’ for this type. Required. Default value is “image_url”.

Type:

The discriminated object type

class azure.ai.inference.models.ImageDetailLevel(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

A representation of the possible image detail levels for image-based chat completions message content.

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the front of the string and works to the end.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

AUTO = 'auto'

Specifies that the model should determine which detail level to apply using heuristics like image size.

HIGH = 'high'

Specifies that image evaluation should enable the ‘high-res’ model that may be more accurate for highly detailed images but may also be slower and consume more tokens.

LOW = 'low'

Specifies that image evaluation should be constrained to the ‘low-res’ model that may be faster and consume fewer tokens but may also be less accurate for highly detailed images.

class azure.ai.inference.models.ImageEmbeddingInput(*args: Any, **kwargs: Any)[source]
as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

classmethod load(*, image_file: str, image_format: str, text: str | None = None) Self[source]

Create an ImageEmbeddingInput object from a local image file. The method reads the image file and encodes it as a base64 string, which together with the image format is then used to format the JSON url value passed in the request payload.

Keyword Arguments:
  • image_file (str) – The name of the local image file to load. Required.

  • image_format (str) – The MIME type format of the image. For example: “jpeg”, “png”. Required.

  • text (str) – Optional. The text input to feed into the model (like DINO, CLIP). Returns a 422 error if the model doesn’t support the value or parameter.

Returns:

An ImageEmbeddingInput object with the image data encoded as a base64 string.

Return type:

EmbeddingsInput

Raises:

FileNotFoundError – when the image file could not be opened.

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

image: str

The input image encoded in base64 string as a data URL. Example: data:image/{format};base64,{data}. Required.

text: str | None

Optional. The text input to feed into the model (like DINO, CLIP). Returns a 422 error if the model doesn’t support the value or parameter.

class azure.ai.inference.models.ImageUrl(*args: Any, **kwargs: Any)[source]
as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

classmethod load(*, image_file: str, image_format: str, detail: str | ImageDetailLevel | None = None) Self[source]

Create an ImageUrl object from a local image file. The method reads the image file and encodes it as a base64 string, which together with the image format is then used to format the JSON url value passed in the request payload.

Keyword Arguments:
  • image_file (str) – The name of the local image file to load. Required.

  • image_format (str) – The MIME type format of the image. For example: “jpeg”, “png”. Required.

  • detail (str or ImageDetailLevel) – The evaluation quality setting to use, which controls relative prioritization of speed, token consumption, and accuracy. Known values are: “auto”, “low”, and “high”.

Returns:

An ImageUrl object with the image data encoded as a base64 string.

Return type:

ImageUrl

Raises:

FileNotFoundError – when the image file could not be opened.

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

detail: str | '_models.ImageDetailLevel' | None

The evaluation quality setting to use, which controls relative prioritization of speed, token consumption, and accuracy. Known values are: “auto”, “low”, and “high”.

url: str

The URL of the image. Required.

class azure.ai.inference.models.InputAudio(*args: Any, **kwargs: Any)[source]
as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

classmethod load(*, audio_file: str, audio_format: str) Self[source]

Create an InputAudio object from a local audio file. The method reads the audio file and encodes it as a base64 string, which together with the audio format is then used to create the InputAudio object passed to the request payload.

Keyword Arguments:
  • audio_file – The name of the local audio file to load. Required.

  • audio_format – The MIME type format of the audio. For example: “wav”, “mp3”. Required.

Returns:

An InputAudio object with the audio data encoded as a base64 string.

Return type:

InputAudio

Raises:

FileNotFoundError – when the image file could not be opened.

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

data: str

Base64 encoded audio data. Required.

format: str | '_models.AudioContentFormat'

“wav” and “mp3”.

Type:

The audio format of the audio content. Required. Known values are

class azure.ai.inference.models.JsonSchemaFormat(*args: Any, **kwargs: Any)[source]

Defines the response format for chat completions as JSON with a given schema. The AI model will need to adhere to this schema when generating completions.

Variables:
  • name (str) – A name that labels this JSON schema. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. Required.

  • schema (dict[str, any]) – The definition of the JSON schema. See https://json-schema.org/overview/what-is-jsonschema. Note that AI models usually only support a subset of the keywords defined by JSON schema. Consult your AI model documentation to determine what is supported. Required.

  • description (str) – A description of the response format, used by the AI model to determine how to generate responses in this format.

  • strict (bool) – If set to true, the service will error out if the provided JSON schema contains keywords not supported by the AI model. An example of such keyword may be maxLength for JSON type string. If false, and the provided JSON schema contains keywords not supported by the AI model, the AI model will not error out. Instead it will ignore the unsupported keywords.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

description: str | None

A description of the response format, used by the AI model to determine how to generate responses in this format.

name: str

A name that labels this JSON schema. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. Required.

schema: Dict[str, Any]

//json-schema.org/overview/what-is-jsonschema. Note that AI models usually only support a subset of the keywords defined by JSON schema. Consult your AI model documentation to determine what is supported. Required.

Type:

The definition of the JSON schema. See https

strict: bool | None

If set to true, the service will error out if the provided JSON schema contains keywords not supported by the AI model. An example of such keyword may be maxLength for JSON type string. If false, and the provided JSON schema contains keywords not supported by the AI model, the AI model will not error out. Instead it will ignore the unsupported keywords.

class azure.ai.inference.models.ModelInfo(*args: Any, **kwargs: Any)[source]

Represents some basic information about the AI model.

Variables:
  • model_name (str) – The name of the AI model. For example: Phi21. Required.

  • model_type (str or ModelType) – The type of the AI model. A Unique identifier for the profile. Required. Known values are: “embeddings”, “image_generation”, “text_generation”, “image_embeddings”, “audio_generation”, and “chat_completion”.

  • model_provider_name (str) – The model provider name. For example: Microsoft Research. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

model_name: str

Phi21. Required.

Type:

The name of the AI model. For example

model_provider_name: str

Microsoft Research. Required.

Type:

The model provider name. For example

model_type: str | _models.ModelType

The type of the AI model. A Unique identifier for the profile. Required. Known values are: “embeddings”, “image_generation”, “text_generation”, “image_embeddings”, “audio_generation”, and “chat_completion”.

class azure.ai.inference.models.ModelType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

The type of AI model.

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the front of the string and works to the end.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

AUDIO_GENERATION = 'audio_generation'

A text-to-audio generative model

CHAT_COMPLETION = 'chat_completion'

A model capable of taking chat-formatted messages and generate responses

EMBEDDINGS = 'embeddings'

A model capable of generating embeddings from a text

IMAGE_EMBEDDINGS = 'image_embeddings'

A model capable of generating embeddings from an image

IMAGE_GENERATION = 'image_generation'

A model capable of generating images from an image and text description

TEXT_GENERATION = 'text_generation'

A text generation model

class azure.ai.inference.models.StreamingChatChoiceUpdate(*args: Any, **kwargs: Any)[source]

Represents an update to a single prompt completion when the service is streaming updates using Server Sent Events (SSE). Generally, n choices are generated per provided prompt with a default value of 1. Token limits and other settings may limit the number of choices generated.

Variables:
  • index (int) – The ordered index associated with this chat completions choice. Required.

  • finish_reason (str or CompletionsFinishReason) – The reason that this chat completions choice completed its generated. Required. Known values are: “stop”, “length”, “content_filter”, and “tool_calls”.

  • delta (StreamingChatResponseMessageUpdate) – An update to the chat message for a given chat completions prompt. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

delta: _models.StreamingChatResponseMessageUpdate

An update to the chat message for a given chat completions prompt. Required.

finish_reason: str | _models.CompletionsFinishReason

The reason that this chat completions choice completed its generated. Required. Known values are: “stop”, “length”, “content_filter”, and “tool_calls”.

index: int

The ordered index associated with this chat completions choice. Required.

class azure.ai.inference.models.StreamingChatCompletions(response: HttpResponse)[source]

Represents an interator over StreamingChatCompletionsUpdate objects. It can be used for either synchronous or asynchronous iterations. The class deserializes the Server Sent Events (SSE) response stream into chat completions updates, each one represented by a StreamingChatCompletionsUpdate object.

close() None[source]
class azure.ai.inference.models.StreamingChatCompletionsUpdate(*args: Any, **kwargs: Any)[source]

Represents a response update to a chat completions request, when the service is streaming updates using Server Sent Events (SSE). Completions support a wide variety of tasks and generate text that continues from or “completes” provided prompt data.

Variables:
  • id (str) – A unique identifier associated with this chat completions response. Required.

  • created (datetime) – The first timestamp associated with generation activity for this completions response, represented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970. Required.

  • model (str) – The model used for the chat completion. Required.

  • choices (list[StreamingChatChoiceUpdate]) – An update to the collection of completion choices associated with this completions response. Generally, n choices are generated per provided prompt with a default value of 1. Token limits and other settings may limit the number of choices generated. Required.

  • usage (CompletionsUsage) – Usage information for tokens processed and generated as part of this completions operation.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

choices: List[_models.StreamingChatChoiceUpdate]

An update to the collection of completion choices associated with this completions response. Generally, n choices are generated per provided prompt with a default value of 1. Token limits and other settings may limit the number of choices generated. Required.

created: datetime

The first timestamp associated with generation activity for this completions response, represented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970. Required.

id: str

A unique identifier associated with this chat completions response. Required.

model: str

The model used for the chat completion. Required.

usage: _models.CompletionsUsage | None

Usage information for tokens processed and generated as part of this completions operation.

class azure.ai.inference.models.StreamingChatResponseMessageUpdate(*args: Any, **kwargs: Any)[source]

A representation of a chat message update as received in a streaming response.

Variables:
  • role (str or ChatRole) – The chat role associated with the message. If present, should always be ‘assistant’. Known values are: “system”, “user”, “assistant”, “tool”, and “developer”.

  • content (str) – The content of the message.

  • tool_calls (list[StreamingChatResponseToolCallUpdate]) – The tool calls that must be resolved and have their outputs appended to subsequent input messages for the chat completions request to resolve as configured.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

content: str | None

The content of the message.

role: str | _models.ChatRole | None

The chat role associated with the message. If present, should always be ‘assistant’. Known values are: “system”, “user”, “assistant”, “tool”, and “developer”.

tool_calls: List[_models.StreamingChatResponseToolCallUpdate] | None

The tool calls that must be resolved and have their outputs appended to subsequent input messages for the chat completions request to resolve as configured.

class azure.ai.inference.models.StreamingChatResponseToolCallUpdate(*args: Any, **kwargs: Any)[source]

An update to the function tool call information requested by the AI model.

Variables:
  • id (str) – The ID of the tool call. Required.

  • function (FunctionCall) – Updates to the function call requested by the AI model. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

function: _models.FunctionCall

Updates to the function call requested by the AI model. Required.

id: str

The ID of the tool call. Required.

class azure.ai.inference.models.SystemMessage(*args: Any, **kwargs: Any)[source]

A request chat message containing system instructions that influence how the model will generate a chat completions response.

Variables:
  • role (str or SYSTEM) – The chat role associated with this message, which is always ‘system’ for system messages. Required.

  • content (str) – The contents of the system message. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

content: str

The contents of the system message. Required.

role: Literal[ChatRole.SYSTEM]

The chat role associated with this message, which is always ‘system’ for system messages. Required.

class azure.ai.inference.models.TextContentItem(*args: Any, **kwargs: Any)[source]

A structured chat content item containing plain text.

Variables:
  • type (str) – The discriminated object type: always ‘text’ for this type. Required. Default value is “text”.

  • text (str) – The content of the message. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

text: str

The content of the message. Required.

type: Literal['text']

always ‘text’ for this type. Required. Default value is “text”.

Type:

The discriminated object type

class azure.ai.inference.models.ToolMessage(*args: Any, **kwargs: Any)[source]

A request chat message representing requested output from a configured tool.

Variables:
  • role (str or TOOL) – The chat role associated with this message, which is always ‘tool’ for tool messages. Required. The role that represents extension tool activity within a chat completions operation.

  • content (str) – The content of the message.

  • tool_call_id (str) – The ID of the tool call resolved by the provided content. Required.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

content: str | None

The content of the message.

role: Literal[ChatRole.TOOL]

The chat role associated with this message, which is always ‘tool’ for tool messages. Required. The role that represents extension tool activity within a chat completions operation.

tool_call_id: str

The ID of the tool call resolved by the provided content. Required.

class azure.ai.inference.models.UserMessage(*args: Any, **kwargs: Any)[source]

A request chat message representing user input to the assistant.

Variables:
  • role (str or USER) – The chat role associated with this message, which is always ‘user’ for user messages. Required. The role that provides input for chat completions.

  • content (str or list[ContentItem]) – The contents of the user message, with available input types varying by selected model. Required. Is either a str type or a [ContentItem] type.

as_dict(*, exclude_readonly: bool = False) Dict[str, Any]

Return a dict that can be turned into json using json.dump.

Keyword Arguments:

exclude_readonly (bool) – Whether to remove the readonly properties.

Returns:

A dict JSON compatible object

Return type:

dict

clear() None

Remove all items from D.

copy() Model
get(key: str, default: Any = None) Any

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items() ItemsView[str, Any]
Returns:

set-like object providing a view on D’s items

Return type:

ItemsView

keys() KeysView[str]
Returns:

a set-like object providing a view on D’s keys

Return type:

KeysView

pop(key: str, default: ~typing.Any = <object object>) Any

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem() Tuple[str, Any]

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault(key: str, default: ~typing.Any = <object object>) Any

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update(*args: Any, **kwargs: Any) None

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values() ValuesView[Any]
Returns:

an object providing a view on D’s values

Return type:

ValuesView

content: str | List[_models.ContentItem]

The contents of the user message, with available input types varying by selected model. Required. Is either a str type or a [ContentItem] type.

role: Literal[ChatRole.USER]

The chat role associated with this message, which is always ‘user’ for user messages. Required. The role that provides input for chat completions.