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

# Quickstart

> Scan your codebase and bill your first AI agent from the command line.

The Paygent CLI is a command line interface for the Paygent API. It scans a codebase for AI provider calls that should be metered, then creates the agents, pricing, customers, and subscriptions to bill them.

## Prerequisites

* Node.js and npm available on your machine.
* A [Paygent account](https://www.withpaygent.com/signup).

## Install

```bash
npm install -g paygent
```

Or run without installing:

```bash
npx paygent scan .
```

## Authenticate

```bash
paygent login
```

This opens a browser, signs you in, and stores credentials on this machine. Confirm with:

```bash
paygent whoami
```

## Scan Your Codebase

```bash
paygent scan .
```

```text
FILE          LINE  PROVIDER       KIND  FUNCTION
generator.py  340   Google Gemini  LLM   _generate_structured
image_gen.py  39    Google Gemini  LLM   generate_image
research.py   47    Google Gemini  LLM   research_topic

  3 call(s) to instrument across 3 file(s).

  Integration plan written to:
    paygent_module/paygent_integration_prompt.md
```

Copy the plan straight to your clipboard and paste it into your coding assistant:

```bash
paygent scan . --copy
```

## Create Your First Agent

```bash
paygent agent create --name "Research" --external-id research
```

Define what you meter:

```bash
paygent agent indicator add research --name "Input tokens (per 1M)" --type ACTIVITY
paygent agent indicator add research --name "Output tokens (per 1M)" --type ACTIVITY
```

Price it:

```bash
paygent agent pricing set research --platform-fee 99 \
  --price "Input tokens (per 1M)=3.00" \
  --price "Output tokens (per 1M)=15.00"
```

Add a customer and turn the agent on:

```bash
paygent customer create --name "Acme Corp" --external-id acme --email billing@acme.com
paygent agent enable research
```

> **Warning**
>
> An agent that is not enabled rejects usage. This is the most common reason a first event disappears.

## See Usage

```bash
paygent usage agent --agent research
paygent billing overview
```

## Common Options

```bash
paygent agent list \
  --output json \
  --org 68b2c1a4f0e1d2c3b4a59687 \
  --timeout 60s
```

* `--output` sets the format: `table`, `json`, `yaml`, or `csv`.
* `--org` acts on a specific organization.
* `--profile` selects a saved configuration profile.
* `--timeout` sets the HTTP timeout.