SAP AI SDK for JavaScript - v2.8.0
    Preparing search index...

    Class AzureOpenAiChatCompletionResponse

    Azure OpenAI chat completion response.

    Index

    Constructors

    Properties

    _data: AzureOpenAiCreateChatCompletionResponse

    The chat completion response.

    rawResponse: HttpResponse

    Methods

    • Parses the response and returns the choice by index.

      Parameters

      • index: number

        The index of the choice to find.

      Returns
          | {
              content_filter_results?: AzureOpenAiContentFilterChoiceResults;
              finish_reason: | "stop"
              | "length"
              | "tool_calls"
              | "content_filter"
              | "function_call";
              index: number;
              logprobs: | {
                  content: AzureOpenAiChatCompletionTokenLogprob[]
                  | null;
                  refusal: AzureOpenAiChatCompletionTokenLogprob[] | null;
              } & Record<string, any>
              | null;
              message: AzureOpenAiChatCompletionResponseMessage;
          } & Record<string, any>
          | undefined

      An LLMChoice object associated with the index.

      • {
            content_filter_results?: AzureOpenAiContentFilterChoiceResults;
            finish_reason:
                | "stop"
                | "length"
                | "tool_calls"
                | "content_filter"
                | "function_call";
            index: number;
            logprobs: | {
                content: AzureOpenAiChatCompletionTokenLogprob[]
                | null;
                refusal: AzureOpenAiChatCompletionTokenLogprob[] | null;
            } & Record<string, any>
            | null;
            message: AzureOpenAiChatCompletionResponseMessage;
        } & Record<string, any>
        • Optionalcontent_filter_results?: AzureOpenAiContentFilterChoiceResults
        • finish_reason: "stop" | "length" | "tool_calls" | "content_filter" | "function_call"

          The reason the model stopped generating tokens. This will be stop if the model hit a natural stop point or a provided stop sequence, length if the maximum number of tokens specified in the request was reached, content_filter if content was omitted due to a flag from our content filters, tool_calls if the model called a tool, or function_call (deprecated) if the model called a function.

        • index: number

          The index of the choice in the list of choices.

        • logprobs:
              | {
                  content: AzureOpenAiChatCompletionTokenLogprob[]
                  | null;
                  refusal: AzureOpenAiChatCompletionTokenLogprob[] | null;
              } & Record<string, any>
              | null

          Log probability information for the choice.

        • message: AzureOpenAiChatCompletionResponseMessage
      • undefined
    • Gets the assistant message from the response.

      Parameters

      • OptionalchoiceIndex: number

        The index of the choice to use (default is 0).

      Returns AzureOpenAiChatCompletionResponseMessage | undefined

      The assistant message.

    • Parses the Azure OpenAI response and returns the content.

      Parameters

      • OptionalchoiceIndex: number

        The index of the choice to parse.

      Returns string | null | undefined

      The message content.

    • Reason for stopping the completion.

      Parameters

      • OptionalchoiceIndex: number

        The index of the choice to parse.

      Returns
          | "stop"
          | "length"
          | "tool_calls"
          | "content_filter"
          | "function_call"
          | undefined

      The finish reason.

    • Parses the Azure OpenAI response and returns the refusal message generated by the model.

      Parameters

      • OptionalchoiceIndex: number

        The index of the choice to parse.

      Returns string | null | undefined

      The refusal string.

    • Usage of tokens in the response.

      Returns AzureOpenAiCompletionUsage | undefined

      Token usage.

    • Parses the Azure OpenAI response and returns the tool calls generated by the model.

      Parameters

      • OptionalchoiceIndex: number

        The index of the choice to parse.

      Returns AzureOpenAiChatCompletionMessageToolCalls | undefined

      The message tool calls.

      Copyright Ⓒ 2026 SAP SE or an SAP affiliate company. All rights reserved.