code: def completions_to_model(cls, payload, config):
      key_mapping = {
          "max_tokens": "max_tokens_to_sample",
          "stop": "stop_sequences",
      }
  
      if "top_p" in payload:
          raise HTTPException(
              status_code=422,
              detail="Cannot set both 'temperature' and 'top_p' parameters. "
              "Please use only the temperature parameter for your query.",
          )
      max_tokens = payload.get(
          "max_tokens", MLFLOW_AI_GATEWAY_ANTHROPIC_DEFAULT_MAX_TOKENS
      )
  
      if max_tokens > MLFLOW_AI_GATEWAY_ANTHROPIC_MAXIMUM_MAX_TOKENS:
          raise HTTPException(
              status_code=422,
              detail="Invalid value for max_tokens: cannot exceed "
              f"{MLFLOW_AI_GATEWAY_ANTHROPIC_MAXIMUM_MAX_TOKENS}.",
          )
  
      payload["max_tokens"] = max_tokens
  
      if payload.get("stream", None) == "true":
          raise HTTPException(
              status_code=422,
              detail="Setting the 'stream' parameter to 'true' is not supported with the MLflow "
              "Gateway.",
          )
      n = payload.pop("n", 1)
      if n != 1:
          raise HTTPException(
              status_code=422,
              detail="'n' must be '1' for the Anthropic provider. Received value: '{n}'.",
          )
  
      payload = rename_payload_keys(payload, key_mapping)
  
      if payload["prompt"].startswith("Human: "):
          payload["prompt"] = "\n\n" + payload["prompt"]
  
      if not payload["prompt"].startswith("\n\nHuman: "):
          payload["prompt"] = "\n\nHuman: " + payload["prompt"]
  
      if not payload["prompt"].endswith("\n\nAssistant:"):
          payload["prompt"] = payload["prompt"] + "\n\nAssistant:"
  
      # The range of Anthropic's temperature is 0-1, but ours is 0-2, so we halve it
      if "temperature" in payload:
          payload["temperature"] = 0.5 * payload["temperature"]
  
      return payload
  
file_path: mlflow/mlflow/gateway/providers/anthropic.py
imports: import time
  from fastapi import HTTPException
  from fastapi.encoders import jsonable_encoder
  from mlflow.gateway.config import AnthropicConfig, RouteConfig
  from mlflow.gateway.constants import MLFLOW_AI_GATEWAY_ANTHROPIC_DEFAULT_MAX_TOKENS, MLFLOW_AI_GATEWAY_ANTHROPIC_MAXIMUM_MAX_TOKENS
  from mlflow.gateway.providers.base import BaseProvider, ProviderAdapter
  from mlflow.gateway.providers.utils import rename_payload_keys, send_request
  from mlflow.gateway.schemas import chat, completions, embeddings
label_desc: Use image node_id 2 for calling the AnthropicAdapter obj's underlying member method code with example usage: obj.completions_to_model(cls, payload, config) and returns: payload