---
title: "Discussion on \"Reliable JSON from any OpenAI-compatible model: json_schema, then json_object, then prompt-only, validated with Pydantic\" | Hashnode"
description: "Discussion on \"Reliable JSON from any OpenAI-compatible model: json_schema, then json_object, then prompt-only, validated with Pydantic\". One function that degrades gracefully when a model doesn't support structured outputs, and repairs invalid replies by showing the model its own validation errors."
url: "https://hashnode.com/posts/reliable-json-from-any-openai-compatible-model-json-schema-then-json-object-then-prompt-only-validated-with-pydantic/6adc69a4a6d3c5bbf619355f"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Reliable JSON from any OpenAI-compatible model: json\_schema, then json\_object, then prompt-only, validated with Pydantic](https://apigoto-notes.hashnode.dev/reliable-json-from-any-openai-compatible-model-json-schema-then-json-object-then-prompt-only-validated-with-pydantic?utm_source=hashnode&utm_medium=feed)

One function that degrades gracefully when a model doesn't support structured outputs, and repairs invalid replies by showing the model its own validation errors.

Oct 24 · 6 min read · apigoto-notes.hashnode.dev  
Read the article

-   [#pydantic](https://hashnode.com/tag/pydantic)
-   [#json](https://hashnode.com/tag/json)
-   [#python](https://hashnode.com/tag/python)
-   [#llm](https://hashnode.com/tag/llm)
-   [#openai-api](https://hashnode.com/tag/openai-api)

## Written by

[lucky wang](https://hashnode.com/@apigoto-builder)

@apigoto-builder · Singapore

  
[View profile](https://hashnode.com/@apigoto-builder)

Building AI prototypes and sharing practical LLM API integration notes.

One OpenAI-compatible endpoint for Claude, GPT, Gemini, DeepSeek and more: unified API, multi-upstream failover, call logs and token usage. www.china-aiapi.com

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
