Output format json schema
--output-format-json-schema¶
Output JSON Schema for a JSON output format and exit.
Use this when an LLM agent, tool call definition, or validation layer needs the contract before consuming JSON output. The schema is emitted separately from the JSON payload so tools can fetch the contract once and validate later command output independently.
Currently supported schema targets:
generate-prompt: schema for--generate-prompt --output-format jsongeneration: schema for normal generation with--output-format jsonmodel-metadata: schema for files emitted by--emit-model-metadatastructured-output: tagged union schema for all structured command outputs, discriminated bykindconfig: schema for JSON-valued configuration options
Usage
datamodel-codegen --output-format-json-schema generate-prompt # (1)!
datamodel-codegen --output-format-json-schema generation # (2)!
datamodel-codegen --output-format-json-schema model-metadata # (3)!
datamodel-codegen --output-format-json-schema structured-output # (4)!
datamodel-codegen --output-format-json-schema config # (5)!
datamodel-codegen --generate-prompt --output-format json # (6)!
datamodel-codegen --input schema.json --emit-model-metadata model-map.json # (7)!
- Emit the JSON Schema for structured prompt output
- Emit the JSON Schema for generated-file output
- Emit the JSON Schema for generated model metadata
- Emit the JSON Schema for all structured command outputs
- Emit the JSON Schema for JSON-valued configuration options
- Emit prompt payloads that match the prompt schema
- Emit metadata payloads that match the model metadata schema