Kensink Labs
Structured OutputDirect LLM · no framework8-week engagement
STRUCTURED OUTPUT · FUNCTION CALLING

LLM as a typed component, not a chatbot.

JSON schema enforcement, validator loops with bounded retries, repair prompts on parse failure. Zod schemas mirror your API contract. Type-safe end-to-end — model output to client.

TypeScriptZodOpenAIAnthropic
Cycle
8 weeks · schema to ship
Stack
TypeScript · Zod · OpenAI / Anthropic
Output
Schemas + validator loop + repair prompts
Discipline
Output validates or doesn't ship — no maybe
[WHY THIS EXISTS]

JSON.parse on model output is a vulnerability.

The model returns 'almost-valid' JSON, your parser throws, your endpoint returns a 500, and the user gets nothing. Or worse — the model returns valid-but-wrong JSON, the field is missing, downstream code crashes with an undefined access. Structured output is about making the gap explicit.

  • Zod schemas as the single source of truth for both API and prompt
  • Validator loop — parse, validate, repair, retry — bounded retries
  • JSON-mode / function-calling on the model when supported
  • Type-safe end-to-end — TypeScript types derived from the Zod schema
[HOW WE BUILD IT]

Schema first, prompt second.

01

Zod as the contract

Define the output shape as a Zod schema. Generate TypeScript types from it. Pass the JSON schema to the model. One source of truth across API, prompt, and client.

02

Validator loop

Parse → validate → if invalid, send a repair prompt with the specific error → retry up to N times → fail loud if budget exhausts. No silent corrupted output.

03

Function-calling mode

OpenAI's response_format or Anthropic's tool-use, when the model supports it. Constrained decoding when self-hosting on vLLM.

04

Eval coverage

Golden eval includes parse-validity tests + schema-conformance tests + content tests. The CI gate fails if any drops.

[OUTCOMES AT HANDOFF]

What's live at week eight.

100%
Schema-valid outputs reaching the client
Bounded
Repair-retry budget on every call
One source
Zod schema drives types + prompt
Type-safe
End-to-end from model to UI
DIRECT LLM · APPLIED K

Bring the problem.
We’ll bring the build.

Eight weeks, fixed price, eval suite at handoff. Direct LLM engineering on top of the K-Framework. Two Q3 slots remain.