Run failed: OpenAI API hits BadRequestError: Error code: 400 - {'error': {'code': 'TooManyHeaders', 'message': 'Your request contains too many headers. Please remove some headers and try again.'}} [Error reference: https://platform.openai.com/docs/guides/

Luc Elsby 75 Reputation points
2024-02-14T16:37:07.39+00:00

I get the following error when I try to run a GPT-4 model deployment run in MS Promptflow.

Run failed: OpenAI API hits BadRequestError: Error code: 400 - {'error': {'code': 'TooManyHeaders', 'message': 'Your request contains too many headers. Please remove some headers and try again.'}} [Error reference: https://platform.openai.com/docs/guides/error-codes/api-errors]

Everything worked fine yesterday and I didn't change any settings. Does anyone know what could be causing this?

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

3 answers

Sort by: Most helpful
  1. Jay 86 Reputation points
    2024-02-15T14:43:56.08+00:00

    Hey all,

    So here is my conclusion from my overall research. I may be wrong as well :)

    Recently (maybe a few days back), Microsoft pushed a new feature to validate all the openai api request headers.

    • If the request header is more than 8 (>8) it will start throwing this error. So the threshold is 8. If you provide even one more (i.e 9 ) it will be the 400 bad requests.
    { "error"``: {`` "code"``: ``"TooManyHeaders"``,`` "message"``: ``"Your request contains too many headers. Please remove some headers and try again." } }
    

    But this push is not released to all models and regions. So this behaviour can be experienced by differently on different endpoints

    So far I can easily reproduce this issue in the below API and region

    gpt-4 version 0613, eastus2

    Feel free to correct me or provide your own feedback and responses

    -Jay

    1 person found this answer helpful.

  2. Andrew Burgess 25 Reputation points
    2024-02-15T08:49:25.8433333+00:00

    This issue now seems to have magically disappeared this morning. I can successfully run prompt flows using GPT-4 across a number of different Azure accounts.


  3. Saurabh Sharma 23,831 Reputation points Microsoft Employee
    2024-02-21T06:38:00.6433333+00:00

    Hi Ryan Edgerley Thanks for the confirmation. Arjun G Jurs, Craig @Luc Elsby Mingyang Xu - Network Christian Wunderlich, The fix has now been made available in production. Please check and let me know if you still see any issues. Thanks Saurabh

    0 comments No comments

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.