> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baseten.co/llms.txt
> Use this file to discover all available pages before exploring further.

# baseten model-api

> Manage Model APIs

List and inspect Baseten Model APIs.

Authenticate with `baseten auth login` or the `BASETEN_API_KEY` environment variable.

## describe

```sh theme={"system"}
baseten model-api describe [OPTIONS]
```

Describe a single Model API by name.

### Options

**-q, --jq** `TEXT`

Filter JSON output with a jq expression; implies `--output` json (or jsonl for streamed commands)

**--model** `TEXT` *required*

Name of the Model API to describe.

**-o, --output** `TEXT` (default: text)

Output format

One of: `text`, `json`, `jsonl`, `none`

**--profile** `TEXT`

Use a specific stored profile for this command, overriding BASETEN\_PROFILE and the current profile

**-v, --verbose** `BOOL`

Enable verbose logging

### Examples

Describe a Model API by name

```sh theme={"system"}
baseten model-api describe --model <name>
```

### Filter output with `--jq`

Print the Model API's invoke URL

```sh theme={"system"}
baseten model-api describe --model <name> --jq '.invoke_url'
```

### Output

**Text mode (`--output text`):** Field-per-line summary of the Model API.

**JSON mode (`--output json`):** payload type `managementapi.ModelAPI`.

## list

```sh theme={"system"}
baseten model-api list [OPTIONS]
```

List the Model APIs in the full visible catalog.

Pass `--added-only` to restrict to just the Model APIs the workspace has added.

> [!NOTE]
>
> CLI v0.3.0 removed `--all` and changed the default: `baseten model-api list` now returns the full catalog instead of just added Model APIs. Scripts that relied on the old default should pass `--added-only`.

### Options

**--added-only** `BOOL`

Restrict to the Model APIs the workspace has added instead of the full visible catalog.

**-q, --jq** `TEXT`

Filter JSON output with a jq expression; implies `--output` json (or jsonl for streamed commands)

**-o, --output** `TEXT` (default: text)

Output format

One of: `text`, `json`, `jsonl`, `none`

**--profile** `TEXT`

Use a specific stored profile for this command, overriding BASETEN\_PROFILE and the current profile

**-v, --verbose** `BOOL`

Enable verbose logging

### Examples

List the full visible catalog of Model APIs

```sh theme={"system"}
baseten model-api list
```

List only the Model APIs the workspace has added

```sh theme={"system"}
baseten model-api list --added-only
```

### Filter output with `--jq`

Print just the Model API names

```sh theme={"system"}
baseten model-api list --jq '.items[].name'
```

### Output

**Text mode (`--output text`):** Table with columns: NAME, CONTEXT, $/1M IN, $/1M OUT, ADDED. When no Model APIs match, prints "No Model APIs found." to stderr.

**JSON mode (`--output json`):** payload type `cmd.ModelAPIList`.

## predict

```sh theme={"system"}
baseten model-api predict [OPTIONS]
```

POST an inference request to a Model API and write the response to stdout.

The request is sent to `--url`, which defaults to the OpenAI chat-completions endpoint on the shared inference host. Override it for other shapes (e.g. /v1/messages, /v1/embeddings) or different hosts.

`--content` is the simple path: it builds an OpenAI chat-completions body with a single user message and `--model` as the model, and prints just the assistant's reply. It is only valid for OpenAI chat URLs and requires `--model`.

`--data` and `--file` send a request body verbatim, so any format the endpoint accepts works (OpenAI, Anthropic, embeddings, custom). The response is written as-is: JSON is pretty-printed, streams and binary bodies are passed through.

Pass `--verbose` to log the request URL, the response status, and the response headers to stderr.

### Options

**--content** `TEXT`

Single user message; builds an OpenAI chat-completions request and prints the assistant's reply. Only valid for OpenAI chat URLs and requires `--model`.

Mutually exclusive with other flags in group `predict-input`.

**--data** `TEXT`

Inline request body, sent verbatim. The accepted shapes are documented at [https://docs.baseten.co/inference/model-apis/overview](https://docs.baseten.co/inference/model-apis/overview.md).

Mutually exclusive with other flags in group `predict-input`.

**--file** `TEXT`

Path to a file containing the request body, sent verbatim. Use '-' for stdin.

Mutually exclusive with other flags in group `predict-input`.

**-q, --jq** `TEXT`

Filter JSON output with a jq expression; implies `--output` json (or jsonl for streamed commands)

**--model** `TEXT`

Name of the Model API. Required with `--content`, where it sets the request's model.

**-o, --output** `TEXT` (default: text)

Output format

One of: `text`, `json`, `jsonl`, `none`

**--profile** `TEXT`

Use a specific stored profile for this command, overriding BASETEN\_PROFILE and the current profile

**--url** `TEXT`

Endpoint to POST the request to. Defaults to [https://inference.baseten.co/v1/chat/completions](https://inference.baseten.co/v1/chat/completions).

**-v, --verbose** `BOOL`

Enable verbose logging

### Examples

Send a single user message

```sh theme={"system"}
baseten model-api predict --model <name> --content "hello"
```

Send a full OpenAI-shaped body and stream it as JSONL

```sh theme={"system"}
baseten model-api predict --model <name> --data '{"model":"<name>","messages":[{"role":"user","content":"hi"}],"stream":true}' --output jsonl
```

### Filter output with `--jq`

Extract the assistant's message content

```sh theme={"system"}
baseten model-api predict --model <name> --content "hi" --jq '.choices[0].message.content'
```

### Output

**Text mode (`--output text`):** With `--content`, the assistant message text. With `--data`/`--file`, the response body as-is (pretty-printed JSON, or a raw stream/binary body).

**JSON mode (`--output json`):** payload type `cmd.JSONUndefined`.

Under `--output json`, `--content` emits the full chat-completions response. For `--data`/`--file`, a streamed response becomes one JSON record per chunk under `--output jsonl`, and a binary body is base64-encoded under a 'body' key.

## usage

```sh theme={"system"}
baseten model-api usage [OPTIONS]
```

Show the workspace's Model APIs token usage as contiguous time buckets, oldest first, broken down by the dimensions passed to `--group-by`.

Buckets with no usage are included, so the series has no gaps. Usage is retained for 92 days; buckets older than that come back empty. Every bucket in the window is fetched, paging as needed, until `--limit` buckets are collected.

Usage is attributed to a user when the request was authenticated with a personal API key or an OAuth credential. Usage from workspace or other non-user-scoped credentials has no user.

For machine-readable streaming, prefer `--output jsonl` over `--output json`.

### Options

**--api-key-prefix** `TEXT (repeatable)`

Only return usage for these API key prefixes. May be repeated.

**--bucket-width** `TEXT` (default: 1d)

Width of each time bucket. Also sets the default window: 7d for 1d, 24h for 1h, 60m for 1m.

One of: `1m`, `1h`, `1d`

**--end** `TEXT`

End of the range, exclusive. ISO 8601, local when no timezone is given. Defaults to now.

**--group-by** `TEXT (repeatable)`

Dimension to break usage down by. May be repeated. One of: api-key, user, model. Defaults to model.

**-q, --jq** `TEXT`

Filter JSON output with a jq expression; implies `--output` json (or jsonl for streamed commands)

**--limit** `INTEGER`

Maximum number of time buckets, paging as needed. Rows per bucket depend on `--group-by`. 0 for no limit.

**--model** `TEXT (repeatable)`

Only return usage for these models. May be repeated.

**-o, --output** `TEXT` (default: text)

Output format

One of: `text`, `json`, `jsonl`, `none`

**--profile** `TEXT`

Use a specific stored profile for this command, overriding BASETEN\_PROFILE and the current profile

**--since** `TEXT`

Window from a relative time ago until now (e.g. '30m', '3d'). Mutually exclusive with `--start` and `--end`.

**--start** `TEXT`

Start of the range, inclusive, snapped down to its bucket start. ISO 8601, local when no timezone is given.

**--user-id** `TEXT (repeatable)`

Only return usage attributed to these user IDs. May be repeated.

**-v, --verbose** `BOOL`

Enable verbose logging

### Examples

Show daily usage per model over the last 7 days

```sh theme={"system"}
baseten model-api usage
```

Show which users drove usage over the last 3 days

```sh theme={"system"}
baseten model-api usage --since 3d --group-by user
```

Break hourly usage down by user and model for one model

```sh theme={"system"}
baseten model-api usage --since 12h --bucket-width 1h --group-by user --group-by model --model <name>
```

### Filter output with `--jq`

Stream each bucket's per-user output tokens as a JSONL stream

```sh theme={"system"}
baseten model-api usage --group-by user --output jsonl --jq '.results[] | {user_id, output_tokens}'
```

### Output

**Text mode (`--output text`):** Table with a time column, one column per `--group-by` dimension, then REQUESTS, INPUT, CACHED, and OUTPUT token counts, followed by an ALL totals row. A bucket with no usage renders as a single "(no usage)" row. When no bucket in the window has any usage, prints "No usage in the selected window." to stderr instead of a table.

**JSON mode (`--output json`):** payload type `managementapi.ModelApisUsageBucket`.

One record per time bucket: its `start_time`, `end_time`, and the per-dimension usage totals in `results`.
