Expose requested, outbound, upstream, and billed service tiers for Fast mode diagnostics
Summary
When an OpenAI /v1/responses request is forwarded with the final outbound service_tier set to priority, a successful request may later be stored as usage_logs.service_tier = default.
This can be correct if the upstream terminal response reports that the request was actually served at the default/standard tier. However, the current logs and usage record do not expose the observed terminal tier or the resolution reason. This makes it impossible to distinguish a legitimate upstream downgrade from a terminal-event parsing or billing-resolution issue.
This issue is not asserting that the billing result is incorrect. It requests enough stage-specific observability to verify how the result was produced.
Environment
- Sub2API:
0.1.182 - Account path: OpenAI OAuth
- Inbound endpoint:
/v1/responses - Upstream endpoint:
/v1/responses - Transport: HTTP streaming (not WebSocket)
- Fast policy rules: empty
- Client, host, account, request, and model identifiers: redacted
Reproduction
-
Send a normal streaming
/v1/responsesrequest with:{ "service_tier": "priority" } -
Use an OpenAI OAuth account with no Fast policy rule that filters or rewrites the tier.
-
Compare the gateway routing diagnostic with the resulting usage record.
Observed behavior
In one redacted test flow containing four upstream requests:
- All four requests used
/v1/responsesinbound and upstream. - The gateway routing diagnostic reported
final_service_tier = priorityfor all four requests. This diagnostic is emitted from the final body passed to the HTTP transport. - All four requests completed with HTTP
200. - All four resulting usage records stored
service_tier = default. - The available logs did not expose the upstream terminal
service_tieror the downgrade/resolution reason.
Aggregated evidence:
requests: 4
outbound final_service_tier: priority (4/4)
HTTP status: 200 (4/4)
usage_logs.service_tier: default (4/4)
upstream terminal tier: not observable
Expected behavior
Please expose enough information to determine how the final billed tier was resolved. Suggested fields are:
requested_service_tieroutbound_service_tierupstream_terminal_service_tierresolved_billing_service_tierservice_tier_downgradedservice_tier_resolution_reason, for example:upstream_terminal_responseoutbound_fallbacklocal_policymissing_or_invalid_upstream_tier
These could be stored as bounded diagnostic fields or emitted in a structured Debug log. They should not include request bodies, prompts, credentials, or complete request identifiers.
Context
The behavior introduced around #6111 and #6129 intentionally prefers the actual upstream tier and prevents local billing from upgrading a request to a more expensive tier. That behavior is reasonable, but a single final usage_logs.service_tier value no longer shows whether:
- the upstream terminal event explicitly reported
default; - the terminal tier was absent or invalid and the resolver used a fallback; or
- the observer/resolver produced an unexpected result.
Could the maintainers also confirm whether priority outbound followed by default usage is expected whenever the upstream terminal event reports the default/standard tier?
Privacy
All infrastructure addresses, domains, API keys, account IDs, request IDs, model aliases, prompts, response content, and token values have been omitted from this report.
I closed this too early, so I checked the database again today.
As of 2026-08-26 02:09 UTC, the latest priority record was from 2026-08-24 13:10:37 UTC, about 37 hours earlier. Since that record, the gateway has processed 24,230 requests:
default: 24,072
NULL: 158
priority: 0
The service is still receiving traffic, so this is not a stale database or an idle account.
I also retested after switching the client to /v1/responses. In a four-request test, the gateway routing diagnostic reported final_service_tier=priority for every request. All four returned HTTP 200, but all four usage rows were stored as default.
I still cannot tell whether the upstream terminal events reported default/standard, or whether Sub2API resolved them that way, because the terminal tier and resolution reason are not logged. That is why the stage-specific fields requested above would be useful.
All client, host, account, key, request, model, prompt, response, and token identifiers remain redacted.
I dug into the v0.1.179 -> v0.1.180 change and reproduced a concrete local bug against v0.1.182. This is more than a logging gap.
The outbound and observed tiers are merged too early:
- The response observer resolves the terminal tier against the outbound tier in
upstream_response_model.go. - The forward result then stores that merged value in both
ServiceTierandUpstreamResponseServiceTierinopenai_gateway_forward.go. - By the time
ResolveBillingServiceTierruns, it receives two identical values. It can no longer tell a requested tier from an observed tier.
I added two local regression tests using the real OpenAIGatewayService.Forward path and the existing HTTP upstream fixture:
case 1: outbound priority + terminal default
expected before billing: requested=priority, observed=default
actual: requested=default, observed=default
case 2: no outbound tier + terminal priority
expected after billing: requested="", observed=priority, billing=""
actual: requested=priority, observed=priority, billing=priority
Both desired-invariant tests fail deterministically on v0.1.182. The existing service-tier observer, forwarding, and billing tests pass. The gap is that forwarding tests accept the already-merged result, while billing tests manually construct separate requested and observed fields. There is no integration test connecting those two stages.
The second case matters even without the production symptom: an untiered request can be promoted to priority before the billing resolver gets a chance to enforce its no-promotion rule.
The smallest fix looks like this:
- Keep
ServiceTieras the final outbound/requested tier. - Keep
UpstreamResponseServiceTieras the terminal observed tier. - Resolve them once, inside the billing/usage stage.
- Reset the observer for each real upstream attempt so a failed attempt cannot leak its terminal tier into a later retry.
There is also a separate contract question. The public OpenAI API documents response service_tier as the actual processing tier and allows Priority requests to be downgraded to default. The ChatGPT Codex OAuth backend is a private endpoint, and I could not find a public guarantee that its terminal service_tier has the same billing meaning. API-key and OAuth/Codex paths may need separate trust rules for the observed tier.
No live credentials, account identifiers, request identifiers, hosts, model aliases, prompts, responses, or token values were used in this reproduction.
@Wei-Shaw 75faedd 这个提交导致现在fast都计费为普通的
Follow-up: Codex OAuth terminal default may not be authoritative
I reproduced the same request/response shape on another OpenAI Codex OAuth deployment:
- the final outbound request carried
service_tier=priority; - the Codex routing hint also carried
tier=priority; - no local Fast policy filtered or rewrote the tier;
- the terminal response reported
service_tier=default; - the current resolver therefore stored and billed the request as Standard.
A sanitized historical comparison of positive-output requests, matched on OAuth account, model, reasoning effort, transport, nearby time, context size, and output size, showed a consistent latency/throughput improvement for requests that asked for priority even though their terminal tier was default. This is observational evidence rather than a randomized benchmark, but it does not support treating every OAuth terminal default as a confirmed Standard-speed downgrade.
This is also consistent with an OpenAI Codex contributor's clarification that, in ChatGPT-authenticated Codex mode, Fast is handled by server-side routing and final response.service_tier=default does not mean Fast was ignored:
https://github.com/openai/codex/issues/14204#issuecomment-4033184620
That OAuth behavior should be kept separate from the public API-key Fast/Priority contract, where terminal default is documented as a real ramp-rate downgrade.
Suggested direction:
- keep terminal-tier downgrade billing for OpenAI API-key accounts;
- for OpenAI Codex OAuth accounts, do not treat terminal
defaultas authoritative proof of downgrade; - preserve requested, post-policy outbound, terminal-observed, and billed tiers separately, with a bounded resolution reason;
- do not let an observed higher tier promote an untiered request;
- cover HTTP, WebSocket, per-turn state, retries, and account failover.
At minimum, an OAuth terminal default should be reported as non-authoritative/unverified rather than using the same billing.service_tier_downgraded classification as the documented API-key ramp-rate case.
All deployment identifiers, account/user/request identifiers, payloads, credentials, and exact operational measurements have been omitted.