feat(cli): add 'models' command to list available Gemini models#27848
feat(cli): add 'models' command to list available Gemini models#27848serkanince wants to merge 4 commits into
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request adds a new command to the Gemini CLI, enabling developers to discover supported models and their capabilities directly from the terminal. The change improves developer experience by providing structured information about model availability and configuration, and includes updated documentation and test coverage to ensure reliability. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
📊 PR Size: size/L
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new 'gemini models' CLI command to list available Gemini models, along with corresponding documentation and unit tests. The review feedback suggests critical improvements to the CLI output and error handling: using standard 'console.log' instead of 'debugLogger.log' for user-facing output to ensure visibility and piping support, throwing errors instead of calling 'process.exit(1)' directly inside the handler, and wrapping the handler in a 'try...finally' block to guarantee terminal cleanup via 'exitCli()'. Additionally, the reviewer recommends updating the unit tests to spy on 'console.log' and simplifying the failure test case by asserting that the handler throws an error.
|
Hi there! Thank you for your interest in contributing to Gemini CLI. To ensure we maintain high code quality and focus on our prioritized roadmap, we only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding. |
Summary
Adds a new
gemini modelscommand that allows users to list all available Gemini models, their context window limits, and their respective tiers (Pro, Flash, etc.). Supports both human-readable text and machine-readable JSON output.Details
This implementation provides a quick way for developers to discover which models are currently supported and accessible within their environment without leaving the terminal.
ModelConfigServiceto ensure consistency with the core engine's model resolution logic.--output-format(alias-o) flag withtext(default) andjsonoptions.Related Issues
Fixes #27847
How to Validate
1. List models in text format
Output example:
2. List models in JSON format
Output example:
[ { "modelId": "auto", "displayName": "Auto", "description": "Let Gemini CLI decide the best model for the task: gemini-3.1-pro-preview, gemini-3.5-flash", "contextWindow": 1048576, "tier": "auto" }, { "modelId": "gemini-3.5-flash", "displayName": "gemini-3.5-flash", "description": "", "contextWindow": 1048576, "tier": "flash" }, { "modelId": "gemini-3.1-pro-preview", "displayName": "gemini-3.1-pro-preview", "description": "", "contextWindow": 1048576, "tier": "pro" }, { "modelId": "gemma-4-31b-it", "displayName": "gemma-4-31b-it", "description": "", "contextWindow": 256000, "tier": "custom" } ]3. Run unit tests
npm test -w @google/gemini-cli -- src/commands/models.test.tsPre-Merge Checklist