Skip to content

fix(providers): xai-oauth chat→responses translation + breaker import (#10165) - #10170

Merged
diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.50from
nordz0r:fix/xai-oauth-chat-to-responses-10165
Aug 13, 2026
Merged

diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.50from
nordz0r:fix/xai-oauth-chat-to-responses-10165

Conversation

@nordz0r

@nordz0r nordz0r commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #10165.

On next-web / 3.8.50, POST /v1/chat/completions for xai-oauth/grok-4.5 could hit xAI native /v1/responses with a chat-shaped body:

  • messages without input → upstream 422 missing field input
  • max_tokens not mapped → 400 use max_output_tokens
  • response_format not mapped → 400 use text.format

Accounts then entered cooldown and were logged as "rate limited" despite healthy OAuth. Control: POST /v1/responses with input already worked.

Also fixes a runtime ReferenceError: isProviderBreakerFailureStatus is not defined on the all-accounts-cooldown path (used but not imported in chat.ts).

Changes

  1. Import isProviderBreakerFailureStatus in src/sse/handlers/chat.ts
  2. Tag xai-oauth model grok-4.5 with targetFormat: "openai-responses"
  3. XaiExecutor.transformRequest: convert chat fields when routing to Responses (uses existing chatRequestToXaiResponses)
  4. normalizeOpenAIResponsesRequest: safety net for chat-shaped bodies that reach Responses normalization
  5. Unit tests tests/unit/executor-xai-chat-to-responses-10165.test.ts

Test plan

  • Unit tests added for tag + chat body conversion
  • POST /v1/chat/completions { model: "xai-oauth/grok-4.5", messages: [...], max_tokens: 16 } → 200
  • same with stream: true
  • same with response_format
  • POST /v1/responses with input still works (native passthrough)
  • no ReferenceError: isProviderBreakerFailureStatus when all xai accounts are in cooldown

Notes

Operational workaround while waiting for this: pin main-web (3.8.49) where chat→Grok still works.

cheaper-inference#10165)

- Import isProviderBreakerFailureStatus in chat.ts (ReferenceError on cooldown path)
- Tag xai-oauth/grok-4.5 with targetFormat openai-responses
- XaiExecutor converts messages/max_tokens/response_format before /v1/responses
- normalizeOpenAIResponsesRequest safety net for chat-shaped bodies

Fixes cheaper-inference#10165
@nordz0r
nordz0r requested a review from diegosouzapw as a code owner August 12, 2026 10:16
@diegosouzapw
diegosouzapw merged commit d085a0e into cheaper-inference:release/v3.8.50 Aug 13, 2026
3 checks passed
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
cheaper-inference#10165) (cheaper-inference#10170)

- Import isProviderBreakerFailureStatus in chat.ts (ReferenceError on cooldown path)
- Tag xai-oauth/grok-4.5 with targetFormat openai-responses
- XaiExecutor converts messages/max_tokens/response_format before /v1/responses
- normalizeOpenAIResponsesRequest safety net for chat-shaped bodies

Fixes cheaper-inference#10165

Co-authored-by: nordz0r <nordz0r@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(providers): xai-oauth/grok-4.5 chat/completions → /v1/responses translator drops input / max_tokens (422/400); OAuth healthy

2 participants