> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automa.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini

> A step-by-step guide to setup Gemini agent for Automa

export const title_0 = "Gemini"

Gemini agent for Automa is based on [Google's Gemini](https://github.com/google-gemini/gemini-cli) CLI tool. It's source code is available on [GitHub](https://github.com/automa/gemini).

It contains the following components:

* **Cache**: A key-value store for jobs & caching.
* **Agent**: The agent that responds to Automa and implements tasks.

## Automa bot

You would need to [register a bot](/bot-development/registration) of [manual](/bots/types#manual) type in Automa (Cloud or Self-hosted) and configure it's webhook URL to point to the **Agent** service. The webhook URL will be `http://<your-server>/hooks/automa` if you are running it on a server with either a public IP address or domain name. Make sure to copy the **Webhook Secret** from Automa.

<Note>
  If you are running the agent on your local machine, you'll need to expose your
  local **Agent** service to the public internet so that Automa's webhooks can
  reach it. A tool like [ngrok](https://ngrok.com/) can create a secure tunnel
  to your `localhost`. You would then set the public URL provided by the tool as
  the webhook URL for the agent in Automa.
</Note>

## Docker

Automa publishes official [Docker](https://www.docker.com) images for the {title_0} agent which can be run on any system with Docker installed. This section will help you set it up using Docker.

### Setting up

You can set all this up locally on your machine or on a server.

There are 2 steps in the setup process:

* Start the needed services.
* Check if the services are working.

You will need:

* **Docker**: to run the cache, and Gemini agent container.
* **Docker network**: containers must share a user-defined network (e.g. `automa-gemini`).
* **Gemini API Key**: to use Google's Gemini models.

#### Cache

We use [Redis](https://redis.io/) for the key-value store. The Redis container will store its data in a Docker volume named `automa-gemini-redis-data`. It listens on port 6379. Make sure to replace `<cache-password>` with a secure password of your choice.

```bash icon="terminal" theme={null}
docker run -d --name automa-gemini-redis \
  --network automa-gemini \
  -e REDIS_PASSWORD=<cache-password> \
  -v automa-gemini-redis-data:/data \
  -p 6379:6379 \
  redis:7-alpine
```

<Tip>
  If you are self-hosting Automa, you can use the **Cache** service from it
  instead of setting up a separate cache. Just make sure the Gemini agent is on
  the same network as your Automa services.
</Tip>

#### Agent

We use the latest [Automa Gemini agent image](https://ghcr.io/automa/gemini). The Agent will connect to the Redis container. It listens on port 8000. Make sure to replace `<gemini-api-key>` with your Gemini API key, `<webhook-secret>` with the webhook secret you copied from Automa earlier and `<cache-password>` with the password you set earlier.

```bash icon="terminal" theme={null}
docker run -d --name automa-gemini \
  --network automa-gemini \
  -e GEMINI_API_KEY=<gemini-api-key> \
  -e AUTOMA_WEBHOOK_SECRET=<webhook-secret> \
  -e REDIS_URL=redis://:<cache-password>@localhost:6379 \
  -p 8000:8000 \
  ghcr.io/automa/gemini
```

#### Check the setup

You can check if the containers are running with the following command:

```bash icon="terminal" theme={null}
docker ps
```

### Updating

We recommend updating periodically to ensure you have the latest features and security updates. To update your services:

```bash icon="terminal" theme={null}
docker pull ghcr.io/automa/gemini
docker restart automa-gemini
```

## Railway

Automa publishes official [Railway](https://railway.com) templates for the Gemini agent. This section will help you set it up using Railway.

### Setting up

There are 2 steps in the setup process:

* Start the needed services.
* Check if the services are working.

#### Start services

You will need an account on [Railway](https://railway.com) to get started. Once you have an account, go to the [Automa Gemini agent template](https://railway.com/deploy/kQnZs_?referralCode=Ri3kTG) and deploy it by clicking on the "**Deploy Now**" button.

You would need to provide the following environment variables for the **Agent** service:

* `GEMINI_API_KEY`: Your Gemini API key.
* `AUTOMA_WEBHOOK_SECRET`: The webhook secret you copied from Automa earlier.

<video autoPlay muted loop playsInline className="mx-auto rounded-xl" src="https://mintcdn.com/automa/eeL4keyWWsKr0LQB/videos/self-hosting/railway-agent-deploy.mp4?fit=max&auto=format&n=eeL4keyWWsKr0LQB&q=85&s=a8ed8dc101ccdf5a0dbf0079bd4f4862" data-path="videos/self-hosting/railway-agent-deploy.mp4" />

#### Check the setup

If you have successfully deployed the template, you should see 2 healthy services in your Railway project: **Agent** and **Redis**.

The **Agent** service in the Railway project should have been automatically assigned a domain name by Railway in the form of `<random>.up.railway.app`. You can find this by clicking on the service. Make sure to update the webhook URL of the agent in Automa to match this domain.

<video autoPlay muted loop playsInline className="mx-auto w-3/4 rounded-xl" src="https://mintcdn.com/automa/eeL4keyWWsKr0LQB/videos/self-hosting/railway-agent-domain.mp4?fit=max&auto=format&n=eeL4keyWWsKr0LQB&q=85&s=567c528aa19e929bfe293b36e9ee47b3" data-path="videos/self-hosting/railway-agent-domain.mp4" />

### Updating

We recommend updating periodically to ensure you have the latest features and security updates. To update your **Agent** service, go to the service in your Railway project, click on the "**Deployments**" tab, click on **three dots** on active deployment, and then choose the "**Redeploy**" option. This will pull the latest changes and redeploy your service.

<video autoPlay muted loop playsInline className="mx-auto rounded-xl" src="https://mintcdn.com/automa/eeL4keyWWsKr0LQB/videos/self-hosting/railway-agent-redeploy.mp4?fit=max&auto=format&n=eeL4keyWWsKr0LQB&q=85&s=54b4c8259a11ec0077856f06670ada96" data-path="videos/self-hosting/railway-agent-redeploy.mp4" />
