> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.beatapi.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.beatapi.io/_mcp/server.

# CLI Integration

> Install the official BeatAPI CLI (npm install -g beatapi) to save your BeatAPI API key in the OS keychain, search and run capabilities, upload local media files, or let terminal AI clients call BeatAPI.

**BeatAPI CLI** (the `beatapi` command) is the official terminal tool for BeatAPI. After you install and sign in to `beatapi`, you or any terminal AI client (Claude Code, Codex, Gemini CLI, Antigravity, OpenCode) can search, check prices, and run BeatAPI capabilities directly from the command line.

BeatAPI CLI fits three common situations:

* You prefer letting a terminal AI client run `beatapi` shell commands instead of editing MCP config files.
* You need to upload a local image, video, or audio file to get a public HTTPS URL before calling a BeatAPI media model (`beatapi files upload`).
* You want to call BeatAPI from shell scripts, scheduled jobs, or CI pipelines.

> **CLI login is separate from MCP:** Running `beatapi auth login` saves credentials for BeatAPI CLI only. CLI login does not configure [BeatAPI MCP](/integrations/mcp) or export environment variables for other apps.

## Prerequisites

1. **Node.js 18 or newer** installed on your machine. Run `node -v` in the terminal (`v18`, `v20`, or `v22` all work).
2. A **BeatAPI API key** created in [BeatAPI Dashboard → API Keys](https://beatapi.io/dashboard/apikeys) (usually starting with `sk-`).

## Step 1: Install BeatAPI CLI

Run this command in your terminal to install `beatapi` globally:

```bash
npm install --global beatapi
```

Confirm the installation and verify your version is `0.3.0` or newer:

```bash
beatapi --version
```

## Step 2: Sign in (OS credential manager)

Run the login command:

```bash
beatapi auth login
```

1. The terminal prompts for your BeatAPI API key. Characters do not appear on screen while you type or paste; this is standard terminal password hiding.
2. Paste your BeatAPI API key and press **Enter**. BeatAPI CLI stores the key in your operating system's credential manager (macOS Keychain, Windows Credential Manager, or Linux Secret Service) without creating a plaintext key file in your project.
3. Run this free check to confirm authentication:

```bash
beatapi auth status
```

Seeing an authenticated status confirms BeatAPI CLI is ready.

## Step 3: Everyday commands

### 1. Search capabilities (free)

Search using platform and action keywords in English or Chinese:

```bash
beatapi capabilities search "小红书 搜索笔记"
beatapi capabilities search "video generation model"
```

Copy the exact capability ID returned by the command (for example, `data:xiaohongshu.app_v2.search_notes`). Do not guess or hand-write capability IDs.

### 2. Check inputs and price (free)

Pass the copied capability ID to `inspect` to check required inputs and single-call pricing:

```bash
beatapi capabilities inspect data:xiaohongshu.app_v2.search_notes
```

### 3. Run a capability and check progress (paid per call)

Use `beatapi capabilities run` to execute the inspected capability, and use `beatapi capabilities status` to check progress on image, video, or deep research jobs. View the exact flags supported by your installed CLI version with:

```bash
beatapi capabilities run --help
beatapi capabilities status --help
```

### 4. Upload a local image, video, or audio file

BeatAPI image, video, and audio models require public HTTPS URLs rather than local file paths. Upload a local file first:

```bash
beatapi files upload ./sample-product.png
```

`beatapi files upload` uses your saved CLI login to upload `./sample-product.png` and prints a public HTTPS URL. Pass that URL into your next model or workflow call.

## Step 4: Let terminal AI clients call BeatAPI CLI

Claude Code, Codex, Gemini CLI, Antigravity, and OpenCode can run `beatapi` directly through their shell tool without MCP configured:

1. Complete Step 1 (`npm install --global beatapi`) and Step 2 (`beatapi auth login`) on your computer.
2. Install the [BeatAPI Agent Skill](/integrations/skill) so your AI client always checks prices before running paid commands.
3. Send a direct instruction in chat:

> Use the installed `beatapi` CLI to search for Xiaohongshu note search, run `beatapi capabilities inspect` on the top result, and show me the required inputs and price. Wait for my confirmation before running `beatapi capabilities run`.

Because your BeatAPI API key is stored in the OS keychain, your AI client executes `beatapi` commands without seeing or printing your raw API key in chat.

## Troubleshooting

* **Terminal prints `command not found: beatapi`:** Your npm global bin folder is not in `PATH`. Run `npm prefix -g`, add `<prefix>/bin` (macOS/Linux) or `<prefix>` (Windows) to `PATH`, and open a new terminal window.
* **`capabilities` subcommand is missing:** Your installed version is older than `0.3.0`. Run `npm install --global beatapi@latest` to upgrade.
* **401 error (missing or invalid key):** Run `beatapi auth status` to check your saved login. If your old key was disabled in the dashboard, create a new key in [BeatAPI Dashboard → API Keys](https://beatapi.io/dashboard/apikeys) and run `beatapi auth login` again.
* **400 error on `capabilities run`:** A required input field is missing or misspelled. Run `beatapi capabilities inspect <capability-id>` to verify the required fields.
* **MCP still does not connect after `beatapi auth login`:** CLI login and MCP configuration are independent. Follow [MCP Integration](/integrations/mcp) to configure `https://beatapi.io/mcp`.

## Related pages

* [MCP Integration](/integrations/mcp) — connect BeatAPI's hosted remote MCP server (`https://beatapi.io/mcp`) to Claude Code, Codex, Cursor, Gemini CLI, Antigravity, OpenCode, and VS Code.
* [Agent Skill Integration](/integrations/skill) — install BeatAPI Skill for Muse, Grok Bot, Manus, OpenClaw, and local coding clients.
* [Official BeatAPI CLI repository](https://github.com/BeatAPI/beatapi-cli) — full command reference, releases, and source code.
* [Capabilities API Reference](/capabilities) — underlying HTTP endpoint documentation.