Gemini Srv is a web server and API that provides a user-friendly interface for interacting with the gemini-cli tool. It allows for persistent, context-aware conversations and includes a powerful scheduler for running autonomous, scheduled tasks.
- AI Assistant on a VM at your disposal: Deploy Gemini Srv on a virtual machine to have a dedicated AI assistant accessible from anywhere.
- Your custom Gemini-CLI agent integrated to Google Chat, Slack or Teams: Integrate the Gemini Srv API with your favorite communication platforms to bring your custom Gemini-CLI agent directly into your team's workflow.
- Automated Task Execution: Leverage the scheduler to run autonomous tasks that gather data, interact with the Gemini model, and perform actions based on predefined conditions.
- Scheduled Reporting and Alerts: Configure scheduled tasks to generate reports or send alerts based on specific criteria, powered by Gemini's analytical capabilities.
- Interactive Web UI for Gemini-CLI: Provides a user-friendly web interface to interact with your Gemini-CLI agent, manage conversations, and monitor scheduled tasks.
- Web UI: A clean, modern web interface for managing conversations and tasks.
- REST API: A simple, stateless API for easy integration with other services like Slack, Teams, or custom scripts.
- Persistent Conversations: Conversation histories are saved to disk, so you can pick up where you left off.
- Scheduled Tasks: Define autonomous tasks in
.tomlfiles that can gather data and conditionally call the Gemini model. - Context-Aware: Leverages
gemini-cli's ability to read context fromGEMINI.mdfiles.
- Go 1.18+
- A working
gemini-cliinstallation.
-
Clone the repository:
git clone <repository_url> cd gemini-srv
-
Create a
.envfile: Copy the example file and customize it with your details.cp .env.example .env # Edit .env with your preferred user/pass and the correct path to gemini-cli -
Build the server:
go build . -
Run the server directly (for testing):
./gemini-srv
-
Open your browser and navigate to
http://localhost:7123.
Gemini-srv needs gemini-cli to be running the A2A server. You can get it running with these steps:
- git clone https://github.com/google-gemini/gemini-cli.git && cd gemini-cli
- npm install && npm run build
- CODER_AGENT_PORT=41242 npm run start --workspace @google/gemini-cli-a2a-server
To run gemini-srv as a persistent background service that starts on boot, you can create a systemd unit file.
-
Create the service file: Create a new file at
/etc/systemd/system/gemini-srv.service:sudo nano /etc/systemd/system/gemini-srv.service
-
Add the following content: Be sure to replace
/path/to/your/gemini-srvwith the actual absolute path to the project directory. TheWorkingDirectoryis crucial as it tells the service where to find the.envfile, thestatic/directory, and thedata/directory.[Unit] Description=Gemini Srv - A web UI and API for gemini-cli After=network.target [Service] Type=simple User=your_username # Replace with the user you want to run the service as Group=your_groupname # Replace with the group for that user # Set the working directory to the project root WorkingDirectory=/path/to/your/gemini-srv # Command to start the server ExecStart=/path/to/your/gemini-srv/gemini-srv Restart=on-failure RestartSec=5s [Install] WantedBy=multi-user.target
-
Enable and start the service:
# Reload the systemd daemon to recognize the new file sudo systemctl daemon-reload # Start the service now sudo systemctl start gemini-srv # Enable the service to start automatically on boot sudo systemctl enable gemini-srv
-
Check the status and logs:
# Check if the service is running sudo systemctl status gemini-srv # View the live logs sudo journalctl -u gemini-srv -f
The server exposes a simple REST API for integrations.
POST /api/v1/conversations: Create a new conversation.GET /api/v1/conversations: List all conversation IDs.GET /api/v1/conversations/{id}: Get the history of a conversation.POST /api/v1/conversations/{id}/prompt: Send a prompt to a conversation.DELETE /api/v1/conversations/{id}: Delete a conversation.
All API endpoints are protected by Basic Authentication using the credentials set in your .env file.
