AI & JSON — LLM Output, Schemas & Agents

Getting reliable JSON from LLMs, structured outputs, function calling, validation, and AI agent tooling.

·11 min read

How Constrained Decoding Forces Valid JSON: XGrammar, Outlines & GBNF

The mechanism under 'JSON mode': how a JSON Schema becomes a grammar that masks illegal tokens at generation time, why XGrammar beats retries, and where constrained decoding still bites.

·9 min read

Vercel AI SDK Structured Output: Type-Safe JSON with generateObject & Zod

Get type-safe JSON from LLMs with the Vercel AI SDK's generateObject and streamObject — validated against a Zod schema, with automatic retries.

·9 min read

Pydantic AI: Type-Safe Structured Output and Agents in Python

Pass a Pydantic BaseModel as output_type and Pydantic AI returns validated, typed JSON from any LLM — retrying automatically when a field is wrong.

·10 min read

OpenAI Responses API vs Chat Completions: What Changes in Your JSON

How OpenAI's Responses API changes your JSON vs Chat Completions: typed items, an output array, structured outputs in text.format, and server-side state.

·8 min read

Structured JSON from Local LLMs with Ollama

Use Ollama's format parameter to force any local LLM's output to match a JSON Schema — reliable, type-safe JSON via constrained decoding, often faster.

·8 min read

Google Gemini Structured Output: responseSchema and JSON Mode

Constrain Google Gemini to a JSON Schema with responseMimeType and responseSchema. Learn the request shape, propertyOrdering, enums, and OpenAI differences.

·11 min read

RAG JSON Formats Explained: Documents, Chunks, Vectors & Citations

Every JSON shape in a retrieval-augmented generation pipeline — documents, chunks, embeddings, vector queries, retrieved matches and cited answers — with copy-ready examples for each stage.

·12 min read

JSON for AI & LLM Engineering: Every Response Shape You'll Parse

A field guide to the JSON behind modern AI apps — OpenAI and Claude responses, tool calling, MCP, embeddings, RAG, agents, structured output and more, each with a copy-ready example.

·9 min read

Preparing Fine-Tuning Data: The JSONL Format Explained

Fine-tuning an LLM means formatting examples as JSONL. Learn the chat message schema, validation, common errors, and how to build a clean training file.

·9 min read

Computer Vision JSON: COCO Format, Bounding Boxes & Annotations

The JSON behind object detection and image annotation — COCO format, bounding box conventions, and how tools like YOLO and Label Studio structure vision data.