Skip to main content
Version: 0.16

AiModel

Defines an AI model endpoint for LLM-based features.

Enterprise feature

This object is only available with an Enterprise license.

This object can be configured from the WebUI under Settings › AI

Fields

name

Type: String · required

Short name for the AI Model

allowInvalidCerts

Type: Boolean · default: false

Whether Stalwart should connect to an endpoint that has an invalid TLS certificate

temperature

Type: Float · default: 0.7 · max: 1 · min: 0

The temperature of the AI model, which controls the randomness of the output. A higher temperature will produce more random output.

model

Type: String · required

The name of the AI model to use.

timeout

Type: Duration · default: "2m"

Maximum amount of time that Stalwart will wait for a response from this endpoint

modelType

Type: AiModelType · default: "Chat"

API type

url

Type: Uri · required

URL of the OpenAI compatible endpoint

httpAuth

Type: HttpAuth · required

The type of HTTP authentication to use

httpHeaders

Type: Map<String, String>

Additional headers to include in HTTP requests

JMAP API

The AiModel object is available via the urn:stalwart:jmap capability.

x:AiModel/get

This is a standard Foo/get method as defined in RFC 8620, Section 5.1.

This method requires the sysAiModelGet permission.

curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:AiModel/get",
{
"ids": [
"id1"
]
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

x:AiModel/set

This is a standard Foo/set method as defined in RFC 8620, Section 5.3.

Supports create, update, and destroy operations in a single call.

Create

This operation requires the sysAiModelCreate permission.

curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:AiModel/set",
{
"create": {
"new1": {
"allowInvalidCerts": false,
"httpAuth": {
"@type": "Unauthenticated"
},
"httpHeaders": {},
"model": "Example",
"modelType": "Chat",
"name": "Example",
"temperature": 0.7,
"timeout": "2m",
"url": "https://example.com"
}
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

Update

This operation requires the sysAiModelUpdate permission.

curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:AiModel/set",
{
"update": {
"id1": {
"name": "updated value"
}
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

Destroy

This operation requires the sysAiModelDestroy permission.

curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:AiModel/set",
{
"destroy": [
"id1"
]
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

x:AiModel/query

This is a standard Foo/query method as defined in RFC 8620, Section 5.5.

This method requires the sysAiModelQuery permission.

curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:AiModel/query",
{
"filter": {}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

CLI

stalwart-cli wraps the same JMAP calls. See the CLI reference for installation, authentication, and general usage.

Fetch

stalwart-cli get ai-model id1

Create

stalwart-cli create ai-model \
--field name=Example \
--field allowInvalidCerts=false \
--field temperature=0.7 \
--field model=Example \
--field timeout=2m \
--field modelType=Chat \
--field url=https://example.com \
--field 'httpAuth={"@type":"Unauthenticated"}' \
--field 'httpHeaders={}'

Query

stalwart-cli query ai-model

Update

stalwart-cli update ai-model id1 --field description='Updated'

Delete

stalwart-cli delete ai-model --ids id1

Nested types

HttpAuth

Defines the HTTP authentication method to use for HTTP requests.

  • Unauthenticated: Anonymous. No additional fields.
  • Basic: Basic Authentication. Carries the fields of HttpAuthBasic.
  • Bearer: Bearer Token. Carries the fields of HttpAuthBearer.

HttpAuthBasic

HTTP Basic authentication credentials.

username

Type: String · required

Username for HTTP Basic Authentication

secret

Type: SecretKey · required

Password for HTTP Basic Authentication

SecretKey

A secret value provided directly, from an environment variable, or from a file.

SecretKeyValue

A secret value provided directly.

secret

Type: String · required · secret

Password or secret value

SecretKeyEnvironmentVariable

A secret value read from an environment variable.

variableName

Type: String · required

Environment variable name to read the secret from

SecretKeyFile

A secret value read from a file.

filePath

Type: String · required

File path to read the secret from

HttpAuthBearer

HTTP Bearer token authentication.

bearerToken

Type: SecretKey · required

Bearer token for HTTP Bearer Authentication

Enums

AiModelType

ValueLabel
ChatChat Completion
TextText Generation