Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

0

Error when connecting to Azure Open AI Service from Fabric Data Engineering notebook

When accessing to Azure Open AI Service with openai==1.61 from Microsoft Fabric notebook, I get the error below.

 

ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)
APIConnectionError: Connection error.

 

 

You can reproduce the issue with the code below.

 

%pip install -U openai

from pyspark.sql import Row
from synapse.ml.services.openai import OpenAIChatCompletion
from openai import AzureOpenAI

def get_response(question):
    prompt = f"""
    Please answer the questions based on the following information.
    """

    messages = [{'role': 'system', 'content': prompt}, {'role': 'user', 'content': question}]

    aoai_client = AzureOpenAI(
        api_key = "<api_key>",
        api_version = "2024-02-01",
        azure_endpoint = "https://<azure_open_ai_service>.openai.azure.com/"
    )

    result = aoai_client.chat.completions.create(messages=messages, model="gpt-4o-mini").choices[0].message.content
    return result

question = "Please tell me how to reserve the restaurant."
response = get_response(question)
print(response)

 

 

Status: Delivered

Hi @eigokainai,

 

I'm glad you found workaround and shared it, for those of you who have had similar experiences check out the comments below.

 

Best regards.
Community Support Team_Caitlyn

Comments
eigokainai
Microsoft Employee

I found the solution.

This is caused by a change in httpx, a dependency of openai.

If I execute `pip install -U openai`, httpx==0.28.1 is installed, which causes the error.

A workaround is to execute `pip install -U openai httpx==0.27.2`.

 

Another workaround is to add the code below.

import certifi
os.environ['SSL_CERT_FILE'] = certifi.where() 

 

v-xiaoyan-msft
Community Support
Status changed to: Delivered

Hi @eigokainai,

 

I'm glad you found workaround and shared it, for those of you who have had similar experiences check out the comments below.

 

Best regards.
Community Support Team_Caitlyn