Skip to content

AiModel

Defines an AI model endpoint used by AI-assisted features such as the spam classifier and the Sieve llm_prompt function.

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

AiModel is a multi-variant object: each instance has an @type discriminator selecting one of the variants below, and each variant carries its own set of fields.

OpenAI compatible

Type: AiOpenAiProfile · default: "OpenAi"

Server profile, which selects the token limit parameter, the structured output format and the authentication header

Type: Boolean · default: false

Whether to request token log probabilities and use them as the classifier confidence

Type: UnsignedInt · default: 4096 · min: 1 · max: 1000000

Maximum number of tokens the model may generate, including reasoning tokens. The spam classifier uses its own smaller limit.

Type: Float? · min: 0 · max: 2

Sampling temperature. When empty, the parameter is omitted and the provider default is used.

Type: AiReasoning · default: "Default"

Reasoning effort requested from the model

Type: Text?

JSON object whose members are merged into every request body

Type: String · required

Short name used to reference this model

Type: String · required

Model identifier sent to the provider

Type: Uri?

Base URL of the provider API. When empty, the provider’s default URL is used.

Type: SecretKeyOptional · default: {"@type":"None"}

API key sent to the provider using its native authentication header

Type: Map<String, String>

Additional headers to include in requests to the provider

Type: Boolean · default: false

Whether to accept invalid TLS certificates from the endpoint

Type: Duration · default: 60000

Maximum time to wait for a single response from the endpoint

Type: UnsignedInt · default: 16 · min: 1 · max: 4096

Maximum number of requests sent to this model at the same time

Type: Rate?

Maximum number of requests sent to this model within the rate period, spaced evenly. When empty, no rate limit is applied.

Anthropic

Type: UnsignedInt · default: 4096 · min: 1 · max: 1000000

Maximum number of tokens the model may generate, including reasoning tokens. The spam classifier uses its own smaller limit.

Type: Float? · min: 0 · max: 2

Sampling temperature. When empty, the parameter is omitted and the provider default is used.

Type: AiReasoning · default: "Default"

Reasoning effort requested from the model

Type: Text?

JSON object whose members are merged into every request body

Type: String · required

Short name used to reference this model

Type: String · required

Model identifier sent to the provider

Type: Uri?

Base URL of the provider API. When empty, the provider’s default URL is used.

Type: SecretKeyOptional · default: {"@type":"None"}

API key sent to the provider using its native authentication header

Type: Map<String, String>

Additional headers to include in requests to the provider

Type: Boolean · default: false

Whether to accept invalid TLS certificates from the endpoint

Type: Duration · default: 60000

Maximum time to wait for a single response from the endpoint

Type: UnsignedInt · default: 16 · min: 1 · max: 4096

Maximum number of requests sent to this model at the same time

Type: Rate?

Maximum number of requests sent to this model within the rate period, spaced evenly. When empty, no rate limit is applied.

Google Gemini

Type: Boolean · default: false

Whether to request token log probabilities and use them as the classifier confidence

Type: UnsignedInt · default: 4096 · min: 1 · max: 1000000

Maximum number of tokens the model may generate, including reasoning tokens. The spam classifier uses its own smaller limit.

Type: Float? · min: 0 · max: 2

Sampling temperature. When empty, the parameter is omitted and the provider default is used.

Type: AiReasoning · default: "Default"

Reasoning effort requested from the model

Type: Text?

JSON object whose members are merged into every request body

Type: String · required

Short name used to reference this model

Type: String · required

Model identifier sent to the provider

Type: Uri?

Base URL of the provider API. When empty, the provider’s default URL is used.

Type: SecretKeyOptional · default: {"@type":"None"}

API key sent to the provider using its native authentication header

Type: Map<String, String>

Additional headers to include in requests to the provider

Type: Boolean · default: false

Whether to accept invalid TLS certificates from the endpoint

Type: Duration · default: 60000

Maximum time to wait for a single response from the endpoint

Type: UnsignedInt · default: 16 · min: 1 · max: 4096

Maximum number of requests sent to this model at the same time

Type: Rate?

Maximum number of requests sent to this model within the rate period, spaced evenly. When empty, no rate limit is applied.

Ollama

Type: Boolean · default: false

Whether to request token log probabilities and use them as the classifier confidence

Type: Duration?

How long Ollama keeps the model loaded after a request. When empty, the server default is used.

Type: UnsignedInt · default: 4096 · min: 1 · max: 1000000

Maximum number of tokens the model may generate, including reasoning tokens. The spam classifier uses its own smaller limit.

Type: Float? · min: 0 · max: 2

Sampling temperature. When empty, the parameter is omitted and the provider default is used.

Type: AiReasoning · default: "Default"

Reasoning effort requested from the model

Type: Text?

JSON object whose members are merged into every request body

Type: String · required

Short name used to reference this model

Type: String · required

Model identifier sent to the provider

Type: Uri?

Base URL of the provider API. When empty, the provider’s default URL is used.

Type: SecretKeyOptional · default: {"@type":"None"}

API key sent to the provider using its native authentication header

Type: Map<String, String>

Additional headers to include in requests to the provider

Type: Boolean · default: false

Whether to accept invalid TLS certificates from the endpoint

Type: Duration · default: 60000

Maximum time to wait for a single response from the endpoint

Type: UnsignedInt · default: 16 · min: 1 · max: 4096

Maximum number of requests sent to this model at the same time

Type: Rate?

Maximum number of requests sent to this model within the rate period, spaced evenly. When empty, no rate limit is applied.

TypeSafe

Type: String · required

Short name used to reference this model

Type: String · required

Model identifier sent to the provider

Type: Uri?

Base URL of the provider API. When empty, the provider’s default URL is used.

Type: SecretKeyOptional · default: {"@type":"None"}

API key sent to the provider using its native authentication header

Type: Map<String, String>

Additional headers to include in requests to the provider

Type: Boolean · default: false

Whether to accept invalid TLS certificates from the endpoint

Type: Duration · default: 60000

Maximum time to wait for a single response from the endpoint

Type: UnsignedInt · default: 16 · min: 1 · max: 4096

Maximum number of requests sent to this model at the same time

Type: Rate?

Maximum number of requests sent to this model within the rate period, spaced evenly. When empty, no rate limit is applied.

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

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

This method requires the sysAiModelGet permission.

Terminal window
curl -X POST https://mail.example.com/jmap/ \
-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"
]
}'

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

Supports the following operations in a single call: create, update, destroy.

This operation requires the sysAiModelCreate permission.

Terminal window
curl -X POST https://mail.example.com/jmap/ \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:AiModel/set",
{
"create": {
"new1": {
"@type": "OpenAi",
"apiKey": {
"@type": "None"
},
"httpHeaders": {},
"model": "Example",
"name": "Example"
}
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'

This operation requires the sysAiModelUpdate permission.

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

This operation requires the sysAiModelDestroy permission.

Terminal window
curl -X POST https://mail.example.com/jmap/ \
-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"
]
}'

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

This method requires the sysAiModelQuery permission.

Terminal window
curl -X POST https://mail.example.com/jmap/ \
-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"
]
}'

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

Terminal window
stalwart-cli get AiModel id1
Terminal window
stalwart-cli create AiModel/OpenAi \
--field name=Example \
--field model=Example \
--field 'apiKey={"@type":"None"}' \
--field 'httpHeaders={}'
Terminal window
stalwart-cli query AiModel
Terminal window
stalwart-cli update AiModel id1 --field extraParameters='updated value'
Terminal window
stalwart-cli delete AiModel --ids id1

An optional secret value, or none.

  • None: No secret. No additional fields.
  • Value: Secret value. Carries the fields of SecretKeyValue.
  • EnvironmentVariable: Secret read from environment variable. Carries the fields of SecretKeyEnvironmentVariable.
  • File: Secret read from file. Carries the fields of SecretKeyFile.

A secret value provided directly.

Type: String · required · secret

Password or secret value

A secret value read from an environment variable.

Type: String · required

Environment variable name to read the secret from

A secret value read from a file.

Type: String · required

File path to read the secret from

Defines a rate limit as a count over a time period.

Type: UnsignedInt · default: 0 · min: 1 · max: 1000000

Count

Type: Duration · default: 0 · min: 1

Period

ValueLabel
OpenAiOpenAI
AzureAzure OpenAI
VllmvLLM
LlamaCppllama.cpp
GenericGeneric
ValueLabel
DefaultProvider default
OffOff
LowLow
MediumMedium
HighHigh