Cost-Hardened AI Architecture
Technical

Cost-Hardened AI Architecture

by Anupam Tandon · 2026-09-16

Your LLM resume parser is probably “working,” right up until it returns valid JSON with the wrong meaning. Or it silently drifts from the schema you thought you enforced, burns tokens on full resumes, and sends uncontrolled text to an external model. Cost-Hardened AI Architecture shows you how to build a resume parsing and matching system that stays bounded, consistent, and cheap. You will lock request and output contracts with schema guards, retrieve only what matters with pgvector, and cache embeddings so you never re-embed the same resume twice. This is a team training doc built for engineers and architects, with endpoint patterns and practical guardrails you can implement fast and explain clearly.

4 chapters 2,078 words ~8 min read English

Read the first chapter

The whole of chapter one, free. About 2 min. Turn the pages with the arrows, your keyboard, or a swipe.

Chapter 1

POST /parse Resume Endpoint

Overview

What happens when a resume parser returns valid JSON with the wrong fields, missing values, or uncontrolled text? This endpoint uses the Zod Lockstep Contract: the request schema, LLM output schema, and API response schema remain aligned. Use it when raw resume text must become bounded, machine-readable data without schema drift or token bleed.

Quick Reference

Item

Value

Endpoint

POST /parse

Content type

application/json

Input

Resume text and optional model settings

Validation

Zod request and response schemas

LLM output

Structured JSON only

Failure status

400 for invalid input, 502 for invalid provider output

Token control

maxResumeChars, bounded field lengths

Parameters

Parameter

Type

Required

Description

resumeText

string

Yes

Plain-text resume content. Maximum 30,000 characters.

maxResumeChars

number

No

Input truncation limit. Default: 30_000; minimum: 1,000.

model

string

No

Provider model identifier. Default: gpt-4o-mini.

temperature

number

No

Sampling temperature. Default: 0; allowed range: 0-0.3.

Code Example

import express from "express"; import OpenAI from "openai"; import { z } from "zod";

const app = express(); app.use(express.json({ limit: "256kb" }));

const RequestSchema = z.object({ resumeText: z.string().trim().min(50), maxResumeChars: z.number().int().min(1_000).max(30_000).default(30_000), model: z.string().default("gpt-4o-mini"), temperature: z.number().min(0).max(0.3).default(0), });

const ResumeSchema = z.object({ name: z.string().max(160).nullable(), email: z.string().email().nullable(), skills: z.array(z.string().max(80)).max(100), experience: z.array(z.object({ title: z.string().max(160), company: z.string().max(160), years: z.number().min(0).max(80).nullable(), })).max(30), });

const client = new OpenAI();

app.post("/parse", async (req, res) => { const input = RequestSchema.parse(req.body); const resumeText = input.resumeText.slice(0, input.maxResumeChars);

const completion = await client.chat.completions.create({ model: input.model, temperature: input.temperature, response_format: { type: "json_object" }, messages: [ { role: "system", content: "Return only the requested resume JSON." }, { role: "user", content: resumeText }, ], });

const raw = JSON.parse(completion.choices[0].message.content?? "{}"); const parsed = ResumeSchema.safeParse(raw);

if (!parsed.success) { return res.status(502).json({ error: "provider_schema_mismatch" }); }

return res.json({ data: parsed.data }); }); Response Format

{ "data": { "name": "Avery Chen", "email": "avery.chen@example.com", "skills": ["TypeScript", "PostgreSQL", "Docker"], "experience": [ { "title": "Backend Engineer", "company": "Northstar Systems", "years": 4.5 } ] } } data is the Zod-validated resume object. Nullable fields represent absent source data; bounded arrays and strings prevent uncontrolled output growth.

Notes & Best Practices

• Reject oversized payloads before the model call. Character limits provide a predictable upper bound on input tokens.

• Use safeParse for provider output and return 502; do not persist or index data that fails the contract.

• Keep temperature at 0 for extraction. Log token usage, model ID, and validation failures without logging full resume text.

• Treat truncation as an explicit policy. For long resumes, extract sections before parsing rather than silently discarding the tail.

The Zod Lockstep Contract makes schema validation part of the request boundary, not a post-processing assumption. That boundary is the foundation for controlling both downstream data quality and model spend.

End of chapter one. 3 more chapters in the full book.

1 / 3

Swipe or use the arrows to turn the page

What's inside: 4 chapters

  1. 1. POST /parse Resume Endpoint
  2. 2. POST /match Candidates Endpoint
  3. 3. GET /resume Embeddings Endpoint
  4. 4. POST /validate Match JSON Endpoint

About this book

"Cost-Hardened AI Architecture" is a technical book by Anupam Tandon with 4 chapters and approximately 2,078 words. Your LLM resume parser is probably “working,” right up until it returns valid JSON with the wrong meaning. Or it silently drifts from the schema you thought you enforced, burns tokens on full resumes, and sends uncontrolled text to an external model.

This book was created using Inkfluence AI, an AI-powered book generation platform that helps authors write, design, and publish complete books. It was made with the AI Documentation Generator.

Frequently Asked Questions

What is "Cost-Hardened AI Architecture" about?

Your LLM resume parser is probably “working,” right up until it returns valid JSON with the wrong meaning. Or it silently drifts from the schema you thought you enforced, burns tokens on full resumes, and sends uncontrolled text to an external model. Cost-Hardened AI Architecture shows you how to build a resume parsing and matching system that stays bounded, consistent, and cheap. You will lock request and output contracts with schema guards, retrieve only what matters with pgvector, and cache embeddings so you never re-embed the same resume twice. This is a team training doc built for engineers and architects, with endpoint patterns and practical guardrails you can implement fast and explain clearly.

How many chapters are in "Cost-Hardened AI Architecture"?

The book contains 4 chapters and approximately 2,078 words. Topics covered include POST /parse Resume Endpoint, POST /match Candidates Endpoint, GET /resume Embeddings Endpoint, POST /validate Match JSON Endpoint.

Who wrote "Cost-Hardened AI Architecture"?

This book was written by Anupam Tandon and created using Inkfluence AI, an AI book generation platform that helps authors write, design, and publish books.

How can I create a similar technical book?

You can create your own technical book using Inkfluence AI. Describe your idea, choose your style, and the AI writes the full book for you. It's free to start.

Write your own technical book with AI

Describe your idea and Inkfluence writes the whole thing. Free to start.

Start writing

Created with Inkfluence AI