# Model service

Completions and embeddings from the models set for this project, the names it can use, and its usage.

Scopes for this area: `models:read`, `models:write` and `models:admin`.

4 operations.

## completion

| Method | Route | What it does | Level | Command |
| --- | --- | --- | --- | --- |
| POST | `/models/v1/chat/completions` | Ask a model through one of the project's routes. The body and the answer follow the OpenAI chat completions format; `model` is a route name from the model list, never a model's own name. With `stream: true` the answer arrives as server-sent events. Uses the project's token allowance. | write | `rivier models completion create` |

## embedding

| Method | Route | What it does | Level | Command |
| --- | --- | --- | --- | --- |
| POST | `/models/v1/embeddings` | Embeddings for one text or a list, in the OpenAI embeddings format. `model` is an embeddings route name from the model list. Say `input_type: "query"` for a search query; texts to be searched are the default. | write | `rivier models embedding create` |

## model

| Method | Route | What it does | Level | Command |
| --- | --- | --- | --- | --- |
| GET | `/models/v1/models` | The route names this project can call, and whether each answers completions or embeddings. Which model stands behind a name is set by Rivier and can change without notice; the name stays. | read | `rivier models model list` |

## usage

| Method | Route | What it does | Level | Command |
| --- | --- | --- | --- | --- |
| GET | `/models/v1/usage` | What the project has used of the model service: its token allowances this period, and how far it is into its spending limits for today and this month, as a share. | read | `rivier models usage get` |
