gemini-cli - ✅(Solved) Fix "code": 400, "message": "Request contains an invalid argument." [1 pull requests, 2 comments, 3 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#27005Fetched 2026-05-14 03:45:40
View on GitHub
Comments
2
Participants
3
Timeline
13
Reactions
0
Author
Timeline (top)
labeled ×5commented ×2added_to_project_v2 ×1cross-referenced ×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?

[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?

bug-report-history-1778694856630.json

Client information

  • CLI Version: 0.42.0
  • Git Commit: 68e2196d5
  • Session ID: 0120ef05-2504-47ec-8b50-28e44d644053
  • Operating System: win32 v24.14.0
  • Sandbox Environment: no sandbox
  • Model Version: auto-gemini-3
  • Auth Type: oauth-personal
  • Memory Usage: 238.9 MB
  • Terminal Name: Unknown
  • Terminal Background: #0c0c0c
  • 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

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