import os from azure.ai.inference import ChatCompletionsClient from azure.ai.inference.models import SystemMessage, UserMessage from azure.core.credentials import AzureKeyCredential # Get these from your Microsoft Foundry project's "Overview" page # (GitHub Models is retiring end of July 2026 - see https://ai.azure.com/catalog/models) token = os.environ["AZURE_INFERENCE_CREDENTIAL"] endpoint = os.environ["AZURE_INFERENCE_ENDPOINT"] model_name = "gpt-4o-mini" client = ChatCompletionsClient( endpoint=endpoint, credential=AzureKeyCredential(token), ) prompt = "Show me 5 recipes for a dish with the following ingredients: chicken, potatoes, and carrots. Per recipe, list all the ingredients used" response = client.complete( messages=[ { "role": "system", "content": "You are a helpful assistant.", }, { "role": "user", "content": prompt, }, ], model=model_name, # Optional parameters temperature=1., max_tokens=1000, top_p=1. ) if response.choices and response.choices[0].message is not None: print(response.choices[0].message.content)