Your Site Name
返回新闻

RT Lago:认识Lago CLI,面向开发者和AI代理。MCP(多步骤工作流程)在发现和调查方面很有用。CLI(命令行界面)更适合多步骤工作流程。T...

RT Lago: Meet the Lago CLI, for developers and AI agents. MCP is useful for discovery and investigation. The CLI is better for multi-step workflows. T...

Matt TurckAI2026-09-11
Lago CLI是从Lago OpenAPI规范生成的。每个端点都是一个命令,每个API字段都是一个标志。它与Lago Cloud US、Lago Cloud EU和自托管Lago兼容。演示:观看Lago CLI演示。安装在macOS和Linux上,Homebrew安装二进制文件、手册页和shell补全:brew install getlago/tap/lago。任何地方,Go 1.27或更高版本运行:go install github.com/getlago/lago-cli/cmd/lago@latest。发布存档(macOS、Linux和Windows)带有由cosign签名的校验和,可在发布页面找到。lago version打印CLI版本和构建时使用的API规范版本。lago upgrade告诉您是否存在新版本以及安装它的命令。如果lago version打印Docker Compose版本,则自托管Lago设置中的名为lago的shell别名正在覆盖二进制文件。运行unalias lago并从您的shell配置文件中删除别名。配置获取从Lago应用中的开发者>API密钥获取API密钥,然后:云US云EU自托管lago init --api-key "$LAGO_API_KEY" --region us --mode test lago init --api-key "$LAGO_API_KEY" --region eu --mode test lago init --api-key "$LAGO_API_KEY" --region self-hosted --api-url https://lago.example.com --mode test init在保存任何内容到~/.config/lago/config.toml之前会检查密钥是否与API匹配。仅传递基本URL:CLI会添加/api/v1。仪表板URL(app.getlago.com)被拒绝,因为它不是API。lago whoami显示配置文件和精确的主机请求地址。lago doctor检查配置、网络和身份验证。首次命令lago billable-metrics create --name Requests --code api_requests --aggregation-type count_agg lago customers create --external-id acme_001 --name "Acme Inc." --currency USD lago customers get acme_001 lago customers list --limit 5 lago customers get acme_001 --output json --query 'customer.email' lago seed demo通过一个命令创建完整的链(指标、计划、客户、订阅、事件、发票预览)。如何使用它...

原文

The Lago CLI is generated from the Lago OpenAPI spec. Every endpoint is a command, every API field is a flag. It works with Lago Cloud US, Lago Cloud EU, and self-hosted Lago. ​Demo Watch the Lago CLI demo. ​Install Homebrew on macOS and Linux installs the binary, the man page and the shell completions: brew install getlago/tap/lago Anywhere Go 1.27 or later runs: go install github.com/getlago/lago-cli/cmd/lago@latest Release archives for macOS, Linux and Windows, with checksums signed by cosign, are on the releases page. lago version prints the CLI version and the API spec version it was built from. lago upgrade tells you whether a newer release exists and the command to install it. If lago version prints a Docker Compose version, a shell alias named lago from a self-hosted Lago setup is shadowing the binary. Run unalias lago and remove the alias from your shell profile. ​Configure Get an API key from Developers > API keys in the Lago app, then: Cloud USCloud EUSelf-hostedlago init --api-key "$LAGO_API_KEY" --region us --mode test lago init --api-key "$LAGO_API_KEY" --region eu --mode test lago init --api-key "$LAGO_API_KEY" --region self-hosted --api-url https://lago.example.com --mode test init checks the key against the API before saving anything to ~/.config/lago/config.toml. Pass the base URL only: the CLI adds /api/v1. The dashboard URL (app.getlago.com) is refused, because it is not the API. lago whoami shows the profile and the exact host requests go to. lago doctor checks configuration, network, and authentication. ​First commands lago billable-metrics create --name Requests --code api_requests --aggregation-type count_agg lago customers create --external-id acme_001 --name "Acme Inc." --currency USD lago customers get acme_001 lago customers list --limit 5 lago customers get acme_001 --output json --query 'customer.email' lago seed demo creates a full chain (metric, plan, customer, subscription, event, invoice preview) in one command. ​How it works ​Flags are API fields A snake_case field is a --kebab-case flag. Nested fields carry their parent as a prefix. Objects and arrays take JSON. --input sends a whole request body. lago customers create --external-id acme_001 --billing-configuration-payment-provider stripe lago customers create --input @customer.json ​Creates print identifiers A create or update prints the identifier block. Add --output json for the full resource. $ lago customers create --external-id acme_001 --name "Acme Inc." --currency USD LAGO_ID 1a901a90-1a90-1a90-1a90-1a901a901a90 EXTERNAL_ID acme_001 NAME Acme Inc. ​Responses are wrapped The API wraps every response in its resource name. A --query starts with that wrapper. A query that matches nothing prints null and lists the available keys on stderr. lago customers get acme_001 --query 'customer.email' lago customers list --query 'customers[].external_id' ​Destructive operations ask first delete, void, finalize, terminate, and retry-paymen