PulseAugur
EN
LIVE 22:01:36

Zod .refine() rules dropped before reaching LLMs via OpenAI/Vercel SDKs

Developers using Zod schemas with the OpenAI Node SDK or Vercel AI SDK may encounter issues where custom validation rules, specifically those defined using `.refine()`, are not passed to the language model. This occurs because the `z.toJSONSchema()` function, used by these SDKs, converts Zod schemas to JSON Schema format but omits `.refine()` checks, treating them as custom rules not supported by standard JSON Schema. Consequently, the model only receives the basic schema structure, and any validation logic defined in `.refine()` is only applied after the model's response is received, not during generation. AI

IMPACT Developers using Zod with AI SDKs need to be aware that custom validation rules are not passed to models, potentially leading to unexpected behavior.

RANK_REASON This item discusses a technical limitation in how specific SDKs handle Zod schemas, impacting developer workflows.

Read on dev.to — LLM tag →

AI-generated summary · Google Gemini · from 1 sources. How we write summaries →

Zod .refine() rules dropped before reaching LLMs via OpenAI/Vercel SDKs

How we ranked this

Signal score
20 / 100
Composite score across the factors below. Higher = stronger signal that this story matters right now.
Newsworthiness bucket
Tool
This item discusses a technical limitation in how specific SDKs handle Zod schemas, impacting developer workflows.
Source corroboration
Single-source cluster
Only one publisher covered this so far. Single-source stories can still rank when the publisher is high-authority, but they lack cross-source corroboration.
Topics
product, infra
Editorial topic classification. Feeds into how the story surfaces on /topic/<slug> hub pages and into the per-entity coverage mix.
AI-industry relevance
High
Clearly on-topic for AI-industry coverage.
Story freshness
Breaking (< 6h)
Fresh story with cross-source coverage still developing. Ranking may shift as more sources report.

Full methodology in our editorial standards.

COVERAGE [1]

  1. dev.to — LLM tag TIER_1 English(EN) · Gabriel Anhaia ·

    Your Zod .refine() Never Reaches the Model: What Survives the Trip to JSON Schema

    <ul> <li> <strong>Book:</strong> <a href="https://www.amazon.com/dp/B0HBN9XMCY" rel="noopener noreferrer">AI That Answers</a> </li> <li> <strong>The series:</strong> <em>AI in TypeScript</em> — 5 books, from your first LLM call to agents in production — <a href="https://xgabriel.…