OperationNotSupported when testing python code from documentation for Azure OpenAI global batch deployment

Rithesh 0 Reputation points
2024-09-13T07:44:28.9866667+00:00

I have been trying to test my openAI development using the following piece of code I got from
https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/batch?tabs=standard-input&pivots=programming-language-python

test.py:

import os
from openai import AzureOpenAI
    
client = AzureOpenAI(
    api_key="api_key",  
    api_version="2024-07-01-preview",
    azure_endpoint = "endpoint_url"    )

# Upload a file with a purpose of "batch"
file = client.files.create(
  file=open("test.jsonl", "rb"), 
  purpose="batch"
)

print(file.model_dump_json(indent=2))
file_id = file.id

test.jsonl:

{"custom_id": "task-0", "method": "POST", "url": "/chat/completions", "body": {"model": "REPLACE-WITH-MODEL-DEPLOYMENT-NAME", "messages": [{"role": "system", "content": "You are an AI assistant that helps people find information."}, {"role": "user", "content": "When was Microsoft founded?"}]}}
{"custom_id": "task-1", "method": "POST", "url": "/chat/completions", "body": {"model": "REPLACE-WITH-MODEL-DEPLOYMENT-NAME", "messages": [{"role": "system", "content": "You are an AI assistant that helps people find information."}, {"role": "user", "content": "When was the first XBOX released?"}]}}
{"custom_id": "task-2", "method": "POST", "url": "/chat/completions", "body": {"model": "REPLACE-WITH-MODEL-DEPLOYMENT-NAME", "messages": [{"role": "system", "content": "You are an AI assistant that helps people find information."}, {"role": "user", "content": "What is Altair Basic?"}]}}

Error:
openai.BadRequestError: Error code: 400 - {'error': {'code': 'OperationNotSupported', 'message': 'The chatCompletion operation does not work with the specified model, gpt-4o. Please choose different model and try again. You can learn more about which models can be used with each operation here: https://go.microsoft.com/fwlink/?linkid=2197993.'}}

According to https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/batch?tabs=image-url&pivots=programming-language-python gpt-4o text+Vision is supported in East US, which is where my resource is located.

What am I doing wrong?

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,041 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Cauan Matheus 0 Reputation points
    2024-09-13T13:24:38.7033333+00:00

    In the file test.jsonl, I think the "model" key should be "gpt4ominibatch".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.