Skip to main content

CometAPI CLI — official command-line interface for the CometAPI AI gateway

Project description

CometAPI CLI

PyPI Python License: MIT

Official command-line interface for CometAPI — 500+ AI Model API, All In One API.

Access 500+ AI models at low cost, directly from the terminal. Chat, search models, check usage, and manage your account — all through a single API key.

Features: multi-model chat (streaming + REPL) · model search · account & usage stats · diagnostics · multi-format output (table/JSON/YAML/CSV/Markdown) · agent-native design · TOML config · shell completion

Installation

pip install cometapi-cli
pipx install cometapi-cli    # isolated environment
uv tool install cometapi-cli  # uv

Prerequisites: Python 3.10+ · CometAPI Key

Quick Start

# 1. Run the setup wizard
cometapi init

# 2. Chat with a model
cometapi chat "Explain quantum computing in one sentence"

# 3. List available models
cometapi models --search gpt --limit 10

Or configure manually:

export COMETAPI_KEY="your-api-key"               # https://www.cometapi.com/console/token?utm_source=cometapi-cli&utm_medium=readme&utm_campaign=oss&utm_content=env-api-key
export COMETAPI_ACCESS_TOKEN="your-access-token"  # https://www.cometapi.com/console/personal?utm_source=cometapi-cli&utm_medium=readme&utm_campaign=oss&utm_content=env-access-token (optional)

Commands

Command Description
chat [MESSAGE] Send a message or start interactive chat REPL (no args)
models List available models (--search, --limit)
balance Show account balance
account Show account profile (requires access token)
stats Show usage statistics (requires access token)
tokens List and search your API keys (requires access token)
logs Show usage logs with filters (requires access token)
tasks Show async task logs (requires access token)
init Interactive setup wizard
doctor Run diagnostics and health checks
repl Start interactive command shell
config Manage CLI configuration (show, set, unset, path)

Chat

cometapi chat "Hello!"                                          # Streaming
cometapi chat "Summarize this" --model claude-sonnet-4-6 --system "Be concise"
cometapi chat "Hello" --json                                    # JSON output
cometapi chat                                                   # Interactive REPL

Chat REPL commands: /model, /system, /clear, /history, /save, /tokens, /help, /exit

Models

cometapi models                        # List all
cometapi models --search claude        # Search by name
cometapi models --limit 5 --json       # JSON output

Logs

cometapi logs                          # Recent usage logs
cometapi logs --model gpt-5.4         # Filter by model
cometapi logs --start 2026-04-01       # Date filter
cometapi logs --export > usage.csv     # CSV export
cometapi logs --limit 50 --json        # JSON output

Tasks

cometapi tasks                         # Recent task logs
cometapi tasks --platform suno         # Filter by platform
cometapi tasks --status SUCCESS        # Filter by status
cometapi tasks --json                  # JSON output

Output Formats

All data commands support --json or --format:

cometapi models --json
cometapi models --format yaml
cometapi stats --format csv
cometapi account --format markdown

Shell Completion

cometapi --install-completion

Configuration

Config file: ~/.config/cometapi/config.toml

cometapi config show              # View current config
cometapi config set api_key sk-…  # Set a value
cometapi config unset api_key     # Remove a value
cometapi config path              # Show config file path

Examples

# Switch default output to JSON (all commands)
cometapi config set output_format json

# Change default model
cometapi config set default_model claude-sonnet-4-6

# Override per-command (regardless of config)
cometapi models --format yaml
cometapi balance --json

Priority: CLI flags > config file > environment variables > defaults

Key Env Variable Description
api_key COMETAPI_KEY API key (required)
access_token COMETAPI_ACCESS_TOKEN Access token for account commands
base_url COMETAPI_BASE_URL API base URL
default_model COMETAPI_DEFAULT_MODEL Default model (fallback: gpt-5.4)
output_format Default output format (table, json, yaml, csv, markdown)

Agent Integration

CometAPI CLI is designed to be agent-friendly:

  • All data commands support --json for structured, machine-readable output
  • Deterministic exit codes (0=success, 64=config missing, 77=auth error, 69=service unavailable)
  • Errors on stderr, data on stdout
  • See SKILL.md for the full agent skill definition

Development

git clone https://github.com/cometapi-dev/cometapi-cli.git
cd cometapi-cli
uv sync --extra dev

uv run pytest -v              # tests
uv run ruff check src/ tests/ # lint
uv run cometapi --version     # verify
Without uv (pip)
git clone https://github.com/cometapi-dev/cometapi-cli.git
cd cometapi-cli
pip install -e ".[dev]"
pytest -v

Security

  • API keys and access tokens are never logged or displayed in full — only the last 4 characters are shown
  • Config files are stored with restrictive permissions (0600)
  • Credentials should never be committed to version control
  • Create credentials at: API Key · Access Token
  • Disclaimer: You are responsible for all usage and charges incurred with your API keys

Troubleshooting

Error Solution
API key not configured Run cometapi init or set COMETAPI_KEY env var
Connection failed Run cometapi doctor to diagnose connectivity
Access token not configured Only needed for account/stats commands — run cometapi init to add one

Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cometapi_cli-0.2.1.tar.gz (105.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cometapi_cli-0.2.1-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file cometapi_cli-0.2.1.tar.gz.

File metadata

  • Download URL: cometapi_cli-0.2.1.tar.gz
  • Upload date:
  • Size: 105.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cometapi_cli-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2d6531dbee0507bf480689c888623098b333205ef7f4aecf4dd356f9f9c9a7ce
MD5 5d669b1255c137483b25695aff772f92
BLAKE2b-256 5d4879fe42dc7b245ad02ac9e0e657765b1e683b6d86582c77f606b3adf2c458

See more details on using hashes here.

Provenance

The following attestation bundles were made for cometapi_cli-0.2.1.tar.gz:

Publisher: publish.yml on cometapi-dev/cometapi-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cometapi_cli-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: cometapi_cli-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 35.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cometapi_cli-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e467e8d8767104a57ae236e47e123a34225ff153553fdd00b72d4a6657e2a12
MD5 b5cf526c08643f8c965e1be17788ab96
BLAKE2b-256 e42c0d71acbd47657d2c542254aff0e0752b13c479c2e305de49986499376f6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cometapi_cli-0.2.1-py3-none-any.whl:

Publisher: publish.yml on cometapi-dev/cometapi-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page