Skip to content

Commit f87698c

Browse files
olddonkeyclaude
andcommitted
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]>
1 parent bcc77c0 commit f87698c

25 files changed

Lines changed: 545 additions & 76 deletions

‎docs-site/src/content/docs/reference/configuration/providers.md‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ differing backup and rewrites known legacy namespaced selected ids to bare ids.
8787
| `modelMaxInputTokens?` | `Record<string, number>` | Positive per-model max input limits used for catalog auto-compaction hints. |
8888
| `defaultMaxOutputTokens?` | `number` | Provider-wide `openai-chat` fallback when the client omits `max_output_tokens`. |
8989
| `modelMaxOutputTokens?` | `Record<string, number>` | Positive per-model `openai-chat` fallback budgets; exact/pattern matches beat the provider default. |
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` → 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. |
9191
| `headers?` | `Record<string, string>` | Extra upstream headers. Authorization, cookies, API-key headers, embedded newlines, and invalid names are rejected. |
9292
| `openRouterRouting?` | `OpenRouterProviderRouting` | Default OpenRouter `order`, `only`, and `allowFallbacks` preferences; valid only for canonical OpenRouter with `openai-chat`. |
9393
| `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:
151151

152152
Explicit capability `false` and Responses caller-tier forwarding retain their existing contracts.
153153

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+
154172
API-key providers may hold a literal key or an environment reference. OAuth providers use the
155173
credential store populated by `ocx login`; subscription-backed Claude Code launch behavior is
156174
configured under [`claudeCode.authMode`](/reference/configuration/server/#claude-code).

‎gui/src/i18n/de.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ export const de: Record<TKey, string> = {
711711
"logs.detail.estimate.cache_detail_missing": "Cache-Details fehlen; Eingabe ist als Obergrenze geschätzt.",
712712
"logs.detail.estimate.expected_price_overlay": "Ein verifizierter Expected-Listenpreis wurde verwendet.",
713713
"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.",
714715
"logs.col.error": "Fehler",
715716
"logs.col.upstreamReason": "Upstream-Grund",
716717
"logs.col.duration": "Dauer",

‎gui/src/i18n/en.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ export const en = {
744744
"logs.detail.estimate.cache_detail_missing": "Cache details were unavailable; input is an upper-bound estimate.",
745745
"logs.detail.estimate.expected_price_overlay": "A verified expected list price was used.",
746746
"logs.detail.estimate.provider_cost_overlay": "A provider-configured price overlay was used.",
747+
"logs.detail.estimate.priority_lower_bound": "xAI has not published a combined Priority and long-context price; the displayed cost is a lower bound.",
747748
"logs.col.error": "Error",
748749
"logs.col.upstreamReason": "Upstream reason",
749750
"logs.col.duration": "Duration",

‎gui/src/i18n/fr.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ export const fr: Record<TKey, string> = {
725725
"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.",
726726
"logs.detail.estimate.expected_price_overlay": "Un tarif catalogue attendu et vérifié a été utilisé.",
727727
"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.",
728729
"logs.col.error": "Erreur",
729730
"logs.col.upstreamReason": "Motif en amont",
730731
"logs.col.duration": "Durée",

‎gui/src/i18n/ja.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ export const ja: Record<TKey, string> = {
687687
"logs.detail.estimate.cache_detail_missing": "キャッシュの詳細が利用できませんでした; 入力は上限の推定です。",
688688
"logs.detail.estimate.expected_price_overlay": "検証済みの予想定価が使用されました。",
689689
"logs.detail.estimate.provider_cost_overlay": "プロバイダー設定の価格オーバーレイが使用されました。",
690+
"logs.detail.estimate.priority_lower_bound": "xAI は Priority と長いコンテキストの組み合わせ価格を公開していないため、表示額は下限です。",
690691
"logs.col.error": "エラー",
691692
"logs.col.upstreamReason": "上流の理由",
692693
"logs.col.duration": "所要時間",

‎gui/src/i18n/ko.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ export const ko: Record<TKey, string> = {
730730
"logs.detail.estimate.cache_detail_missing": "캐시 상세가 없어 입력 전액을 상한으로 추정했습니다.",
731731
"logs.detail.estimate.expected_price_overlay": "검증된 expected 정가를 사용했습니다.",
732732
"logs.detail.estimate.provider_cost_overlay": "프로바이더 구성 가격 오버레이를 사용했습니다.",
733+
"logs.detail.estimate.priority_lower_bound": "xAI가 Priority와 긴 컨텍스트의 결합 가격을 공개하지 않아 표시 비용은 하한입니다.",
733734
"logs.col.error": "오류",
734735
"logs.col.upstreamReason": "업스트림 원인",
735736
"logs.col.duration": "소요 시간",

‎gui/src/i18n/ru.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ export const ru: Record<TKey, string> = {
728728
"logs.detail.estimate.cache_detail_missing": "Детализация кэша недоступна; входные токены оценены по верхней границе.",
729729
"logs.detail.estimate.expected_price_overlay": "Использована подтверждённая ожидаемая цена из прайс-листа.",
730730
"logs.detail.estimate.provider_cost_overlay": "Использован ценовой оверлей провайдера.",
731+
"logs.detail.estimate.priority_lower_bound": "xAI не опубликовала совмещённую цену Priority и длинного контекста; показанная стоимость является нижней границей.",
731732
"logs.col.error": "Ошибка",
732733
"logs.col.upstreamReason": "Причина от провайдера",
733734
"logs.col.duration": "Длительность",

‎gui/src/i18n/tr.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ export const tr: Record<TKey, string> = {
735735
"logs.detail.estimate.cache_detail_missing": "Önbellek detayları eksik.",
736736
"logs.detail.estimate.expected_price_overlay": "Doğrulanmış liste fiyatı kullanıldı.",
737737
"logs.detail.estimate.provider_cost_overlay": "Kullanıcı tarafından yapılandırılan bir sağlayıcı fiyat katmanı kullanıldı.",
738+
"logs.detail.estimate.priority_lower_bound": "xAI, Priority ile uzun bağlamın birleşik fiyatını yayımlamadı; gösterilen maliyet alt sınırdır.",
738739
"logs.col.error": "Hata",
739740
"logs.col.upstreamReason": "Yukarı akış nedeni",
740741
"logs.col.duration": "Süre",

‎gui/src/i18n/zh-TW.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,6 +1805,7 @@ export const zhTW: Record<TKey, string> = {
18051805
"logs.detail.attempt.recovery.emptyCompletion": "空白完成重試",
18061806
"logs.detail.attempt.recovery.unknown": "未知的復原原因",
18071807
"logs.detail.estimate.provider_cost_overlay": "已使用供應商設定的價格覆蓋。",
1808+
"logs.detail.estimate.priority_lower_bound": "xAI 尚未公布 Priority 與長上下文的組合價格;目前顯示的是費用下界。",
18081809
"pws.cockpitImportDescription": "從此裝置匯入 Cockpit Tools Antigravity JSON 匯出檔。不會顯示檔案內容。",
18091810
"pws.cockpitImportFileLabel": "Cockpit Tools Antigravity JSON 匯出檔",
18101811
"pws.cockpitImportChooseFile": "選擇 JSON 檔案",

‎gui/src/i18n/zh.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ export const zh: Record<TKey, string> = {
723723
"logs.detail.estimate.cache_detail_missing": "缺少缓存明细;输入费用按上限估算。",
724724
"logs.detail.estimate.expected_price_overlay": "使用了已验证的 Expected 标价。",
725725
"logs.detail.estimate.provider_cost_overlay": "使用了用户配置的提供方价格覆盖。",
726+
"logs.detail.estimate.priority_lower_bound": "xAI 尚未公布 Priority 与长上下文的组合价格;当前显示的是费用下界。",
726727
"logs.col.error": "错误",
727728
"logs.col.upstreamReason": "上游原因",
728729
"logs.col.duration": "耗时",

0 commit comments

Comments
 (0)