Hello Romanowski, Tomasz,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are having issue with running a completion operation on a GPT-4o model deployed in Azure OpenAI Service and this makes you to request for an assistance in identifying a suitable model and modifying your code to work with the model.
Solution
The error message you're seeing indicates that the gpt-4o model does not support the completion operation you're trying to perform. This is a known limitation of the gpt-4o model in the Azure OpenAI service and you can read more from this Azure OpenAI documentation: https://go.microsoft.com/fwlink/?linkid=2197993
To resolve this issue, you need to ensure that you are using a model that supports the completion operation. According to the Azure OpenAI documentation, certain models like gpt-35-turbo-instruct are recommended for such tasks. This is how you can modify your code to use the gpt-35-turbo model:
import os
from openai import AzureOpenAI
# Set environment variables
os.environ["AZURE_OPENAI_API_KEY"] = "your_azure_openai_api_key"
os.environ["AZURE_OPENAI_ENDPOINT"] = "your_azure_openai_endpoint"
# Initialize the client
client = AzureOpenAI(
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
api_version="2024-02-01",
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT")
)
# Use the correct deployment name for a supported model
deployment_name = 'gpt-35-turbo-instruct-deployment' # Replace with your deployment name
# Send a completion call to generate an answer
print('Sending a test completion job')
start_phrase = 'Write a tagline for an ice cream shop. '
response = client.completions.create(model=deployment_name, prompt=start_phrase, max_tokens=10)
print(start_phrase + response.choices[0].text)
I replaced gpt-35-turbo with your actual deployment name if you have deployed the gpt-35-turbo model. If you haven't, you might need to deploy it first.
References
Source: This is the current limitation. Assistants doesn't support GPT-4o yet. Accessed, 6/8/2024.
Source: Work with the GPT-35-Turbo and GPT-4 models - Azure OpenAI Service. Accessed, 6/8/2024.
Source: [Azure OpenAI documentation.] Accessed, 6/8/2024.
Accept Answer
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.
Best Regards,
Sina Salam