https://github.com/badbye/define-json-schema
Generate JSON Schema for OpenAI's structure output
https://github.com/badbye/define-json-schema
Last synced: 18 days ago
JSON representation
Generate JSON Schema for OpenAI's structure output
- Host: GitHub
- URL: https://github.com/badbye/define-json-schema
- Owner: badbye
- Created: 2025-04-08T11:33:39.000Z (about 2 months ago)
- Default Branch: master
- Last Pushed: 2025-04-28T03:27:16.000Z (27 days ago)
- Last Synced: 2025-05-07T11:57:18.801Z (18 days ago)
- Language: Vue
- Homepage: https://define-json-schema.vercel.app
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JSON Schema for OpenAI API
ref: https://platform.openai.com/docs/guides/structured-outputs?api-mode=chat#supported-schemas
## Python Code Generation
After generating the JSON schema, you can use it to generate Python classes using Pydantic. Here's how you can do it:```
pip install datamodel-code-generator
# save the JSON schema to a file named json_schema.json
datamodel-codegen --input json_schema.json --input-file-type jsonschema --output model.py
```reference: https://docs.pydantic.dev/latest/integrations/datamodel_code_generator/