[Bug] Client specified an invalid argument with grok-code-fast-1 model via GitHub Copilot #8713

Open
opened 2026-02-16 18:10:38 -05:00 by yindo · 1 comment
Owner

Originally created by @Dragonator-EU on GitHub (Feb 6, 2026).

Originally assigned to: @rekram1-node on GitHub.

[Bug] Client specified an invalid argument with grok-code-fast-1 model via GitHub Copilot

Summary

OpenCode fails with AI_APICallError: Client specified an invalid argument when using the grok-code-fast-1 model through the GitHub Copilot provider. This error occurs consistently across all types of prompts, including simple greetings.

Environment

  • OpenCode Version: 1.1.53
  • Provider: github-copilot
  • Model: grok-code-fast-1
  • Platform: Linux (Arch-based)
  • Package: @ai-sdk/provider-utils@3.0.20
  • API Endpoint: https://api.githubcopilot.com/chat/completions

Error Details

Error Message

ERROR service=session.processor error=Client specified an invalid argument
stack="AI_APICallError: Client specified an invalid argument
    at <anonymous> (../../node_modules/.bun/@ai-sdk+provider-utils@3.0.20+d6123d32214422cb/node_modules/@ai-sdk/provider-utils/dist/index.mjs:936:18)
    at processTicksAndRejections (native:7:39)" process

Reproduction Steps

  1. Connect OpenCode to GitHub Copilot (/connect → Select GitHub Copilot)
  2. Select grok-code-fast-1 as the model (via /model command)
  3. Send any prompt (even a simple "Hello")
  4. Error occurs immediately after the LLM service starts streaming

Reproducibility

  • Frequency: 100% reproducible
  • Tested prompts: Simple greetings ("Hello"), coding questions, and complex queries all fail
  • Pattern: Error occurs consistently regardless of prompt complexity

Root Cause Analysis

Based on research of similar issues in other frameworks:

Known xAI API Limitations

  1. Unsupported stop parameter: xAI's Grok models (including grok-code-fast-1) do not support the stop parameter that OpenAI-compatible APIs typically use

  2. Unsupported strict mode: xAI's API doesn't support strict mode in function calling

API Compatibility Issue

The error occurs because:

  • OpenCode uses @ai-sdk/provider-utils which assumes OpenAI API compatibility
  • The package likely includes parameters like stop sequences or strict mode flags
  • xAI's Grok models explicitly reject these parameters with HTTP 400 error
  • Error message: BadRequestError: XaiException - Error code: 400 - {'code': 'Client specified an invalid argument', 'error': 'Argument not supported on this model: stop'}

Expected Behavior

OpenCode should successfully use grok-code-fast-1 when accessed through GitHub Copilot, since:

  1. GitHub Copilot officially supports OpenCode (as of January 16, 2026)
  2. GitHub Copilot officially offers grok-code-fast-1 as a model option
  3. The model is listed as a launch partner for xAI

Actual Behavior

OpenCode immediately fails with Client specified an invalid argument error when attempting to use grok-code-fast-1, regardless of prompt complexity.

Suggested Fix

OpenCode should conditionally exclude unsupported parameters when using xAI models:

// Pseudo-code example
if (model.provider === 'xai' || model.id.startsWith('grok-')) {
  // Don't send 'stop' parameter
  // Don't send 'strict' mode flag
  // Use only xAI-compatible parameters
}

Similar logic is needed in other frameworks:

  • OpenHands added model-specific parameter handling
  • LiteLLM proxy added xAI-specific adapters
  • Frameworks now check model capabilities before sending parameters

Additional Context

Other Affected Frameworks

This is a widespread compatibility issue affecting multiple AI coding agents:

  • OpenHands (CodeActAgent)
  • LiteLLM
  • Hugging Face smolagents
  • LiveKit agents
  • Google ADK

Model Configuration

From model configuration:

  • grok-code-fast-1 is configured through github-copilot provider
  • Multiple GitHub Copilot models are configured and working (GPT-5.x, Claude, Gemini)
  • Only grok-code-fast-1 exhibits this error

Related GitHub Issues

Workaround

Until this is fixed, use alternative models available through GitHub Copilot:

  • gpt-5-mini (works)
  • claude-sonnet-4.5 (works)
  • gemini-2.5-pro (works via Google provider)
Originally created by @Dragonator-EU on GitHub (Feb 6, 2026). Originally assigned to: @rekram1-node on GitHub. # [Bug] Client specified an invalid argument with grok-code-fast-1 model via GitHub Copilot ## Summary OpenCode fails with `AI_APICallError: Client specified an invalid argument` when using the `grok-code-fast-1` model through the GitHub Copilot provider. This error occurs consistently across all types of prompts, including simple greetings. ## Environment - **OpenCode Version**: 1.1.53 - **Provider**: `github-copilot` - **Model**: `grok-code-fast-1` - **Platform**: Linux (Arch-based) - **Package**: `@ai-sdk/provider-utils@3.0.20` - **API Endpoint**: `https://api.githubcopilot.com/chat/completions` ## Error Details ### Error Message ``` ERROR service=session.processor error=Client specified an invalid argument stack="AI_APICallError: Client specified an invalid argument at <anonymous> (../../node_modules/.bun/@ai-sdk+provider-utils@3.0.20+d6123d32214422cb/node_modules/@ai-sdk/provider-utils/dist/index.mjs:936:18) at processTicksAndRejections (native:7:39)" process ``` ### Reproduction Steps 1. Connect OpenCode to GitHub Copilot (`/connect` → Select GitHub Copilot) 2. Select `grok-code-fast-1` as the model (via `/model` command) 3. Send any prompt (even a simple "Hello") 4. Error occurs immediately after the LLM service starts streaming ### Reproducibility - **Frequency**: 100% reproducible - **Tested prompts**: Simple greetings ("Hello"), coding questions, and complex queries all fail - **Pattern**: Error occurs consistently regardless of prompt complexity ## Root Cause Analysis Based on research of similar issues in other frameworks: ### Known xAI API Limitations 1. **Unsupported `stop` parameter**: xAI's Grok models (including `grok-code-fast-1`) do not support the `stop` parameter that OpenAI-compatible APIs typically use - See: [BerriAI/litellm#12635](https://github.com/BerriAI/litellm/issues/12635) - See: [OpenHands/OpenHands#9655](https://github.com/OpenHands/OpenHands/issues/9655) 2. **Unsupported `strict` mode**: xAI's API doesn't support strict mode in function calling - See: [livekit/agents#2253](https://github.com/livekit/agents/issues/2253) ### API Compatibility Issue The error occurs because: - OpenCode uses `@ai-sdk/provider-utils` which assumes OpenAI API compatibility - The package likely includes parameters like `stop` sequences or `strict` mode flags - xAI's Grok models explicitly reject these parameters with HTTP 400 error - Error message: `BadRequestError: XaiException - Error code: 400 - {'code': 'Client specified an invalid argument', 'error': 'Argument not supported on this model: stop'}` ## Expected Behavior OpenCode should successfully use `grok-code-fast-1` when accessed through GitHub Copilot, since: 1. GitHub Copilot officially supports OpenCode (as of January 16, 2026) 2. GitHub Copilot officially offers `grok-code-fast-1` as a model option 3. The model is listed as a launch partner for xAI ## Actual Behavior OpenCode immediately fails with `Client specified an invalid argument` error when attempting to use `grok-code-fast-1`, regardless of prompt complexity. ## Suggested Fix OpenCode should conditionally exclude unsupported parameters when using xAI models: ```typescript // Pseudo-code example if (model.provider === 'xai' || model.id.startsWith('grok-')) { // Don't send 'stop' parameter // Don't send 'strict' mode flag // Use only xAI-compatible parameters } ``` Similar logic is needed in other frameworks: - OpenHands added model-specific parameter handling - LiteLLM proxy added xAI-specific adapters - Frameworks now check model capabilities before sending parameters ## Additional Context ### Other Affected Frameworks This is a widespread compatibility issue affecting multiple AI coding agents: - OpenHands (CodeActAgent) - LiteLLM - Hugging Face smolagents - LiveKit agents - Google ADK ### Model Configuration From model configuration: - `grok-code-fast-1` is configured through `github-copilot` provider - Multiple GitHub Copilot models are configured and working (GPT-5.x, Claude, Gemini) - Only `grok-code-fast-1` exhibits this error ## Related GitHub Issues - [github copilot models not working · Issue #11673 · anomalyco/opencode](https://github.com/anomalyco/opencode/issues/11673) - [Opencode Github Agent with GitHub Copilot provider Throw AI_APICallError · Issue #3287 · anomalyco/opencode](https://github.com/sst/opencode/issues/3287) ## Workaround Until this is fixed, use alternative models available through GitHub Copilot: - `gpt-5-mini` (works) - `claude-sonnet-4.5` (works) - `gemini-2.5-pro` (works via Google provider)
yindo added the zen label 2026-02-16 18:10:38 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 6, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #4313: Edit Tool issues with Grok Code Fast 1 - Related to Grok Code Fast 1 compatibility issues
  • #7024: xai - grok errors out when selected from the /models dropdown - Similar error when using xAI Grok models
  • #10348: Grok Code Fast 1 disappeared from OpenCode Zen - Related to Grok model availability and configuration
  • #5759: AI_TypeValidationError on Grok Fast 1 (Opencode Zen mode) - Another Grok Fast 1 error with validation failures

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Feb 6, 2026): This issue might be a duplicate of existing issues. Please check: - #4313: Edit Tool issues with Grok Code Fast 1 - Related to Grok Code Fast 1 compatibility issues - #7024: xai - grok errors out when selected from the /models dropdown - Similar error when using xAI Grok models - #10348: Grok Code Fast 1 disappeared from OpenCode Zen - Related to Grok model availability and configuration - #5759: AI_TypeValidationError on Grok Fast 1 (Opencode Zen mode) - Another Grok Fast 1 error with validation failures Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8713