A command-line interface (CLI) for Google Gemini.
Google Gemini is a family of multimodal artificial intelligence (AI) large language models that have capabilities in language, audio, code and video understanding.
This application offers a command-line interface for interacting with various generative models through multi-turn chat. Model selection is controlled via system command inputs.
Choose a binary from releases.
Download and install Go.
Install the application:
go install github.com/reugn/gemini-cli/cmd/gemini@latest
See the go install instructions for more information about the command.
Note
For information on the available regions for the Gemini API and Google AI Studio, see here.
To use gemini-cli
, you'll need an API key set in the GEMINI_API_KEY
environment variable.
If you don't already have one, create a key in Google AI Studio.
Set the environment variable in the terminal:
export GEMINI_API_KEY=<your_api_key>
The system chat message must begin with an exclamation mark and is used for internal operations. A short list of supported system commands:
Command | Description |
---|---|
!p | Select the generative model system prompt 1 |
!m | Select from a list of generative model operations 2 |
!h | Select from a list of chat history operations 3 |
!i | Toggle the input mode (single-line <-> multi-line) |
!q | Exit the application |
!help | Show system command instructions |
1 System instruction (also known as "system prompt") is a more forceful prompt to the model. The model will follow instructions more closely than with a standard prompt. The user must specify system instructions in the configuration file. Note that not all generative models support them.
2 Model operations:
- Select a generative model from the list of available models
- Show the selected model information
3 History operations:
- Clear the chat history
- Store the chat history to the configuration file
- Load a chat history record from the configuration file
- Delete all history records from the configuration file
The application uses a configuration file to store generative model settings and chat history. This file is optional. If it doesn't exist, the application will attempt to create it using default values. You can use the config flag to specify the location of the configuration file.
An example of basic configuration:
{
"SystemPrompts": {
"Software Engineer": "You are an experienced software engineer.",
"Technical Writer": "Act as a tech writer. I will provide you with the basic steps of an app functionality, and you will come up with an engaging article on how to do those steps."
},
"SafetySettings": [
{
"Category": 7,
"Threshold": 1
},
{
"Category": 10,
"Threshold": 1
}
],
"History": {
}
}
Upon user request, the History
map will be populated with records. Note that the chat history is stored in plain
text format. See history operations for details.
$ ./gemini -h
Gemini CLI Tool
Usage:
[flags]
Flags:
-c, --config string path to configuration file in JSON format (default "gemini_cli_config.json")
-h, --help help for this command
-m, --model string generative model name (default "gemini-1.5-flash")
--multiline read input as a multi-line string
-s, --style string markdown format style (ascii, dark, light, pink, notty, dracula) (default "auto")
-t, --term string multi-line input terminator (default "$")
-v, --version version for this command
-w, --wrap int line length for response word wrapping (default 80)
MIT