Перейти к навигации

CLI Integration

Просмотр в формате Markdown

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 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 (usually starting with sk-).

Step 1: Install BeatAPI CLI

Run this command in your terminal to install beatapi globally:

npm install --global beatapi

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

beatapi --version

Step 2: Sign in (OS credential manager)

Run the login command:

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:
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:

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:

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:

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:

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 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 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 to configure https://beatapi.io/mcp.