Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions content/docs/guides/connecting-agents.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
title: Connecting AI agents to the API
---

If you'd like to connect an AI agent to the Umami API, for example to help you analyze the events, this guide shows you how.


## 1. Install the Prerequisites

On the machine where the agent will run, we'll install the
Latchkey tool. That will allow the agent to send authenticated
HTTP requests to the API without leaking any secrets to prompts.

1. Make sure your system has a working `node` installation. If not, you can download it from the [official page](https://nodejs.org/en/download).
2. Install Latchkey:

```bash
npm install -g latchkey
```

## 2. Generate and Configure the API Token

1. Follow the [authentication docs](../api/authentication) to obtain an API token or an API key.
2. If you don't use Umami Cloud, point Latchkey to your instance. For example:

```bash
latchkey services register my-umami \
--service-family umami \
--base-api-url=http://203.0.113.1:3000/api/
```

3. Insert the API token:

```bash
latchkey auth set my-umami -H "Authorization: Bearer <your_token>"
```

Alternatively, for Umami Cloud:

```bash
latchkey auth set umami -H "x-umami-api-key: <your_api_key>"
```


## 3. Configure the AI Agent

Using [skills.sh](https://skills.sh/):

```bash
npx skills add imbue-ai/latchkey
```

You can also configure the AI agent manually. The exact steps
will differ depending on the agent. Taking OpenCode as an example:

```bash
mkdir -p ~/.opencode/skills/latchkey
latchkey skill-md > ~/.opencode/skills/latchkey/SKILL.md
```


## 4. Use the AI Agent

After completing the previous steps, you should now be able to
use your AI agent of choice to work with Umami! Here are some
example questions and tasks for the agent:

> Which referrer sends the highest-quality traffic (with the highest average session duration)?

or

> What does my audience look like on weekends vs. weekdays?

or even

> Tell me what's working on our blog and what isn't.

From here, it's up to your imagination.
4 changes: 3 additions & 1 deletion content/docs/guides/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"running-on-railway",
"running-on-sevalla",
"running-on-supabase",
"running-on-vercel"
"running-on-vercel",
"---AI---",
"connecting-agents"
],
"defaultOpen": true
}