Back to all articles

API & Integration

Jev Batch Processing & Cost Optimization: Classifying 100k+ Records Cleanly

Engineering guide to high-volume Jev AI batch processing and pricing control: bounded concurrency pools, 429 retry backoff, input-token trimming, two-tier Clef Flash + Jev 1.14 routing, and JSONL checkpointing.

By Jev AINov 30, 20264 min read
Jev Batch Processing & Cost Optimization: Classifying 100k+ Records Cleanly

To batch-process tens of thousands of records with Jev AI without blowing your budget or hitting rate limits, combine four engineering practices: deduplicate and trim noisy state fields, bundle multiple questions into one parallel /v1/systemone request, cap in-flight concurrency to your plan limit with jittered retries, and cascade uncertain rows from a lightweight model (cloudflare/clef-flash) to typesafe/jev-1.14.

Decision models have a major economic advantage over generative LLMs: output tokens are free, and every response is a tiny typed JSON object instead of paragraphs of prose. That means your batch cost is determined almost entirely by input tokens and request count.

This guide walks through a battle-tested batch architecture for classifying 10k–100k+ support tickets, product SKUs, invoices, or evaluation logs using the Jev AI API — including resilient TypeScript worker code, two-tier cost routing, and practical payload optimization.

Table of contents

How Jev AI batch billing works

Every API-key call to POST https://thejevai.com/v1/systemone returns both data.result.usage (input_tokens, output_tokens) and data.creditsUsed. Because decision models bill on input tokens (with a minimum of 1 credit per API request) and charge zero for output tokens, two rules govern high-volume unit economics:

  1. Never send duplicate state payloads across separate API calls. Asking 5 questions in one parallel request uses 1× state tokens instead of 5×.
  2. Prototype in the free Playground before launching a 50k-row batch. Validate your criteria wording and sample token size on 20 real edge cases in the Jev AI Playground so you never waste credits on a broken rubric.

See current credit tiers on the Jev AI Pricing page and per-model credit rates in our Decision Models directory.

Resilient batch architecture: dedupe, semaphore, retry, checkpoint

Firing Promise.all() over 50,000 rows will immediately overwhelm sockets and trigger HTTP 429 errors. Structure every batch job as a five-stage pipeline:

Five-stage batch concurrency pipeline: Hash and Dedupe, Semaphore Queue, Backoff Loop, Append JSONL Checkpoint, and Audit Metrics

  1. Hash & Deduplicate: Compute a SHA-256 hash over normalized state. In support logs, product feeds, and web scrapes, 10%–30% of rows are often duplicates—cache and reuse their decision results for free.
  2. Bounded Concurrency Semaphore: Limit active requests to match your workspace concurrency tier.
  3. Jittered Exponential Backoff: Retry transient 429 and 5xx responses (500ms → 1s → 2s → 4s with random jitter); fail fast on 400 schema errors.
  4. Crash-Safe JSONL Checkpointing: Append each completed { id, answers, creditsUsed } line immediately to an output .jsonl file so restarting a job skips already-processed IDs.
  5. Telemetry Audit: Aggregate total creditsUsed, mean input_tokens, and p95 elapsedMs after the first 500 rows before scaling to 100k.

Three payload optimizations that cut credit spend by 50%+

Before touching model selection, optimize what goes into state:

Three payload optimization levers: Strip Boilerplate State, Bundle Parallel Questions, and Filter Deterministic Rules First

  • Strip HTML & boilerplate footers: Raw support emails often carry 1,000+ tokens of confidentiality disclaimers, thread history, and CSS tags. Extracting only the latest customer message plus structured order metadata frequently cuts input tokens by 60%–70% and improves classification accuracy.
  • Bundle parallel questions: Combine intent, urgency, language, and escalation checks into one questions map rather than running separate batch passes.
  • Filter deterministic rules in code first: If a regex, SKU table, or numeric rule (invoice_total > 10000) already settles the outcome, never spend an API call on it.

Two-tier cascade: Clef Flash first, Jev 1.14 for edge cases

Because Jev AI serves both compact models and flagship typesafe/jev-1.14 on the exact same endpoint, large batch jobs can use confidence-gated model cascading:

Two-tier model cascade diagram: 80% high-confidence rows resolved by Tier 1 Clef Flash and 20% uncertain rows escalated to Tier 2 Jev 1.14

  1. Run Pass 1 on a lightweight model such as cloudflare/clef-flash or liquid/d1.2.
  2. Accept any decision where confidence >= 0.88 (typically ~75%–85% of straightforward rows).
  3. Escalate only the ambiguous ~15%–25% to typesafe/jev-1.14 for flagship calibration and hard-tier accuracy (compare both on Jev vs Cloudflare Clef and Jev Benchmark).

Production TypeScript batch runner with JSONL resume

import fs from "node:fs";

interface Row { id: string; text: string }

async function callJevWithRetry(payload: Record<string, unknown>, maxRetries = 4) {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    const res = await fetch("https://thejevai.com/v1/systemone", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.JEV_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify(payload),
    });
    if (res.ok) return res.json();
    if (res.status !== 429 && res.status < 500) {
      throw new Error(`Non-retryable HTTP ${res.status}`);
    }
    const delay = Math.min(8000, 500 * 2 ** attempt) + Math.random() * 250;
    await new Promise((r) => setTimeout(r, delay));
  }
  throw new Error("Max retries exceeded");
}

export async function runBatch(rows: Row[], outPath: string, concurrency = 8) {
  const done = new Set<string>();
  if (fs.existsSync(outPath)) {
    for (const line of fs.readFileSync(outPath, "utf8").split("\n")) {
      if (line.trim()) done.add(JSON.parse(line).id);
    }
  }
  const queue = rows.filter((r) => !done.has(r.id));
  const out = fs.createWriteStream(outPath, { flags: "a" });

  async function worker() {
    while (queue.length > 0) {
      const row = queue.shift()!;
      const body = await callJevWithRetry({
        model: "typesafe/jev-1.14",
        state: row.text,
        questions: {
          spam: { type: "noul", instructions: "Is this text promotional spam?" },
        },
      });
      out.write(JSON.stringify({ id: row.id, ...body.data }) + "\n");
    }
  }

  await Promise.all(Array.from({ length: concurrency }, () => worker()));
  out.end();
}

Matching concurrency to your Jev AI plan

  • Starter plan: Keep concurrency at 3 parallel workers—ideal for validating 1k–10k row datasets and pilot workflows.
  • Pro plan: Scale to 10 parallel workers with fast-lane routing for recurring nightly jobs and live production pipelines.
  • Enterprise plan: Unlimited concurrency with dedicated fast lane for 100k+ real-time or batch classification pipelines.

Explore real batchable schemas (content moderation, catalog tagging, CSV dedupe, invoice audit) on our Jev Use Cases page.

Frequently asked questions

Is there a free way to estimate how many credits my batch will use?

Yes. Run 10–20 representative rows first and inspect data.creditsUsed and data.result.usage.input_tokens in the API response, then multiply by your deduplicated row count. You can also design your questions for free in the Playground.

Does Jev AI have a separate batch endpoint?

You run batch workloads against the same high-speed POST https://thejevai.com/v1/systemone endpoint using bounded client concurrency and JSONL checkpointing—giving you immediate streaming results instead of waiting 24 hours for an offline batch queue.

Do one-time credit packs expire if I only run occasional batch jobs?

No—one-time credit packs on Jev AI Pricing do not auto-renew and remain available without expiry while your account is active.

© 2026 Jev AI JournalBack home