{"detail":"Extra parameters ['safe_prompt'] are not allowed when extra-parameters is not set or set to be 'error'. Set extra-parameters to 'pass-through' to pass to the model."}

Anonymous
2024-10-30T10:36:07+00:00

Hi,

I have a working code, it suddenly getting following exception:

httpx.HTTPStatusError: Error response 400 while fetching https://mistral-nemo-iggff.swedencentral.models.ai.azure.com/chat/completions: {"detail":"Extra parameters ['safe_prompt'] are not allowed when extra-parameters is not set or set to be 'error'. Set extra-parameters to 'pass-through' to pass to the model."}

I am using langchain ChatMistralAI to initiate the connection. How can I fix it? this code was working for last 15 days and no changes were deployed. suddenly I'm getting this issue.

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,106 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Jaumann 35 Reputation points
    2024-11-12T14:43:47.1433333+00:00

    I have found a solution for this by using the OpenAI-compltible endpoint of the mistral model and setting the extra-parameter header.

    from langchain_openai import  ChatOpenAI
    
    mistral_model = ChatOpenAI(
            default_headers={"extra-parameters": "pass-through"},
            base_url=base_url_mistral,
            api_key=os.getenv("AZURE_MISTRAL_KEY"),
            model=deployment_name_mistral,
        )
    
    # This produces an exception.
    mistral_model.invoke("hi")
    
    

    The extra-parameters header is documented here

    2 people found this answer helpful.
    0 comments No comments

  2. Philipp Lang 0 Reputation points
    2024-12-02T21:21:36.8233333+00:00

    This is likely a breaking change on the Azure side. Using the OpenAI client will break some features, like structured output. Another option is to set safe_mode to None

    This way it won't be added to the headers:

    
    mistral_model = ChatMistralAI(
    	base_url=base_url_mistral,
    	api_key=os.getenv("AZURE_MISTRAL_KEY"),
    	model=deployment_name_mistral,
    )
    mistral_model.safe_mode = None
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.