---
title: "How Should an OpenAI API Client Handle a Refusal When JSON Output Is Required?"  
description: "How Should an OpenAI API Client Handle a Refusal When JSON Output Is Required?"  
author: "Katherine Sullivan"  
published: 2026-10-15  
canonical: https://answers.mindstick.com/qa/117593/how-should-an-openai-api-client-handle-a-refusal-when-json-output-is-required  
category: "Mix Category"  
tags: ["openai", "API development", "JSON", "AI Safety"]  
reading_time: 1 minute  

---

# How Should an OpenAI API Client Handle a Refusal When JSON Output Is Required?

I’m building a feature that asks a model for [structured JSON](https://www.mindstick.com/forum/161282/how-are-json-objects-structured-in-javascript), and most responses match the schema. But what should the client do if the model refuses the request? A refusal message clearly isn’t the same thing as a valid object with the fields my application expects.

Should refusals be handled as a separate response state before schema validation, or is there a recommended way to represent them within the application’s own data model? I’m interested in approaches that avoid brittle parsing and make the refusal visible to the user.


---

Original Source: https://answers.mindstick.com/qa/117593/how-should-an-openai-api-client-handle-a-refusal-when-json-output-is-required

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
