cometapi-cli 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/AGENTS.md +3 -3
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/CHANGELOG.md +7 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/PKG-INFO +1 -1
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/authentication.md +1 -1
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/commands/balance.md +6 -6
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/pyproject.toml +1 -1
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/skills/live-test/SKILL.md +3 -3
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/__init__.py +1 -1
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/commands/balance.py +26 -4
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/test_balance.py +21 -4
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/uv.lock +1 -1
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/.github/workflows/ci.yml +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/.github/workflows/publish.yml +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/.gitignore +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/CODE_OF_CONDUCT.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/CONTRIBUTING.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/LICENSE +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/README.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/SECURITY.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/SKILL.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/README.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/commands/account.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/commands/chat.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/commands/config.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/commands/doctor.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/commands/init.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/commands/logs.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/commands/models.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/commands/repl.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/commands/stats.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/commands/tasks.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/commands/tokens.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/configuration.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/errors.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/installation.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/docs/output-formats.md +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/app.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/client.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/commands/__init__.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/commands/account.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/commands/chat.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/commands/chat_repl.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/commands/config_cmd.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/commands/doctor.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/commands/logs.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/commands/models.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/commands/repl.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/commands/stats.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/commands/tasks.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/commands/tokens.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/config.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/console.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/constants.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/errors.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/formatters.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/src/cometapi_cli/main.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/__init__.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/conftest.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/test_account.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/test_chat.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/test_config.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/test_doctor.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/test_errors.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/test_formatters.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/test_help.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/test_logs.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/test_models.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/test_stats.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/test_tasks.py +0 -0
- {cometapi_cli-0.2.1 → cometapi_cli-0.2.2}/tests/test_tokens.py +0 -0
|
@@ -201,13 +201,13 @@ These options apply to **every** command via the root Typer callback.
|
|
|
201
201
|
|
|
202
202
|
| Parameter | Alias | Type | Default | Description |
|
|
203
203
|
|-----------|-------|------|---------|-------------|
|
|
204
|
-
| `--source` | `-s` | `str` (`account` or `
|
|
204
|
+
| `--source` | `-s` | `str` (`account` or `key`) | `None` (auto-detect) | Force data source: `account` = full account balance via `/api/user/self`; `key` = per-API-key billing via `/v1/dashboard/billing/*` |
|
|
205
205
|
| `--format` | `-f` | `OutputFormat` | inherits global | Per-command output format override |
|
|
206
206
|
| `--json` | — | flag | `false` | Output raw balance dict as JSON |
|
|
207
207
|
|
|
208
208
|
**Auto-detection logic** (when `--source` is omitted):
|
|
209
209
|
1. If `COMETAPI_ACCESS_TOKEN` is available → uses `account` source.
|
|
210
|
-
2. Otherwise → falls back to `
|
|
210
|
+
2. Otherwise → falls back to `key` (per-key billing) source.
|
|
211
211
|
|
|
212
212
|
**Display — `account` source:**
|
|
213
213
|
| Field | Description |
|
|
@@ -216,7 +216,7 @@ These options apply to **every** command via the root Typer callback.
|
|
|
216
216
|
| Used | Total amount consumed (USD) |
|
|
217
217
|
| Total Topped Up | Lifetime top-up amount (USD) |
|
|
218
218
|
|
|
219
|
-
**Display — `
|
|
219
|
+
**Display — `key` (billing) source:**
|
|
220
220
|
| Field | Description |
|
|
221
221
|
|-------|-------------|
|
|
222
222
|
| Limit | Spending cap (`Unlimited` if no cap set) |
|
|
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.2.2] — 2026-04-14
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- `balance --source` now uses `key` for the API-key billing view so the CLI terminology matches `api_key` and `access_token`.
|
|
13
|
+
- `balance --source token` is still accepted as a compatibility alias and is normalized to the same API-key billing behavior.
|
|
14
|
+
|
|
8
15
|
## [0.2.1] — 2026-04-14
|
|
9
16
|
|
|
10
17
|
### Changed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cometapi-cli
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: CometAPI CLI — official command-line interface for the CometAPI AI gateway
|
|
5
5
|
Project-URL: Homepage, https://github.com/cometapi-dev/cometapi-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/cometapi-dev/cometapi-cli
|
|
@@ -9,7 +9,7 @@ Used for **AI relay endpoints** — the core API functionality:
|
|
|
9
9
|
- `chat` — chat completions
|
|
10
10
|
- `models` — list available models
|
|
11
11
|
- `doctor` — connectivity check
|
|
12
|
-
- `balance` — per-
|
|
12
|
+
- `balance` — per-key billing stats (fallback mode)
|
|
13
13
|
|
|
14
14
|
**How to get one**: [https://www.cometapi.com/console/token](https://www.cometapi.com/console/token)
|
|
15
15
|
|
|
@@ -10,7 +10,7 @@ cometapi balance [OPTIONS]
|
|
|
10
10
|
|
|
11
11
|
| Option | Alias | Type | Default | Description |
|
|
12
12
|
|--------|-------|------|---------|-------------|
|
|
13
|
-
| `--source` | `-s` | string | — | Data source: `account` (full account) or `
|
|
13
|
+
| `--source` | `-s` | string | — | Data source: `account` (full account) or `key` (current API key) |
|
|
14
14
|
| `--format` | `-f` | choice | `table` | Output format: `table`, `json`, `yaml`, `csv`, `markdown` |
|
|
15
15
|
| `--json` | — | flag | `false` | Output as JSON |
|
|
16
16
|
| `--help` | `-h` | flag | — | Show help |
|
|
@@ -21,7 +21,7 @@ Requires `COMETAPI_KEY`. Access token is optional but provides richer data.
|
|
|
21
21
|
|
|
22
22
|
## Behavior
|
|
23
23
|
|
|
24
|
-
By default, the command shows account-level balance if an access token is available, falling back to per-
|
|
24
|
+
By default, the command shows account-level balance if an access token is available, falling back to per-key billing stats from the API key. Use `--source` to force a specific view.
|
|
25
25
|
|
|
26
26
|
### Source: `account` (access token required)
|
|
27
27
|
|
|
@@ -33,9 +33,9 @@ Shows full account balance:
|
|
|
33
33
|
| `used` | Total amount consumed in USD |
|
|
34
34
|
| `total_topped_up` | Total amount added to the account in USD |
|
|
35
35
|
|
|
36
|
-
### Source: `
|
|
36
|
+
### Source: `key` (API key only)
|
|
37
37
|
|
|
38
|
-
Shows per-
|
|
38
|
+
Shows per-key billing stats:
|
|
39
39
|
|
|
40
40
|
| Field | Description |
|
|
41
41
|
|-------|-------------|
|
|
@@ -59,8 +59,8 @@ cometapi balance
|
|
|
59
59
|
# Force account-level balance
|
|
60
60
|
cometapi balance --source account
|
|
61
61
|
|
|
62
|
-
# Force per-
|
|
63
|
-
cometapi balance --source
|
|
62
|
+
# Force per-key billing stats
|
|
63
|
+
cometapi balance --source key
|
|
64
64
|
|
|
65
65
|
# JSON output for scripting
|
|
66
66
|
cometapi balance --json
|
|
@@ -134,14 +134,14 @@ uv run cometapi models --format yaml --limit 3
|
|
|
134
134
|
|
|
135
135
|
```bash
|
|
136
136
|
uv run cometapi balance
|
|
137
|
-
uv run cometapi balance --source
|
|
137
|
+
uv run cometapi balance --source key
|
|
138
138
|
uv run cometapi balance --source account
|
|
139
139
|
uv run cometapi balance --json
|
|
140
140
|
```
|
|
141
141
|
|
|
142
142
|
**Verify:**
|
|
143
143
|
- Default: shows "Available Balance", "Used", "Total Topped Up" (account source, if access token available).
|
|
144
|
-
- `--source
|
|
144
|
+
- `--source key`: shows "Limit" (may be "Unlimited") and "Used".
|
|
145
145
|
- `--source account`: same as default account view.
|
|
146
146
|
- `--json`: outputs valid JSON with `balance`, `used`, `total_topped_up`, `source` fields.
|
|
147
147
|
|
|
@@ -330,7 +330,7 @@ uv run cometapi --version
|
|
|
330
330
|
uv run cometapi -h
|
|
331
331
|
uv run cometapi models --limit 3 --json
|
|
332
332
|
uv run cometapi balance
|
|
333
|
-
uv run cometapi balance --source
|
|
333
|
+
uv run cometapi balance --source key
|
|
334
334
|
uv run cometapi chat "ping" --json
|
|
335
335
|
uv run cometapi account --json
|
|
336
336
|
uv run cometapi tokens --limit 3 --json
|
|
@@ -7,28 +7,50 @@ from typing import Annotated
|
|
|
7
7
|
import typer
|
|
8
8
|
|
|
9
9
|
from ..config import get_client
|
|
10
|
+
from ..console import err_console
|
|
10
11
|
from ..errors import handle_errors
|
|
11
12
|
from ..formatters import OutputFormat, output, resolve_format
|
|
12
13
|
|
|
14
|
+
BALANCE_SOURCE_ALIASES = {
|
|
15
|
+
"account": "account",
|
|
16
|
+
"key": "key",
|
|
17
|
+
"token": "key",
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _normalize_balance_source(source: str | None) -> str | None:
|
|
22
|
+
if source is None:
|
|
23
|
+
return None
|
|
24
|
+
|
|
25
|
+
normalized = BALANCE_SOURCE_ALIASES.get(source.lower())
|
|
26
|
+
if normalized is not None:
|
|
27
|
+
return normalized
|
|
28
|
+
|
|
29
|
+
err_console.print(f"[red]Invalid source:[/] {source}. Valid sources: account, key")
|
|
30
|
+
raise typer.Exit(code=2)
|
|
31
|
+
|
|
13
32
|
|
|
14
33
|
@handle_errors
|
|
15
34
|
def balance(
|
|
16
35
|
ctx: typer.Context,
|
|
17
36
|
source: Annotated[
|
|
18
37
|
str | None,
|
|
19
|
-
typer.Option("--source", "-s", help="Data source: 'account' (full account) or '
|
|
38
|
+
typer.Option("--source", "-s", help="Data source: 'account' (full account) or 'key' (current API key)."),
|
|
39
|
+
] = None,
|
|
40
|
+
output_format: Annotated[
|
|
41
|
+
OutputFormat | None,
|
|
42
|
+
typer.Option("--format", "-f", help="Output format (table, json, yaml, csv, markdown)."),
|
|
20
43
|
] = None,
|
|
21
|
-
output_format: Annotated[OutputFormat | None, typer.Option("--format", "-f", help="Output format (table, json, yaml, csv, markdown).")] = None,
|
|
22
44
|
json_output: Annotated[bool, typer.Option("--json", help="Output as JSON.")] = False,
|
|
23
45
|
) -> None:
|
|
24
46
|
"""Show your CometAPI account balance.
|
|
25
47
|
|
|
26
48
|
By default shows account-level balance (requires access token), falling back
|
|
27
|
-
to per-
|
|
49
|
+
to per-key billing stats. Use --source to force a specific view.
|
|
28
50
|
"""
|
|
29
51
|
fmt = resolve_format(ctx, json_output, output_format)
|
|
30
52
|
client = get_client()
|
|
31
|
-
raw = client.get_balance(source=source)
|
|
53
|
+
raw = client.get_balance(source=_normalize_balance_source(source))
|
|
32
54
|
|
|
33
55
|
# For JSON output, pass raw data for maximum information
|
|
34
56
|
if fmt == OutputFormat.JSON:
|
|
@@ -22,8 +22,8 @@ def test_balance_table(cli_runner, patched_client):
|
|
|
22
22
|
assert "$3,305.90" in result.output
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
def
|
|
26
|
-
"""Test --source
|
|
25
|
+
def test_balance_source_key(cli_runner, patched_client):
|
|
26
|
+
"""Test --source key shows billing view."""
|
|
27
27
|
patched_client.get_balance.return_value = {
|
|
28
28
|
"balance": -1,
|
|
29
29
|
"used": 280.05,
|
|
@@ -31,11 +31,18 @@ def test_balance_source_token(cli_runner, patched_client):
|
|
|
31
31
|
"currency": "USD",
|
|
32
32
|
"source": "billing",
|
|
33
33
|
}
|
|
34
|
-
result = cli_runner("balance", "--source", "
|
|
34
|
+
result = cli_runner("balance", "--source", "key")
|
|
35
35
|
assert result.exit_code == 0
|
|
36
36
|
assert "Unlimited" in result.output
|
|
37
37
|
assert "$280.05" in result.output
|
|
38
|
-
patched_client.get_balance.assert_called_with(source="
|
|
38
|
+
patched_client.get_balance.assert_called_with(source="key")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_balance_source_token_alias(cli_runner, patched_client):
|
|
42
|
+
"""Test deprecated --source token still maps to API-key billing view."""
|
|
43
|
+
result = cli_runner("balance", "--source", "token")
|
|
44
|
+
assert result.exit_code == 0
|
|
45
|
+
patched_client.get_balance.assert_called_with(source="key")
|
|
39
46
|
|
|
40
47
|
|
|
41
48
|
def test_balance_source_account(cli_runner, patched_client):
|
|
@@ -50,4 +57,14 @@ def test_balance_help(cli_runner):
|
|
|
50
57
|
result = cli_runner("balance", "-h")
|
|
51
58
|
assert result.exit_code == 0
|
|
52
59
|
assert "--source" in result.output
|
|
60
|
+
assert "Data source:" in result.output
|
|
61
|
+
assert "'key'" in result.output
|
|
62
|
+
assert "API key" in result.output
|
|
63
|
+
assert "'token'" not in result.output
|
|
53
64
|
assert "--json" in result.output
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_balance_source_invalid(cli_runner):
|
|
68
|
+
result = cli_runner("balance", "--source", "billing")
|
|
69
|
+
assert result.exit_code == 2
|
|
70
|
+
assert "Valid sources: account, key" in result.output
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|