I try to use Azure OpenAI GPT 4o mini batch. I first need to create the batch. I ran:
import os
from openai import AzureOpenAI
client = AzureOpenAI(
api_key="[insert Azure OpenAI API key here]",
api_version="2023-07-01-preview",
azure_endpoint="https://[insert Azure OpenAI API enddpoint here].openai.azure.com/",
)
file = client.files.create(
file=open("./dummy.jsonl", "rb"),
purpose="batch"
)
file_id = file.id
with dummy.jsonl
containing:
{
"custom_id": "request-1",
"method": "POST",
"url": "/v1/chat/completions",
"body": {
"model": "gpt-3.5-turbo-0125",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello world!"
}
],
"max_tokens": 1000
}
}
I get the error:
BadRequestError: Error code: 400 - {'error': {'code': 'invalidPayload', 'message': 'Invalid value for purpose.'}}
How to fix that error?
To make the code work, upgrade the api_version
. E.g., the following works:
import os
from openai import AzureOpenAI
client = AzureOpenAI(
api_key="[insert Azure OpenAI API key here]",
api_version="2023-07-01-preview",
azure_endpoint="https://[insert Azure OpenAI API enddpoint here].openai.azure.com/",
)
file = client.files.create(
file=open("./dummy.jsonl", "rb"),
purpose="batch"
)
file_id = file.id