diff --git a/README.md b/README.md index 1f09847..c7d8408 100644 --- a/README.md +++ b/README.md @@ -561,7 +561,9 @@ row: it describes the subscription (zero token price, budget/requests) rather th the pay-as-you-go list price. A non-streaming response carries `X-Junction-Tokens-In`, `X-Junction-Tokens-Out` -and, when the price is known, `X-Junction-Cost-Usd`. An unpriced model keeps +and, when the price is known, `X-Junction-Cost-Usd`. A reviewed answer puts the +sum over the worker and all rounds in both `X-Junction-Review-Cost-Usd` and the +general `X-Junction-Cost-Usd`, so one header is enough. An unpriced model keeps `unknown`; without any price table the headers are not invented. A cache hit is a call that cost nothing: it reports cost `0.000000` and zero tokens even though the cached body still contains the provider's original usage. The spend log and diff --git a/src/junction.c b/src/junction.c index 4c8e5d3..71f13c3 100644 --- a/src/junction.c +++ b/src/junction.c @@ -3636,6 +3636,9 @@ static int review_serve(j_conn *client, j_endpoint *ep, const j_req *rq, if (rev.cost_known) { snprintf(v, sizeof v, "%.6f", rev.cost); j_hdrs_set(&h, "X-Junction-Review-Cost-Usd", v); + /* The same total in the general per-call header: a client that + * knows one cost header should not have to special-case review. */ + j_hdrs_set(&h, "X-Junction-Cost-Usd", v); } } add_route_meta_headers(&h); diff --git a/tests/review.sh b/tests/review.sh index 4256c82..e208684 100644 --- a/tests/review.sh +++ b/tests/review.sh @@ -301,6 +301,7 @@ UH=$(tr -d '\r' < "$TMP/review_usage_h.txt") contains "$UH" "X-Junction-Review-Tokens-In: 3600" "the header carries the summed input tokens" contains "$UH" "X-Junction-Review-Tokens-Out: 900" "the header carries the summed output tokens" contains "$UH" "X-Junction-Review-Cost-Usd: 0.005400" "the header carries the summed cost" +contains "$UH" "X-Junction-Cost-Usd: 0.005400" "the general cost header carries the review total too" contains "$UH" "X-Junction-Ms: " "the request time covers the whole review" # Streaming: derselbe Block steckt im finalen SSE-Chunk, nicht nur im JSON-Pfad.