class_docstr: Client for interacting with OpenAI endpoints.
  
  Example:
  
  First, set up credentials for authentication:
  
  .. code-block:: bash
  
      export OPENAI_API_KEY=...
  
  .. seealso::
  
      See https://mlflow.org/docs/latest/python_api/openai/index.html for other authentication methods.
  
  Then, create a deployment client and use it to interact with OpenAI endpoints:
  
  .. code-block:: python
  
      from mlflow.deployments import get_deploy_client
  
      client = get_deploy_client("openai")
      client.predict(
          endpoint="gpt-3.5-turbo",
          inputs={
              "messages": [
                  {"role": "user", "content": "Hello!"},
              ],
          },
      )
class_docstr_tok: ["Client","for","interacting","with","OpenAI","endpoints",".","Example",":","First",",","set","up","credentials","for","authentication",":","..","code-block",":",":","bash","export","OPENAI_API_KEY=","...","..","seealso",":",":","See","https",":","\/\/mlflow.org\/docs\/latest\/python_api\/openai\/index.html","for","other","authentication","methods",".","Then",",","create","a","deployment","client","and","use","it","to","interact","with","OpenAI","endpoints",":","..","code-block",":",":","python","from","mlflow.deployments","import","get_deploy_client","client","=","get_deploy_client","(","``","openai","''",")","client.predict","(","endpoint=","''","gpt-3.5-turbo","''",",","inputs=","{","``","messages","''",":","[","{","``","role","''",":","``","user","''",",","``","content","''",":","``","Hello","!","``","}",",","]",",","}",",",")"]
docstr: Query an OpenAI endpoint.
  See https://platform.openai.com/docs/api-reference for more information.
  
  Args:
      deployment_name: Unused.
      inputs: A dictionary containing the model inputs to query.
      endpoint: The name of the endpoint to query.
  
  Returns:
      A dictionary containing the model outputs.
docstr_tok: ["Query","an","OpenAI","endpoint",".","See","https",":","\/\/platform.openai.com\/docs\/api-reference","for","more","information",".","Args",":","deployment_name",":","Unused",".","inputs",":","A","dictionary","containing","the","model","inputs","to","query",".","endpoint",":","The","name","of","the","endpoint","to","query",".","Returns",":","A","dictionary","containing","the","model","outputs","."]
code: def predict(self, deployment_name=None, inputs=None, endpoint=None):
      """Query an OpenAI endpoint.
      See https://platform.openai.com/docs/api-reference for more information.
  
      Args:
          deployment_name: Unused.
          inputs: A dictionary containing the model inputs to query.
          endpoint: The name of the endpoint to query.
  
      Returns:
          A dictionary containing the model outputs.
  
      """
      _check_openai_key()
  
      from mlflow.openai.api_request_parallel_processor import (
          process_api_requests,
      )
  
      api_config = _get_api_config_without_openai_dep()
      api_token = _OAITokenHolder(api_config.api_type)
  
      if api_config.api_type in ("azure", "azure_ad", "azuread"):
          api_base = api_config.api_base
          api_version = api_config.api_version
          engine = api_config.engine
          deployment_id = 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."
                  )
              inputs = {"engine": engine, **inputs}
          elif deployment_id is None:
              raise MlflowException(
                  "Either engine or deployment_id must be set for Azure OpenAI API",
              )
  
          request_url = (
              f"{api_base}/openai/deployments/{deployment_id}"
              f"/chat/completions?api-version={api_version}"
          )
      else:
          inputs = {"model": endpoint, **inputs}
          request_url = REQUEST_URL_CHAT
  
      try:
          return process_api_requests(
              [inputs],
              request_url,
              api_token=api_token,
              throw_original_error=True,
              max_workers=1,
          )[0]
      except MlflowException:
          raise
      except Exception as e:
          raise MlflowException(f"Error response from OpenAI:\n {e}")
  
imports: import logging
  import os
  from mlflow.exceptions import MlflowException
  from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
  from mlflow.utils.openai_utils import REQUEST_URL_CHAT, _OAITokenHolder, _OpenAIApiConfig, _OpenAIEnvVar
  from mlflow.utils.rest_utils import augmented_raise_for_status
  from mlflow.deployments import BaseDeploymentClient
label_desc: Use image node_id 6 for calling the OpenAIDeploymentClient obj's underlying member method code with example usage: obj.predict(deployment_name, inputs, endpoint) and returns: process_api_requests