code: def completion(
      self,
      model: str,
      messages: list,
      model_response: ModelResponse,
      api_key: str,
      api_base: str,
      api_version: str,
      api_type: str,
      azure_ad_token: str,
      print_verbose: Callable,
      timeout,
      logging_obj,
      optional_params,
      litellm_params,
      logger_fn,
      acompletion: bool = False,
      headers: Optional[dict] = None,
      client=None,
  ):
      super().completion()
      exception_mapping_worked = False
      try:
          if model is None or messages is None:
              raise AzureOpenAIError(
                  status_code=422, message=f"Missing model or messages"
              )
  
          max_retries = optional_params.pop("max_retries", 2)
  
          ### CHECK IF CLOUDFLARE AI GATEWAY ###
          ### if so - set the model as part of the base url
          if "gateway.ai.cloudflare.com" in api_base:
              ## build base url - assume api base includes resource name
              if client is None:
                  if not api_base.endswith("/"):
                      api_base += "/"
                  api_base += f"{model}"
  
                  azure_client_params = {
                      "api_version": api_version,
                      "base_url": f"{api_base}",
                      "http_client": litellm.client_session,
                      "max_retries": max_retries,
                      "timeout": timeout,
                  }
                  if api_key is not None:
                      azure_client_params["api_key"] = api_key
                  elif azure_ad_token is not None:
                      azure_client_params[
                          "azure_ad_token"
                      ] = azure_ad_token
  
                  if acompletion is True:
                      client = AsyncAzureOpenAI(**azure_client_params)
                  else:
                      client = AzureOpenAI(**azure_client_params)
  
              data = {
                  "model": None,
                  "messages": messages,
                  **optional_params,
              }
          else:
              data = {
                  "model": model,  # type: ignore
                  "messages": messages,
                  **optional_params,
              }
  
          if acompletion is True:
              if optional_params.get("stream", False):
                  return self.async_streaming(
                      logging_obj=logging_obj,
                      api_base=api_base,
                      data=data,
                      model=model,
                      api_key=api_key,
                      api_version=api_version,
                      azure_ad_token=azure_ad_token,
                      timeout=timeout,
                      client=client,
                  )
              else:
                  return self.acompletion(
                      api_base=api_base,
                      data=data,
                      model_response=model_response,
                      api_key=api_key,
                      api_version=api_version,
                      model=model,
                      azure_ad_token=azure_ad_token,
                      timeout=timeout,
                      client=client,
                      logging_obj=logging_obj,
                  )
          elif (
              "stream" in optional_params
              and optional_params["stream"] == True
          ):
              return self.streaming(
                  logging_obj=logging_obj,
                  api_base=api_base,
                  data=data,
                  model=model,
                  api_key=api_key,
                  api_version=api_version,
                  azure_ad_token=azure_ad_token,
                  timeout=timeout,
                  client=client,
              )
          else:
              ## LOGGING
              logging_obj.pre_call(
                  input=messages,
                  api_key=api_key,
                  additional_args={
                      "headers": {
                          "api_key": api_key,
                          "azure_ad_token": azure_ad_token,
                      },
                      "api_version": api_version,
                      "api_base": api_base,
                      "complete_input_dict": data,
                  },
              )
              if not isinstance(max_retries, int):
                  raise AzureOpenAIError(
                      status_code=422,
                      message="max retries must be an int",
                  )
              # init AzureOpenAI Client
              azure_client_params = {
                  "api_version": api_version,
                  "azure_endpoint": api_base,
                  "azure_deployment": model,
                  "http_client": litellm.client_session,
                  "max_retries": max_retries,
                  "timeout": timeout,
              }
              if api_key is not None:
                  azure_client_params["api_key"] = api_key
              elif azure_ad_token is not None:
                  azure_client_params["azure_ad_token"] = azure_ad_token
              if client is None:
                  azure_client = AzureOpenAI(**azure_client_params)
              else:
                  azure_client = client
              response = azure_client.chat.completions.create(**data, timeout=timeout)  # type: ignore
              stringified_response = response.model_dump()
              ## LOGGING
              logging_obj.post_call(
                  input=messages,
                  api_key=api_key,
                  original_response=stringified_response,
                  additional_args={
                      "headers": headers,
                      "api_version": api_version,
                      "api_base": api_base,
                  },
              )
              return convert_to_model_response_object(
                  response_object=stringified_response,
                  model_response_object=model_response,
              )
      except AzureOpenAIError as e:
          exception_mapping_worked = True
          raise e
      except Exception as e:
          if hasattr(e, "status_code"):
              raise AzureOpenAIError(
                  status_code=e.status_code, message=str(e)
              )
          else:
              raise AzureOpenAIError(status_code=500, message=str(e))
  
imports: from typing import Optional, Union, Any
  import types, requests
  from .base import BaseLLM
  from litellm.utils import ModelResponse, Choices, Message, CustomStreamWrapper, convert_to_model_response_object
  from typing import Callable, Optional
  from litellm import OpenAIConfig
  import litellm, json
  import httpx
  from .custom_httpx.azure_dall_e_2 import CustomHTTPTransport, AsyncCustomHTTPTransport
  from openai import AzureOpenAI, AsyncAzureOpenAI
label_desc: Use image node_id 3 for calling the AzureChatCompletion obj's underlying member method code with example usage: obj.completion(model, messages, model_response, api_key, api_base, api_version, api_type, azure_ad_token, print_verbose, timeout, logging_obj, optional_params, litellm_params, logger_fn, acompletion, headers, client) and returns: self, self, self, convert_to_model_response_object