Metadata-Version: 2.4
Name: otari-cli
Version: 0.1.0
Summary: Command-line interface for the otari LLM gateway and platform
Project-URL: Homepage, https://github.com/mozilla-ai/otari-cli
Project-URL: Documentation, https://mozilla-ai.github.io/otari/
Project-URL: Repository, https://github.com/mozilla-ai/otari-cli
Project-URL: Issues, https://github.com/mozilla-ai/otari-cli/issues
Author-email: Mozilla AI <ai-engineering@mozilla.com>
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: httpx>=0.25.0
Requires-Dist: otari>=0.1.0
Requires-Dist: rich>=13.0
Requires-Dist: typer>=0.12
Provides-Extra: dev
Requires-Dist: mypy>=1.13; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.8; extra == 'dev'
Description-Content-Type: text/markdown

<div align="center">

# otari-cli

![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue)
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
[![CI](https://github.com/mozilla-ai/otari-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/mozilla-ai/otari-cli/actions/workflows/ci.yml)

**Command-line interface for [otari](https://github.com/mozilla-ai/otari), the OpenAI-compatible LLM gateway you own and run yourself.**

[otari gateway](https://github.com/mozilla-ai/otari) | [Python SDK](https://github.com/mozilla-ai/otari-sdk-python) | [Documentation](https://mozilla-ai.github.io/otari/)

</div>

> otari-cli is a thin command-line wrapper over the [`otari`](https://pypi.org/project/otari/) Python client SDK. It talks to a self-hosted otari gateway or the hosted platform at [otari.ai](https://otari.ai).

## Installation

### Requirements

- Python 3.11 or newer

### Install

```bash
pip install otari-cli
```

This installs the `otari` console command.

## Authentication

otari-cli reads the same environment variables as the otari SDK, so it works in
two modes. Flags always override the environment.

| Variable | Mode | Purpose |
| --- | --- | --- |
| `OTARI_AI_TOKEN` | Platform | Bearer token; base URL defaults to `https://api.otari.ai`. |
| `GATEWAY_API_BASE` | Self-hosted | Gateway base URL (required for self-hosted). |
| `GATEWAY_API_KEY` | Self-hosted | Virtual API key (sent via the `Otari-Key` header). |
| `GATEWAY_ADMIN_KEY` | Either | Admin key for control-plane commands (`keys`, `usage`). |

Equivalent flags: `--token`, `--api-base`, `--api-key`, `--admin-key`.

## Usage

```bash
# Show help and the available commands
otari --help

# Check that the configured gateway is reachable
otari --api-base http://localhost:8000 health

# List the models the gateway can route to
otari models

# Create a chat completion
otari completion -m openai:gpt-4o-mini "Write a haiku about gateways."

# Stream the response token by token
otari completion -m openai:gpt-4o-mini --stream "Tell me a short story."

# Emit machine-readable JSON instead of formatted output
otari --json models
```

### Generation commands

```bash
otari completion -m openai:gpt-4o-mini "Hello"        # chat completions (+ --stream)
otari message -m anthropic:claude-3-5-sonnet "Hello"  # Anthropic-style messages (+ --stream)
otari response -m openai:gpt-4o-mini "Hello"          # Responses API (+ --stream)
otari embedding -m openai:text-embedding-3-small "a sentence"
otari moderation -m openai:omni-moderation-latest "some text"
otari rerank -m cohere:rerank-v3.5 -q "query" "doc one" "doc two"
otari models
otari batches create -m openai:gpt-4o-mini --input requests.jsonl
otari batches list --provider openai
otari batches results <batch-id> --provider openai
```

The `--json` and `--stream` flags compose: with both set, streaming commands emit
one JSON event object per chunk (newline-delimited) rather than a single document.

### Control-plane commands (self-hosted / admin)

These require an admin credential and a self-hosted gateway:

```bash
# Keys
otari keys list
otari keys create --name prod --user u_123 --metadata '{"team": "ml"}'
otari keys update <key-id> --inactive
otari keys delete <key-id>

# Users, budgets, pricing
otari users create u_123 --alias "ML team" --budget b_1
otari budgets create --max-budget 100 --duration-sec 86400
otari pricing set openai:gpt-4o-mini --input-price 0.15 --output-price 0.60

# Usage
otari usage list --user u_123 --start 2026-01-01 --end 2026-01-31
otari users usage u_123
```

## Development

otari-cli uses [`uv`](https://docs.astral.sh/uv/).

```bash
uv sync --extra dev      # install with dev dependencies
uv run otari --help      # run the CLI from source
uv run ruff check .      # lint
uv run mypy src/         # type check (strict)
uv run pytest            # tests
```

See [CONTRIBUTING.md](CONTRIBUTING.md) and [AGENTS.md](AGENTS.md) for the full
workflow and conventions.

## Commands

| Group | Commands |
| --- | --- |
| Generation | `completion`, `message`, `response` (each with `--stream`), `embedding`, `moderation`, `rerank`, `models` |
| Batches | `batches create`, `batches retrieve`, `batches list`, `batches cancel`, `batches results` |
| Control plane | `keys`, `users`, `budgets`, `pricing` (CRUD), `usage list`, `users usage` |
| Diagnostics | `health` |

Run `otari <command> --help` for the full options of any command.

## License

otari-cli is licensed under the Apache License 2.0. See the [LICENSE](LICENSE)
file for details.
