#1363·promptflow

[Feature request] Can’t pass headers in AzureOpenAI connections

Author: rishabhsahaCreated Dec 4, 2023Updated Dec 4, 2024
Labelsfeaturepromptflow-core

Describe the bug I can’t seem to be able to pass headers while creating AzureOpenAI connections. Headers are needed in cases of Azure OpenAI instances placed behind Azure API Management.

How To Reproduce the bug Steps to reproduce the behavior, how frequent can you experience the bug:

  1. Try passing in an header which you can do while creating the OpenAI client

Expected behavior We should be able to pass in headers in the connection settings as well. OpenAI 1.x library requires you pass it when the client is being initialized. Example as below;

# Setting the auth headers
auth_headers = {
    ‘Ocp-Apim-Subscription-Key’: my_apim_sub_key,
    ‘Authorization’: f’Bearer {my_jwt_token}’
}

# Setting the Azure OpenAI client
azure_openai_client = AzureOpenAI(
   api_key = ‘null’,
   api_version = ‘2023-07-01-preview’,
   azure_endpoint = my_special_url,
   default_headers = auth_headers
)

# Calling Azure OpenAI
openai_response = azure_openai_client.chat.completions.create(
    model = ‘gpt-35-turbo-16k’,
    messages = my_messages
)

Running Information(please complete the following information):

  • Promptflow Package Version using pf -v: [e.g. 0.0.102309906]
  • Operating System: [e.g. Ubuntu 20.04, Windows 11]
  • Python Version using python --version: [e.g. python==3.10.12]

Additional context Add any other context about the problem here.