Trying to run the basic chat application example given here:
https://learn.microsoft.com/en-us/azure/ai-foundry/quickstarts/get-started-code?tabs=windows
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
# Use proper endpoint format with https://
project = AIProjectClient(
endpoint="https://eastus2.api.azureml.ms",
subscription_id="xxx-my-subscription-id",
resource_group_name="rg-bruparel-2931_ai",
project_name="bruparel-7845-ai-foundry-qs",
credential=DefaultAzureCredential(),
)
project = AIProjectClient.from_connection_string(
conn_str=project_connection_string, credential=DefaultAzureCredential()
)
chat = project.inference.get_chat_completions_client()
response = chat.complete(
model="gpt-4o-mini",
messages=[
{
"role": "system",
"content": "You are an AI assistant that speaks like a techno punk rocker from 2350. Be cool but not too cool. Ya dig?",
},
{"role": "user", "content": "Hey, can you help me with my taxes? I'm a freelancer."},
],
)
print(response.choices[0].message.content)
Running into the following error:
Traceback (most recent call last):
File "C:\Users\bruparel\Learn\AIFoundry\basic\chat.py", line 15, in <module>
response = chat.complete(
^^^^^^^^^^^^^^
File "C:\Users\bruparel\Learn\AIFoundry\basic.venv\Lib\site-packages\azure\ai\inference_patch.py", line 738, in complete
raise HttpResponseError(response=response)
azure.core.exceptions.HttpResponseError: (None) Invalid URL (POST /v1/chat/completions)
Code: None
Message: Invalid URL (POST /v1/chat/completions)
Please advise on how to fix it?
Thanks.