Back to All questionsHow do I fix BadRequestError: 400 - schema must be a JSON Schema of 'type: "object"', got 'type: "string"'?
Ask questionpython
response = client.beta.chat.completions.parse(
model="gpt-4o-2024-08-06",
messages=[{"role": "user", "content": "Hello"}],
response_format=str
)
Error:
text
BadRequestError: Error code: 400 - {'error': {'message': "schema
must be a JSON Schema of 'type: \"object\"', got 'type:
\"string\"'"}}
1 answerHelpful solutions from the community
Fix:
python
class StringOutput(BaseModel):
result: str
response = client.beta.chat.completions.parse(
model="gpt-4o-2024-08-06",
messages=[{"role": "user", "content": "Hello"}],
response_format=StringOutput
)
Need a custom solution?
Tell us about your project and get help tailored to your problem.
Contact usHave an answer? Join the conversation.
Everyone can read. Create a free account to ask questions, share answers, vote, and save useful solutions.