Skip to content

fix: skip frequency_penalty and presence_penalty for XAI grok reasoning models#399

Open
octo-patch wants to merge 1 commit into
coaidev:mainfrom
octo-patch:fix/issue-374-xai-reasoning-model-params
Open

fix: skip frequency_penalty and presence_penalty for XAI grok reasoning models#399
octo-patch wants to merge 1 commit into
coaidev:mainfrom
octo-patch:fix/issue-374-xai-reasoning-model-params

Conversation

@octo-patch
Copy link
Copy Markdown

Fixes #374

Problem

XAI's grok reasoning models (e.g. grok-3-mini, grok-3-mini-fast) do not support the frequency_penalty and presence_penalty parameters. When users configure an XAI channel using the OpenAI-compatible adapter and select a thinking/reasoning model, the request always includes these parameters, causing the XAI API to return HTTP 400.

Solution

Detect grok reasoning models by their naming pattern (grok- prefix + -mini substring) and omit frequency_penalty and presence_penalty from the request body for these models. Since both fields are tagged omitempty in ChatRequest, setting them to nil ensures they are not serialized.

This follows the same pattern already used for o1/o3/gpt-5 models where unsupported parameters are conditionally excluded.

Testing

  • Verified gofmt and go build pass with no errors.
  • The change is limited to GetChatBody in adapter/openai/chat.go and only affects models matching the grok reasoning model pattern.

…ng models (fixes coaidev#374)

XAI's grok reasoning models (e.g. grok-3-mini, grok-3-mini-fast) do not support
the frequency_penalty and presence_penalty parameters, and return HTTP 400 when
these fields are present in the request body.

Detect grok reasoning models by their name prefix ("grok-") and "-mini" suffix,
and omit the two unsupported parameters from the request, matching the existing
pattern for o1/o3/gpt-5 model compatibility.

Co-Authored-By: Octopus <liyuan851277048@icloud.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.

XAI模型无法使用思考类模型

1 participant