This action allows you to interact with Google's Gemini API directly from your GitHub Actions workflows. You can send text prompts and system instructions to the Gemini model and receive its generated answer.
- Sends text prompts to the Gemini API (model
gemini-2.5-flashviav1betaendpoint). - Supports optional system-level instructions to guide the model's behavior.
- Validates required inputs (
gemini-api-key,text). - Ensures
curlandjqare available in the runner environment, installing them if necessary (on Debian/Ubuntu and Alpine-based images). - Outputs the generated answer from Gemini.
- Provides detailed console output including the full JSON response from the API (for debugging) and the extracted answer.
gemini-api-key- Description: Your API key for the Google Gemini API.
- Required:
true
text- Description: The main text prompt to send to the Gemini model.
- Required:
true
system-instruction- Description: Optional system-level instructions to steer the model's behavior. This can include context, desired format, or examples.
- Required:
false - Default:
""
answer- Description: The text answer generated by Gemini.
name: Ask Gemini
on: [push]
jobs:
chat_with_gemini:
runs-on: ubuntu-latest
steps:
- name: Call Gemini Action
id: gemini_response
uses: ViRGiL175/gemini-chat-action@main
with:
gemini-api-key: ${{ secrets.GEMINI_API_KEY }}
text: "Translate 'Hello, world!' to Spanish."
system-instruction: "You are a helpful translation assistant."
- name: Show Gemini's Answer
run: echo "Gemini says: ${{ steps.gemini_response.outputs.answer }}"The action is a composite action, defined in action.yml. It uses curl to make requests to the Gemini API and jq to parse the JSON response.
curljq
The action attempts to install these if they are not found on the runner, supporting apt-get (Debian/Ubuntu) and apk (Alpine). For other systems, ensure these tools are pre-installed on your runner.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a pull request or open an issue.
This is an unofficial action and is not affiliated with Google. Use the Gemini API in accordance with Google's terms of service.