Semestra

AI providers and models

GET
/ai/assignments

Not for agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Response Body

Successful Response

application/json
  1. response
items*array<>
Example Request
curl -X GET 'https://example.com/ai/assignments'
Example Response
{  "items": [    {      "purpose": "chat",      "provider_id": "string",      "model": "string",      "params": {        "temperature": 0,        "max_tokens": 1,        "reasoning_effort": "minimal"      },      "recommended": {        "provider_id": "string",        "model": "string"      }    }  ]}
PUT
/ai/assignments

provider_id null removes the choice so the default applies. Not for agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Request Body

application/json
  1. body
purpose*Purpose

Which purpose to configure.

Value in"chat""extraction""vision""ocr""embedding""title"
provider_id*|

Provider to use; null removes the choice (the recommended default applies), or, for ocr and embedding with a local model name in model, picks that model this server runs itself.

model?|

Model name at that provider.

params?|

Model parameters for the purpose; left out, the current ones stay.

Response Body

Successful Response

application/json
  1. response
items*array<>
Example Request
curl -X PUT 'https://example.com/ai/assignments' \  -H 'Content-Type: application/json' \  -d '{  "purpose": "chat",  "provider_id": "string"}'
Example Response
{  "items": [    {      "purpose": "chat",      "provider_id": "string",      "model": "string",      "params": {        "temperature": 0,        "max_tokens": 1,        "reasoning_effort": "minimal"      },      "recommended": {        "provider_id": "string",        "model": "string"      }    }  ]}
PUT
/ai/assignments/params

They apply whichever model serves the purpose, Auto included. Not for agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Request Body

application/json
  1. body
purpose*Purpose

Which purpose to configure.

Value in"chat""extraction""vision""ocr""embedding""title"
params*

Its model parameters, whichever model serves it (on Auto too).

Response Body

Successful Response

application/json
  1. response
items*array<>
Example Request
curl -X PUT 'https://example.com/ai/assignments/params' \  -H 'Content-Type: application/json' \  -d '{  "purpose": "chat",  "params": {}}'
Example Response
{  "items": [    {      "purpose": "chat",      "provider_id": "string",      "model": "string",      "params": {        "temperature": 0,        "max_tokens": 1,        "reasoning_effort": "minimal"      },      "recommended": {        "provider_id": "string",        "model": "string"      }    }  ]}
POST
/ai/local-models/delete

Frees its disk space for every user of the server; whoever uses it gets it downloaded again when it is next needed. Refused while it downloads. Not for agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Request Body

application/json
  1. body
purpose*Purpose

What the model is for.

Value in"ocr""embedding"
model*Model

The local model to remove from this server.

Lengthlength <= 200

Response Body

Successful Response

application/json
  1. response
purpose*Purpose
Value in"ocr""embedding"
model*Model
Example Request
curl -X POST 'https://example.com/ai/local-models/delete' \  -H 'Content-Type: application/json' \  -d '{  "purpose": "ocr",  "model": "string"}'
Example Response
{  "purpose": "ocr",  "model": "string"}
POST
/ai/local-models/download

Defaults to the user's model for that purpose. Returns the download job's id, or null when the model is already here. Not for agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Request Body

application/json
  1. body
purpose*Purpose

What the model is for.

Value in"ocr""embedding"
model?|

A local model; defaults to the one this user's purpose uses.

Response Body

Successful Response

application/json
  1. response
job_id*string|null
Example Request
curl -X POST 'https://example.com/ai/local-models/download' \  -H 'Content-Type: application/json' \  -d '{  "purpose": "ocr"}'
Example Response
{  "job_id": "string"}
GET
/ai/providers

Providers the user connected with their own API keys. Not for agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Response Body

Successful Response

application/json
  1. response
items*array<>
Example Request
curl -X GET 'https://example.com/ai/providers'
Example Response
{  "items": [    {      "id": "string",      "kind": "anthropic",      "display_name": "string",      "base_url": "string",      "key_hint": "string",      "capabilities": [        "chat"      ],      "capabilities_editable": true,      "enabled": true,      "max_concurrency": 0,      "last_checked_at": "2019-08-24T14:15:22Z",      "last_error_code": "string",      "created_at": "2019-08-24T14:15:22Z",      "updated_at": "2019-08-24T14:15:22Z"    }  ]}
POST
/ai/providers

Checks the key and URL by listing the provider's models before saving; a failed check returns ai.provider_check_failed with the reason. Not for agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Request Body

application/json
  1. body
kind*Kind

Provider type.

Value in"anthropic""anthropic_compatible""openai""openai_compatible""openai_responses""gemini""ollama"
display_name?|

Name shown in the list; defaults to the type.

base_url?|

API base URL; required for the compatible kinds and ollama.

api_key?|

API key (stored encrypted).

capabilities?array<>|

What the endpoint supports; only for the compatible kinds and ollama.

Response Body

Successful Response

application/json
  1. response
id*Id
kind*Kind
Value in"anthropic""anthropic_compatible""openai""openai_compatible""openai_responses""gemini""ollama"
display_name*Display Name
base_url*string|null
key_hint*string|null
capabilities*array<>
capabilities_editable*Capabilities Editable
enabled*Enabled
max_concurrency*integer|null
last_checked_at*|null
last_error_code*string|null
created_at*Created At
Formatdate-time
updated_at*Updated At
Formatdate-time
Example Request
curl -X POST 'https://example.com/ai/providers' \  -H 'Content-Type: application/json' \  -d '{  "kind": "anthropic"}'
Example Response
{  "id": "string",  "kind": "anthropic",  "display_name": "string",  "base_url": "string",  "key_hint": "string",  "capabilities": [    "chat"  ],  "capabilities_editable": true,  "enabled": true,  "max_concurrency": 0,  "last_checked_at": "2019-08-24T14:15:22Z",  "last_error_code": "string",  "created_at": "2019-08-24T14:15:22Z",  "updated_at": "2019-08-24T14:15:22Z"}
PATCH
/ai/providers/{id}

A new key or base URL is checked again before saving. Not for agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Path Parameters

id*Id

Provider id.

Request Body

application/json
  1. body
display_name?|

New name.

base_url?|

New base URL.

api_key?|

New API key; the provider is checked again before saving.

capabilities?array<>|

New capabilities (compatible kinds and ollama only).

enabled?|

Turn the provider on or off.

max_concurrency?|

Most requests sent to the provider at once; null for the default (4).

Response Body

Successful Response

application/json
  1. response
id*Id
kind*Kind
Value in"anthropic""anthropic_compatible""openai""openai_compatible""openai_responses""gemini""ollama"
display_name*Display Name
base_url*string|null
key_hint*string|null
capabilities*array<>
capabilities_editable*Capabilities Editable
enabled*Enabled
max_concurrency*integer|null
last_checked_at*|null
last_error_code*string|null
created_at*Created At
Formatdate-time
updated_at*Updated At
Formatdate-time
Example Request
curl -X PATCH 'https://example.com/ai/providers/string' \  -H 'Content-Type: application/json' \  -d '{}'
Example Response
{  "id": "string",  "kind": "anthropic",  "display_name": "string",  "base_url": "string",  "key_hint": "string",  "capabilities": [    "chat"  ],  "capabilities_editable": true,  "enabled": true,  "max_concurrency": 0,  "last_checked_at": "2019-08-24T14:15:22Z",  "last_error_code": "string",  "created_at": "2019-08-24T14:15:22Z",  "updated_at": "2019-08-24T14:15:22Z"}
DELETE
/ai/providers/{id}

Not for agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Path Parameters

id*Id

Provider id.

Response Body

Successful Response

application/json
  1. response
id*Id
cleared_purposes*array<>
Example Request
curl -X DELETE 'https://example.com/ai/providers/string'
Example Response
{  "id": "string",  "cleared_purposes": [    "chat"  ]}
GET
/ai/providers/{id}/models

Cached for an hour. Not for agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Path Parameters

id*Id

Provider id.

Response Body

Successful Response

application/json
  1. response
items*array<>
manual_entry*Manual Entry
Example Request
curl -X GET 'https://example.com/ai/providers/string/models'
Example Response
{  "items": [    {      "id": "string",      "display_name": "string"    }  ],  "manual_entry": true}
POST
/ai/providers/{id}:test

Records the result on the provider. Not for agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Path Parameters

id*Id

Provider id.

Response Body

Successful Response

application/json
  1. response
ok*Ok
error_code*string|null
checked_at*Checked At
Formatdate-time
Example Request
curl -X POST 'https://example.com/ai/providers/string:test'
Example Response
{  "ok": true,  "error_code": "string",  "checked_at": "2019-08-24T14:15:22Z"}
GET
/ai/status

The frontend enables or greys out AI features with it. Not for agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Response Body

Successful Response

application/json
  1. response
items*array<>
local?array<>
Example Request
curl -X GET 'https://example.com/ai/status'
Example Response
{  "items": [    {      "purpose": "chat",      "available": true,      "source": "assignment",      "provider_id": "string",      "provider_kind": "anthropic",      "provider_name": "string",      "model": "string"    }  ],  "local": [    {      "purpose": "ocr",      "models": [        "string"      ],      "default": "string",      "downloaded": [        "string"      ],      "sizes": {        "property1": 0,        "property2": 0      },      "downloading": [        "string"      ],      "download_job": "string",      "custom": false    }  ]}
GET
/ai/usage

Defaults to all time; days or start/end narrow it. Not for agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Query Parameters

days?|

How many days back to summarise, today included; omit for all time.

start?|

First local day to summarise; overrides days.

end?|

Last local day to summarise (inclusive); defaults to today.

tz?Tz

IANA time zone for day buckets.

Default"UTC"

Response Body

Successful Response

application/json
  1. response
since*Since
Formatdate-time
until*Until
Formatdate
totals*
cost_complete*Cost Complete
by_day*array<>
by_purpose*array<>
by_module*array<>
by_model*array<>
Example Request
curl -X GET 'https://example.com/ai/usage'
Example Response
{  "since": "2019-08-24T14:15:22Z",  "until": "2019-08-24",  "totals": {    "calls": 0,    "errors": 0,    "input_tokens": 0,    "cached_tokens": 0,    "output_tokens": 0,    "cost_usd": 0  },  "cost_complete": true,  "by_day": [    {      "date": "2019-08-24",      "purpose": "chat",      "calls": 0,      "input_tokens": 0,      "output_tokens": 0,      "cost_usd": 0,      "cost_complete": true    }  ],  "by_purpose": [    {      "calls": 0,      "errors": 0,      "input_tokens": 0,      "cached_tokens": 0,      "output_tokens": 0,      "cost_usd": 0,      "key": "string",      "cost_complete": true    }  ],  "by_module": [    {      "calls": 0,      "errors": 0,      "input_tokens": 0,      "cached_tokens": 0,      "output_tokens": 0,      "cost_usd": 0,      "key": "string",      "cost_complete": true    }  ],  "by_model": [    {      "calls": 0,      "errors": 0,      "input_tokens": 0,      "cached_tokens": 0,      "output_tokens": 0,      "cost_usd": 0,      "key": "string",      "cost_complete": true    }  ]}