Skip to content

feat(cli): add 'models' command to list available Gemini models#27848

Open
serkanince wants to merge 4 commits into
google-gemini:mainfrom
serkanince:feat/models-command
Open

feat(cli): add 'models' command to list available Gemini models#27848
serkanince wants to merge 4 commits into
google-gemini:mainfrom
serkanince:feat/models-command

Conversation

@serkanince

Copy link
Copy Markdown

Summary

Adds a new gemini models command 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.

  • Integrated with ModelConfigService to ensure consistency with the core engine's model resolution logic.
  • Added --output-format (alias -o) flag with text (default) and json options.
  • Includes full unit test coverage for the new command and its options.

Related Issues

Fixes #27847

How to Validate

1. List models in text format

gemini models

Output example:

Available Gemini Models:

Auto (auto)
  Description: Let Gemini CLI decide the best model for the task: gemini-3.1-pro-preview, gemini-3.5-flash
  Context Window: 1.048.576 tokens
  Tier: auto

gemini-3.5-flash (gemini-3.5-flash)
  Context Window: 1.048.576 tokens
  Tier: flash

gemini-3.1-pro-preview (gemini-3.1-pro-preview)
  Context Window: 1.048.576 tokens
  Tier: pro

gemini-3.1-flash-lite (gemini-3.1-flash-lite)
  Context Window: 1.048.576 tokens
  Tier: flash-lite

gemma-4-31b-it (gemma-4-31b-it)
  Context Window: 256.000 tokens
  Tier: custom

2. List models in JSON format

gemini models --output-format json

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.ts

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:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@serkanince serkanince requested review from a team as code owners June 11, 2026 14:30
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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

  • New 'models' Command: Introduced a new 'gemini models' command that allows users to list all available Gemini models, including their context window limits and tiers.
  • Flexible Output Formats: Added an '--output-format' (or '-o') flag supporting both human-readable text and machine-readable JSON output.
  • Integration and Testing: Integrated the command with 'ModelConfigService' for consistent model resolution and included comprehensive unit tests.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added the size/l A large sized PR label Jun 11, 2026
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown

📊 PR Size: size/L

  • Lines changed: 259
  • Additions: +259
  • Deletions: -0
  • Files changed: 4

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/cli/src/commands/models.ts
Comment thread packages/cli/src/commands/models.ts
Comment thread packages/cli/src/commands/models.ts
Comment thread packages/cli/src/commands/models.test.ts
Comment thread packages/cli/src/commands/models.test.ts Outdated
Comment thread packages/cli/src/commands/models.test.ts Outdated
Comment thread packages/cli/src/commands/models.test.ts Outdated
@gemini-cli gemini-cli Bot added priority/p3 Backlog - a good idea but not currently a priority. area/non-interactive Issues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automation labels Jun 11, 2026
@gemini-cli

gemini-cli Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/non-interactive Issues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automation priority/p3 Backlog - a good idea but not currently a priority. size/l A large sized PR status/pr-nudge-sent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add a command to list available models in machine-readable format (e.g., --list-models --json)

1 participant