You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f87698c
Browse filesBrowse the repository at this point in the historyBrowse files
feat(xai): enable Priority Processing on the API-key transport
Phase B2 of the FastWire umbrella (#1886), closing the
request in #1875. Fast now works end to end for xAI, and only where xAI
documents it.
Capability follows the transport. The registry gains a key-auth service-tier
overlay applied only when a preset allows the key override and the captured
effective auth transport is key-based; xAI declares Fast there and stays
unclassified on OAuth, because Priority Processing is documented for the public
api.x.ai endpoints and not for the Grok CLI subscription gateway. The overlay
resolves inside the shared FastPolicyAuthority capture, so the catalog and the
runtime cannot disagree — and the runtime only rewrites the base URL to that
gateway when authMode is "oauth", exactly when the overlay withholds the
capability, so Fast can never be injected into the unverified endpoint.
The catalog stops telling every provider OpenAI's story. Fast tier copy is now
per-provider, and xAI's says what xAI actually charges: priority processing at
2x token price, not "1.5x speed". Providers that declare nothing keep their
current bytes.
Pricing is declared rather than hardcoded to one vendor. The OpenAI-only
provider gate becomes exact (provider, model) priority rules, so xAI gets its
documented flat 2x while routed resellers sharing the grok slug inherit
nothing. The long-context relationship is likewise a declaration: OpenAI
publishes that Fast and long context are exclusive regimes, while xAI publishes
neither a combined rate nor an exclusion — so a confirmed-priority request above
200k prices at the published long-context rate and is marked a known lower
bound, surfaced in the dashboard as "≥$" rather than an invented stacked
multiplier. Billing still follows the response echo, which matches xAI's rule
that the priority rate applies only when the response confirms it.
NOTE — beyond the Fast path: xAI's bundled cached-input price for grok-4.6 was
$0.30 against an official $0.50, so every xai cost estimate (not just Fast) was
low. A verified-override layer corrects it ahead of the bundled row, which the
existing expected-price overlays sit behind and could not reach. The Fast
multiplier applies on top of the base price, so shipping the premium without
this correction would have compounded the error.
Full suite at this commit: 13330 pass / 10 skip / 1 fail — the one failure is
the pre-existing dev-side key-login-live-update regression, confirmed to
reproduce on this branch's own base commit (bcc77c0) with none of these
changes applied.
Co-Authored-By: Claude Fable 5 <[email protected]>
| `modelCosts?` | `Record<string, Cost4>` | Per-model display prices (USD per 1M tokens), keyed by that provider's exact upstream model id — not a provider identifier or a routed `provider/model` label, e.g. `{ "deepseek-v4-flash": { "input": 0.14, "output": 0.28, "cacheRead": 0.0028, "cacheWrite": 0 } }`. Any model id is a valid key — custom providers may target any OpenAI-compatible endpoint through the `openai-chat` adapter, and local or internal provider ids work even when they are absent from the built-in catalogs. User-configured prices win over the built-in catalogs in the Logs `~$` and Usage estimates; historical entries are repriced from the current overlay, so editing a price can move past totals. The fallback order is user `modelCosts` → jawcode catalog → expected-price overlay → model-level vendor fallback, and an all-zero entry falls through to the next source in that sequence. Each rate must be a non-negative finite number at most 1,000,000 (USD per 1M tokens); out-of-range rows are rejected by the management boundary and dropped on load. Display-time estimation only: overlays never affect routing, account selection, quotas, or billing. |
90
+
| `modelCosts?` | `Record<string, Cost4>` | Per-model display prices (USD per 1M tokens), keyed by that provider's exact upstream model id — not a provider identifier or a routed `provider/model` label, e.g. `{ "deepseek-v4-flash": { "input": 0.14, "output": 0.28, "cacheRead": 0.0028, "cacheWrite": 0 } }`. Any model id is a valid key — custom providers may target any OpenAI-compatible endpoint through the `openai-chat` adapter, and local or internal provider ids work even when they are absent from the built-in catalogs. User-configured prices win over the built-in catalogs in the Logs `~$` and Usage estimates; historical entries are repriced from the current overlay, so editing a price can move past totals. The fallback order is user `modelCosts` → exact official correction → jawcode catalog → expected-price overlay → model-level vendor fallback, and an all-zero entry falls through to the next source in that sequence. Each rate must be a non-negative finite number at most 1,000,000 (USD per 1M tokens); out-of-range rows are rejected by the management boundary and dropped on load. Display-time estimation only: overlays never affect routing, account selection, quotas, or billing. |
91
91
|`headers?`|`Record<string, string>`| Extra upstream headers. Authorization, cookies, API-key headers, embedded newlines, and invalid names are rejected. |
92
92
|`openRouterRouting?`|`OpenRouterProviderRouting`| Default OpenRouter `order`, `only`, and `allowFallbacks` preferences; valid only for canonical OpenRouter with `openai-chat`. |
93
93
|`modelOpenRouterRouting?`|`Record<string, OpenRouterProviderRouting>`| Exact model-id overrides that replace the provider-wide OpenRouter preference. |
@@ -151,6 +151,24 @@ contract; existing configurations see these migration deltas:
151
151
152
152
Explicit capability `false` and Responses caller-tier forwarding retain their existing contracts.
153
153
154
+
### xAI Priority Processing
155
+
156
+
The built-in `xai` preset advertises and injects Fast only when its effective transport uses
157
+
`authMode: "key"`. It sends `service_tier: "priority"` to xAI's public Chat Completions or
158
+
Responses API. `ocx login xai` uses the separate Grok CLI subscription gateway, so OAuth remains
159
+
unclassified: its catalog rows do not advertise Fast and the proxy does not inject a tier.
160
+
161
+
xAI charges Priority Processing at 2× the standard token price for input, output, cached, and
162
+
reasoning tokens; cache discounts are applied before the multiplier. Cost estimates use that premium
163
+
only when xAI echoes `service_tier: "priority"` (or when an adapter explicitly records an assumed
164
+
priority outcome). An echoed `default` is a downgrade and stays at the standard price.
165
+
166
+
For `grok-4.6`, the standard rate per 1M tokens is $2.00 input, $0.50 cached input, and $6.00
167
+
output. A prompt of at least 200,000 tokens reprices the whole request at $4.00 / $1.00 / $12.00.
168
+
xAI has not published how that long-context band combines with Priority Processing. When a
169
+
long-context response confirms `priority`, the dashboard therefore shows the published long-context
170
+
cost with a `≥` marker and a lower-bound explanation; it never invents a stacked multiplier.
171
+
154
172
API-key providers may hold a literal key or an environment reference. OAuth providers use the
155
173
credential store populated by `ocx login`; subscription-backed Claude Code launch behavior is
156
174
configured under [`claudeCode.authMode`](/reference/configuration/server/#claude-code).
"logs.detail.estimate.cache_detail_missing": "Cache-Details fehlen; Eingabe ist als Obergrenze geschätzt.",
712
712
"logs.detail.estimate.expected_price_overlay": "Ein verifizierter Expected-Listenpreis wurde verwendet.",
713
713
"logs.detail.estimate.provider_cost_overlay": "Ein vom Anbieter konfiguriertes Preis-Overlay wurde verwendet.",
714
+
"logs.detail.estimate.priority_lower_bound": "xAI hat keinen kombinierten Preis für Priority und langen Kontext veröffentlicht; die angezeigten Kosten sind eine Untergrenze.",
"logs.detail.estimate.cache_detail_missing": "Les détails du cache n’étaient pas disponibles ; l’entrée est une estimation de la limite supérieure.",
726
726
"logs.detail.estimate.expected_price_overlay": "Un tarif catalogue attendu et vérifié a été utilisé.",
727
727
"logs.detail.estimate.provider_cost_overlay": "Un remplacement de tarif configuré pour le fournisseur a été utilisé.",
728
+
"logs.detail.estimate.priority_lower_bound": "xAI n’a pas publié de tarif combinant Priority et contexte long ; le coût affiché est une borne inférieure.",
"logs.detail.estimate.priority_lower_bound": "xAI не опубликовала совмещённую цену Priority и длинного контекста; показанная стоимость является нижней границей.",
731
732
"logs.col.error": "Ошибка",
732
733
"logs.col.upstreamReason": "Причина от провайдера",
0 commit comments