Expand description
AI-04 (#194): Batch API support and half-price metering.
OpenAI and Anthropic batch APIs are 50% cheaper than real-time
endpoints. The gateway proxies batch creation/status/cancel as a
passthrough (no translation), and when batch results are retrieved
the JSONL output file is parsed line-by-line. Each line’s usage
object is metered at the batch rate (batch_input_per_1k_micros /
batch_output_per_1k_micros, falling back to standard rates when
batch-specific rates are not configured).
The half-price cost computation already exists in
ai::cost::PricingTable::cost_micros(batch=true); this module
provides the JSONL parsing and batch result metering.
Structs§
- Batch
Metering Summary - Summary of a batch result file’s metering.
- Batch
Prompt Token Details - The
prompt_tokens_detailssub-object. - Batch
Response - The
responsefield of a batch result line. - Batch
Result Line - One line of a batch result JSONL file. The OpenAI Batch API result format has this shape per line:
- Batch
Usage - The
usagefield of a batch response.
Functions§
- meter_
batch_ results - Parse a batch result JSONL file and compute the total cost at the batch (50% discount) rate. Each line is parsed independently; a malformed line is counted as an error and skipped.