GeminiCLI is a command-line interface tool written in Go, designed to interact with the generative language API provided by Google. It enables users to generate content by sending requests to the API and receiving responses directly in the terminal. This tool is particularly useful for developers and researchers working on natural language processing and generative AI models.
- Send requests to the generative language API.
- Save conversation history in markdown files with timestamps.
- Clear screen functionality for better user experience.
- Load context from a file to influence the generation.
- Command-line flags for flexible configuration.
- Before installing GeminiCLI, ensure you have Go installed on your system. You can download and install Go from the official Go website.
- Setup an API Key for Gemini by following this documentation - Gemini API Key
To install GeminiCLI, clone the repository to your local machine:
git clone https://github.com/benjaminwestern/geminicli.git && cd geminicli
Change directory to the geminicli repo you just cloned, then, build the binary using:
go build .
This will create the geminicli
executable in your current directory.
To start using GeminiCLI, you can run the executable directly from the command line.
Here are some common commands to get you started:
- To generate content with a context file:
./geminicli -context path/to/your/context.txt
- To specify an output file for the conversation log:
./geminicli -output path/to/your/output/
- For help and a list of available flags:
./geminicli -help
GeminiCLI expects the API_KEY
environment variable to be set with your API key.
You can set this variable in your shell configuration file, or export it directly in the terminal:
export API_KEY=your_api_key_here
You can also set some other environment variables to configure the tool's behaviour. The following environment variables are available for configuration:
TOP_K
- The top-k value for the generation. Default:1
TOP_P
- The top-p value for the generation. Default:1
TEMPERATURE
- The temperature value for the generation. Default:0.9
MAX_TOKENS
- The maximum number of tokens to generate. Default:2048
MODEL_TYPE
- The model to use for the generation. Default:gemini-1.0-pro
API_VERSION
- The version of the generative language API to use. Default:v1beta
The generative language API has a number of safety settings that can be configured to control the content generated by the model. These settings are available as environment variables:
HARASSMENT
- The harassment setting for the generation. Default:BLOCK_NONE
HATE_SPEECH
- The hate speech setting for the generation. Default:BLOCK_NONE
SEXUALLY_EXPLICIT
- The sexually explicit setting for the generation. Default:BLOCK_NONE
DANGEROUS_CONTENT
- The dangerous content setting for the generation. Default:BLOCK_NONE
The available options for these settings are: Reference can be found here
HARM_BLOCK_THRESHOLD_UNSPECIFIED
- Threshold is unspecified.BLOCK_LOW_AND_ABOVE
- Content with NEGLIGIBLE will be allowed.BLOCK_MEDIUM_AND_ABOVE
- Content with NEGLIGIBLE and LOW will be allowed.BLOCK_ONLY_HIGH
- Content with NEGLIGIBLE, LOW, and MEDIUM will be allowed.BLOCK_NONE
- All content will be allowed.
Ensure you have at least the API_KEY
set as an environment variable with your API key before running the tool.
I welcome contributions from the community! If you'd like to contribute to GeminiCLI, please fork the repository and submit a pull request with your changes. For major changes, please open an issue first to discuss what you would like to change.
GeminiCLI is open-sourced under the MIT License. See the LICENSE file for more details.
If you encounter any issues or have questions about using GeminiCLI, please open an issue on the GitHub issue tracker. For more information about the generative language API and its configuration, visit Google's API documentation.
Please ensure you are aware that anything you input into these models (if you're using a personal Google account) will be utilised to further train the Gemini models, so PLEASE think twice before sending private content to these models! Google's Gemini FAQs
- Add tests.
- Add CI/CD to build and test the tool on each commit.
- Update the handling of environment variables to be more flexible.
- Add support for changing output file format (e.g. JSON, plaintext).
- Add support to disable the output file.
- Add support for changing the output file name.
- Add support for reading context from files in a folder.
- Add support for handling API Responses other than 200 OK.
- Add support for defining Environment file location for configuration.
- Add support for the setting of Environment variables in the tool.