> ## Documentation Index
> Fetch the complete documentation index at: https://getlago.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# AI tools for Lago

> Use the Lago CLI and the v2 OpenAPI contract to configure and verify contract billing with your coding agent.

Start with the [Lago CLI](https://github.com/getlago/lago-cli) when your coding agent has terminal access. Its `lago v2` commands configure the product catalog, plans and contracts, return JSON, and read contract usage. Your application connects to Lago through the REST API under `/api/v2`. Lago Cloud is managed. Self-hosting is optional.

> [!NOTE]
>
> API v2 is in beta. Endpoints return the `X-Lago-Endpoint-Status: beta` header.

You can inspect public docs and build local application tests without a Lago account. Calling your organization's API requires its API key and the product catalog enabled on the organization.

## Start with the CLI and OpenAPI

The `lago v2` commands ship in CLI 1.3.0 and later.

```bash theme={"dark"}
brew install getlago/tap/lago
lago version
lago init
lago whoami --output json
lago doctor
lago v2 contracts list --limit 5 --output json
```

`lago init` asks for your region and API key. [Get access to your organization](#connect-to-lago-when-you-are-ready) before connecting. Keep keys out of prompts and source control.

The [v2 OpenAPI contract](https://swagger.getlago.com/openapi-v2.yaml) supplies exact fields for requests, generated clients and agent tools. An agent with HTTP access can call the API directly. The CLI is optional. Read the [API introduction](https://getlago.com/docs/v2/api-reference/intro.md) for base URLs and conventions.

To add contract billing to your application, follow [Build Lago billing with a coding agent](https://getlago.com/docs/v2/guide/ai-agents/coding-agents.md). It covers repository work, local tests, CLI setup and a check against Lago.

## Pick your agent

The [Lago plugin](https://github.com/getlago/lago-plugin) gives Claude Code and Codex guided examples and implementation instructions. Its guidance targets the v1 API: plans with charges on `/api/v1`. For contract billing, give your agent this page, [How v2 differs from v1](https://getlago.com/docs/v2/guide/introduction/contracts-vs-subscriptions.md) and the v2 OpenAPI contract instead.

## Connect to Lago when you are ready

First, get access to the organization you will use:

* **Your team already uses Lago Cloud:** Ask your Lago organization admin for an invitation, accept it, and sign in. Confirm whether the organization is in the US or EU region.
* **You need a new Lago Cloud organization:** [Request access from Lago](https://getlago.com/book-a-demo). Tell the team which region you need and that you want the product catalog for contracts.
* **You use self-hosted Lago:** [Deploy Lago](https://getlago.com/docs/v2/guide/lago-self-hosted/overview.md) and sign up in its web app to create your organization, or ask your team's operator for access to an existing instance. Record the API service URL.

Once signed in to that organization, get its API key from **Developers → API keys**, or ask an admin to provide one. See [API keys](https://getlago.com/docs/v2/guide/security/api-keys.md). Keep it out of prompts and source control. Follow the [billing workflow](https://getlago.com/docs/v2/guide/ai-agents/coding-agents.md) to connect the CLI and check usage.

| Tool | What it gives your agent | Lago API key? |
| - | - | - |
| [Lago CLI](https://github.com/getlago/lago-cli) | `lago v2` commands to inspect, configure and verify catalog, plans and contracts | Yes, for live commands |
| [v2 OpenAPI contract](https://swagger.getlago.com/openapi-v2.yaml) | Exact schemas for clients, requests and agent tools | No, to read the contract |
| [Documentation MCP](https://docs.getlago.com/mcp) | Search of Lago's public docs | No |
| [REST API](https://getlago.com/docs/v2/api-reference/intro.md) | Your application's server-side billing integration under `/api/v2` | Yes |

If you want your agent to look up exact event or pricing guidance while coding, add `https://docs.getlago.com/mcp` as a remote HTTP MCP server. It searches public docs and cannot read your organization's data.

The Lago MCP server, the in-app assistants, the Agent SDK, the Agent Storefront and x402 work with the v1 API (`/api/v1`) only. See [Agent tools and contracts](https://getlago.com/docs/v2/guide/ai-agents/agent-tools.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.