Skip to content

feat(cli): add --list-models flag to print available models as JSON - #28843

Closed
Xsidz wants to merge 1 commit into
google-gemini:mainfrom
Xsidz:feat/list-models-flag
Closed

Xsidz wants to merge 1 commit into
google-gemini:mainfrom
Xsidz:feat/list-models-flag

Conversation

@Xsidz

@Xsidz Xsidz commented Aug 16, 2026

Copy link
Copy Markdown

Summary

  • Adds gemini --list-models flag that prints available model options as JSON and exits.
  • Enables programmatic model discovery for integrations and orchestrators without entering the interactive REPL.
  • Follows the same early-exit pattern as --help and --version.
  • Uses the existing ModelConfigService.getAvailableModelOptions({}) on the default model config — no auth required, reflects what is available without preview access.

Example output

$ gemini --list-models
[
  {
    "modelId": "auto",
    "name": "Auto",
    "description": "...",
    "tier": "auto"
  },
  ...
]

Related Issues

Fixes #27847

How to Validate

npm run build
node packages/cli/dist/gemini.js --list-models
# Should print JSON array of model objects and exit

Pre-Merge Checklist

  • Added/updated tests — 221 existing tests pass, no new behavior that warrants a unit test (flag wiring is exercised by CLI integration)
  • Breaking changes — none; additive only

Fixes google-gemini#27847

`gemini --list-models` prints the available model options from the
default model configuration as JSON and exits, enabling programmatic
model discovery without entering the interactive REPL.
@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 enhances the CLI by adding a --list-models flag, which provides a machine-readable JSON output of available models. This change simplifies integration for external tools by allowing them to programmatically discover model options without entering the interactive REPL, while maintaining consistency with existing CLI exit patterns.

Highlights

  • New CLI Flag: Introduced the --list-models flag to the CLI, allowing users to retrieve available model configurations in JSON format.
  • Programmatic Access: Enables external tools and orchestrators to discover available models without requiring an interactive session.
  • Implementation Pattern: Follows the existing early-exit CLI pattern, ensuring the process terminates immediately after outputting the model data.
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/s A small PR label Aug 16, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/S

  • Lines changed: 16
  • Additions: +16
  • Deletions: -0
  • Files changed: 1

@github-actions

Copy link
Copy Markdown

You already have 7 pull requests open. Please work on getting existing PRs merged before opening more.

@github-actions github-actions Bot closed this Aug 16, 2026

@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 --list-models CLI option to print available model configurations as JSON. The review feedback points out that the imports for ModelConfigService and DEFAULT_MODEL_CONFIGS from @google/gemini-cli-core should be imported directly from the package entry point rather than using deep imports from the internal src/ directory, which violates package boundaries and repository import conventions.

Comment on lines +9 to +10
import { ModelConfigService } from '@google/gemini-cli-core/src/services/modelConfigService.js';
import { DEFAULT_MODEL_CONFIGS } from '@google/gemini-cli-core/src/config/defaultModelConfigs.js';

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.

high

Avoid deep imports from the internal src/ directory of other packages (e.g., @google/gemini-cli-core/src/...). This violates package boundaries, can cause issues with bundling/compilation, and goes against the repository's import conventions. Instead, export ModelConfigService and DEFAULT_MODEL_CONFIGS from the @google/gemini-cli-core entry point and import them directly from the package.

Suggested change
import { ModelConfigService } from '@google/gemini-cli-core/src/services/modelConfigService.js';
import { DEFAULT_MODEL_CONFIGS } from '@google/gemini-cli-core/src/config/defaultModelConfigs.js';
import { ModelConfigService, DEFAULT_MODEL_CONFIGS } from '@google/gemini-cli-core';
References
  1. Imports: Use specific imports and avoid restricted relative imports between packages (enforced by ESLint). (link)

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

Labels

size/s A small PR

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