# CLI

> Install the sference CLI and authenticate with an API key.

Source: https://sference.com/docs/cli

The **`sference`** command-line tool is published on PyPI as **`sference-cli`**. It wraps the same inference API as the Python SDK: auth, batches, streams, and responses.

## Install (one line)

macOS and Linux:

```bash
curl -fsSL https://raw.githubusercontent.com/s-ference/sference/main/install.sh | sh
```

That script installs **`sference`** on your PATH (via `uv tool` when available).

## Other install options

```bash
uv tool install sference-cli
```

```bash
pip install sference-cli
# or
pipx install sference-cli
```

Then verify:

```bash
sference --help
```

## Authenticate

Create an API key in the [sference console](https://app.sference.com), then:

```bash
export SFERENCE_API_KEY='sk_...'
sference auth login --api-key "$SFERENCE_API_KEY"
sference auth me --json
```

`SFERENCE_API_KEY` overrides the saved credential file for every subcommand.

## Batch JSONL

Each line in a batch input file becomes one row in `POST /v1/batches`. **All rows must use the same model**: either repeat `body.model` on every OpenAI-style line or set **`--model`** once for content-only lines. The model must be catalog-available; invalid or mixed models return **400** at create.

Inner `body` accepts **chat completions** (`messages`) or **Responses** (`input`). Responses fields are normalized at create; invalid rows return **400** with row index / `custom_id`.

```jsonl
{"custom_id":"a","method":"POST","url":"/v1/chat/completions","body":{"model":"…","messages":[{"role":"user","content":"hi"}]}}
{"custom_id":"b","method":"POST","url":"/v1/responses","body":{"model":"…","input":[{"role":"user","content":"hi"}]}}
{"content":"content-only, pass --model on submit"}
```

Full guide: **[Batch inference](https://sference.com/docs/guides/batches)**. Subcommand reference: **[OSS CLI README](https://github.com/s-ference/sference/blob/main/cli/README.md)**.

## Go deeper

Subcommands, JSONL batch formats, and stream workflows live in the **[sference OSS repository](https://github.com/s-ference/sference)** (`cli/README.md`).

- [Python SDK](https://sference.com/docs/sdk): Library-first path for application code and coding agents.
- [Quickstart](https://sference.com/docs/quickstart): API keys and your first inference request.
