SDK for structured JSON output from LLMs, validated via Zod schemas
Top 53.7% on sourcepulse
ZodGPT provides a library for obtaining structured, fully typed, and validated JSON outputs from OpenAI and Anthropic language models. It targets developers building applications that require reliable data extraction from LLMs, ensuring type safety and data integrity through Zod schema validation and automatic output correction.
How It Works
ZodGPT leverages the LLM's function calling capabilities to coerce responses into a structured format. It integrates with the Zod library for schema definition, serialization, and parsing. A key feature is "auto-healing," where the library automatically prompts the LLM to correct its own output if it deviates from the expected schema or function call format, enhancing reliability.
Quick Start & Requirements
npm i zod-gpt
or yarn: yarn add zod-gpt
.llm-api
for LLM provider integration.completion
from zod-gpt
and an LLM API client (e.g., OpenAIChatApi
) from llm-api
.Highlighted Details
autoSlice
option to handle token limit issues by splitting prompts.Maintenance & Community
The project appears to be maintained by a single author, dzhng. There are no explicit mentions of community channels (like Discord/Slack) or a public roadmap in the README.
Licensing & Compatibility
The README does not explicitly state a license. This requires further investigation to determine compatibility for commercial use or closed-source linking.
Limitations & Caveats
The schema
option currently only accepts object type schemas due to limitations of the function calling API; other types must be wrapped in an object. The contextSize
must be explicitly set in llm-api
options to enable token overflow error detection for autoSlice
.
1 year ago
1+ week