# Endpoints

> Model calls, the catalog, routes, usage, calls, limits, keys, browser tokens and the rest.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://ai.docs.sypnia.com/api/endpoints/

For agents: AI API endpoints: POST /chat/completions, POST /embeddings, POST /moderations, GET /models, GET /models/{id}; GET /tasks; GET /routes, PUT /routes (person), GET /routes/history, POST /routes/rollback; GET /usage?group_by=&since=&until=; GET /calls?case=&status=&since=&cursor=, GET /calls/{id}, GET /calls/{id}/body (admin, audited, only when stored); GET|PUT /limits; GET|POST /keys, DELETE /keys/{id}; POST /browser-tokens; GET|POST /provider-keys, DELETE /provider-keys/{id} (Cloud); GET|POST /origins, DELETE /origins/{id}; POST /cache/purge; DELETE /end-users/{id}; GET /health. OpenAPI at spec/openapi.yaml in the gateway repository.

## Model calls

| Method and path          | Does                                                         |
| ------------------------ | ------------------------------------------------------------ |
| `POST /chat/completions` | A chat call; `stream: true` answers Server-Sent Events       |
| `POST /embeddings`       | Embeddings for up to 256 texts                               |
| `POST /moderations`      | Check a text with the content checks, without asking a model |

## Catalog and tasks

| Method and path                   | Does                                                                      |
| --------------------------------- | ------------------------------------------------------------------------- |
| `GET /models`, `GET /models/{id}` | The catalog: inputs, tools, structured answers, context, retention, price |
| `GET /tasks`                      | The project's tasks and the model of each                                 |

## Routes

| Method and path                                | Does                                                                                          |
| ---------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `GET /routes`                                  | The project's routes, as JSON or as the TOML of the `[ai]` table (`Accept: application/toml`) |
| `PUT /routes`                                  | Replace them with a new version; a person with the owner or admin role                        |
| `GET /routes/history`, `POST /routes/rollback` | Versions, and `{ version }` to go back                                                        |

## Usage and calls

| Method and path                           | Does                                                                   |
| ----------------------------------------- | ---------------------------------------------------------------------- |
| `GET /usage?group_by=case&since=&until=`  | Usage grouped by `case`, `task`, `key`, `end_user`, `model` or `day`   |
| `GET /calls?case=&status=&since=&cursor=` | Recent calls                                                           |
| `GET /calls/{id}`                         | One call: route, attempts, tokens, credits, timings                    |
| `GET /calls/{id}/body`                    | What was asked and answered, when the route kept it; `admin`, recorded |

## Limits, keys and access

| Method and path                                          | Does                                                                                                     |
| -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `GET\|PUT /limits`                                       | The project's limits                                                                                     |
| `GET\|POST /keys`, `DELETE /keys/{id}`                   | Keys                                                                                                     |
| `POST /browser-tokens`                                   | A browser token: with the publishable key and a Sypnia Data session, or with a secret key and `end_user` |
| `GET\|POST /provider-keys`, `DELETE /provider-keys/{id}` | Your own provider keys **\[Cloud]**                                                                      |
| `GET\|POST /origins`, `DELETE /origins/{id}`             | Sites allowed to use browser tokens                                                                      |
| `POST /cache/purge`                                      | `{ task }`: empty a route's cache                                                                        |
| `DELETE /end-users/{id}`                                 | Forget a person of your app                                                                              |
| `GET /health`                                            | The gateway and each provider                                                                            |

The OpenAPI document is in the gateway's repository, at `spec/openapi.yaml`.
