harshcligemini
v1.0.2
Published
Run Google Gemini from your terminal. Fast CLI with chat mode, Markdown, and config management.
Downloads
20
Maintainers
Readme
Streaming output (token-by-token):
gemini --stream "Write a limerick about cats"npm-gemini
Run Google Gemini from your terminal. Fast CLI with chat mode, Markdown output, and simple config.
Install
Global install (recommended):
# from the project root
npm install -g .Or use it locally with npx while developing:
npx --yes . --helpAuthenticate
You need a Gemini API key. Get one from:
- https://aistudio.google.com/app/apikey
Then set it once:
gemini auth YOUR_API_KEYAlternatively, set an environment variable (takes priority):
export GEMINI_API_KEY=YOUR_API_KEYUsage
Basic prompt:
gemini "Explain webhooks like I'm five"Pipe from stdin:
# prompt can be provided as args or omitted when piping
cat README.md | gemini "Summarize this file"
cat README.md | geminiChoose a model and temperature:
gemini -m gemini-1.5-pro -t 0.4 "Draft a professional email about a shipping delay"Raw JSON output:
gemini --json "Return a JSON array of 5 startup ideas with fields: name, one_liner"Disable Markdown rendering:
gemini --no-md "Show raw text only"Interactive chat:
gemini chatWith a system instruction:
gemini chat --system "You are a concise, senior TypeScript engineer."Config
View current config:
gemini whoamiGet config JSON:
gemini config --getSet defaults:
gemini config --set model=gemini-1.5-pro temp=0.4 system="Be terse"Config is stored at:
~/.config/gemini-cli/config.json
Environment variable GEMINI_API_KEY overrides the stored key.
Programmatic API
You can also import the library methods if you install this package as a dep:
import { generateText } from 'npm-gemini';
const { text } = await generateText({
apiKey: process.env.GEMINI_API_KEY,
model: 'gemini-1.5-flash',
temperature: 0.7,
prompt: 'Write a haiku about JavaScript',
});
console.log(text);Notes
- Requires Node.js 18+.
- Uses the official
@google/generative-aiSDK. - Markdown is rendered in the terminal via
marked+marked-terminal. Use--no-mdto print plain text. - For issues or feature requests (e.g., response streaming), open an issue.
