Repository navigation
feat: price OpenAI fast/priority and ultrafast by actual service tier - #4532
Merged
Merged
Conversation
Cost accounting now uses the tier the provider actually served instead of the one requested, covering chat, responses, and websocket transports. Custom endpoints, routers, and cost overrides are left alone. WebSocket and HTTP paths now resolve the base URL the same way, fixed at client construction for both transports. Assisted-By: docker-agent
aheritier
approved these changes
Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cost estimates for
service_tier: fast,priority, and the newultrafastrequests have been using catalogue pricing regardless of what OpenAI actually billed. Since a request can be downgraded to standard pricing even after Fast or Ultrafast was asked for, the previous approach could overstate costs, and there was no coverage at all for the new Ultrafast mode on GPT-6 Astra.Cost accounting now reads the service tier the provider actually served from the response, instead of trusting the one requested, and applies the right multiplier at settlement time. This is wired through Chat Completions and Responses, over both SSE and WebSocket, including incomplete responses. The allowlist of models eligible for premium pricing is explicit: Fast and priority apply a 2x multiplier to
gpt-5.6and its Sol/Terra/Luna aliases plusgpt-6-astra,gpt-6-sol,gpt-6-luna, andgpt-6.1-sol; Ultrafast applies 6x, and only togpt-6-astra. Multipliers cover fresh input, cache read, cache write, output, and the long-context band. A response that comes back asdefaultkeeps standard pricing even if a premium tier was requested, and the zero-cost case is handled explicitly rather than falling through.Custom endpoints (including
OPENAI_BASE_URL), rule-based routers, and OpenAI-compatible providers are left on catalogue pricing, and gateway model IDs that are already priced as-fastare not multiplied a second time. The model catalogue is cloned before these adjustments so the shared, cached catalogue stays immutable. As part of this, the WebSocket transport now resolves its base URL the same way the HTTP transport does, fixed once at client construction, so both paths agree on which endpoint is in play.This only changes how fast/ultrafast tiers are costed; it does not touch request routing, semantic RAG, or any other stream accounting behavior. Docs and
examples/openai-service-tier.yamlwere updated to describe Ultrafast mode and the new pricing behavior.