Confirm this is an issue with the Python library and not an underlying OpenAI API
[ ] This is an issue with the Python library
Describe the bug
I used AsyncOpenAI Client to execute the tasks that required structed output (model as "gpt-4o-mini"). The first few runs of the same code returned normal results, but without any changes to the code, Suddenly I get a 400 error "response_format value as json_schema is enabled only for api versions 2024-08-01-preview and later".
To Reproduce
Instantiate one AsyncOpenAI:
aclient = AsyncOpenAI()
Define the data model as follows:
class Term(BaseModel):
term: str
definition: str
class Terms(BaseModel):
terms: List[Term]
Use the following code to make the request:
reference_text = "Machine learning is a very important subject."
system_promt = "You are an expert in the field of machine learning.Please extract the terms and definitions from the reference text according to the appropriate format."
user_prompt = "Given the following reference text:\n{}"
### Code snippets
```Python
openai.BadRequestError: Error code: 400 - {'error': {'message': 'response_format value as json_schema is enabled only for api versions 2024-08-01-preview and later', 'type': '', 'param': '', 'code': 'BadRequest'}}
Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
I used AsyncOpenAI Client to execute the tasks that required structed output (model as "gpt-4o-mini"). The first few runs of the same code returned normal results, but without any changes to the code, Suddenly I get a 400 error "response_format value as json_schema is enabled only for api versions 2024-08-01-preview and later".
To Reproduce
async def aquery(self, reference_text: str): response = await aclient.beta.chat.completions.parse( model="gpt-4o-mini", messages=[{"role": "system", "content": system_prompt}, {"role": "user", "content": user_prompt.format(reference_text)}], temperature=0.1, response_format=Terms ) return json.loads(response.choices[0].message.content)
OS
Ubuntu 20.04.6 LTS
Python version
Python 3.10.15
Library version
openai v1.51.1