# Class AzureOpenAiChatCompletionResponse

Azure OpenAI chat completion response.

- Defined in packages/foundation-models/dist/azure-openai/azure-openai-chat-completion-response.d.ts:6

##### Index

### Constructors

constructor

### Properties

_data
rawResponse

### Methods

findChoiceByIndex
getAssistantMessage
getContent
getFinishReason
getRefusal
getRequestId
getTokenUsage
getToolCalls

## Constructors

### constructor

- new AzureOpenAiChatCompletionResponse(
  rawResponse: HttpResponse,
  ): AzureOpenAiChatCompletionResponse

  #### Parameters

  - rawResponse: HttpResponse

  #### Returns AzureOpenAiChatCompletionResponse

  - Defined in packages/foundation-models/dist/azure-openai/azure-openai-chat-completion-response.d.ts:12

## Properties

### `Readonly`_data

_data: AzureOpenAiCreateChatCompletionResponse

The chat completion response.

- Defined in packages/foundation-models/dist/azure-openai/azure-openai-chat-completion-response.d.ts:11

### `Readonly` rawResponse

rawResponse: HttpResponse

- Defined in packages/foundation-models/dist/azure-openai/azure-openai-chat-completion-response.d.ts:7

## Methods

### findChoiceByIndex

- findChoiceByIndex(
  index: number,
  ):
  | {
  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

  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>

    - ##### `Optional` content_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
  - Defined in packages/foundation-models/dist/azure-openai/azure-openai-chat-completion-response.d.ts:58

### getAssistantMessage

- getAssistantMessage(
  choiceIndex?: number,
  ): AzureOpenAiChatCompletionResponseMessage | undefined

  Gets the assistant message from the response.

  #### Parameters

  - `Optional` choiceIndex: number

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

  #### Returns AzureOpenAiChatCompletionResponseMessage | undefined

  The assistant message.

  - Defined in packages/foundation-models/dist/azure-openai/azure-openai-chat-completion-response.d.ts:52

### getContent

- getContent(choiceIndex?: number): string | null | undefined

  Parses the Azure OpenAI response and returns the content.

  #### Parameters

  - `Optional` choiceIndex: number

    The index of the choice to parse.

  #### Returns string | null | undefined

  The message content.

  - Defined in packages/foundation-models/dist/azure-openai/azure-openai-chat-completion-response.d.ts:34

### getFinishReason

- getFinishReason(
  choiceIndex?: number,
  ):
  | "stop"
  | "length"
  | "tool_calls"
  | "content_filter"
  | "function_call"
  | undefined

  Reason for stopping the completion.

  #### Parameters

  - `Optional` choiceIndex: number

    The index of the choice to parse.

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

  The finish reason.

  - Defined in packages/foundation-models/dist/azure-openai/azure-openai-chat-completion-response.d.ts:28

### getRefusal

- getRefusal(choiceIndex?: number): string | null | undefined

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

  #### Parameters

  - `Optional` choiceIndex: number

    The index of the choice to parse.

  #### Returns string | null | undefined

  The refusal string.

  - Defined in packages/foundation-models/dist/azure-openai/azure-openai-chat-completion-response.d.ts:46

### getRequestId

- getRequestId(): string | undefined

  Gets the request ID from the response headers.

  #### Returns string | undefined

  The request ID, or undefined if the header is not present.

  - Defined in packages/foundation-models/dist/azure-openai/azure-openai-chat-completion-response.d.ts:17

### getTokenUsage

- getTokenUsage(): AzureOpenAiCompletionUsage | undefined

  Usage of tokens in the response.

  #### Returns AzureOpenAiCompletionUsage | undefined

  Token usage.

  - Defined in packages/foundation-models/dist/azure-openai/azure-openai-chat-completion-response.d.ts:22

### getToolCalls

- getToolCalls(
  choiceIndex?: number,
  ): AzureOpenAiChatCompletionMessageToolCalls | undefined

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

  #### Parameters

  - `Optional` choiceIndex: 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.

  - Defined in packages/foundation-models/dist/azure-openai/azure-openai-chat-completion-response.d.ts:40