Skip to content

Instantly share code, notes, and snippets.

@vedant
Created February 24, 2024 19:14
Show Gist options
  • Save vedant/263b1af29edf3e250941e996534f576a to your computer and use it in GitHub Desktop.
Save vedant/263b1af29edf3e250941e996534f576a to your computer and use it in GitHub Desktop.
Gemini command-line utility
gem() { api_key="SOME_API_KEY"; if [ -p /dev/stdin ]; then p=$(cat); else p=""; fi; f="$1 $p"; j=$(jq -n --arg text "$f" '{contents: [ { parts: [ { text: $text } ] } ] }'); curl -s -H 'Content-Type: application/json' -d "$j" -X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=$api_key" | jq -r '.candidates[0].content.parts[0].text'; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment