cometapi-cli 0.2.2__tar.gz → 0.3.1__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.
Files changed (88) hide show
  1. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/AGENTS.md +77 -9
  2. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/CHANGELOG.md +29 -0
  3. cometapi_cli-0.3.1/PKG-INFO +311 -0
  4. cometapi_cli-0.3.1/README.md +276 -0
  5. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/README.md +5 -1
  6. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/commands/logs.md +70 -14
  7. cometapi_cli-0.3.1/docs/commands/model.md +63 -0
  8. cometapi_cli-0.3.1/docs/commands/models.md +86 -0
  9. cometapi_cli-0.3.1/docs/commands/run.md +73 -0
  10. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/configuration.md +9 -9
  11. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/installation.md +1 -1
  12. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/pyproject.toml +3 -6
  13. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/__init__.py +1 -1
  14. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/app.py +4 -0
  15. cometapi_cli-0.3.1/src/cometapi_cli/catalog.py +141 -0
  16. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/commands/account.py +4 -1
  17. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/commands/chat.py +12 -3
  18. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/commands/config_cmd.py +14 -3
  19. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/commands/doctor.py +4 -1
  20. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/commands/logs.py +117 -54
  21. cometapi_cli-0.3.1/src/cometapi_cli/commands/model.py +70 -0
  22. cometapi_cli-0.3.1/src/cometapi_cli/commands/models.py +255 -0
  23. cometapi_cli-0.3.1/src/cometapi_cli/commands/run.py +210 -0
  24. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/commands/stats.py +4 -1
  25. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/commands/tasks.py +12 -2
  26. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/commands/tokens.py +4 -1
  27. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/constants.py +7 -0
  28. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/formatters.py +1 -1
  29. cometapi_cli-0.3.1/src/cometapi_cli/urls.py +20 -0
  30. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/tests/conftest.py +5 -2
  31. cometapi_cli-0.3.1/tests/test_catalog.py +48 -0
  32. cometapi_cli-0.3.1/tests/test_help.py +118 -0
  33. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/tests/test_logs.py +15 -5
  34. cometapi_cli-0.3.1/tests/test_model_info.py +39 -0
  35. cometapi_cli-0.3.1/tests/test_models.py +138 -0
  36. cometapi_cli-0.3.1/tests/test_run.py +87 -0
  37. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/uv.lock +1 -1
  38. cometapi_cli-0.2.2/PKG-INFO +0 -246
  39. cometapi_cli-0.2.2/README.md +0 -208
  40. cometapi_cli-0.2.2/docs/commands/models.md +0 -59
  41. cometapi_cli-0.2.2/src/cometapi_cli/commands/models.py +0 -95
  42. cometapi_cli-0.2.2/tests/test_help.py +0 -65
  43. cometapi_cli-0.2.2/tests/test_models.py +0 -57
  44. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  45. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  46. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  47. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/.github/workflows/ci.yml +0 -0
  48. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/.github/workflows/publish.yml +0 -0
  49. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/.gitignore +0 -0
  50. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/CODE_OF_CONDUCT.md +0 -0
  51. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/CONTRIBUTING.md +0 -0
  52. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/LICENSE +0 -0
  53. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/SECURITY.md +0 -0
  54. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/SKILL.md +0 -0
  55. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/authentication.md +0 -0
  56. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/commands/account.md +0 -0
  57. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/commands/balance.md +0 -0
  58. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/commands/chat.md +0 -0
  59. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/commands/config.md +0 -0
  60. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/commands/doctor.md +0 -0
  61. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/commands/init.md +0 -0
  62. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/commands/repl.md +0 -0
  63. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/commands/stats.md +0 -0
  64. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/commands/tasks.md +0 -0
  65. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/commands/tokens.md +0 -0
  66. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/errors.md +0 -0
  67. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/docs/output-formats.md +0 -0
  68. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/skills/live-test/SKILL.md +0 -0
  69. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/client.py +0 -0
  70. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/commands/__init__.py +0 -0
  71. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/commands/balance.py +0 -0
  72. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/commands/chat_repl.py +0 -0
  73. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/commands/repl.py +0 -0
  74. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/config.py +0 -0
  75. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/console.py +0 -0
  76. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/errors.py +0 -0
  77. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/src/cometapi_cli/main.py +0 -0
  78. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/tests/__init__.py +0 -0
  79. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/tests/test_account.py +0 -0
  80. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/tests/test_balance.py +0 -0
  81. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/tests/test_chat.py +0 -0
  82. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/tests/test_config.py +0 -0
  83. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/tests/test_doctor.py +0 -0
  84. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/tests/test_errors.py +0 -0
  85. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/tests/test_formatters.py +0 -0
  86. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/tests/test_stats.py +0 -0
  87. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/tests/test_tasks.py +0 -0
  88. {cometapi_cli-0.2.2 → cometapi_cli-0.3.1}/tests/test_tokens.py +0 -0
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## Overview
6
6
 
7
- The CLI is a Typer + Rich command-line tool that proxies all business logic through `cometapi-python`. It must **never** make direct HTTP requests all network calls go through `CometClient` from the Python SDK.
7
+ The CLI is a Typer + Rich command-line tool with a self-contained `CometClient`. OpenAI-compatible commands should use `CometClient` where practical. Public catalog access and multi-protocol `run` requests may use standard-library HTTP because they call CometAPI-specific catalog endpoints or non-OpenAI wire formats.
8
8
 
9
9
  ## Project Layout
10
10
 
@@ -22,14 +22,18 @@ cometapi-cli/
22
22
  │ ├── main.py # Backward compat shim → app.py
23
23
  │ ├── config.py # Config file (~/.config/cometapi/config.toml), get_client()
24
24
  │ ├── constants.py # Shared constants (QUOTA_PER_UNIT, helpers)
25
+ │ ├── catalog.py # Public model catalog fetch/cache/detail helpers
25
26
  │ ├── console.py # Shared Rich Console instances
26
27
  │ ├── errors.py # CometCLIError hierarchy, exit codes, handle_errors decorator
27
28
  │ ├── formatters.py # Multi-format output (table/json/yaml/csv/markdown)
29
+ │ ├── urls.py # Base URL normalization helpers
28
30
  │ └── commands/
29
31
  │ ├── __init__.py
30
32
  │ ├── chat.py # chat send (streaming + JSON), REPL entry
31
33
  │ ├── chat_repl.py # Multi-turn chat REPL with prompt_toolkit
32
- │ ├── models.py # models list with search/limit
34
+ │ ├── models.py # models list with catalog metadata, filters, cache, source selection
35
+ │ ├── model.py # model info command group
36
+ │ ├── run.py # unified request runner for chat/responses/anthropic/gemini
33
37
  │ ├── balance.py # account balance
34
38
  │ ├── account.py # user profile (access_token)
35
39
  │ ├── stats.py # usage statistics (access_token)
@@ -49,6 +53,9 @@ cometapi-cli/
49
53
  ├── test_errors.py # Error types and exit codes
50
54
  ├── test_formatters.py # Multi-format output tests
51
55
  ├── test_models.py # Models command tests
56
+ ├── test_catalog.py # Catalog cache/detail tests
57
+ ├── test_model_info.py # Model info command tests
58
+ ├── test_run.py # Unified runner tests
52
59
  ├── test_balance.py # Balance command tests (incl. --source)
53
60
  ├── test_account.py # Account command tests
54
61
  ├── test_stats.py # Stats command tests
@@ -60,7 +67,14 @@ cometapi-cli/
60
67
  ## Key Design Decisions
61
68
 
62
69
  - **Self-contained client.** `cometapi_cli/client.py` contains `CometClient` (inherits `openai.OpenAI`). The CLI has **no dependency** on the `cometapi` Python SDK package.
63
- - **No direct HTTP for OpenAI-compatible endpoints.** Always use inherited methods via `CometClient`. Only CometAPI-specific endpoints use `self._client.request()` directly.
70
+ - **Prefer `CometClient` for OpenAI-compatible commands.** Use inherited methods via `CometClient` for normal SDK-shaped flows. Standard-library HTTP is acceptable for public catalog endpoints and `run` endpoint formats that intentionally bypass the OpenAI SDK surface.
71
+
72
+ ## Documentation Policy
73
+
74
+ - **README is the PyPI homepage.** User-facing CLI features must be understandable from `README.md` without access to the private repository.
75
+ - **Every user-visible CLI change must update docs in the same change.** New commands, renamed commands, new options, changed defaults, output-shape changes, or behavior changes must update `README.md`, the relevant file under `docs/`, and the public docs site pages under `docs-cometapi/libraries/cli/`.
76
+ - **Help output is the command contract.** For option or argument changes, run `uv run cometapi -h` and the affected `uv run cometapi <command> -h` commands, then align README and docs with the generated help.
77
+ - **Public links must stay public.** Do not add PyPI metadata or README links that require access to the private GitHub repository. Use PyPI and the public docs site for user-facing navigation.
64
78
 
65
79
  ## Model ID Policy
66
80
 
@@ -184,14 +198,68 @@ These options apply to **every** command via the root Typer callback.
184
198
 
185
199
  | Parameter | Alias | Type | Default | Description |
186
200
  |-----------|-------|------|---------|-------------|
187
- | `--search` | `-s` | `str` | `None` | Filter models by name (case-insensitive substring match) |
201
+ | `--search` | `-s` | `str` | `None` | Filter models by ID, code, name, description, or provider |
202
+ | `--provider` | — | `str` | `None` | Filter by provider code or name |
203
+ | `--type` | `--modality` | `str` | `None` | Filter by model type or modality |
204
+ | `--feature` | `--capability` | `str` | `None` | Filter by feature or capability |
205
+ | `--endpoint` | — | `str` | `None` | Filter by endpoint name, method, or path |
188
206
  | `--limit` | `-l` | `int` | `None` (show all) | Maximum number of models to display |
207
+ | `--source` | — | `catalog\|openai` | `catalog` | Source: public catalog metadata or OpenAI-compatible `/v1/models` |
208
+ | `--refresh` | — | flag | `false` | Refresh the public catalog cache |
209
+ | `--no-cache` | — | flag | `false` | Bypass the public catalog cache |
189
210
  | `--format` | `-f` | `OutputFormat` | inherits global | Per-command output format override |
190
211
  | `--json` | — | flag | `false` | Output as JSON |
191
212
 
192
- **Behavior:** Fetches all models via `client.models.list()`, applies `--search`, sorts model IDs in descending natural/version-aware order so newer variants surface first, then applies `--limit`.
213
+ **Behavior:**
214
+ - Default source calls public `GET /api/models` and caches results for one hour at `~/.cache/cometapi/models.json`.
215
+ - Catalog source supports `--provider`, `--type/--modality`, `--feature/--capability`, `--endpoint`, `--search`, `--limit`, `--refresh`, and `--no-cache`.
216
+ - `--source openai` calls `client.models.list()` for `/v1/models` compatibility and supports `--search` plus `--limit`.
217
+
218
+ **Catalog output fields:** `id`, `provider`, `model_type`, `features`, `endpoints`, `pricing`, `context_length`, `max_completion_tokens`.
219
+
220
+ ---
221
+
222
+ ### `model info` — Show one model's public metadata
223
+
224
+ **Auth:** `COMETAPI_KEY`
225
+
226
+ | Parameter | Alias | Type | Default | Description |
227
+ |-----------|-------|------|---------|-------------|
228
+ | `MODEL_ID` | — | argument | required | Model ID to inspect |
229
+ | `--refresh` | — | flag | `false` | Refresh the public catalog cache before lookup |
230
+ | `--no-cache` | — | flag | `false` | Bypass the public catalog cache |
231
+ | `--format` | `-f` | `OutputFormat` | inherits global | Per-command output format override |
232
+ | `--json` | — | flag | `false` | Output raw detail JSON |
233
+
234
+ **Behavior:** Resolves `MODEL_ID` against the public catalog, uses the catalog `code` to request `GET /api/model/{code}`, then displays detail metadata. Supports slash-style and dotted model IDs.
235
+
236
+ **Table fields:** `id`, `code`, `provider`, `model_type`, `features`, `endpoints`, `pricing`, `context_length`, `max_completion_tokens`, `api_doc_url`, `overview`.
237
+
238
+ ---
239
+
240
+ ### `run` — Send one request through a selected endpoint format
241
+
242
+ **Auth:** `COMETAPI_KEY`
243
+
244
+ | Parameter | Alias | Type | Default | Description |
245
+ |-----------|-------|------|---------|-------------|
246
+ | `MODEL` | — | argument, optional | `body.model` or config default | Model ID; overrides `body.model` |
247
+ | `--endpoint` | `-e` | `chat\|responses\|anthropic\|gemini` | `chat` | Endpoint format |
248
+ | `--input-file` | — | path | `None` | JSON object request body |
249
+ | `--input` | `-i` | `key=value` | repeatable | Merge inline request fields into the body |
250
+ | `--prompt` | `-p` | `str` | `None` | Prompt shortcut |
251
+ | `--json` | — | flag | `false` | Output raw JSON response |
252
+
253
+ **Endpoint mapping:**
254
+
255
+ | Endpoint | Method and path | Auth header |
256
+ |----------|-----------------|-------------|
257
+ | `chat` | `POST /v1/chat/completions` | `Authorization: Bearer $COMETAPI_KEY` |
258
+ | `responses` | `POST /v1/responses` | `Authorization: Bearer $COMETAPI_KEY` |
259
+ | `anthropic` | `POST /v1/messages` | `x-api-key: $COMETAPI_KEY`, plus `anthropic-version: 2023-06-01` |
260
+ | `gemini` | `POST /v1beta/models/{model}:generateContent` | `x-goog-api-key: $COMETAPI_KEY` |
193
261
 
194
- **Table columns:** `id` (cyan).
262
+ **Body merge order:** `--input-file` JSON object → repeated `-i key=value` values → `-p/--prompt` shortcut → positional `MODEL` override. Inline values parse JSON when possible and dotted keys create nested objects.
195
263
 
196
264
  ---
197
265
 
@@ -460,11 +528,11 @@ When `cometapi chat` is started without a message, these slash commands are avai
460
528
  ## Build & Test
461
529
 
462
530
  ```bash
463
- uv sync # Install deps (links local cometapi-python)
531
+ uv sync # Install dependencies
464
532
  uv run cometapi --version # Verify CLI version
465
533
  uv run cometapi -h # List all commands
466
534
  uv run cometapi doctor # Check configuration health
467
- uv run pytest -v # Run tests (98 tests)
535
+ uv run pytest -v # Run tests
468
536
  uv run ruff check src/ tests/ # Lint
469
537
  ```
470
538
 
@@ -489,7 +557,7 @@ uv run ruff check src/ tests/ # Lint
489
557
 
490
558
  ## Dependencies
491
559
 
492
- - `cometapi` — CometAPI Python SDK (local editable in dev)
560
+ - `openai>=1.0.0` — OpenAI-compatible client base
493
561
  - `typer>=0.12` — CLI framework
494
562
  - `rich>=13.0` — Terminal UI
495
563
  - `tomli>=2.0` — TOML reading (Python 3.10 only; 3.11+ uses stdlib `tomllib`)
@@ -5,6 +5,35 @@ 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.3.1] — 2026-05-29
9
+
10
+ ### Fixed
11
+
12
+ - `logs` now emits a consistent field set across all output formats. Previously `--json` dumped the raw API response (no computed `cost`, `other` left as a stringified blob, internal junk fields), while `table`/`yaml`/`markdown` showed a curated card.
13
+ - `logs --request-id` detail duration now reflects true end-to-end latency (`other.total_ms`) instead of the coarse `use_time` seconds value.
14
+ - `logs --request-id` cost now shows 6 decimal places (e.g. `$0.000384`) so sub-cent calls are no longer rounded to `$0.0004`.
15
+
16
+ ### Changed
17
+
18
+ - `logs` JSON/YAML output is now a canonical, typed record (raw numbers, booleans, ISO 8601 time, computed `cost_usd`, exploded `other` fields, normalized `model_price`) with a stable schema; `table`/`markdown` render the same fields as formatted strings.
19
+
20
+ ## [0.3.0] — 2026-05-26
21
+
22
+ ### Added
23
+
24
+ - `models` now reads the public model catalog by default, with OpenAI-compatible `/v1/models` kept as `--source openai`.
25
+ - `models` includes provider, type, features, endpoints, pricing, context length, and completion token metadata when catalog data is available.
26
+ - `models` supports catalog filtering by provider, modality/type, feature/capability, endpoint, text search, limit, cache refresh, and cache bypass.
27
+ - `model info <id>` shows detailed catalog metadata for a model and supports raw JSON output.
28
+ - `run` provides a unified execution entrypoint for chat completions, responses, Anthropic messages, and Gemini generateContent.
29
+ - `run` supports JSON input files, repeated `-i key=value` body overrides, prompt shortcuts, and raw JSON response output.
30
+
31
+ ### Changed
32
+
33
+ - README and command docs now position PyPI as the public package homepage and document the enhanced model catalog and unified run workflow.
34
+ - Package metadata now points to the PyPI homepage and public CLI documentation instead of private GitHub links.
35
+ - Agent instructions now require user-visible CLI changes to update README, local docs, and public docs together.
36
+
8
37
  ## [0.2.2] — 2026-04-14
9
38
 
10
39
  ### Changed
@@ -0,0 +1,311 @@
1
+ Metadata-Version: 2.4
2
+ Name: cometapi-cli
3
+ Version: 0.3.1
4
+ Summary: CometAPI CLI — official command-line interface for the CometAPI AI gateway
5
+ Project-URL: Homepage, https://pypi.org/project/cometapi-cli/
6
+ Project-URL: Documentation, https://apidoc.cometapi.com/libraries/cli/overview
7
+ Author-email: CometAPI <support@cometapi.com>
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Keywords: ai,api-gateway,chat,cli,cometapi,llm,openai,streaming
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Internet
21
+ Classifier: Topic :: Software Development :: Libraries
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: openai>=1.0.0
25
+ Requires-Dist: prompt-toolkit>=3.0
26
+ Requires-Dist: pyyaml>=6.0
27
+ Requires-Dist: rich>=13.0
28
+ Requires-Dist: tomli-w>=1.0
29
+ Requires-Dist: tomli>=2.0; python_version < '3.11'
30
+ Requires-Dist: typer>=0.12
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest>=8.0; extra == 'dev'
33
+ Requires-Dist: ruff>=0.8; extra == 'dev'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # CometAPI CLI
37
+
38
+ [![PyPI](https://img.shields.io/pypi/v/cometapi-cli)](https://pypi.org/project/cometapi-cli/)
39
+ [![Python](https://img.shields.io/pypi/pyversions/cometapi-cli)](https://pypi.org/project/cometapi-cli/)
40
+
41
+ Official command-line interface for [CometAPI](https://www.cometapi.com/?utm_source=cometapi-cli&utm_medium=readme&utm_campaign=pypi&utm_content=homepage), a multi-model AI gateway for GPT, Claude, Gemini, image, audio, and video models.
42
+
43
+ The [PyPI package page](https://pypi.org/project/cometapi-cli/) is the public homepage for installation and release metadata. The public documentation is available at [CometAPI CLI docs](https://apidoc.cometapi.com/libraries/cli/overview).
44
+
45
+ ## Features
46
+
47
+ - Chat with CometAPI models from the terminal, with streaming and an interactive REPL
48
+ - Browse the public model catalog with provider, modality, endpoint, capability, context, and pricing metadata
49
+ - Inspect one model with `cometapi model info <id>`
50
+ - Send one request through OpenAI Chat Completions, OpenAI Responses, Anthropic Messages, or Gemini Generate Content with `cometapi run`
51
+ - Check balance, account data, usage stats, API keys, logs, and async task history
52
+ - Output tables, JSON, YAML, CSV, or Markdown for terminal use and automation
53
+ - Store local configuration in `~/.config/cometapi/config.toml`
54
+
55
+ ## Installation
56
+
57
+ The CLI requires Python 3.10 or later.
58
+
59
+ ```bash
60
+ pip install cometapi-cli
61
+ ```
62
+
63
+ You can also install it in an isolated tool environment:
64
+
65
+ ```bash
66
+ pipx install cometapi-cli
67
+ uv tool install cometapi-cli
68
+ ```
69
+
70
+ Create an API key in the [CometAPI console](https://www.cometapi.com/console/token?utm_source=cometapi-cli&utm_medium=readme&utm_campaign=pypi&utm_content=api-key). Account-management commands can also use an optional [access token](https://www.cometapi.com/console/personal?utm_source=cometapi-cli&utm_medium=readme&utm_campaign=pypi&utm_content=access-token).
71
+
72
+ ## Quick start
73
+
74
+ Run the setup wizard:
75
+
76
+ ```bash
77
+ cometapi init
78
+ ```
79
+
80
+ Or configure credentials with environment variables:
81
+
82
+ ```bash
83
+ export COMETAPI_KEY="your-api-key"
84
+ export COMETAPI_ACCESS_TOKEN="your-access-token" # optional, for account/log/task commands
85
+ ```
86
+
87
+ Verify the installation and available commands:
88
+
89
+ ```bash
90
+ cometapi --version
91
+ cometapi -h
92
+ cometapi doctor
93
+ ```
94
+
95
+ Send a chat message:
96
+
97
+ ```bash
98
+ cometapi chat "Explain quantum computing in one sentence"
99
+ ```
100
+
101
+ Search the model catalog:
102
+
103
+ ```bash
104
+ cometapi models --search gpt --limit 10
105
+ ```
106
+
107
+ Inspect one model:
108
+
109
+ ```bash
110
+ cometapi model info your-model-id
111
+ ```
112
+
113
+ Run a one-off request through the default chat endpoint:
114
+
115
+ ```bash
116
+ cometapi run your-model-id -p "Reply with OK only."
117
+ ```
118
+
119
+ ## Command reference
120
+
121
+ Use `-h` on the root command or any subcommand to see the exact options for the installed version:
122
+
123
+ ```bash
124
+ cometapi -h
125
+ cometapi models -h
126
+ cometapi model info -h
127
+ cometapi run -h
128
+ ```
129
+
130
+ | Command | Description | Credential |
131
+ |---------|-------------|------------|
132
+ | `chat [MESSAGE]` | Send a chat message or start the chat REPL | API key |
133
+ | `models` | List and filter public model catalog metadata | API key |
134
+ | `model info <id>` | Show provider, endpoint, capability, context, pricing, and docs metadata for one model | API key |
135
+ | `run [MODEL]` | Send one request through chat, responses, anthropic, or gemini endpoint formats | API key |
136
+ | `balance` | Show account or current API key balance | API key or access token |
137
+ | `account` | Show account profile | Access token |
138
+ | `stats` | Show usage statistics | Access token |
139
+ | `tokens` | List and search API keys | Access token |
140
+ | `logs` | Browse usage logs and export CSV | Access token |
141
+ | `tasks` | Browse async task logs | Access token |
142
+ | `init` | Run the interactive setup wizard | None |
143
+ | `doctor` | Check configuration and connectivity | API key |
144
+ | `repl` | Start an interactive command shell | Depends on command used |
145
+ | `config` | Show, set, unset, or locate local configuration | None |
146
+
147
+ ## Models
148
+
149
+ `cometapi models` uses the public model catalog by default and displays richer metadata than `/v1/models`.
150
+
151
+ ```bash
152
+ # Search by keyword
153
+ cometapi models --search gpt --limit 10
154
+
155
+ # Filter by provider, modality, capability, or endpoint
156
+ cometapi models --provider openai --type chat --limit 10
157
+ cometapi models --feature image --endpoint responses --json
158
+
159
+ # Refresh the one-hour local cache
160
+ cometapi models --refresh
161
+
162
+ # Use the OpenAI-compatible /v1/models source
163
+ cometapi models --source openai --search gpt
164
+ ```
165
+
166
+ Catalog rows include:
167
+
168
+ - `id`
169
+ - `provider`
170
+ - `model_type`
171
+ - `features`
172
+ - `endpoints`
173
+ - `pricing`
174
+ - `context_length`
175
+ - `max_completion_tokens`
176
+
177
+ The catalog cache is stored at `~/.cache/cometapi/models.json`. Use `--refresh` to replace stale cache data or `--no-cache` to bypass the cache for one command.
178
+
179
+ ## Model info
180
+
181
+ Use `cometapi model info <id>` when you need the detail page metadata for one model.
182
+
183
+ ```bash
184
+ # Human-readable table
185
+ cometapi model info your-model-id
186
+
187
+ # Raw model detail JSON
188
+ cometapi model info your-model-id --json
189
+
190
+ # Refresh catalog metadata before resolving the model
191
+ cometapi model info your-model-id --refresh
192
+ ```
193
+
194
+ The command resolves the public catalog entry first, then loads detail metadata from the model detail API. It supports slash-style model IDs and dotted IDs.
195
+
196
+ ## Run
197
+
198
+ `cometapi run` is a unified request entrypoint for CometAPI's multi-protocol gateway. It accepts an optional positional model, a JSON request body, repeated inline inputs, and a prompt shortcut.
199
+
200
+ ```bash
201
+ # OpenAI Chat Completions format (default)
202
+ cometapi run your-model-id -p "Write one sentence about CometAPI."
203
+
204
+ # OpenAI Responses format
205
+ cometapi run your-model-id --endpoint responses -p "Reply with OK only." -i max_output_tokens=32 --json
206
+
207
+ # Anthropic Messages format
208
+ cometapi run your-model-id --endpoint anthropic -p "Reply with OK only." -i max_tokens=32
209
+
210
+ # Gemini Generate Content format
211
+ cometapi run your-model-id --endpoint gemini -p "Reply with OK only." -i generationConfig.maxOutputTokens=32
212
+ ```
213
+
214
+ Build a request from a JSON file and override fields inline:
215
+
216
+ ```bash
217
+ cometapi run your-model-id \
218
+ --endpoint responses \
219
+ --input-file body.json \
220
+ -i temperature=0.2 \
221
+ -i metadata.source='"cli"' \
222
+ --json
223
+ ```
224
+
225
+ Input precedence is:
226
+
227
+ 1. `--input-file` JSON object
228
+ 2. Repeated `-i key=value` values
229
+ 3. `-p/--prompt` convenience body
230
+ 4. Positional `MODEL`, which overrides `body.model`
231
+
232
+ `-i key=value` parses JSON values when possible, so numbers, booleans, `null`, objects, and arrays can be passed without string coercion. Dotted keys create nested JSON objects.
233
+
234
+ ## Output formats
235
+
236
+ Most data commands support `--json` or `--format`:
237
+
238
+ ```bash
239
+ cometapi models --json
240
+ cometapi models --format yaml
241
+ cometapi stats --format csv
242
+ cometapi account --format markdown
243
+ ```
244
+
245
+ Set a persistent default format:
246
+
247
+ ```bash
248
+ cometapi config set output_format json
249
+ ```
250
+
251
+ ## Configuration
252
+
253
+ Config file: `~/.config/cometapi/config.toml`
254
+
255
+ ```bash
256
+ cometapi config show
257
+ cometapi config set api_key "$COMETAPI_KEY"
258
+ cometapi config set default_model your-model-id
259
+ cometapi config unset api_key
260
+ cometapi config path
261
+ ```
262
+
263
+ | Key | Env variable | Description |
264
+ |-----|--------------|-------------|
265
+ | `api_key` | `COMETAPI_KEY` | API key for model and balance commands |
266
+ | `access_token` | `COMETAPI_ACCESS_TOKEN` | Access token for account, stats, token, log, and task commands |
267
+ | `base_url` | `COMETAPI_BASE_URL` | API base URL |
268
+ | `default_model` | `COMETAPI_DEFAULT_MODEL` | Default model for `chat` and `run` |
269
+ | `output_format` | - | Default output format |
270
+
271
+ Configuration priority: CLI flags > config file > environment variables > defaults.
272
+
273
+ ## Chat REPL
274
+
275
+ Run `cometapi chat` without a message to start a multi-turn chat session.
276
+
277
+ ```bash
278
+ cometapi chat
279
+ ```
280
+
281
+ Available slash commands:
282
+
283
+ | Command | Description |
284
+ |---------|-------------|
285
+ | `/model <name>` | Switch model mid-conversation |
286
+ | `/system <prompt>` | Set the system prompt |
287
+ | `/clear` | Clear conversation history |
288
+ | `/history` | Show conversation history |
289
+ | `/save <file.json|file.md>` | Save the session |
290
+ | `/tokens` | Show approximate token count |
291
+ | `/help` | Show REPL help |
292
+ | `/exit` | Exit the REPL |
293
+
294
+ ## Security
295
+
296
+ - API keys and access tokens are never displayed in full by CLI diagnostics.
297
+ - Config files are stored with restrictive permissions (`0600`).
298
+ - Keep credentials out of source control and shell history.
299
+ - You are responsible for usage and charges incurred with your API keys.
300
+
301
+ ## Troubleshooting
302
+
303
+ | Error | Fix |
304
+ |-------|-----|
305
+ | `API key not configured` | Run `cometapi init` or set `COMETAPI_KEY` |
306
+ | `Connection failed` | Run `cometapi doctor` |
307
+ | `Access token not configured` | Set `COMETAPI_ACCESS_TOKEN` only when using account, stats, tokens, logs, or tasks |
308
+
309
+ ## License
310
+
311
+ MIT