gemini-cli - ✅(Solved) Fix API Error "message": "Request contains an invalid argument." [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#26997Fetched 2026-05-14 03:45:44
View on GitHub
Comments
1
Participants
2
Timeline
12
Reactions
0
Author
Participants
Timeline (top)
labeled ×6unlabeled ×2added_to_project_v2 ×1commented ×1

Error Message

│ error: undefined, │ │ [Symbol(gaxios-gaxios-error)]: '6.7.1' ▄│

Fix Action

Fixed

PR fix notes

PR #27007: fix(core): add aliases and thinking config for gemini-3.1 models

Description (problem / solution / changelog)

Summary

This PR resolves the INVALID_ARGUMENT (400) API error encountered when using Gemini 3.1 models. It ensures that all Gemini 3.1 variants are correctly mapped to the chat-base-3 configuration, which includes the mandatory thinkingLevel parameter required by the Google Generative AI API.

Details

The investigation revealed that while gemini-3.1-pro-preview was present, it lacked an entry in the aliases section of defaultModelConfigs.ts. This caused the CLI to fall back to a basic configuration that enabled "Thinking" mode but failed to provide a thinkingLevel (e.g., HIGH). Gemini 3.1 models strictly require this level when thinking is enabled; without it, the API rejects the request as an invalid argument.

Changes include:

  • Added gemini-3.1-pro-preview, gemini-3.1-pro-preview-customtools, and gemini-3.1-flash-lite-preview to the core alias registry.
  • Mapped these models to inherit from chat-base-3 to ensure ThinkingLevel.HIGH is included in all requests.

Related Issues

Fixes #26997, #27000, #27005, #26996

How to Validate

  1. Run Tests: Execute the updated test suite in packages/core/src/config/models.test.ts to ensure 3.1 models resolve with the correct config.
    • npm run test core
  2. Manual Verification: Use a Gemini 3.1 model to process a comparison prompt (e.g., "AMD Ryzen 9 9950X vs 9950X3D") and verify the 400 error no longer occurs.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • Windows (Validated via MINGW64/git-bash)
      • npm run

Changed files

  • packages/core/src/config/defaultModelConfigs.ts (modified, +18/-0)
  • packages/core/src/config/models.test.ts (modified, +32/-0)
RAW_BUFFERClick to expand / collapse

What happened?

It's happen with 3.1 pro. Can't use it.

'content-type': 'application/json; charset=UTF-8', │ │ date: 'Wed, 13 May 2026 17:13:12 GMT', │ │ server: 'ESF', │ │ 'server-timing': 'gfet4t7; dur=3025', │ │ vary: 'Origin, X-Origin, Referer', │ │ 'x-cloudaicompanion-trace-id': 'b362bed316d1423c', │ │ 'x-content-type-options': 'nosniff', │ │ 'x-frame-options': 'SAMEORIGIN', │ │ 'x-xss-protection': '0' │ │ }, │ │ status: 400, │ │ statusText: 'Bad Request', │ │ request: { │ │ responseURL: 'https://cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse' │ │ } │ │ }, │ │ error: undefined, │ │ status: 400, │ │ [Symbol(gaxios-gaxios-error)]: '6.7.1' ▄│ │ }

[ACTION REQUIRED] 📎 PLEASE ATTACH THE EXPORTED CHAT HISTORY JSON FILE TO THIS ISSUE IF YOU FEEL COMFORTABLE SHARING IT.

What did you expect to happen?

be fixed

Client information

  • CLI Version: 0.42.0
  • Git Commit: 68e2196d5
  • Session ID: ff01b71d-8ed2-4761-8344-b71ce307e301
  • Operating System: linux v22.22.1
  • Sandbox Environment: no sandbox
  • Model Version: gemini-3.1-pro-preview
  • Auth Type: oauth-personal
  • Memory Usage: 327.0 MB
  • Terminal Name: VTE(7600)
  • Terminal Background: #300a24
  • Kitty Keyboard Protocol: Unsupported

Login information

No response

Anything else we need to know?

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING