Metadata-Version: 2.5
Name: otterai-cli
Version: 0.1.4
Summary: Unofficial Otter.ai CLI — list, search, download, and manage meeting transcripts. Built for developers, scripts, and AI agents.
Project-URL: Homepage, https://github.com/erickhchan/otterai-cli
Project-URL: Repository, https://github.com/erickhchan/otterai-cli
Project-URL: Issues, https://github.com/erickhchan/otterai-cli/issues
Project-URL: Changelog, https://github.com/erickhchan/otterai-cli/releases
Project-URL: Documentation, https://github.com/erickhchan/otterai-cli#readme
Author-email: Eric Chan <eric.kahei.chan@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: ai-agent,automation,cli,meeting,meeting-notes,meeting-transcription,otter,otter.ai,speech-to-text,transcript
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Communications
Classifier: Topic :: Office/Business
Classifier: Topic :: Text Processing
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Requires-Dist: click>=8.0
Requires-Dist: keyring>=23.0
Requires-Dist: requests
Requires-Dist: requests-toolbelt
Requires-Dist: websocket-client>=1.6
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: responses; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Description-Content-Type: text/markdown

# otterai-cli — Otter.ai CLI & AI Agent Tool

[![PyPI](https://img.shields.io/pypi/v/otterai-cli)](https://pypi.org/project/otterai-cli/)
[![Python](https://img.shields.io/pypi/pyversions/otterai-cli)](https://pypi.org/project/otterai-cli/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

A command-line interface for [Otter.ai](https://otter.ai) to list, search, download, and manage your meeting transcripts and recordings. Built for developers, scripts, and AI agents like Claude, ChatGPT, and Cursor.

> **Note:** This project is not affiliated with or endorsed by Otter.ai / Aisense Inc.

## Features

- **List, search, and filter** meeting transcripts by date, folder, speaker, or keyword
- **Search your whole archive** by keyword, speaker, and date window (`otter search`)
- **Ask Otter's AI Chat** questions across all your conversations (`otter ask`)
- **Paginate the full archive** with `speeches list --all`
- **Batch edits in one session**: rename many recordings from a plan, tag or untag many transcript segments
- **Download transcripts** as txt, pdf, md, docx, or srt
- **Download meeting audio** as mp3
- **Export markdown** with configurable YAML frontmatter
- **Upload audio files** for transcription
- **Manage speakers, folders, and groups** programmatically
- **JSON output** for scripting, piping, and AI agent consumption
- **Secure credential storage** via OS keychain (macOS Keychain, Windows Credential Locker, etc.)
- **Automatic retry with backoff** on HTTP 429 and 5xx responses

## AI Agent & LLM Usage

This CLI is designed to be used by AI agents (Claude, GPT, Cursor, Windsurf, etc.) as a tool for accessing Otter.ai meeting data.

### Quick Reference

| Task | Command | Output |
|------|---------|--------|
| List recent meetings | `otter speeches list --days 7 --json` | Object with a `speeches` array |
| List every meeting (all pages) | `otter speeches list --all --json` | Speeches + `pagination` report |
| Search the whole archive | `otter search "query" --json` | `{"hits": [...]}` |
| Find meetings with a speaker | `otter search --speaker "Jane Doe" --json` | `{"hits": [...]}` |
| Ask a question across meetings | `otter ask "question" --json` | Answer text + cited sources |
| Get full transcript | `otter speeches get OTID --json` | Speech + transcript segments |
| Download as markdown | `otter speeches download OTID -f md` | `.md` file saved to disk |
| Download as text | `otter speeches download OTID -f txt` | `.txt` file saved to disk |
| Download audio | `otter speeches download OTID -f mp3` | `.mp3` file saved to disk |
| Search in meeting | `otter speeches search "query" OTID` | Matching transcript segments |
| One speaker's lines in a meeting | `otter speeches search "query" OTID --speaker "Jane" --json` | `{"results": [...]}` |
| Rename many meetings | `otter speeches rename-batch plan.json --dry-run --json` | Preview, then apply without `--dry-run` |
| List folders | `otter folders list --json` | Object with a `folders` array |
| List speakers | `otter speakers list --json` | Object with a `speakers` array |

Agents can:

```bash
# List recent meetings (JSON for easy parsing)
otter speeches list --days 7 --json

# Every meeting in the last 30 days, across all pages
otter speeches list --all --days 30 --json

# Search the whole archive (keyword, speakers, dates)
otter search "pricing" --days 30 --json

# Ask Otter's AI Chat across all meetings (creates a new chat thread)
otter ask "What action items came up this week?" --json

# Search within a specific meeting transcript
otter speeches search "action items" SPEECH_ID

# Download a transcript as markdown
otter speeches download SPEECH_ID --format md

# Get full speech details and transcript
otter speeches get SPEECH_ID --json

# List all folders and speakers
otter folders list --json
otter speakers list --json
```

Most commands support `--json` for structured, machine-readable output that agents can parse directly. Progress lines and warnings go to stderr, so stdout stays parseable.

#### Which command to use

| Goal | Use |
|------|-----|
| A question whose answer spans many meetings ("what did we decide about X?") | `otter ask` |
| Which meetings mention a keyword, include a speaker, or fall in a date range | `otter search` |
| An exact, complete list (every meeting, every meeting in a window) | `otter speeches list --all` |
| Exact quotes or lines from one known meeting | `otter speeches search QUERY OTID` or `otter speeches get OTID` |

`otter ask` answers come from Otter's AI and cite sources; verify important details with `otter speeches get OTID`. `otter search` keyword results are best-effort (see [Archive search](#archive-search-otter-search)).

#### Side effects agents must know

- `otter ask` creates a new AI Chat thread in the user's Otter account on every call.
- `otter speeches rename-batch` (without `--dry-run`) writes recording titles.
- `otter speakers tag ... --all` assigns the chosen speaker to **every** segment, including other people's turns. `otter speakers untag ... --all --yes` clears **every** segment's speaker tag.
- `otter speeches move` and `otter speeches trash` change where recordings live.
- Listing commands (`speakers tag OTID SPEAKER_ID` and `speakers untag OTID` with no `-t`/`--all`, `rename-batch --dry-run`) change nothing.

### JSON Output Schema

`otter speeches list --json` returns:

```json
{
  "speeches": [
    {
      "otid": "jqb7OHo6mrHtCuMkyLN0nUS8mxY",
      "speech_id": "22WB27HAEBEJYFCA",
      "title": "Weekly Standup",
      "created_at": "2025-02-20T10:00:00Z",
      "summary": "Discussed sprint progress and blockers...",
      "folder": {"id": 12345, "folder_name": "Work"}
    }
  ]
}
```

Speech objects are passed through from Otter's API, so extra fields vary. A recording in Otter's trash may carry `"deleted": true` in `--json` output; the human listing marks it `[TRASH]`.

`otter speeches list --all --json` (and `--speaker`) returns the same `speeches` array plus a `pagination` report as the last key:

```json
{
  "status": "OK",
  "end_of_list": true,
  "speeches": [ ... ],
  "pagination": {
    "complete": true,
    "scope": "all",
    "created_after": null,
    "pages_fetched": 3,
    "unique_fetched": 128,
    "stop_reason": "end_of_list",
    "error": null,
    "retry_after_seconds": null
  }
}
```

| Field | Meaning |
|-------|---------|
| `complete` | `true` only when every page (or the whole `--days` window) was fetched |
| `scope` | `all`, or `date_window` with `--days` |
| `created_after` | Unix-time cutoff for `--days`, else `null` |
| `pages_fetched` / `unique_fetched` | Pages read and unique otids seen (before the date filter) |
| `stop_reason` | `end_of_list`, `date_cutoff`, `single_page`, `page_limit`, `api_error`, `transport_error`, `invalid_page`, `invalid_cursor`, or `stalled_cursor` |
| `error` | Why the listing stopped early, else `null`; top-level `status` becomes `"failed"` |
| `retry_after_seconds` | Server-requested delay when rate limited |

`otter speeches get SPEECH_ID --json` returns the full speech object including transcript segments:

```json
{
  "speech": {
    "otid": "jqb7OHo6mrHtCuMkyLN0nUS8mxY",
    "title": "Weekly Standup",
    "summary": "Discussed sprint progress and blockers...",
    "transcripts": [
      {
        "uuid": "a1b2c3d4-...",
        "speaker_id": 11,
        "speaker_name": "Alice",
        "transcript": "Let's go over the sprint updates.",
        "start_offset": 0,
        "end_offset": 4500
      }
    ]
  }
}
```

`otter search --json` returns `{"hits": [...]}`. Each hit includes `speech_otid`, `title`, `duration`, `start_time`, `matched_transcripts` (empty for speaker-only and date-only listings), and the CLI adds `recorded_at` (Unix time; from the title's "on Mon Sep 21st 2026 @ 7:37am ET" suffix when present, else the start time).

`otter ask --json` returns:

```json
{
  "question": "What action items came up this week?",
  "answer_text": "- Alice will send the deck [jqb7OHo6mrHtCuMkyLN0nUS8mxY]",
  "blocks": [ ... ],
  "sources": [
    {"title": "Weekly Standup", "otid": "jqb7OHo6mrHtCuMkyLN0nUS8mxY", "speech_id": "22WB27HAEBEJYFCA", "start_time": "1740045600"}
  ],
  "thread_uuid": "...",
  "message_uuid": "..."
}
```

`blocks` is Otter's raw answer structure (`null` when absent). Source fields are strings and may be empty when Otter cites only a link. On failure with `--json`, stdout gets `{"error": "..."}` (plus `frames_received` and `frames_matched` when no answer arrived) and the exit code is `1`.

On error, the CLI exits with code `1` and prints a message to stderr:

```
Error: Not logged in. Run 'otter login' first.
```

### Agent Workflow Example

Find last week's standup, download its transcript as markdown:

```bash
# Step 1: List recent meetings as JSON, filter by title
OTID=$(otter speeches list --days 7 --json | jq -r '.speeches[] | select(.title | test("standup"; "i")) | .otid' | head -1)

# Step 2: Download the transcript
# (-o/--output takes a base name without an extension; the format adds it,
# so this writes standup.md)
otter speeches download "$OTID" --format md --output standup

# Step 3: Or get full transcript data for further processing
otter speeches get "$OTID" --json | jq -r '.speech.transcripts[] | (.speaker_name // "?") + ": " + .transcript'
```

### Agent Skill

This project includes an [Agent Skill](https://agentskills.io) at [`skills/otterai-cli/`](skills/otterai-cli/SKILL.md) — a portable skill file that compatible agents (Claude Code, Cursor, Copilot, Gemini CLI, etc.) can use to learn this CLI's commands automatically. Copy the `skills/otterai-cli/` directory into your agent's skills folder to give it full Otter.ai access.

### Authentication for Automated Environments

For CI, scripts, or AI agents, use environment variables instead of interactive login:

```bash
export OTTERAI_USERNAME="you@example.com"
export OTTERAI_PASSWORD="your-password"
otter speeches list --json  # no login prompt needed
```

### Rate limits (HTTP 429)

- The client retries HTTP 429 and 5xx responses automatically (up to 4 retries with exponential backoff, honoring `Retry-After` up to 16 seconds) before a command reports failure.
- If a command still reports a 429, **stop**. Wait for the reported `retry_after_seconds` / `Retry-After`; when none is given, wait 60-90 seconds, then retry slowly. Do not loop retries.
- Each `otter` invocation logs in again. Prefer the batch forms, which share one login and one HTTP session: `speeches list --all`, `speeches rename-batch`, `speakers tag` / `speakers untag` with repeated `-t`.
- Batch commands stop at the first failure and report what was saved, what failed, and what was not attempted, so a rerun can resume.

## Requirements

- Python 3.10+

## Installation

```bash
uv tool install otterai-cli
```

This makes the `otter` command available globally.

To update to the latest version:

```bash
uv tool upgrade otterai-cli
```

Or run directly without installing:

```bash
uvx --from otterai-cli otter --help
```

## Setup

```bash
otter login
```

Credentials are stored in your OS keychain (macOS Keychain, Windows Credential Locker, etc.) via [keyring](https://pypi.org/project/keyring/), with `~/.otterai/config.json` as fallback.

You can also use environment variables (`OTTERAI_USERNAME`, `OTTERAI_PASSWORD`), which take highest precedence.

### Auth commands

```bash
otter user      # check current user
otter logout    # remove saved credentials
```

## Command Reference

| Command | Flags | Description |
|---------|-------|-------------|
| `otter login` | | Interactive login, saves credentials to keychain |
| `otter logout` | | Remove saved credentials |
| `otter user` | | Show current authenticated user |
| `otter ask QUESTION` | `--json`, `--timeout SECONDS` (default 120), `--debug` | Ask Otter's AI Chat across all conversations (creates a chat thread) |
| `otter search [QUERY]` | `--speaker NAME` (repeatable or comma-separated), `--all`, `--from YYYY-MM-DD`, `--to YYYY-MM-DD`, `--days N`, `--sort recent\|relevant`, `--limit N`, `--tries N`, `--max-seconds N`, `--debug`, `--json` | Search the archive by keyword, speakers, and dates |
| `otter speeches list` | `--days N`, `--folder NAME`, `--page-size N`, `--source owned\|shared\|all`, `--all`, `--max-pages N`, `--speaker NAME\|ID`, `--json` | List speeches |
| `otter speeches get OTID` | `--json` | Get speech details + full transcript |
| `otter speeches download OTID` | `--format txt\|pdf\|md\|docx\|srt\|mp3`, `--output NAME`, `--frontmatter-fields FIELDS` | Download transcript or audio |
| `otter speeches search QUERY OTID` | `--size N`, `--speaker NAME\|ID`, `--json` | Search within a speech transcript |
| `otter speeches upload FILE` | `-t, --content-type MIME` (default `audio/mp4`) | Upload audio file for transcription |
| `otter speeches trash OTID` | `-y, --yes` (skip confirmation; required in non-interactive runs, which otherwise abort with exit 1) | Move speech to trash |
| `otter speeches rename OTID TITLE` | | Rename a speech |
| `otter speeches rename-batch PLAN.json` | `--dry-run`, `--json` | Rename many speeches from a JSON plan in one session |
| `otter speeches move OTID...` | `--folder NAME`, `--create` | Move speeches to a folder (verifies each move) |
| `otter speakers list` | `--json` | List all speakers |
| `otter speakers create NAME` | | Create a new speaker |
| `otter speakers tag OTID SPEAKER_ID` | `-t UUID` (repeatable or comma-separated; several values run as a batch), `--all`, `--batch`, `--strict`, `--json` | Tag speaker on transcript segments |
| `otter speakers untag OTID` | `-t UUID` (repeatable or comma-separated), `--all --yes`, `--json` | Clear speaker tags on transcript segments |
| `otter folders list` | `--json` | List all folders |
| `otter folders create NAME` | `--json` | Create a folder |
| `otter folders rename ID NAME` | | Rename a folder |
| `otter groups list` | `--json` | List all groups |
| `otter config show` | | Show current config |
| `otter config clear` | | Clear saved config |
| `otter help [COMMAND...]` | | Show help for a command or group, e.g. `otter help speakers tag` (`otter --help` also lists every command) |

## Usage

```bash
otter speeches list                          # list all speeches
otter speeches list --days 7                 # last 7 days
otter speeches list --folder "Work"          # by folder name
otter speeches get SPEECH_ID                 # get speech details + transcript
otter speeches download SPEECH_ID -f txt     # download as txt, pdf, mp3, docx, srt, or md
otter speeches search "keyword" SPEECH_ID    # search within a speech
otter search "keyword" --days 30             # search the whole archive
otter ask "What did we decide about pricing?" # ask Otter's AI Chat
otter speakers list                          # list all speakers
otter folders list                           # list all folders
```

Run `otter --help` (which ends with an inventory of every command), `otter <command> --help`, or `otter help <group> <command>` for more options.

### Important: Speech IDs (otid vs speech_id)

Otter.ai speeches have two identifiers:
- **`speech_id`** (e.g. `22WB27HAEBEJYFCA`) -- internal ID, does **NOT** work with API endpoints
- **`otid`** (e.g. `jqb7OHo6mrHtCuMkyLN0nUS8mxY`) -- the ID used in all API calls

All CLI commands that accept a `SPEECH_ID` argument expect the **otid** value. Use `otter speeches list` to find otids, or `otter speeches list --json | jq '.speeches[].otid'` for just the IDs.

### Speeches

```bash
# List all speeches
otter speeches list

# List with options
otter speeches list --page-size 10 --source owned

# List speeches from the last N days
otter speeches list --days 2

# List speeches in a specific folder (by name or ID)
otter speeches list --folder "CoverNode"

# Fetch every page with one login (--days N with --all: the complete date window)
otter speeches list --all
otter speeches list --all --days 30 --json
otter speeches list --all --max-pages 20

# Only speeches with a matching speaker (name substring, case-insensitive, or exact speaker id)
otter speeches list --all --speaker "Jane"

# Only one speaker's segments that also contain the query text
otter speeches search "budget" SPEECH_ID --speaker "Jane" --json

# Get a specific speech
otter speeches get SPEECH_ID

# Search within a speech
otter speeches search "search query" SPEECH_ID

# Download a speech (formats: txt, pdf, mp3, docx, srt, md)
otter speeches download SPEECH_ID --format txt

# Download as markdown (generated locally from transcript data)
otter speeches download SPEECH_ID --format md
otter speeches download SPEECH_ID --format md --output meeting-notes
otter speeches download SPEECH_ID --format md --frontmatter-fields "title,summary,speakers,start_time,end_time,duration_seconds,source,speech_id,folder,folder_id"

# Upload an audio file
otter speeches upload recording.mp4

# Move to trash (asks for confirmation; agents and scripts must pass --yes)
otter speeches trash SPEECH_ID
otter speeches trash SPEECH_ID --yes

# Rename a speech
otter speeches rename SPEECH_ID "New Title"

# Move speeches to a folder (by name or ID)
otter speeches move SPEECH_ID --folder "CoverNode"
otter speeches move ID1 ID2 ID3 --folder "CoverNode"

# Move to a new folder (auto-create if it doesn't exist)
otter speeches move SPEECH_ID --folder "New Folder" --create

# Rename many speeches from a plan: preview first, then apply
otter speeches rename-batch plan.json --dry-run --json
otter speeches rename-batch plan.json --json
```

#### Listing every page (`--all`, `--max-pages`, `--speaker`)

- Without `--all` or `--speaker`, `speeches list` makes one request and its output is unchanged. `--days` on its own still filters only that single page.
- `--all` follows Otter's cursor until the end of the list, using one login. With `--days N` it stops once pages predate the window, so the result is the complete date window. `--max-pages N` (default 1000) caps the pages and needs `--all`.
- `--speaker NAME|ID` matches a speaker name (case-insensitive substring) or an exact speaker id. Without `--all` it filters only the first page and warns on stderr when more pages exist. **An empty single-page result does not prove there is no match:** use `--all` and check `.pagination.complete` in `--json`.
- With `--all`, `--page-size` and `--days` must be at least 1.
- If paging stops early (rate limit, API error, `--max-pages`), the partial results are printed first, then the reason goes to stderr and the exit code is `1`. In `--json`, `status` becomes `"failed"` and `pagination.error` explains why. See the [JSON Output Schema](#json-output-schema) for the `pagination` fields.

#### Searching one speaker's lines (`speeches search --speaker`)

`otter speeches search QUERY OTID --speaker S` loads the full transcript instead of using Otter's in-meeting search. It keeps segments whose speaker name contains `S` (case-insensitive) or whose `speaker_id` equals `S`, and whose text contains `QUERY` (case-insensitive). Up to `--size` matches are printed, each under a header like `[1] Jane Doe`; `--json` prints `{"results": [...segments]}`.

#### Batch rename (`speeches rename-batch`)

The plan is a JSON array of objects with exactly three fields:

```json
[
  {"otid": "jqb7OHo6mrHtCuMkyLN0nUS8mxY", "old_title": "Untitled", "new_title": "Weekly Standup 2026-10-26"},
  {"otid": "Kx2RvA9pQ3nLm8tWz1yBcDe4FgH", "old_title": null, "new_title": "Design Review"}
]
```

- `otid`: nonempty, no whitespace, unique within the plan.
- `old_title`: the title you expect now (a string, or `null` for a recording with no title).
- `new_title`: a nonblank string. Titles are used exactly as written.

The whole plan is validated before login; an invalid plan exits `1` and changes nothing.

Workflow:

1. **Always preview first:** `otter speeches rename-batch plan.json --dry-run --json`. This validates the plan without logging in and prints `{"status": "preview", "dry_run": true, "count": N, "changes": [...]}`.
2. **Apply:** `otter speeches rename-batch plan.json --json`. For each entry in order it reads the current title, skips it when it already equals `new_title`, refuses when it differs from `old_title` (no write is sent), otherwise renames and reads it back to verify. Progress lines like `[1/2] OTID: saved and verified` go to stderr.
3. **The first failure stops the batch** with exit `1`. Fix the cause, reload the failed recording, and rerun the same plan: saved titles count as already correct.

The `--json` report:

| Key | Meaning |
|-----|---------|
| `saved_otids` | Renamed and verified |
| `unchanged_otids` | Already had `new_title` |
| `failed_otid` | Where the batch stopped, else `null` |
| `unattempted_otids` | Entries after the failure |
| `error` | The failure message, else `null` |
| `retry_after_seconds` | Server-requested delay when rate limited |
| `unconfirmed_write` | `true` when a rename may have been sent but could not be verified: reload that recording before retrying |
| `status` | `"OK"` or `"failed"` |
| `dry_run` | `false` |
| `total` | Number of plan entries |

#### Move verification and trashed recordings

- Each OTID is sent in its own request. When Otter's acknowledgement lists `added_speech_otids`, every requested OTID must appear in it.
- Otter can acknowledge a move but skip recordings it cannot find, usually because they are in Otter's trash. On a partial or malformed acknowledgement, `move` prints a report to stderr (`Move confirmed for N/M recordings.`, `Confirmed OTIDs: ...`, `Unconfirmed OTIDs: ...`), names the recordings that are not among your active recordings, and exits `1`. Restore trashed recordings in Otter before moving them.
- It stops at the first failed request and lists the rest as unconfirmed. Moves are never retried automatically: reload the affected recordings before retrying.
- With `--create`, a folder is created only when the name is definitely not found. A failed folder lookup exits instead, so a transient error never creates a duplicate folder.
- Blank OTIDs are rejected before login with `Provide nonempty OTIDs; no speeches were moved.`

#### Markdown frontmatter (`--format md`)

Markdown export includes YAML frontmatter, configurable per download:

```bash
# Use defaults
otter speeches download SPEECH_ID --format md

# Pick exact fields (in your own order)
otter speeches download SPEECH_ID --format md --frontmatter-fields "title,speech_id,summary"

# Disable all frontmatter fields
otter speeches download SPEECH_ID --format md --frontmatter-fields none
```

Default frontmatter fields (in order):
1. `title`
2. `summary`
3. `speakers`
4. `start_time`
5. `end_time`
6. `duration_seconds`
7. `source`
8. `speech_id`
9. `folder`
10. `folder_id`

Available frontmatter fields for `--frontmatter-fields`:
- `title`
- `summary`
- `speakers`
- `start_time`
- `end_time`
- `duration_seconds`
- `source`
- `speech_id`
- `folder`
- `folder_id`
- `otid`
- `created_at`
- `transcript_updated_at`
- `language`
- `transcript_count`
- `process_status`

Notes:
- `--frontmatter-fields` is valid only with `--format md`.
- `speech_id` in frontmatter is the Otter internal `speech_id`; command argument `SPEECH_ID` still expects the `otid`.

### Speakers

```bash
# List all speakers
otter speakers list

# Create a new speaker
otter speakers create "Speaker Name"

# Tag a speaker on transcript segments
otter speakers tag SPEECH_ID SPEAKER_ID                 # list segments, change nothing
otter speakers tag SPEECH_ID SPEAKER_ID -t UUID
otter speakers tag SPEECH_ID SPEAKER_ID --all           # EVERY segment, including other people's

# Tag selected segments in one session
otter speakers tag SPEECH_ID SPEAKER_ID -t UUID1 -t UUID2
otter speakers tag SPEECH_ID SPEAKER_ID -t UUID1,UUID2 --json
otter speakers tag SPEECH_ID SPEAKER_ID -t UUID --strict --json

# Clear speaker tags
otter speakers untag SPEECH_ID                          # list segments, change nothing
otter speakers untag SPEECH_ID -t UUID1 -t UUID2
otter speakers untag SPEECH_ID --all --yes              # clears EVERY segment
```

#### Tag selected speakers in one session

- **Batch mode** runs automatically when `-t` is repeated or holds comma-separated UUIDs; `--batch` or `--strict` also applies it to a single `-t` or to `--all`. Duplicate UUIDs are removed and every UUID is checked against the conversation first: an unknown UUID exits `1` before anything is saved. The batch then writes in order with one login and stops at the first failed write (exit `1`).
- Human output: `Tagged n/m segments as 'NAME'`; on failure `Saved UUIDs: ...`, `Unattempted UUIDs: ...` and the stop message go to stderr.
- `--json` report keys, in order: `tagged_uuids`, `failed_uuid`, `unattempted_uuids`, `error`, `retry_after_seconds`, `unconfirmed_write`, `status` (`"OK"` or `"failed"`), `speech_otid`, `speaker_id`, `speaker_name`. When `unconfirmed_write` is `true`, reload `failed_uuid` before retrying.
- `--all` combined with `-t` is a usage error in batch mode (exit `2`), as is an empty comma piece such as `-t U1,,U2`.
- A single `-t` or a bare `--all`, without `--batch` or `--strict`, keeps the original behavior: each failure is reported and the command exits `0`.
- The client already retries 429/5xx automatically before a batch stops; see [Rate limits](#rate-limits-http-429).

#### Clear speaker tags (`speakers untag`)

- With no `-t` and no `--all`, `untag` lists the segments and their current speakers (cleared segments show as `Untagged`).
- `-t` works as in `tag` batch mode, without needing any extra flag (repeatable or comma-separated; all UUIDs checked first; stops at the first failed write). Output: `Cleared n/m segments`.
- `--all` removes the tag from **every** segment and requires `--yes`; without it, the command exits `1` without sending any request. `--all` with `-t` is a usage error (exit `2`).
- `--json` uses the same first six report keys as `tag` (`tagged_uuids` lists the cleared UUIDs), plus `status` and `speech_otid`.
- After untagging, Otter shows a generic "Speaker N" label; only the selected paragraphs change, not the whole voice cluster.

### Archive search (`otter search`)

```bash
otter search Disney                                          # keyword, best-effort
otter search --speaker "Kate Furman" --speaker "Emily White" # both must be present
otter search --from 2026-09-21 --to 2026-09-24               # date window
otter search Disney --speaker "Kate Furman" --days 7 --sort recent --json
otter search --speaker "Kate Furman" --all --max-seconds 300 # whole archive
```

- **Keyword results are best-effort.** Otter returns a varying subset per call, so the CLI unions `--tries` calls (default 5, 1-10) about 3.5 seconds apart. A default keyword search takes 15 seconds or more.
- **Speakers:** repeat `--speaker` or separate names with commas; every speaker must be present. A speaker-only search (no QUERY) scans the recordings list with exact full-name matching: the last 90 days by default, a `--from`/`--to`/`--days` window when given, or the whole archive with `--all`, bounded by `--max-seconds` (default 120, 10-600). A date-only search (no QUERY, no `--speaker`) uses Otter's search with the date window and falls back to scanning your owned recordings list (with a stderr `Note:`) when that fails or returns nothing; without a window it scans the listing directly. `--max-seconds` applies only to speaker-only scans.
- **Speaker-only searches and the date-only listing fallback scan only recordings you own.** Meetings shared with you are missed (the Otter MCP server does cover them). If a speaker-only scan hits `--max-seconds` (`Time budget reached ...`) or a listing page after the first fails (`Warning: listing failed ... Returning partial results`), the command still prints the hits found so far and exits `0`; the only signal is that stderr notice, and the JSON has no completeness field. An empty or short result therefore does not prove absence. For a complete answer, use `otter speeches list --all --source all --speaker NAME --json` and check `.pagination.complete`; note that `speeches list --speaker` matches a case-insensitive substring of the name or an exact speaker id, while search matches the exact full name.
- **Dates** use your local timezone. `--to` is inclusive and requires `--from`; `--days N` (last N calendar days including today) conflicts with `--from`/`--to`. A title ending "on Mon Sep 21st 2026 @ 7:37am ET" sets the recording time (`recorded_at`).
- `--sort relevant` (default) or `recent`; `--limit N` (default 500) caps the results.
- `--json` prints `{"hits": [...]}`; progress and notices go to stderr. `--debug` prints request and response details to stderr.
- To read a hit, pass its `speech_otid` to `otter speeches get`.

### Ask Otter's AI Chat (`otter ask`)

```bash
otter ask "What action items came up in my meetings this week?"
otter ask "Summarize status updates from last week" --json --timeout 180
```

- Searches **all** your conversations with Otter's own AI Chat. For a single meeting use `otter speeches search` or `otter speeches get`.
- **Each call creates a new AI Chat thread in your Otter account.**
- Human output is the answer with inline `[OTID]` citations, then a `Sources:` list (`- Title [OTID]`). Pass those OTIDs to `otter speeches get`. See the [JSON Output Schema](#json-output-schema) for `--json`.
- `--timeout` (default 120 seconds) bounds the wait for the answer after the question is sent.
- The answer arrives over a websocket. The token is discovered automatically after login; set `OTTERAI_WS_TOKEN` to override it. `--debug` prints token-discovery and websocket diagnostics (names and lengths only, never token values) to stderr.
- Exit codes: `0` success, `1` failure (timeout, websocket error, no answer), `2` usage error.

### Folders and Groups

```bash
# List folders
otter folders list

# Create a folder
otter folders create "My Folder"

# Rename a folder
otter folders rename FOLDER_ID "New Name"

# List groups
otter groups list
```

### Configuration

```bash
# Show current config
otter config show

# Clear saved config
otter config clear
```

### JSON Output

Most commands support `--json` flag for machine-readable output:

```bash
otter speeches list --json
otter speakers list --json
```

## Error Handling

The CLI returns exit code `0` on success, `1` on any error, and `2` on a usage error (bad flags or flag combinations). Commands that check Otter's responses also exit `1` when a `200` response carries an explicit non-OK status or is missing the expected data. Common errors:

| Error | Cause | Fix |
|-------|-------|-----|
| `Not logged in. Run 'otter login' first.` | No saved credentials and no `OTTERAI_USERNAME`/`OTTERAI_PASSWORD` | Run `otter login` or set `OTTERAI_USERNAME` + `OTTERAI_PASSWORD` env vars |
| `Login failed: ...` | Wrong credentials, or the `/login` request failed (including a rate limit) | Check credentials; on a 429 see [Rate limits](#rate-limits-http-429) |
| `Failed to get speech: ...` / `unexpected Otter API response (HTTP ...)` | Invalid `otid`, or Otter returned an error or garbage speech response | Use `otter speeches list --json` to get valid otids |
| HTTP `429` / `Rate limited` | Too many API requests (after the client's automatic retries) | Stop; wait `retry_after_seconds` or 60-90 seconds, then retry slowly. See [Rate limits](#rate-limits-http-429) |
| `Listing stopped; results are incomplete` | `speeches list --all` stopped early | Partial results were printed; check `pagination.error` and rerun later |
| `Stopped at ...` | A batch (`rename-batch`, `speakers tag/untag -t ...`) hit a failure | Reload the failed item; rerun to resume |

## FAQ

### How do I bulk export all my Otter.ai transcripts?

```bash
otter speeches list --all --json | jq -r '.speeches[].otid' | while read otid; do
  otter speeches download "$otid" --format md || break
  sleep 5
done
```

Each `otter speeches download` call logs in again, so this loop makes one `/login` request per recording. The `sleep` paces those logins, and `|| break` stops the loop at the first failure. If a download reports a 429, stop and wait `retry_after_seconds` (or 60-90 seconds when none is given) before resuming. See [Rate limits](#rate-limits-http-429).

### How do I download Otter.ai meeting notes as markdown?

```bash
otter speeches download SPEECH_ID --format md
```

This generates a markdown file with YAML frontmatter (title, summary, speakers, timestamps). See [Markdown frontmatter](#markdown-frontmatter---format-md) for customization.

### Can AI agents like Claude or ChatGPT use this tool?

Yes. Install the CLI, set `OTTERAI_USERNAME` and `OTTERAI_PASSWORD` environment variables, and agents can use all commands with `--json` for structured output. See [AI Agent & LLM Usage](#ai-agent--llm-usage).

### Is there an Agent Skill for this CLI?

Yes. The [`skills/otterai-cli/`](skills/otterai-cli/SKILL.md) directory contains an [Agent Skill](https://agentskills.io) compatible with Claude Code, Cursor, Copilot, Gemini CLI, and other supporting agents. Copy it into your agent's skills directory and the agent will automatically know how to use all `otter` commands.

## Use Cases

- **Bulk export / backup** — download all your Otter.ai transcripts programmatically
- **Automate meeting workflows** — pipe transcript data into scripts or cron jobs
- **AI agent integration** — let Claude, GPT, or other LLM agents access your meeting notes
- **Search across meetings** — find specific discussions without opening the Otter.ai UI
- **Meeting note pipelines** — download as markdown, process with other tools
- **Transcript archival** — export meetings before they expire or for compliance

## Alternatives

| Tool | Type | Notes |
|------|------|-------|
| [Otter.ai web app](https://otter.ai) | Web UI | Official interface, no CLI or API access |
| [otterai-api](https://github.com/gmchad/otterai-api) | Python library | API wrapper only, no CLI — this project builds on it |
| Manual export | Web UI | One-at-a-time downloads from the Otter.ai dashboard |

## Development

```bash
uv sync --dev        # install dependencies
uv run pytest        # run tests
```

## Acknowledgements

Based on [gmchad/otterai-api](https://github.com/gmchad/otterai-api) by Chad Lohrli, with CLI functionality from [PR #9](https://github.com/gmchad/otterai-api/pull/9) by [@andrewfurman](https://github.com/andrewfurman).

## License

MIT
