This link provides the steps to access openai through Azure OpenAI with APIM.
https://github.com/microsoft/AzureOpenAI-with-APIM/blob/main/example_code/example.py
Following is the code as given in the above link to use chat_completions API by OpenAI .
apim_url = “apim_url” deployment_name = “deployment_name” api_version = “2024-02-15-preview” subscription_key = “subscription_key”
url = f”{apim_url}/deployments/{deployment_name}/chat/completions?api-version={api_version}” headers = { “Content-Type”: “application/json”, “Ocp-Apim-Subscription-Key”: subscription_key }
json_payload = { “messages”: [ { “role”: “system”, “content”: “You are an AI assistant that helps people find information.” }, { “role”: “user”, “content”: “What are the differences between Azure Machine Learning and Azure AI services?” } ], “temperature”: 0.7, “top_p”: 0.95, “max_tokens”: 800 }
response = requests.post(url, headers=headers, json=json_payload)
I want to use the Open AI files and Batch API in this way . How can I do that ?