Your nightly LLM jobs don't need real-time prices: run them through the Batch API for 50% off (Monday AI Insight)
Monday AI Insight. One practical cost lesson: if nobody is waiting for the answer, don't pay real-time prices for it. Eval runs, backfills, re-embedding a corpus, classifying a big dataset, nightly summaries: these jobs usually go through the same synchronous endpoint your chat UI uses, one request

Monday AI Insight. One practical cost lesson: if nobody is waiting for the answer, don't pay real-time prices for it. Eval runs, backfills, re-embedding a corpus, classifying a big dataset, nightly summaries: these jobs usually go through the same synchronous endpoint your chat UI uses, one request at a time, fighting your per-minute rate limits. OpenAI, Anthropic and Google all offer a batch mode for exactly this work, and all three price it at half the standard rate.
OpenAI Batch API. OpenAI's guide lists a 50% cost discount compared to synchronous APIs, substantially more rate-limit headroom, and a 24-hour completion window ("and often more quickly"). completion_window can currently only be set to 24h. Supported endpoints include /v1/responses, /v1/chat/completions, /v1/embeddings, /v1/completions and /v1/moderations. The guide's own example use cases: running evaluations, classifying large datasets, and embedding content repositories.
Anthropic Message Batches API. All usage is charged at 50 percent of standard API prices. Most batches finish in less than 1 hour; batches that don't finish processing within 24 hours expire. Almost any Messages API request can go in a batch (vision, tool use, system messages, multi-turn, extended thinking), and you can mix request types in one batch. stream: true is not supported.
Google Gemini Batch API. Also 50% of the standard interactive cost, with a target turnaround of 24 hours ("in majority of cases, it is much quicker"). You can send inline requests (total request size under 20MB) or a JSONL input file of up to 2GB.
Anthropic uses the same idea with a slightly different shape: you send a list of requests, each with a custom_id (1 to 64 characters, letters, digits, hyphens and underscores) and normal Messages params. Gemini uses a user-defined key per line instead of custom_id.
OpenAI: "the output line order may not match the input line order." Anthropic: batch results "can be returned in any order." Never zip inputs and outputs by position. Match on custom_id, and make it something meaningful, like eval-42 or doc-8812-chunk-3, so a result points straight back to its source row.
import json from openai import OpenAI client = OpenAI ( ) MODEL = "gpt-6-luna" # any Batch-supported model; one model per input file tickets = { "t-101": "App crashes on login", "t-102": "Refund not received" } # 1) Build the JSONL: one request per line, unique custom_id with open ( "batch_input.jsonl", "w" ) as f: for tid, text in tickets. items ( ): f. write ( json. dumps ( { "custom_id": tid, "method": "POST", "url": "/v1/responses", "body": { "model": MODEL, "input": f "Label as bug, billing or other: {text}", "max_output_tokens": 16 }, } ) + "\n" ) # 2) Upload + create the batch f = client. files. create ( file = open ( "batch_input.jsonl", "rb" ), purpose = "batch" ) batch = client. batches. create ( input_file_id = f. id, endpoint = "/v1/responses", completion_window = "24h", metadata = { "job": "nightly-ticket-labels" } ) # 3) Later, after polling client.batches.retrieve(batch.id) until a final status: def read_jsonl ( file_id ): if not file_id: return [ ] return [ json. loads ( l ) for l in client. files. content ( file_id ). text. splitlines ( ) if l ] batch = client. batches. retrieve ( batch. id ) results, failed = { }, [ ] for row in read_jsonl ( batch. output_file_id ) + read_jsonl ( batch. error_file_id ): resp = row. get ( "response" ) if row. get ( "error" ) or not resp or resp [ "status_code" ]!= 200: failed. append ( row [ "custom_id" ] ) continue body = resp [ "body" ] text = "". join ( c [ "text" ] for o in body [ "output" ] if o [ "type" ] == "message" for c in o [ "content" ] if c [ "type" ] == "output_text" ) results [ row [ "custom_id" ] ] = text # matched by custom_id, not by position # Anything we sent but never got back also needs a retry failed += [ tid for tid in tickets if tid not in results and tid not in failed ] print ( results, "retry:", failed ) Enter fullscreen mode Exit fullscreen mode Partial failures and expiry: retry only what failed A batch is not all-or-nothing:
So the retry loop is simple: collect the custom_id s that didn't succeed, rebuild a smaller JSONL from your source rows, and submit only that.
Anthropic says prompt caching discounts and batch discounts stack, but cache hits in a batch are best-effort because requests run concurrently and in any order. Their tips: put identical cache_control blocks in every request, share as much prefix as possible, and since batches can take longer than 5 minutes, consider the 1-hour cache duration. Gemini supports context caching in batch requests via cached_content; cache hits are billed at standard context caching rates. For an eval set where every request shares the same long system prompt and rubric, that's a big chunk of input you stop paying full price for.
Takeaway: the same model, the same prompt, half the price, as long as you can wait. Most teams have more "can wait" traffic than they think.
Which of your LLM jobs could move to batch tomorrow: evals, embeddings, or nightly summaries?