code: def _call_openai_api(openai_uri, payload, eval_parameters):
      if "OPENAI_API_KEY" not in os.environ:
          raise MlflowException(
              "OPENAI_API_KEY environment variable not set",
              error_code=INVALID_PARAMETER_VALUE,
          )
  
      from mlflow.openai import _get_api_config
      from mlflow.openai.api_request_parallel_processor import (
          process_api_requests,
      )
      from mlflow.utils.openai_utils import _OAITokenHolder
  
      api_config = _get_api_config()
      api_token = _OAITokenHolder(api_config.api_type)
  
      payload = {
          "messages": [{"role": "user", "content": payload}],
          **eval_parameters,
      }
  
      if api_config.api_type in ("azure", "azure_ad", "azuread"):
          api_base = getattr(api_config, "api_base")
          api_version = getattr(api_config, "api_version")
          engine = getattr(api_config, "engine")
          deployment_id = getattr(api_config, "deployment_id")
  
          if engine:
              # Avoid using both parameters as they serve the same purpose
              # Invalid inputs:
              #   - Wrong engine + correct/wrong deployment_id
              #   - No engine + wrong deployment_id
              # Valid inputs:
              #   - Correct engine + correct/wrong deployment_id
              #   - No engine + correct deployment_id
              if deployment_id is not None:
                  _logger.warning(
                      "Both engine and deployment_id are set. "
                      "Using engine as it takes precedence."
                  )
              payload = {"engine": engine, **payload}
          elif deployment_id is None:
              raise MlflowException(
                  "Either engine or deployment_id must be set for Azure OpenAI API",
              )
          payload = payload
  
          request_url = (
              f"{api_base}/openai/deployments/{deployment_id}"
              f"/chat/completions?api-version={api_version}"
          )
      else:
          payload = {"model": openai_uri, **payload}
          request_url = REQUEST_URL_CHAT
  
      try:
          resp = process_api_requests(
              [payload],
              request_url,
              api_token=api_token,
              throw_original_error=True,
              max_workers=1,
          )[0]
      except MlflowException as e:
          raise e
      except Exception as e:
          raise MlflowException(f"Error response from OpenAI:\n {e}")
  
      return _parse_chat_response_format(resp)
  
file_path: mlflow/mlflow/metrics/genai/model_utils.py
imports: import logging
  import os
  import urllib.parse
  from mlflow.exceptions import MlflowException
  from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
  from mlflow.utils.openai_utils import REQUEST_URL_CHAT
label_desc: Use image node_id 3 for calling a global function with example usage: _call_openai_api(openai_uri, payload, eval_parameters) and returns: _parse_chat_response_format